#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*/ assert(int);
int test_stdarg_int(int, int);
int test_stdarg_long(int, int);
int test_stdarg_long_long(int, int);
int /*<<< orphan*/ test_stdarg_printf(char *, ...);
int main(void) {
  int i = 0;
  assert(0 == test_stdarg_int(i, 0));
  assert(42 == test_stdarg_int(i, 42));
  assert(2147483647 == test_stdarg_long(i, 2147483647));
  assert(9223372036854775807 == test_stdarg_long_long(i, 9223372036854775807));
  test_stdarg_printf("str:%s\n", "hello world");
  test_stdarg_printf("int:%d\n", 42);
  test_stdarg_printf("hello world %d \n", 42);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%edi
xor    %esi,%esi
call   1070 <test_stdarg_int@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x8(%rbp),%edi
mov    $0x2a,%esi
call   1070 <test_stdarg_int@plt>
mov    %eax,%ecx
mov    $0x2a,%eax
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x8(%rbp),%edi
mov    $0x7fffffff,%esi
call   1040 <test_stdarg_long@plt>
mov    %eax,%ecx
mov    $0x7fffffff,%eax
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x8(%rbp),%edi
mov    $0xffffffff,%esi
call   1050 <test_stdarg_long_long@plt>
movslq %eax,%rcx
movabs $0x7fffffffffffffff,%rax
ff ff 7f
cmp    %rcx,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
lea    0xe06(%rip),%rdi
lea    0xe07(%rip),%rsi
mov    $0x0,%al
call   1030 <test_stdarg_printf@plt>
lea    0xe05(%rip),%rdi
mov    $0x2a,%esi
mov    $0x0,%al
call   1030 <test_stdarg_printf@plt>
lea    0xdfa(%rip),%rdi
mov    $0x2a,%esi
mov    $0x0,%al
call   1030 <test_stdarg_printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
xor    %edi,%edi
xor    %esi,%esi
call   1070 <test_stdarg_int@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1060 <assert@plt>
xor    %edi,%edi
mov    $0x2a,%esi
call   1070 <test_stdarg_int@plt>
xor    %edi,%edi
cmp    $0x2a,%eax
sete   %dil
call   1060 <assert@plt>
xor    %edi,%edi
mov    $0x7fffffff,%esi
call   1040 <test_stdarg_long@plt>
xor    %edi,%edi
cmp    $0x7fffffff,%eax
sete   %dil
call   1060 <assert@plt>
xor    %edi,%edi
mov    $0xffffffff,%esi
call   1050 <test_stdarg_long_long@plt>
xor    %edi,%edi
call   1060 <assert@plt>
lea    0xe49(%rip),%rdi
lea    0xe4a(%rip),%rsi
xor    %eax,%eax
call   1030 <test_stdarg_printf@plt>
lea    0xe48(%rip),%rdi
mov    $0x2a,%esi
xor    %eax,%eax
call   1030 <test_stdarg_printf@plt>
lea    0xe3d(%rip),%rdi
mov    $0x2a,%esi
xor    %eax,%eax
call   1030 <test_stdarg_printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [8 x i8] c"str:%s\0A\00"
@.str.1 = [12 x i8] c"hello world\00"
@.str.2 = [8 x i8] c"int:%d\0A\00"
@.str.3 = [17 x i8] c"hello world %d \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
%3 = load i32, i32* %2
%4 = call i32 @test_stdarg_int(i32 %3, i32 0)
%5 = icmp eq i32 0, %4
%6 = zext i1 %5 to i32
%7 = call i32 @assert(i32 %6)
%8 = load i32, i32* %2
%9 = call i32 @test_stdarg_int(i32 %8, i32 42)
%10 = icmp eq i32 42, %9
%11 = zext i1 %10 to i32
%12 = call i32 @assert(i32 %11)
%13 = load i32, i32* %2
%14 = call i32 @test_stdarg_long(i32 %13, i32 2147483647)
%15 = icmp eq i32 2147483647, %14
%16 = zext i1 %15 to i32
%17 = call i32 @assert(i32 %16)
%18 = load i32, i32* %2
%19 = call i32 @test_stdarg_long_long(i32 %18, i32 -1)
%20 = sext i32 %19 to i64
%21 = icmp eq i64 9223372036854775807, %20
%22 = zext i1 %21 to i32
%23 = call i32 @assert(i32 %22)
%24 = call i32 (i8*, ...) @test_stdarg_printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%25 = call i32 (i8*, ...) @test_stdarg_printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 42)
%26 = call i32 (i8*, ...) @test_stdarg_printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i32 42)
ret i32 0
}

LLVM IR (-O2):
@.str = [8 x i8] c"str:%s\0A\00"
@.str.1 = [12 x i8] c"hello world\00"
@.str.2 = [8 x i8] c"int:%d\0A\00"
@.str.3 = [17 x i8] c"hello world %d \0A\00"
define i32 @main() {
%1 = tail call i32 @test_stdarg_int(i32 0, i32 0)
%2 = icmp eq i32 %1, 0
%3 = zext i1 %2 to i32
%4 = tail call i32 @assert(i32 %3)
%5 = tail call i32 @test_stdarg_int(i32 0, i32 42)
%6 = icmp eq i32 %5, 42
%7 = zext i1 %6 to i32
%8 = tail call i32 @assert(i32 %7)
%9 = tail call i32 @test_stdarg_long(i32 0, i32 2147483647)
%10 = icmp eq i32 %9, 2147483647
%11 = zext i1 %10 to i32
%12 = tail call i32 @assert(i32 %11)
%13 = tail call i32 @test_stdarg_long_long(i32 0, i32 -1)
%14 = tail call i32 @assert(i32 0)
%15 = tail call i32 (i8*, ...) @test_stdarg_printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%16 = tail call i32 (i8*, ...) @test_stdarg_printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 42)
%17 = tail call i32 (i8*, ...) @test_stdarg_printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i32 42)
ret i32 0
}