2 added a note about the last example
source | link

First, the rudeness and the apology. Your two forms are different. This one makes it clear that the rudeness was solidly in the past:

He apologised for having been rude.

The more succinct one is ambiguous as to when the rudeness might have occurred.

I don't buy

If you wanted to pass the exam, you had to study harder.

Here are a couple of ways it could be fixed:

If you had wanted to pass the exam, you would have had to study harder.

If you had wanted to pass the exam, you should have studied harder.

In the last example, "had" can be omitted.

First, the rudeness and the apology. Your two forms are different. This one makes it clear that the rudeness was solidly in the past:

He apologised for having been rude.

The more succinct one is ambiguous as to when the rudeness might have occurred.

I don't buy

If you wanted to pass the exam, you had to study harder.

Here are a couple of ways it could be fixed:

If you had wanted to pass the exam, you would have had to study harder.

If you had wanted to pass the exam, you should have studied harder.

First, the rudeness and the apology. Your two forms are different. This one makes it clear that the rudeness was solidly in the past:

He apologised for having been rude.

The more succinct one is ambiguous as to when the rudeness might have occurred.

I don't buy

If you wanted to pass the exam, you had to study harder.

Here are a couple of ways it could be fixed:

If you had wanted to pass the exam, you would have had to study harder.

If you had wanted to pass the exam, you should have studied harder.

In the last example, "had" can be omitted.

1
source | link

First, the rudeness and the apology. Your two forms are different. This one makes it clear that the rudeness was solidly in the past:

He apologised for having been rude.

The more succinct one is ambiguous as to when the rudeness might have occurred.

I don't buy

If you wanted to pass the exam, you had to study harder.

Here are a couple of ways it could be fixed:

If you had wanted to pass the exam, you would have had to study harder.

If you had wanted to pass the exam, you should have studied harder.