#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*/ printf(char *, ...);
int roll_dice();
bool play_game(void) {
  int roll, point;
  roll = roll_dice();
  printf("\nYou rolled: %d\n", roll);
  if (roll == 7 || roll == 11) {
    printf("You win!\n\n");
    return true;
  } else if (roll == 2 || roll == 3 || roll == 12) {
    printf("You lose!\n\n");
    return false;
  } else {
    point = roll;
    printf("Your point is %d\n", point);
  }
  for (;;) {
    roll = roll_dice();
    printf("You rolled: %d\n", roll);
    if (roll == point) {
      printf("You win!\n\n");
      return true;
    }
    if (roll == 7 || roll == 11) {
      printf("You lose!\n\n");
      return false;
    }
  }
}


x86 assembly (clang, -O0):
<play_game>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1040 <roll_dice@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xec4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x7,-0x8(%rbp)
je     1157 <play_game+0x37>
cmpl   $0xb,-0x8(%rbp)
jne    1171 <play_game+0x51>
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    123e <play_game+0x11e>
cmpl   $0x2,-0x8(%rbp)
je     118f <play_game+0x6f>
cmpl   $0x3,-0x8(%rbp)
je     118f <play_game+0x6f>
cmpl   $0xc,-0x8(%rbp)
jne    11a9 <play_game+0x89>
lea    0xe86(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    123e <play_game+0x11e>
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe6f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11c5 <play_game+0xa5>
jmp    11ca <play_game+0xaa>
mov    $0x0,%al
call   1040 <roll_dice@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xe23(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jne    120b <play_game+0xeb>
lea    0xe19(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    123e <play_game+0x11e>
cmpl   $0x7,-0x8(%rbp)
je     121f <play_game+0xff>
cmpl   $0xb,-0x8(%rbp)
jne    1239 <play_game+0x119>
lea    0xdf6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    123e <play_game+0x11e>
jmp    11ca <play_game+0xaa>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<play_game>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %eax,%eax
call   1050 <roll_dice@plt>
mov    %eax,%r12d
lea    0xeb4(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    -0x2(%r12),%eax
cmp    $0xb,%eax
jae    1169 <play_game+0x39>
mov    $0x623,%ecx
bt     %eax,%ecx
jb     11c9 <play_game+0x99>
lea    0xea1(%rip),%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe80(%rip),%r15
lea    0xea6(%rip),%r14
lea    0xe94(%rip),%r13
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1050 <roll_dice@plt>
mov    %eax,%ebx
mov    %r15,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    %r12d,%ebx
je     11e5 <play_game+0xb5>
cmp    $0x7,%ebx
je     11c4 <play_game+0x94>
cmp    $0xb,%ebx
jne    11a0 <play_game+0x70>
mov    %r13,%r14
jmp    11ea <play_game+0xba>
cltq
lea    0xe66(%rip),%rcx
movslq (%rcx,%rax,4),%r14
add    %rcx,%r14
lea    0xe84(%rip),%rcx
mov    (%rcx,%rax,4),%ebp
jmp    11ea <play_game+0xba>
mov    $0x1,%ebp
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [17 x i8] c"\0AYou rolled: %d\0A\00"
@.str.1 = [11 x i8] c"You win!\0A\0A\00"
@.str.2 = [12 x i8] c"You lose!\0A\0A\00"
@.str.3 = [18 x i8] c"Your point is %d\0A\00"
@.str.4 = [16 x i8] c"You rolled: %d\0A\00"
define i32 @play_game() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = call i32 (...) @roll_dice()
store i32 %4, i32* %2
%5 = load i32, i32* %2
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = load i32, i32* %2
%8 = icmp eq i32 %7, 7
br i1 %8, label %12, label %9
9: ; preds = %0
%10 = load i32, i32* %2
%11 = icmp eq i32 %10, 11
br i1 %11, label %12, label %14
12: ; preds = %9, %0
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %1
br label %49
14: ; preds = %9
%15 = load i32, i32* %2
%16 = icmp eq i32 %15, 2
br i1 %16, label %23, label %17
17: ; preds = %14
%18 = load i32, i32* %2
%19 = icmp eq i32 %18, 3
br i1 %19, label %23, label %20
20: ; preds = %17
%21 = load i32, i32* %2
%22 = icmp eq i32 %21, 12
br i1 %22, label %23, label %25
23: ; preds = %20, %17, %14
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %1
br label %49
25: ; preds = %20
%26 = load i32, i32* %2
store i32 %26, i32* %3
%27 = load i32, i32* %3
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i32 %27)
br label %29
29: ; preds = %25
br label %30
30: ; preds = %29
br label %31
31: ; preds = %48, %30
%32 = call i32 (...) @roll_dice()
store i32 %32, i32* %2
%33 = load i32, i32* %2
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i32 %33)
%35 = load i32, i32* %2
%36 = load i32, i32* %3
%37 = icmp eq i32 %35, %36
br i1 %37, label %38, label %40
38: ; preds = %31
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %1
br label %49
40: ; preds = %31
%41 = load i32, i32* %2
%42 = icmp eq i32 %41, 7
br i1 %42, label %46, label %43
43: ; preds = %40
%44 = load i32, i32* %2
%45 = icmp eq i32 %44, 11
br i1 %45, label %46, label %48
46: ; preds = %43, %40
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %1
br label %49
48: ; preds = %43
br label %31
49: ; preds = %46, %38, %23, %12
%50 = load i32, i32* %1
ret i32 %50
}

LLVM IR (-O2):
@.str = [17 x i8] c"\0AYou rolled: %d\0A\00"
@.str.3 = [18 x i8] c"Your point is %d\0A\00"
@.str.4 = [16 x i8] c"You rolled: %d\0A\00"
@str.6 = [11 x i8] c"You lose!\0A\00"
@str.7 = [10 x i8] c"You win!\0A\00"
@reltable.play_game = [11 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([11 x i8]* @str.6 to i64), i64 ptrtoint ([11 x i32]* @reltable.play_game to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([11 x i8]* @str.6 to i64), i64 ptrtoint ([11 x i32]* @reltable.play_game to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @str.7 to i64), i64 ptrtoint ([11 x i32]* @reltable.play_game to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @str.7 to i64), i64 ptrtoint ([11 x i32]* @reltable.play_game to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @str.7 to i64), i64 ptrtoint ([11 x i32]* @reltable.play_game to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @str.7 to i64), i64 ptrtoint ([11 x i32]* @reltable.play_game to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @str.7 to i64), i64 ptrtoint ([11 x i32]* @reltable.play_game to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @str.7 to i64), i64 ptrtoint ([11 x i32]* @reltable.play_game to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @str.7 to i64), i64 ptrtoint ([11 x i32]* @reltable.play_game to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @str.7 to i64), i64 ptrtoint ([11 x i32]* @reltable.play_game to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([11 x i8]* @str.6 to i64), i64 ptrtoint ([11 x i32]* @reltable.play_game to i64)) to i32)]
@switch.table.play_game.8 = [11 x i32] [i32 0, i32 0, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 0]
define i32 @play_game() {
%1 = tail call i32 (...) @roll_dice()
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %1)
%3 = add i32 %1, -2
%4 = icmp ult i32 %3, 11
br i1 %4, label %12, label %5
5: ; preds = %12, %0
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i32 %1)
br label %7
7: ; preds = %11, %5
%8 = tail call i32 (...) @roll_dice()
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i32 %8)
%10 = icmp eq i32 %8, %1
br i1 %10, label %24, label %11
11: ; preds = %7
switch i32 %8, label %7 [
i32 11, label %24
i32 7, label %24
]
12: ; preds = %0
%13 = trunc i32 %3 to i16
%14 = lshr i16 1571, %13
%15 = and i16 %14, 1
%16 = icmp eq i16 %15, 0
br i1 %16, label %5, label %17
17: ; preds = %12
%18 = sext i32 %3 to i64
%19 = shl i64 %18, 2
%20 = call i8* @llvm.load.relative.i64(i8* bitcast ([11 x i32]* @reltable.play_game to i8*), i64 %19)
%21 = sext i32 %3 to i64
%22 = getelementptr inbounds [11 x i32], [11 x i32]* @switch.table.play_game.8, i64 0, i64 %21
%23 = load i32, i32* %22
br label %24
24: ; preds = %11, %11, %7, %17
%25 = phi i8* [ %20, %17 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @str.7, i64 0, i64 0), %7 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @str.6, i64 0, i64 0), %11 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @str.6, i64 0, i64 0), %11 ]
%26 = phi i32 [ %23, %17 ], [ 1, %7 ], [ 0, %11 ], [ 0, %11 ]
%27 = tail call i32 @puts(i8* dereferenceable(1) %25)
ret i32 %26
}