final_greeting(char *fmt, ...) {
  __builtin_va_list l;
  printf("before\n");
  __builtin_va_start(l, fmt);
  vprintf(fmt, l);
  __builtin_va_end(l);
  printf("after\n");
}


x86 assembly (clang, -O0):
<final_greeting>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
test   %al,%al
je     115c <final_greeting+0x3c>
movaps %xmm0,-0xb0(%rbp)
movaps %xmm1,-0xa0(%rbp)
movaps %xmm2,-0x90(%rbp)
movaps %xmm3,-0x80(%rbp)
movaps %xmm4,-0x70(%rbp)
movaps %xmm5,-0x60(%rbp)
movaps %xmm6,-0x50(%rbp)
movaps %xmm7,-0x40(%rbp)
mov    %r9,-0xb8(%rbp)
mov    %r8,-0xc0(%rbp)
mov    %rcx,-0xc8(%rbp)
mov    %rdx,-0xd0(%rbp)
mov    %rsi,-0xd8(%rbp)
mov    %rdi,-0x10(%rbp)
lea    0xe76(%rip),%rdi
xor    %eax,%eax
mov    %al,-0xe1(%rbp)
call   1030 <printf@plt>
lea    -0xe0(%rbp),%rax
mov    %rax,-0x20(%rbp)
lea    0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
movl   $0x30,-0x2c(%rbp)
movl   $0x8,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1040 <vprintf@plt>
mov    -0xe1(%rbp),%al
lea    0xe36(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<final_greeting>:
push   %rbx
sub    $0xd0,%rsp
mov    %rdi,%rbx
mov    %rsi,0x28(%rsp)
mov    %rdx,0x30(%rsp)
mov    %rcx,0x38(%rsp)
mov    %r8,0x40(%rsp)
mov    %r9,0x48(%rsp)
test   %al,%al
je     117f <final_greeting+0x5f>
movaps %xmm0,0x50(%rsp)
movaps %xmm1,0x60(%rsp)
movaps %xmm2,0x70(%rsp)
movaps %xmm3,0x80(%rsp)
movaps %xmm4,0x90(%rsp)
movaps %xmm5,0xa0(%rsp)
movaps %xmm6,0xb0(%rsp)
movaps %xmm7,0xc0(%rsp)
lea    0xe7a(%rip),%rdi
call   1030 <puts@plt>
movabs $0x3000000008,%rax
mov    %rax,(%rsp)
lea    0xe0(%rsp),%rax
mov    %rax,0x8(%rsp)
lea    0x20(%rsp),%rax
mov    %rax,0x10(%rsp)
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1040 <vprintf@plt>
lea    0xe45(%rip),%rdi
call   1030 <puts@plt>
add    $0xd0,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.__va_list_tag = type { i32, i32, i8*, i8* }
@.str = [8 x i8] c"before\0A\00"
@.str.1 = [7 x i8] c"after\0A\00"
define i32 @final_greeting(i8* %0, ...) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca [1 x %struct.__va_list_tag]
store i8* %0, i8** %3
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%6 = getelementptr inbounds [1 x %struct.__va_list_tag], [1 x %struct.__va_list_tag]* %4, i64 0, i64 0
%7 = bitcast %struct.__va_list_tag* %6 to i8*
%8 = load i8*, i8** %3
%9 = getelementptr inbounds [1 x %struct.__va_list_tag], [1 x %struct.__va_list_tag]* %4, i64 0, i64 0
%10 = call i32 @vprintf(i8* %8, %struct.__va_list_tag* %9)
%11 = getelementptr inbounds [1 x %struct.__va_list_tag], [1 x %struct.__va_list_tag]* %4, i64 0, i64 0
%12 = bitcast %struct.__va_list_tag* %11 to i8*
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%14 = load i32, i32* %2
ret i32 %14
}

LLVM IR (-O2):
%struct.__va_list_tag = type { i32, i32, i8*, i8* }
@str = [7 x i8] c"before\00"
@str.2 = [6 x i8] c"after\00"
define i32 @final_greeting(i8* nocapture %0, ...) {
%2 = alloca [1 x %struct.__va_list_tag]
%3 = bitcast [1 x %struct.__va_list_tag]* %2 to i8*
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str, i64 0, i64 0))
%5 = getelementptr inbounds [1 x %struct.__va_list_tag], [1 x %struct.__va_list_tag]* %2, i64 0, i64 0
%6 = call i32 @vprintf(i8* %0, %struct.__va_list_tag* %5)
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.2, i64 0, i64 0))
ret i32 undef
}