f(int a, ...) {
  __builtin_va_list l;
  int ret;
  __builtin_va_start(l, a);
  __builtin_va_arg(l, int);
  ret = a + __builtin_va_arg(l, int);
  __builtin_va_end(l);
  return ret;
}


x86 assembly (clang, -O0):
<f>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
test   %al,%al
je     113c <f+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    %edi,-0x4(%rbp)
lea    -0x20(%rbp),%rax
lea    -0xe0(%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,-0xf0(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0xe4(%rbp)
cmp    $0x28,%eax
ja     11c8 <f+0xc8>
mov    -0xf0(%rbp),%rcx
mov    -0xe4(%rbp),%edx
movslq %edx,%rax
add    0x10(%rcx),%rax
add    $0x8,%edx
mov    %edx,(%rcx)
mov    %rax,-0xf8(%rbp)
jmp    11e5 <f+0xe5>
mov    -0xf0(%rbp),%rcx
mov    0x8(%rcx),%rdx
mov    %rdx,%rax
add    $0x8,%rdx
mov    %rdx,0x8(%rcx)
mov    %rax,-0xf8(%rbp)
mov    -0xf8(%rbp),%rax
mov    -0x4(%rbp),%eax
mov    %eax,-0x10c(%rbp)
lea    -0x20(%rbp),%rax
mov    %rax,-0x108(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0xfc(%rbp)
cmp    $0x28,%eax
ja     1237 <f+0x137>
mov    -0x108(%rbp),%rcx
mov    -0xfc(%rbp),%edx
movslq %edx,%rax
add    0x10(%rcx),%rax
add    $0x8,%edx
mov    %edx,(%rcx)
mov    %rax,-0x118(%rbp)
jmp    1254 <f+0x154>
mov    -0x108(%rbp),%rcx
mov    0x8(%rcx),%rdx
mov    %rdx,%rax
add    $0x8,%rdx
mov    %rdx,0x8(%rcx)
mov    %rax,-0x118(%rbp)
mov    -0x10c(%rbp),%eax
mov    -0x118(%rbp),%rcx
mov    (%rcx),%ecx
add    %ecx,%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<f>:
sub    $0x58,%rsp
mov    %eax,%r10d
mov    %edi,%eax
mov    %rsi,-0x58(%rsp)
mov    %rdx,-0x50(%rsp)
mov    %rcx,-0x48(%rsp)
mov    %r8,-0x40(%rsp)
mov    %r9,-0x38(%rsp)
test   %r10b,%r10b
je     114e <f+0x4e>
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),%rcx
mov    %rcx,-0x70(%rsp)
lea    0x60(%rsp),%rcx
mov    %rcx,-0x78(%rsp)
movabs $0x3000000008,%rcx
mov    %rcx,-0x80(%rsp)
mov    $0x8,%edx
cmp    $0x29,%rdx
jae    1197 <f+0x97>
lea    0x8(%rdx),%rcx
mov    %ecx,-0x80(%rsp)
cmp    $0x20,%edx
ja     119d <f+0x9d>
add    -0x70(%rsp),%rcx
or     $0x10,%edx
mov    %edx,-0x80(%rsp)
jmp    11ab <f+0xab>
addq   $0x8,-0x78(%rsp)
mov    -0x78(%rsp),%rcx
lea    0x8(%rcx),%rdx
mov    %rdx,-0x78(%rsp)
add    (%rcx),%eax
add    $0x58,%rsp
ret

LLVM IR (-O0):
%struct.__va_list_tag = type { i32, i32, i8*, i8* }
define i32 @f(i32 %0, ...) {
%2 = alloca i32
%3 = alloca [1 x %struct.__va_list_tag]
%4 = alloca i32
store i32 %0, i32* %2
%5 = getelementptr inbounds [1 x %struct.__va_list_tag], [1 x %struct.__va_list_tag]* %3, i64 0, i64 0
%6 = bitcast %struct.__va_list_tag* %5 to i8*
%7 = getelementptr inbounds [1 x %struct.__va_list_tag], [1 x %struct.__va_list_tag]* %3, i64 0, i64 0
%8 = getelementptr inbounds %struct.__va_list_tag, %struct.__va_list_tag* %7, i32 0, i32 0
%9 = load i32, i32* %8
%10 = icmp ule i32 %9, 40
br i1 %10, label %11, label %17
11: ; preds = %1
%12 = getelementptr inbounds %struct.__va_list_tag, %struct.__va_list_tag* %7, i32 0, i32 3
%13 = load i8*, i8** %12
%14 = getelementptr i8, i8* %13, i32 %9
%15 = bitcast i8* %14 to i32*
%16 = add i32 %9, 8
store i32 %16, i32* %8
br label %22
17: ; preds = %1
%18 = getelementptr inbounds %struct.__va_list_tag, %struct.__va_list_tag* %7, i32 0, i32 2
%19 = load i8*, i8** %18
%20 = bitcast i8* %19 to i32*
%21 = getelementptr i8, i8* %19, i32 8
store i8* %21, i8** %18
br label %22
22: ; preds = %17, %11
%23 = phi i32* [ %15, %11 ], [ %20, %17 ]
%24 = load i32, i32* %23
%25 = load i32, i32* %2
%26 = getelementptr inbounds [1 x %struct.__va_list_tag], [1 x %struct.__va_list_tag]* %3, i64 0, i64 0
%27 = getelementptr inbounds %struct.__va_list_tag, %struct.__va_list_tag* %26, i32 0, i32 0
%28 = load i32, i32* %27
%29 = icmp ule i32 %28, 40
br i1 %29, label %30, label %36
30: ; preds = %22
%31 = getelementptr inbounds %struct.__va_list_tag, %struct.__va_list_tag* %26, i32 0, i32 3
%32 = load i8*, i8** %31
%33 = getelementptr i8, i8* %32, i32 %28
%34 = bitcast i8* %33 to i32*
%35 = add i32 %28, 8
store i32 %35, i32* %27
br label %41
36: ; preds = %22
%37 = getelementptr inbounds %struct.__va_list_tag, %struct.__va_list_tag* %26, i32 0, i32 2
%38 = load i8*, i8** %37
%39 = bitcast i8* %38 to i32*
%40 = getelementptr i8, i8* %38, i32 8
store i8* %40, i8** %37
br label %41
41: ; preds = %36, %30
%42 = phi i32* [ %34, %30 ], [ %39, %36 ]
%43 = load i32, i32* %42
%44 = add nsw i32 %25, %43
store i32 %44, i32* %4
%45 = getelementptr inbounds [1 x %struct.__va_list_tag], [1 x %struct.__va_list_tag]* %3, i64 0, i64 0
%46 = bitcast %struct.__va_list_tag* %45 to i8*
%47 = load i32, i32* %4
ret i32 %47
}

LLVM IR (-O2):
%struct.__va_list_tag = type { i32, i32, i8*, i8* }
define i32 @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 %11, label %7
7: ; preds = %1
%8 = getelementptr inbounds [1 x %struct.__va_list_tag], [1 x %struct.__va_list_tag]* %2, i64 0, i64 0, i32 2
%9 = load i8*, i8** %8
%10 = getelementptr i8, i8* %9, i64 8
store i8* %10, i8** %8
br label %20
11: ; preds = %1
%12 = add nuw nsw i32 %5, 8
store i32 %12, i32* %4
%13 = icmp ult i32 %5, 33
br i1 %13, label %14, label %20
14: ; preds = %11
%15 = getelementptr inbounds [1 x %struct.__va_list_tag], [1 x %struct.__va_list_tag]* %2, i64 0, i64 0, i32 3
%16 = load i8*, i8** %15
%17 = zext i32 %12 to i64
%18 = getelementptr i8, i8* %16, i64 %17
%19 = add nuw nsw i32 %5, 16
store i32 %19, i32* %4
br label %24
20: ; preds = %7, %11
%21 = getelementptr inbounds [1 x %struct.__va_list_tag], [1 x %struct.__va_list_tag]* %2, i64 0, i64 0, i32 2
%22 = load i8*, i8** %21
%23 = getelementptr i8, i8* %22, i64 8
store i8* %23, i8** %21
br label %24
24: ; preds = %20, %14
%25 = phi i8* [ %18, %14 ], [ %22, %20 ]
%26 = bitcast i8* %25 to i32*
%27 = load i32, i32* %26
%28 = add nsw i32 %27, %0
ret i32 %28
}