#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 */
long atol(char *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
long get_random();
long increment(long);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stdin;
int do_stuff() {
  long ans = get_random();
  ans = increment(ans);
  int res = 0;
  printf("What number would you like to guess?\n");
  char guess[100];
  fgets(guess, 100, stdin);
  long g = atol(guess);
  if (!g) {
    printf("That's not a valid number!\n");
  } else {
    if (g == ans) {
      printf("Congrats! You win! Your prize is this print statement!\n\n");
      res = 1;
    } else {
      printf("Nope!\n\n");
    }
  }
  return res;
}


x86 assembly (clang, -O0):
<do_stuff>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    $0x0,%al
call   1030 <get_random@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <increment@plt>
mov    %rax,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xe7f(%rip),%rdi
call   1050 <printf@plt>
lea    -0x70(%rbp),%rdi
mov    0x2e57(%rip),%rax
mov    (%rax),%edx
mov    $0x64,%esi
call   1060 <fgets@plt>
lea    -0x70(%rbp),%rdi
call   1070 <atol@plt>
mov    %rax,-0x78(%rbp)
cmpq   $0x0,-0x78(%rbp)
jne    11c6 <do_stuff+0x76>
lea    0xe6a(%rip),%rdi
call   1050 <printf@plt>
jmp    11fd <do_stuff+0xad>
mov    -0x78(%rbp),%rax
cmp    -0x8(%rbp),%rax
jne    11ec <do_stuff+0x9c>
lea    0xe67(%rip),%rdi
call   1050 <printf@plt>
movl   $0x1,-0xc(%rbp)
jmp    11f8 <do_stuff+0xa8>
lea    0xe88(%rip),%rdi
call   1050 <printf@plt>
jmp    11fd <do_stuff+0xad>
mov    -0xc(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_stuff>:
push   %r14
push   %rbx
sub    $0x68,%rsp
xor    %eax,%eax
call   1040 <get_random@plt>
mov    %rax,%rdi
call   1050 <increment@plt>
mov    %rax,%r14
lea    0xe90(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e6c(%rip),%rax
mov    (%rax),%edx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x64,%esi
call   1060 <fgets@plt>
mov    %rbx,%rdi
call   1070 <atol@plt>
cmp    %r14,%rax
lea    0xea7(%rip),%rcx
lea    0xe99(%rip),%rdx
cmove  %rcx,%rdx
sete   %cl
test   %rax,%rax
setne  %al
lea    0xe6a(%rip),%rdi
cmovne %rdx,%rdi
and    %cl,%al
movzbl %al,%ebx
call   1030 <puts@plt>
mov    %ebx,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [38 x i8] c"What number would you like to guess?\0A\00"
@stdin = global i32 0
@.str.1 = [28 x i8] c"That's not a valid number!\0A\00"
@.str.2 = [57 x i8] c"Congrats! You win! Your prize is this print statement!\0A\0A\00"
@.str.3 = [8 x i8] c"Nope!\0A\0A\00"
define i32 @do_stuff() {
%1 = alloca i64
%2 = alloca i32
%3 = alloca [100 x i8]
%4 = alloca i64
%5 = call i64 (...) @get_random()
store i64 %5, i64* %1
%6 = load i64, i64* %1
%7 = call i64 @increment(i64 %6)
store i64 %7, i64* %1
store i32 0, i32* %2
%8 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%9 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%10 = load i32, i32* @stdin
%11 = call i32 @fgets(i8* %9, i32 100, i32 %10)
%12 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%13 = call i64 @atol(i8* %12)
store i64 %13, i64* %4
%14 = load i64, i64* %4
%15 = icmp ne i64 %14, 0
br i1 %15, label %18, label %16
16: ; preds = %0
%17 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
br label %27
18: ; preds = %0
%19 = load i64, i64* %4
%20 = load i64, i64* %1
%21 = icmp eq i64 %19, %20
br i1 %21, label %22, label %24
22: ; preds = %18
%23 = call i32 @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %2
br label %26
24: ; preds = %18
%25 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
br label %26
26: ; preds = %24, %22
br label %27
27: ; preds = %26, %16
%28 = load i32, i32* %2
ret i32 %28
}

LLVM IR (-O2):
@stdin = global i32 0
@str = [37 x i8] c"What number would you like to guess?\00"
@str.4 = [27 x i8] c"That's not a valid number!\00"
@str.5 = [7 x i8] c"Nope!\0A\00"
@str.6 = [56 x i8] c"Congrats! You win! Your prize is this print statement!\0A\00"
define i32 @do_stuff() {
%1 = alloca [100 x i8]
%2 = tail call i64 (...) @get_random()
%3 = tail call i64 @increment(i64 %2)
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str, i64 0, i64 0))
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%6 = load i32, i32* @stdin
%7 = call i32 @fgets(i8* %5, i32 100, i32 %6)
%8 = call i64 @atol(i8* %5)
%9 = icmp eq i64 %8, 0
%10 = icmp eq i64 %8, %3
%11 = select i1 %10, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @str.6, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @str.5, i64 0, i64 0)
%12 = select i1 %9, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @str.4, i64 0, i64 0), i8* %11
%13 = xor i1 %9, true
%14 = select i1 %13, i1 %10, i1 false
%15 = zext i1 %14 to i32
%16 = call i32 @puts(i8* dereferenceable(1) %12)
ret i32 %15
}