#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("Failed doubling NULL\n");
  } else {
    printf("Doubling NULL gave us: %d\n", result);
  }
  ret_value = doubler(NULL, &result);
  if (ret_value != 0) {
    printf("Failed doubling NULL\n");
  } else {
    printf("Doubling NULL gave us: %d\n", result);
  }
  ret_value = doubler(&value, NULL);
  if (ret_value != 0) {
    printf("Failed doubling NULL\n");
  } else {
    printf("Doubling %d gave us: %d\n", value, result);
  }
  ret_value = doubler(&value, &result);
  if (ret_value != 0) {
    printf("Failed doubling NULL\n");
  } else {
    printf("Doubling %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    0xeaa(%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    0xe6c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11b1 <main+0x91>
mov    -0x10(%rbp),%esi
lea    0xe6c(%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    0xe2e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11f2 <main+0xd2>
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    0xe46(%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     121f <main+0xff>
lea    0xded(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1233 <main+0x113>
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    0xe05(%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    0xee7(%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    0xebd(%rip),%rdi
call   1030 <puts@plt>
jmp    118f <main+0x5f>
mov    (%rsp),%esi
lea    0xe78(%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    0xe8e(%rip),%rdi
call   1030 <puts@plt>
jmp    11c2 <main+0x92>
mov    0x4(%rsp),%esi
mov    (%rsp),%edx
lea    0xe60(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x4(%rsp),%rdi
mov    %rsp,%rsi
call   1050 <doubler@plt>
test   %eax,%eax
je     11e1 <main+0xb1>
lea    0xe5a(%rip),%rdi
call   1030 <puts@plt>
jmp    11f6 <main+0xc6>
mov    0x4(%rsp),%esi
mov    (%rsp),%edx
lea    0xe2c(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [22 x i8] c"Failed doubling NULL\0A\00"
@.str.1 = [27 x i8] c"Doubling NULL gave us: %d\0A\00"
@.str.2 = [25 x i8] c"Doubling %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 ([22 x i8], [22 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 ([27 x i8], [27 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 ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
br label %22
19: ; preds = %13
%20 = load i32, i32* %4
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, 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 ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
br label %32
28: ; preds = %22
%29 = load i32, i32* %3
%30 = load i32, i32* %4
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 %29, i32 %30)
br label %32
32: ; preds = %28, %26
%33 = call i32 @doubler(i32* %3, i32* %4)
store i32 %33, i32* %2
%34 = load i32, i32* %2
%35 = icmp ne i32 %34, 0
br i1 %35, label %36, label %38
36: ; preds = %32
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
br label %42
38: ; preds = %32
%39 = load i32, i32* %3
%40 = load i32, i32* %4
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 %39, i32 %40)
br label %42
42: ; preds = %38, %36
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [27 x i8] c"Doubling NULL gave us: %d\0A\00"
@.str.2 = [25 x i8] c"Doubling %d gave us: %d\0A\00"
@str.5 = [21 x i8] c"Failed doubling 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 ([21 x i8], [21 x i8]* @str.5, i64 0, i64 0))
br label %11
9: ; preds = %0
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 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 ([21 x i8], [21 x i8]* @str.5, 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 ([27 x i8], [27 x i8]* @.str.1, 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 ([21 x i8], [21 x i8]* @str.5, i64 0, i64 0))
br label %28
24: ; preds = %19
%25 = load i32, i32* %1
%26 = load i32, i32* %2
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 %25, i32 %26)
br label %28
28: ; preds = %24, %22
%29 = call i32 @doubler(i32* %1, i32* %2)
%30 = icmp eq i32 %29, 0
br i1 %30, label %33, label %31
31: ; preds = %28
%32 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.5, i64 0, i64 0))
br label %37
33: ; preds = %28
%34 = load i32, i32* %1
%35 = load i32, i32* %2
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 %34, i32 %35)
br label %37
37: ; preds = %33, %31
ret i32 0
}