#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 = roll_dice();
  int point = 0;
  printf("First roll: %d\n", roll);
  if (roll == 7 || roll == 11) {
    printf("You won!\n");
    return true;
  } else if (roll == 2 || roll == 3 || roll == 12) {
    printf("You lost!\n");
    return false;
  } else {
    point = roll;
    printf("Point is: %d\n", point);
    while (1) {
      roll = roll_dice();
      printf("Rolled: %d\n", roll);
      if (roll == point) {
        printf("You won!\n");
        return true;
      } else if (roll == 7) {
        printf("You lost!\n");
        return false;
      } else {
        continue;
      }
    }
  }
}


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)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%esi
lea    0xebd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x7,-0x8(%rbp)
je     115e <play_game+0x3e>
cmpl   $0xb,-0x8(%rbp)
jne    1178 <play_game+0x58>
lea    0xeab(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1231 <play_game+0x111>
cmpl   $0x2,-0x8(%rbp)
je     1196 <play_game+0x76>
cmpl   $0x3,-0x8(%rbp)
je     1196 <play_game+0x76>
cmpl   $0xc,-0x8(%rbp)
jne    11b0 <play_game+0x90>
lea    0xe7d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1231 <play_game+0x111>
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe65(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <roll_dice@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xe58(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jne    1208 <play_game+0xe8>
lea    0xe1b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1231 <play_game+0x111>
cmpl   $0x7,-0x8(%rbp)
jne    122c <play_game+0x10c>
lea    0xe01(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1231 <play_game+0x111>
jmp    11c7 <play_game+0xa7>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<play_game>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
xor    %eax,%eax
call   1050 <roll_dice@plt>
mov    %eax,%ebx
lea    0xeb8(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    -0x2(%rbx),%eax
cmp    $0xb,%eax
jae    1163 <play_game+0x33>
mov    $0x623,%ecx
bt     %eax,%ecx
jb     11bc <play_game+0x8c>
lea    0xea6(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xea4(%rip),%r15
lea    0xeb3(%rip),%r14
lea    0xea2(%rip),%r12
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1050 <roll_dice@plt>
mov    %eax,%ebp
mov    %r15,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    %ebx,%ebp
je     11b5 <play_game+0x85>
cmp    $0x7,%ebp
jne    1190 <play_game+0x60>
xor    %ebx,%ebx
mov    %r12,%r14
jmp    11d6 <play_game+0xa6>
mov    $0x1,%ebx
jmp    11d6 <play_game+0xa6>
cltq
lea    0xe7b(%rip),%rcx
movslq (%rcx,%rax,4),%r14
add    %rcx,%r14
lea    0xe99(%rip),%rcx
mov    (%rcx,%rax,4),%ebx
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %ebx,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [16 x i8] c"First roll: %d\0A\00"
@.str.1 = [10 x i8] c"You won!\0A\00"
@.str.2 = [11 x i8] c"You lost!\0A\00"
@.str.3 = [14 x i8] c"Point is: %d\0A\00"
@.str.4 = [12 x i8] c"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
store i32 0, i32* %3
%5 = load i32, i32* %2
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 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 ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %1
br label %44
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 ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %1
br label %44
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 ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %27)
br label %29
29: ; preds = %25, %43
%30 = call i32 (...) @roll_dice()
store i32 %30, i32* %2
%31 = load i32, i32* %2
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 %31)
%33 = load i32, i32* %2
%34 = load i32, i32* %3
%35 = icmp eq i32 %33, %34
br i1 %35, label %36, label %38
36: ; preds = %29
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %1
br label %44
38: ; preds = %29
%39 = load i32, i32* %2
%40 = icmp eq i32 %39, 7
br i1 %40, label %41, label %43
41: ; preds = %38
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %1
br label %44
43: ; preds = %38
br label %29
44: ; preds = %41, %36, %23, %12
%45 = load i32, i32* %1
ret i32 %45
}

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