#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ printf(char *, double);
double testVaArgDouble(int, int, int, int, int, int, int, int, int, int, int,
                       int, int, int, int, int, int);
int testVaArgInt(int, int, int, int, int, int, int, int, int, int, int, int,
                 int, int, int, int, int);
int main(void) {
  printf("Test int va_arg    : %d\n",
         testVaArgInt(8, 1., 2, 3., 4, 5., 6, 7., 8, 9., 10, 11., 12, 13., 14,
                      15., 16));
  printf("Test double va_arg : %f\n",
         testVaArgDouble(8, 1., 2, 3., 4, 5., 6, 7., 8, 9., 10, 11., 12, 13.,
                         14, 15., 16));
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    $0x8,%edi
mov    $0x1,%esi
mov    $0x2,%edx
mov    $0x3,%ecx
mov    $0x4,%r8d
mov    $0x5,%r9d
movl   $0x6,(%rsp)
movl   $0x7,0x8(%rsp)
movl   $0x8,0x10(%rsp)
movl   $0x9,0x18(%rsp)
movl   $0xa,0x20(%rsp)
movl   $0xb,0x28(%rsp)
movl   $0xc,0x30(%rsp)
movl   $0xd,0x38(%rsp)
movl   $0xe,0x40(%rsp)
movl   $0xf,0x48(%rsp)
movl   $0x10,0x50(%rsp)
call   1040 <testVaArgInt@plt>
cvtsi2sd %eax,%xmm0
lea    0xe41(%rip),%rdi
call   1030 <printf@plt>
mov    $0x8,%edi
mov    $0x1,%esi
mov    $0x2,%edx
mov    $0x3,%ecx
mov    $0x4,%r8d
mov    $0x5,%r9d
movl   $0x6,(%rsp)
movl   $0x7,0x8(%rsp)
movl   $0x8,0x10(%rsp)
movl   $0x9,0x18(%rsp)
movl   $0xa,0x20(%rsp)
movl   $0xb,0x28(%rsp)
movl   $0xc,0x30(%rsp)
movl   $0xd,0x38(%rsp)
movl   $0xe,0x40(%rsp)
movl   $0xf,0x48(%rsp)
movl   $0x10,0x50(%rsp)
call   1050 <testVaArgDouble@plt>
lea    0xdd2(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
sub    $0x8,%rsp
mov    $0x8,%edi
mov    $0x1,%esi
mov    $0x2,%edx
mov    $0x3,%ecx
mov    $0x4,%r8d
mov    $0x5,%r9d
push   $0x10
push   $0xf
push   $0xe
push   $0xd
push   $0xc
push   $0xb
push   $0xa
push   $0x9
push   $0x8
push   $0x7
push   $0x6
call   1040 <testVaArgInt@plt>
add    $0x60,%rsp
cvtsi2sd %eax,%xmm0
lea    0xe81(%rip),%rdi
call   1030 <printf@plt>
sub    $0x8,%rsp
mov    $0x8,%edi
mov    $0x1,%esi
mov    $0x2,%edx
mov    $0x3,%ecx
mov    $0x4,%r8d
mov    $0x5,%r9d
push   $0x10
push   $0xf
push   $0xe
push   $0xd
push   $0xc
push   $0xb
push   $0xa
push   $0x9
push   $0x8
push   $0x7
push   $0x6
call   1050 <testVaArgDouble@plt>
add    $0x60,%rsp
lea    0xe4b(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [25 x i8] c"Test int va_arg : %d\0A\00"
@.str.1 = [25 x i8] c"Test double va_arg : %f\0A\00"
define i32 @main() {
%1 = call i32 @testVaArgInt(i32 8, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 16)
%2 = sitofp i32 %1 to double
%3 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), double %2)
%4 = call double @testVaArgDouble(i32 8, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 16)
%5 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), double %4)
ret i32 0
}

LLVM IR (-O2):
@.str = [25 x i8] c"Test int va_arg : %d\0A\00"
@.str.1 = [25 x i8] c"Test double va_arg : %f\0A\00"
define i32 @main() {
%1 = tail call i32 @testVaArgInt(i32 8, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 16)
%2 = sitofp i32 %1 to double
%3 = tail call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), double %2)
%4 = tail call double @testVaArgDouble(i32 8, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 16)
%5 = tail call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), double %4)
ret i32 0
}