#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 EXIT_SUCCESS;
int iterate(char *, ...);
int /*<<< orphan*/ printf(char *, int);
int main(void) {
  char *string = "variadic functions";
  printf("number of elements: %2d (char)\n", iterate("char", string));
  int arr[] = {10, 20, 30, 40, 50, 60, -1};
  printf("number of elements: %2d (int)\n", iterate("int", arr));
  long long vec[] = {100, 200, 300, 400, 500, 600, -1};
  printf("number of elements: %2d (long long)\n", iterate("long long", vec));
  return (EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xede(%rip),%rdi
mov    $0x0,%al
call   1050 <iterate@plt>
mov    %eax,%esi
lea    0xeae(%rip),%rdi
call   1030 <printf@plt>
mov    0xf1f(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xf1c(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xf19(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xf17(%rip),%eax
mov    %eax,-0x18(%rbp)
lea    -0x30(%rbp),%rsi
lea    0xeb8(%rip),%rdi
mov    $0x0,%al
call   1050 <iterate@plt>
mov    %eax,%esi
lea    0xe89(%rip),%rdi
call   1030 <printf@plt>
lea    -0x70(%rbp),%rdi
lea    0xef1(%rip),%rsi
mov    $0x38,%edx
call   1040 <memcpy@plt>
lea    -0x70(%rbp),%rsi
lea    0xeac(%rip),%rdi
mov    $0x0,%al
call   1050 <iterate@plt>
mov    %eax,%esi
lea    0xe77(%rip),%rdi
call   1030 <printf@plt>
mov    0x2df0(%rip),%rax
mov    (%rax),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x58,%rsp
lea    0xf08(%rip),%rdi
lea    0xece(%rip),%rsi
xor    %eax,%eax
call   1040 <iterate@plt>
lea    0xed3(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
movups 0xf4e(%rip),%xmm0
movups %xmm0,0xc(%rsp)
movaps 0xf36(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0xef2(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1040 <iterate@plt>
lea    0xec2(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    0xf5c(%rip),%rax
mov    %rax,0x50(%rsp)
movaps 0xf40(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xf24(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xf08(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
lea    0xecc(%rip),%rdi
lea    0x20(%rsp),%rsi
xor    %eax,%eax
call   1040 <iterate@plt>
lea    0xe94(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    0x2e0b(%rip),%rax
mov    (%rax),%eax
add    $0x58,%rsp
ret

LLVM IR (-O0):
@.str = [19 x i8] c"variadic functions\00"
@.str.1 = [32 x i8] c"number of elements: %2d (char)\0A\00"
@.str.2 = [5 x i8] c"char\00"
@__const.main.arr = [7 x i32] [i32 10, i32 20, i32 30, i32 40, i32 50, i32 60, i32 -1]
@.str.3 = [31 x i8] c"number of elements: %2d (int)\0A\00"
@.str.4 = [4 x i8] c"int\00"
@__const.main.vec = [7 x i64] [i64 100, i64 200, i64 300, i64 400, i64 500, i64 600, i64 -1]
@.str.5 = [37 x i8] c"number of elements: %2d (long long)\0A\00"
@.str.6 = [10 x i8] c"long long\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca [7 x i32]
%4 = alloca [7 x i64]
store i32 0, i32* %1
store i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8** %2
%5 = load i8*, i8** %2
%6 = call i32 (i8*, ...) @iterate(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %5)
%7 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i32 %6)
%8 = bitcast [7 x i32]* %3 to i8*
%9 = getelementptr inbounds [7 x i32], [7 x i32]* %3, i64 0, i64 0
%10 = call i32 (i8*, ...) @iterate(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32* %9)
%11 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i32 %10)
%12 = bitcast [7 x i64]* %4 to i8*
%13 = getelementptr inbounds [7 x i64], [7 x i64]* %4, i64 0, i64 0
%14 = call i32 (i8*, ...) @iterate(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i64* %13)
%15 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.5, i64 0, i64 0), i32 %14)
%16 = load i32, i32* @EXIT_SUCCESS
ret i32 %16
}

LLVM IR (-O2):
@.str = [19 x i8] c"variadic functions\00"
@.str.1 = [32 x i8] c"number of elements: %2d (char)\0A\00"
@.str.2 = [5 x i8] c"char\00"
@__const.main.arr = [7 x i32] [i32 10, i32 20, i32 30, i32 40, i32 50, i32 60, i32 -1]
@.str.3 = [31 x i8] c"number of elements: %2d (int)\0A\00"
@.str.4 = [4 x i8] c"int\00"
@__const.main.vec = [7 x i64] [i64 100, i64 200, i64 300, i64 400, i64 500, i64 600, i64 -1]
@.str.5 = [37 x i8] c"number of elements: %2d (long long)\0A\00"
@.str.6 = [10 x i8] c"long long\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca [7 x i32]
%2 = alloca [7 x i64]
%3 = tail call i32 (i8*, ...) @iterate(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i32 %3)
%5 = bitcast [7 x i32]* %1 to i8*
%6 = getelementptr inbounds [7 x i32], [7 x i32]* %1, i64 0, i64 0
%7 = call i32 (i8*, ...) @iterate(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32* %6)
%8 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i32 %7)
%9 = bitcast [7 x i64]* %2 to i8*
%10 = getelementptr inbounds [7 x i64], [7 x i64]* %2, i64 0, i64 0
%11 = call i32 (i8*, ...) @iterate(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i64* %10)
%12 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.5, i64 0, i64 0), i32 %11)
%13 = load i32, i32* @EXIT_SUCCESS
ret i32 %13
}