void f(int i, ...) {
  __builtin_va_list ap;
  __builtin_va_start(ap, i);
  __builtin_va_arg(ap, int);
  __builtin_va_end(ap);
}


x86 assembly (clang, -O0):
<f>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
test   %al,%al
je     1136 <f+0x36>
movaps %xmm0,-0xa0(%rbp)
movaps %xmm1,-0x90(%rbp)
movaps %xmm2,-0x80(%rbp)
movaps %xmm3,-0x70(%rbp)
movaps %xmm4,-0x60(%rbp)
movaps %xmm5,-0x50(%rbp)
movaps %xmm6,-0x40(%rbp)
movaps %xmm7,-0x30(%rbp)
mov    %r9,-0xa8(%rbp)
mov    %r8,-0xb0(%rbp)
mov    %rcx,-0xb8(%rbp)
mov    %rdx,-0xc0(%rbp)
mov    %rsi,-0xc8(%rbp)
mov    %edi,-0x4(%rbp)
lea    -0x20(%rbp),%rax
lea    -0xd0(%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,-0xe0(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0xd4(%rbp)
cmp    $0x28,%eax
ja     11c2 <f+0xc2>
mov    -0xe0(%rbp),%rcx
mov    -0xd4(%rbp),%edx
movslq %edx,%rax
add    0x10(%rcx),%rax
add    $0x8,%edx
mov    %edx,(%rcx)
mov    %rax,-0xe8(%rbp)
jmp    11df <f+0xdf>
mov    -0xe0(%rbp),%rcx
mov    0x8(%rcx),%rdx
mov    %rdx,%rax
add    $0x8,%rdx
mov    %rdx,0x8(%rcx)
mov    %rax,-0xe8(%rbp)
mov    -0xe8(%rbp),%rax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<f>:
sub    $0x58,%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 <f+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    0x60(%rsp),%rax
mov    %rax,-0x78(%rsp)
movabs $0x3000000008,%rax
mov    %rax,-0x80(%rsp)
mov    $0x8,%eax
cmp    $0x28,%eax
ja     1181 <f+0x81>
add    $0x8,%eax
mov    %eax,-0x80(%rsp)
add    $0x58,%rsp
ret
addq   $0x8,-0x78(%rsp)
add    $0x58,%rsp
ret

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

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