#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 doubler(int *, int *);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  int ret_value;
  int value = 13;
  int result;
  ret_value = doubler(NULL, NULL);
  if (ret_value != 0) {
    printf("Test passed. Failed doubling NULL, NULL\n");
  } else {
    printf("Uh-oh, doubler(NULL, NULL) set result to: %d\n", result);
  }
  ret_value = doubler(NULL, &result);
  if (ret_value != 0) {
    printf("Test passed. Failed doubling NULL, &result\n");
  } else {
    printf("Uh-oh, doubler(NULL, &result) set result to: %d\n", result);
  }
  ret_value = doubler(&value, NULL);
  if (ret_value != 0) {
    printf("Test passed. Failed doubling &value, NULL\n");
  } else {
    printf("Uh-oh, doubler(&value, NULL) set result to: %d\n", result);
  }
  ret_value = doubler(&value, &result);
  if (ret_value != 0) {
    printf("Uh-oh, doubler(&value, &result) returned error code.\n");
  } else {
    printf("Test passed. doubler(&value, &result) where value was %d gave us: "
           "%d\n",
           value, result);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xd,-0xc(%rbp)
xor    %eax,%eax
mov    %eax,%esi
mov    %rsi,%rdi
call   1040 <doubler@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     1162 <main+0x42>
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1173 <main+0x53>
mov    -0x10(%rbp),%esi
lea    0xebd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    -0x10(%rbp),%rsi
call   1040 <doubler@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     11a0 <main+0x80>
lea    0xec3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11b1 <main+0x91>
mov    -0x10(%rbp),%esi
lea    0xed9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0xc(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <doubler@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     11de <main+0xbe>
lea    0xee2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11ef <main+0xcf>
mov    -0x10(%rbp),%esi
lea    0xef7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0xc(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <doubler@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     121c <main+0xfc>
lea    0xeff(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1230 <main+0x110>
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    0xf1c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
movl   $0xd,0x4(%rsp)
xor    %edi,%edi
xor    %esi,%esi
call   1050 <doubler@plt>
test   %eax,%eax
je     1154 <main+0x24>
lea    0x1012(%rip),%rdi
call   1030 <puts@plt>
jmp    1162 <main+0x32>
lea    0xea5(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rsp,%rsi
xor    %edi,%edi
call   1050 <doubler@plt>
test   %eax,%eax
je     117e <main+0x4e>
lea    0xfbd(%rip),%rdi
call   1030 <puts@plt>
jmp    118f <main+0x5f>
mov    (%rsp),%esi
lea    0xea6(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x4(%rsp),%rdi
xor    %esi,%esi
call   1050 <doubler@plt>
test   %eax,%eax
je     11ad <main+0x7d>
lea    0xf64(%rip),%rdi
call   1030 <puts@plt>
jmp    11be <main+0x8e>
mov    (%rsp),%esi
lea    0xea8(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x4(%rsp),%rdi
mov    %rsp,%rsi
call   1050 <doubler@plt>
test   %eax,%eax
je     11dd <main+0xad>
lea    0xeff(%rip),%rdi
call   1030 <puts@plt>
jmp    11f2 <main+0xc2>
mov    0x4(%rsp),%esi
mov    (%rsp),%edx
lea    0xea4(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [41 x i8] c"Test passed. Failed doubling NULL, NULL\0A\00"
@.str.1 = [46 x i8] c"Uh-oh, doubler(NULL, NULL) set result to: %d\0A\00"
@.str.2 = [44 x i8] c"Test passed. Failed doubling NULL, &result\0A\00"
@.str.3 = [49 x i8] c"Uh-oh, doubler(NULL, &result) set result to: %d\0A\00"
@.str.4 = [43 x i8] c"Test passed. Failed doubling &value, NULL\0A\00"
@.str.5 = [48 x i8] c"Uh-oh, doubler(&value, NULL) set result to: %d\0A\00"
@.str.6 = [54 x i8] c"Uh-oh, doubler(&value, &result) returned error code.\0A\00"
@.str.7 = [70 x i8] c"Test passed. doubler(&value, &result) where value was %d gave us: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 13, i32* %3
%5 = call i32 @doubler(i32* null, i32* null)
store i32 %5, i32* %2
%6 = load i32, i32* %2
%7 = icmp ne i32 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %0
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
br label %13
10: ; preds = %0
%11 = load i32, i32* %4
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0), i32 %11)
br label %13
13: ; preds = %10, %8
%14 = call i32 @doubler(i32* null, i32* %4)
store i32 %14, i32* %2
%15 = load i32, i32* %2
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %13
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0))
br label %22
19: ; preds = %13
%20 = load i32, i32* %4
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.3, i64 0, i64 0), i32 %20)
br label %22
22: ; preds = %19, %17
%23 = call i32 @doubler(i32* %3, i32* null)
store i32 %23, i32* %2
%24 = load i32, i32* %2
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %22
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.4, i64 0, i64 0))
br label %31
28: ; preds = %22
%29 = load i32, i32* %4
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.5, i64 0, i64 0), i32 %29)
br label %31
31: ; preds = %28, %26
%32 = call i32 @doubler(i32* %3, i32* %4)
store i32 %32, i32* %2
%33 = load i32, i32* %2
%34 = icmp ne i32 %33, 0
br i1 %34, label %35, label %37
35: ; preds = %31
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.6, i64 0, i64 0))
br label %41
37: ; preds = %31
%38 = load i32, i32* %3
%39 = load i32, i32* %4
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str.7, i64 0, i64 0), i32 %38, i32 %39)
br label %41
41: ; preds = %37, %35
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [46 x i8] c"Uh-oh, doubler(NULL, NULL) set result to: %d\0A\00"
@.str.3 = [49 x i8] c"Uh-oh, doubler(NULL, &result) set result to: %d\0A\00"
@.str.5 = [48 x i8] c"Uh-oh, doubler(&value, NULL) set result to: %d\0A\00"
@.str.7 = [70 x i8] c"Test passed. doubler(&value, &result) where value was %d gave us: %d\0A\00"
@str = [53 x i8] c"Uh-oh, doubler(&value, &result) returned error code.\00"
@str.8 = [42 x i8] c"Test passed. Failed doubling &value, NULL\00"
@str.9 = [43 x i8] c"Test passed. Failed doubling NULL, &result\00"
@str.10 = [40 x i8] c"Test passed. Failed doubling NULL, NULL\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
store i32 13, i32* %1
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 @doubler(i32* null, i32* null)
%6 = icmp eq i32 %5, 0
br i1 %6, label %9, label %7
7: ; preds = %0
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str.10, i64 0, i64 0))
br label %11
9: ; preds = %0
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0), i32 undef)
br label %11
11: ; preds = %9, %7
%12 = call i32 @doubler(i32* null, i32* %2)
%13 = icmp eq i32 %12, 0
br i1 %13, label %16, label %14
14: ; preds = %11
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str.9, i64 0, i64 0))
br label %19
16: ; preds = %11
%17 = load i32, i32* %2
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str.3, i64 0, i64 0), i32 %17)
br label %19
19: ; preds = %16, %14
%20 = call i32 @doubler(i32* %1, i32* null)
%21 = icmp eq i32 %20, 0
br i1 %21, label %24, label %22
22: ; preds = %19
%23 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str.8, i64 0, i64 0))
br label %27
24: ; preds = %19
%25 = load i32, i32* %2
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.5, i64 0, i64 0), i32 %25)
br label %27
27: ; preds = %24, %22
%28 = call i32 @doubler(i32* %1, i32* %2)
%29 = icmp eq i32 %28, 0
br i1 %29, label %32, label %30
30: ; preds = %27
%31 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str, i64 0, i64 0))
br label %36
32: ; preds = %27
%33 = load i32, i32* %1
%34 = load i32, i32* %2
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([70 x i8], [70 x i8]* @.str.7, i64 0, i64 0), i32 %33, i32 %34)
br label %36
36: ; preds = %32, %30
ret i32 0
}