void fun(int a, ...) {
  printf("%d %d \n", a, &a);
  int *temp = &a;
  temp++;
  for (int i = 0; i < a; ++i) {
    printf("%d %d \n", *temp, temp);
    temp++;
  }
}


x86 assembly (clang, -O0):
<fun>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%esi
lea    0xedb(%rip),%rdi
lea    -0x4(%rbp),%rdx
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x4(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1189 <fun+0x79>
mov    -0x10(%rbp),%rax
mov    (%rax),%esi
mov    -0x10(%rbp),%rdx
lea    0xe98(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    114b <fun+0x3b>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fun>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %edi,%esi
mov    %edi,0xc(%rsp)
lea    0xedb(%rip),%rdi
lea    0xc(%rsp),%rdx
xor    %eax,%eax
call   1030 <printf@plt>
cmpl   $0x0,0xc(%rsp)
jle    116c <fun+0x5c>
lea    0x10(%rsp),%rbx
lea    0xebc(%rip),%r14
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
mov    (%rbx),%esi
mov    %r14,%rdi
mov    %rbx,%rdx
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%ebp
add    $0x4,%rbx
cmp    0xc(%rsp),%ebp
jl     1150 <fun+0x40>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [8 x i8] c"%d %d \0A\00"
define void @fun(i32 %0, ...) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
store i32 %0, i32* %2
%5 = load i32, i32* %2
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %5, i32* %2)
store i32* %2, i32** %3
%7 = load i32*, i32** %3
%8 = getelementptr inbounds i32, i32* %7, i32 1
store i32* %8, i32** %3
store i32 0, i32* %4
br label %9
9: ; preds = %20, %1
%10 = load i32, i32* %4
%11 = load i32, i32* %2
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %23
13: ; preds = %9
%14 = load i32*, i32** %3
%15 = load i32, i32* %14
%16 = load i32*, i32** %3
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %15, i32* %16)
%18 = load i32*, i32** %3
%19 = getelementptr inbounds i32, i32* %18, i32 1
store i32* %19, i32** %3
br label %20
20: ; preds = %13
%21 = load i32, i32* %4
%22 = add nsw i32 %21, 1
store i32 %22, i32* %4
br label %9
23: ; preds = %9
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"%d %d \0A\00"
define void @fun(i32 %0, ...) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %0, i32* %2)
%4 = load i32, i32* %2
%5 = icmp sgt i32 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %1
%7 = getelementptr inbounds i32, i32* %2, i64 1
br label %9
8: ; preds = %9, %1
ret void
9: ; preds = %6, %9
%10 = phi i32* [ %15, %9 ], [ %7, %6 ]
%11 = phi i32 [ %14, %9 ], [ 0, %6 ]
%12 = load i32, i32* %10
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %12, i32* %10)
%14 = add nuw nsw i32 %11, 1
%15 = getelementptr inbounds i32, i32* %10, i64 1
%16 = load i32, i32* %2
%17 = icmp slt i32 %14, %16
br i1 %17, label %9, label %8
}