void f5(int a, ...) {
  __builtin_va_list ap;
  __builtin_va_start(ap, a);
  int b = __builtin_va_arg(ap, int);
  __builtin_va_list ap2;
  __builtin_va_copy(ap2, ap);
  __builtin_va_end(ap);
}


x86 assembly (clang, -O0):
<f5>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
test   %al,%al
je     113f <f5+0x3f>
movaps %xmm0,-0xc0(%rbp)
movaps %xmm1,-0xb0(%rbp)
movaps %xmm2,-0xa0(%rbp)
movaps %xmm3,-0x90(%rbp)
movaps %xmm4,-0x80(%rbp)
movaps %xmm5,-0x70(%rbp)
movaps %xmm6,-0x60(%rbp)
movaps %xmm7,-0x50(%rbp)
mov    %r9,-0xc8(%rbp)
mov    %r8,-0xd0(%rbp)
mov    %rcx,-0xd8(%rbp)
mov    %rdx,-0xe0(%rbp)
mov    %rsi,-0xe8(%rbp)
mov    %edi,-0x4(%rbp)
lea    -0x20(%rbp),%rax
lea    -0xf0(%rbp),%rcx
mov    %rcx,0x10(%rax)
lea    0x10(%rbp),%rcx
mov    %rcx,0x8(%rax)
movl   $0x30,0x4(%rax)
movl   $0x8,(%rax)
lea    -0x20(%rbp),%rax
mov    %rax,-0x100(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0xf4(%rbp)
cmp    $0x28,%eax
ja     11cb <f5+0xcb>
mov    -0x100(%rbp),%rcx
mov    -0xf4(%rbp),%edx
movslq %edx,%rax
add    0x10(%rcx),%rax
add    $0x8,%edx
mov    %edx,(%rcx)
mov    %rax,-0x108(%rbp)
jmp    11e8 <f5+0xe8>
mov    -0x100(%rbp),%rcx
mov    0x8(%rcx),%rdx
mov    %rdx,%rax
add    $0x8,%rdx
mov    %rdx,0x8(%rcx)
mov    %rax,-0x108(%rbp)
mov    -0x108(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
movaps -0x20(%rbp),%xmm0
movaps %xmm0,-0x40(%rbp)
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<f5>:
sub    $0x68,%rsp
mov    %rsi,-0x58(%rsp)
mov    %rdx,-0x50(%rsp)
mov    %rcx,-0x48(%rsp)
mov    %r8,-0x40(%rsp)
mov    %r9,-0x38(%rsp)
test   %al,%al
je     1148 <f5+0x48>
movaps %xmm0,-0x30(%rsp)
movaps %xmm1,-0x20(%rsp)
movaps %xmm2,-0x10(%rsp)
movaps %xmm3,(%rsp)
movaps %xmm4,0x10(%rsp)
movaps %xmm5,0x20(%rsp)
movaps %xmm6,0x30(%rsp)
movaps %xmm7,0x40(%rsp)
lea    -0x60(%rsp),%rax
mov    %rax,-0x70(%rsp)
lea    0x70(%rsp),%rax
mov    %rax,-0x78(%rsp)
movabs $0x3000000008,%rax
mov    %rax,-0x80(%rsp)
mov    $0x8,%eax
cmp    $0x28,%eax
ja     1181 <f5+0x81>
add    $0x8,%eax
mov    %eax,-0x80(%rsp)
add    $0x68,%rsp
ret
addq   $0x8,-0x78(%rsp)
add    $0x68,%rsp
ret

LLVM IR (-O0):
%struct.__va_list_tag = type { i32, i32, i8*, i8* }
define void @f5(i32 %0, ...) {
%2 = alloca i32
%3 = alloca [1 x %struct.__va_list_tag]
%4 = alloca i32
%5 = alloca [1 x %struct.__va_list_tag]
store i32 %0, i32* %2
%6 = getelementptr inbounds [1 x %struct.__va_list_tag], [1 x %struct.__va_list_tag]* %3, i64 0, i64 0
%7 = bitcast %struct.__va_list_tag* %6 to i8*
%8 = getelementptr inbounds [1 x %struct.__va_list_tag], [1 x %struct.__va_list_tag]* %3, i64 0, i64 0
%9 = getelementptr inbounds %struct.__va_list_tag, %struct.__va_list_tag* %8, i32 0, i32 0
%10 = load i32, i32* %9
%11 = icmp ule i32 %10, 40
br i1 %11, label %12, label %18
12: ; preds = %1
%13 = getelementptr inbounds %struct.__va_list_tag, %struct.__va_list_tag* %8, i32 0, i32 3
%14 = load i8*, i8** %13
%15 = getelementptr i8, i8* %14, i32 %10
%16 = bitcast i8* %15 to i32*
%17 = add i32 %10, 8
store i32 %17, i32* %9
br label %23
18: ; preds = %1
%19 = getelementptr inbounds %struct.__va_list_tag, %struct.__va_list_tag* %8, i32 0, i32 2
%20 = load i8*, i8** %19
%21 = bitcast i8* %20 to i32*
%22 = getelementptr i8, i8* %20, i32 8
store i8* %22, i8** %19
br label %23
23: ; preds = %18, %12
%24 = phi i32* [ %16, %12 ], [ %21, %18 ]
%25 = load i32, i32* %24
store i32 %25, i32* %4
%26 = getelementptr inbounds [1 x %struct.__va_list_tag], [1 x %struct.__va_list_tag]* %5, i64 0, i64 0
%27 = getelementptr inbounds [1 x %struct.__va_list_tag], [1 x %struct.__va_list_tag]* %3, i64 0, i64 0
%28 = bitcast %struct.__va_list_tag* %26 to i8*
%29 = bitcast %struct.__va_list_tag* %27 to i8*
%30 = getelementptr inbounds [1 x %struct.__va_list_tag], [1 x %struct.__va_list_tag]* %3, i64 0, i64 0
%31 = bitcast %struct.__va_list_tag* %30 to i8*
ret void
}

LLVM IR (-O2):
%struct.__va_list_tag = type { i32, i32, i8*, i8* }
define void @f5(i32 %0, ...) {
%2 = alloca [1 x %struct.__va_list_tag]
%3 = alloca [1 x %struct.__va_list_tag]
%4 = bitcast [1 x %struct.__va_list_tag]* %2 to i8*
%5 = getelementptr inbounds [1 x %struct.__va_list_tag], [1 x %struct.__va_list_tag]* %2, i64 0, i64 0, i32 0
%6 = load i32, i32* %5
%7 = icmp ult i32 %6, 41
br i1 %7, label %8, label %10
8: ; preds = %1
%9 = add nuw nsw i32 %6, 8
store i32 %9, i32* %5
br label %14
10: ; preds = %1
%11 = getelementptr inbounds [1 x %struct.__va_list_tag], [1 x %struct.__va_list_tag]* %2, i64 0, i64 0, i32 2
%12 = load i8*, i8** %11
%13 = getelementptr i8, i8* %12, i64 8
store i8* %13, i8** %11
br label %14
14: ; preds = %10, %8
%15 = bitcast [1 x %struct.__va_list_tag]* %3 to i8*
ret void
}