#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 */
char getchar();
int /*<<< orphan*/ printf(char *, ...);
int roll_dice();
int /*<<< orphan*/ srand(unsigned int);
scalar_t__ time(int /*<<< orphan*/ *);
bool play_game() {
  int trial, sum;
  bool points_table[6 + 6 + 1] = {0};
  srand((unsigned)time(NULL));
  for (trial = 1;; trial++) {
    while (getchar() != '\n') {
    }
    sum = roll_dice();
    switch (sum) {
    case 2:
    case 3:
    case 12: {
      printf("you rolled: %d\n\n", sum);
      printf("you lose\n");
      return false;
    }
    case 7:
    case 11: {
      if (trial == 1) {
        printf("you rolled %d on first roll.\n\n", sum);
        printf("you win\n");
        return true;
      } else if ((sum == 7 || sum == 11) && trial != 1) {
        printf("you rolled %d more than once\n", sum);
        printf("you lose\n");
        return false;
      }
    }
    default: {
      if (points_table[sum] == true) {
        printf("you rolled %d\n", sum);
        printf("you win\n");
        return true;
      } else {
        printf("you rolled %d\n", sum);
        printf("you point is %d\n", sum);
        points_table[sum] = true;
      }
    }
    }
  }
}


x86 assembly (clang, -O0):
<play_game>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x34,%edx
call   1040 <memset@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
movl   $0x1,-0x8(%rbp)
jmp    1194 <play_game+0x34>
mov    $0x0,%al
call   1060 <getchar@plt>
movsbl %al,%eax
cmp    $0xa,%eax
je     11ac <play_game+0x4c>
jmp    1194 <play_game+0x34>
xor    %eax,%eax
call   1080 <roll_dice@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x44(%rbp)
add    $0xfffffffe,%eax
sub    $0x2,%eax
jb     1200 <play_game+0xa0>
jmp    11cd <play_game+0x6d>
mov    -0x44(%rbp),%eax
sub    $0x7,%eax
je     122b <play_game+0xcb>
jmp    11de <play_game+0x7e>
mov    -0x44(%rbp),%eax
sub    $0xb,%eax
je     122b <play_game+0xcb>
jmp    11ef <play_game+0x8f>
mov    -0x44(%rbp),%eax
sub    $0xc,%eax
jne    12b3 <play_game+0x153>
jmp    1200 <play_game+0xa0>
mov    -0xc(%rbp),%esi
lea    0xdf6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xdf9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1333 <play_game+0x1d3>
cmpl   $0x1,-0x8(%rbp)
jne    1260 <play_game+0x100>
mov    -0xc(%rbp),%esi
lea    0xddc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xded(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1333 <play_game+0x1d3>
cmpl   $0x7,-0xc(%rbp)
je     1274 <play_game+0x114>
cmpl   $0xb,-0xc(%rbp)
jne    12a9 <play_game+0x149>
cmpl   $0x1,-0x8(%rbp)
je     12a9 <play_game+0x149>
mov    -0xc(%rbp),%esi
lea    0xdbb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xd7b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1333 <play_game+0x1d3>
jmp    12ae <play_game+0x14e>
jmp    12b3 <play_game+0x153>
movslq -0xc(%rbp),%rax
cmpl   $0x1,-0x40(%rbp,%rax,4)
jne    12ed <play_game+0x18d>
mov    -0xc(%rbp),%esi
lea    0xd95(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xd60(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1333 <play_game+0x1d3>
mov    -0xc(%rbp),%esi
lea    0xd6a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%esi
lea    0xd68(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movslq -0xc(%rbp),%rax
movl   $0x1,-0x40(%rbp,%rax,4)
jmp    1320 <play_game+0x1c0>
jmp    1325 <play_game+0x1c5>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    118f <play_game+0x2f>
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<play_game>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
movl   $0x0,0x30(%rsp)
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
mov    $0x1,%r14d
lea    0xeac(%rip),%r13
lea    0xeb4(%rip),%r12
nopl   0x0(%rax)
xor    %eax,%eax
call   1060 <getchar@plt>
cmp    $0xa,%al
jne    11b0 <play_game+0x50>
xor    %ebp,%ebp
xor    %eax,%eax
call   1080 <roll_dice@plt>
mov    %eax,%ebx
cmp    $0xc,%eax
ja     11f1 <play_game+0x91>
mov    $0x880,%eax
bt     %ebx,%eax
jae    11e7 <play_game+0x87>
cmp    $0x1,%r14d
je     1251 <play_game+0xf1>
cmp    $0x7,%ebx
je     1223 <play_game+0xc3>
cmp    $0xb,%ebx
jne    11f1 <play_game+0x91>
jmp    1223 <play_game+0xc3>
mov    $0x100c,%eax
bt     %ebx,%eax
jb     1233 <play_game+0xd3>
movslq %ebx,%rbp
mov    (%rsp,%rbp,4),%r15d
mov    %r13,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x1,%r15d
je     1243 <play_game+0xe3>
mov    %r12,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
movl   $0x1,(%rsp,%rbp,4)
add    $0x1,%r14d
jmp    11b0 <play_game+0x50>
lea    0xe06(%rip),%rdi
lea    0xe45(%rip),%r14
jmp    1264 <play_game+0x104>
lea    0xdc6(%rip),%rdi
lea    0xe35(%rip),%r14
jmp    1264 <play_game+0x104>
mov    $0x1,%ebp
lea    0xe1f(%rip),%r14
jmp    126d <play_game+0x10d>
mov    $0x1,%ebp
lea    0xe11(%rip),%r14
lea    0xdad(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %ebp,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [17 x i8] c"you rolled: %d\0A\0A\00"
@.str.1 = [10 x i8] c"you lose\0A\00"
@.str.2 = [31 x i8] c"you rolled %d on first roll.\0A\0A\00"
@.str.3 = [9 x i8] c"you win\0A\00"
@.str.4 = [30 x i8] c"you rolled %d more than once\0A\00"
@.str.5 = [15 x i8] c"you rolled %d\0A\00"
@.str.6 = [17 x i8] c"you point is %d\0A\00"
define i32 @play_game() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [13 x i32]
%5 = bitcast [13 x i32]* %4 to i8*
%6 = call i64 @time(i32* null)
%7 = trunc i64 %6 to i32
%8 = call i32 @srand(i32 %7)
store i32 1, i32* %2
br label %9
9: ; preds = %64, %0
br label %10
10: ; preds = %14, %9
%11 = call signext i8 (...) @getchar()
%12 = sext i8 %11 to i32
%13 = icmp ne i32 %12, 10
br i1 %13, label %14, label %15
14: ; preds = %10
br label %10
15: ; preds = %10
%16 = call i32 (...) @roll_dice()
store i32 %16, i32* %3
%17 = load i32, i32* %3
switch i32 %17, label %44 [
i32 2, label %18
i32 3, label %18
i32 12, label %18
i32 7, label %22
i32 11, label %22
]
18: ; preds = %15, %15, %15
%19 = load i32, i32* %3
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %19)
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %1
br label %67
22: ; preds = %15, %15
%23 = load i32, i32* %2
%24 = icmp eq i32 %23, 1
br i1 %24, label %25, label %29
25: ; preds = %22
%26 = load i32, i32* %3
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i32 %26)
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %1
br label %67
29: ; preds = %22
%30 = load i32, i32* %3
%31 = icmp eq i32 %30, 7
br i1 %31, label %35, label %32
32: ; preds = %29
%33 = load i32, i32* %3
%34 = icmp eq i32 %33, 11
br i1 %34, label %35, label %42
35: ; preds = %32, %29
%36 = load i32, i32* %2
%37 = icmp ne i32 %36, 1
br i1 %37, label %38, label %42
38: ; preds = %35
%39 = load i32, i32* %3
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i32 %39)
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %1
br label %67
42: ; preds = %35, %32
br label %43
43: ; preds = %42
br label %44
44: ; preds = %15, %43
%45 = load i32, i32* %3
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds [13 x i32], [13 x i32]* %4, i64 0, i64 %46
%48 = load i32, i32* %47
%49 = icmp eq i32 %48, 1
br i1 %49, label %50, label %54
50: ; preds = %44
%51 = load i32, i32* %3
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i32 %51)
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %1
br label %67
54: ; preds = %44
%55 = load i32, i32* %3
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i32 %55)
%57 = load i32, i32* %3
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0), i32 %57)
%59 = load i32, i32* %3
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds [13 x i32], [13 x i32]* %4, i64 0, i64 %60
store i32 1, i32* %61
br label %62
62: ; preds = %54
br label %63
63: ; preds = %62
br label %64
64: ; preds = %63
%65 = load i32, i32* %2
%66 = add nsw i32 %65, 1
store i32 %66, i32* %2
br label %9
67: ; preds = %50, %38, %25, %18
%68 = load i32, i32* %1
ret i32 %68
}

LLVM IR (-O2):
@.str = [17 x i8] c"you rolled: %d\0A\0A\00"
@.str.2 = [31 x i8] c"you rolled %d on first roll.\0A\0A\00"
@.str.4 = [30 x i8] c"you rolled %d more than once\0A\00"
@.str.5 = [15 x i8] c"you rolled %d\0A\00"
@.str.6 = [17 x i8] c"you point is %d\0A\00"
@str.8 = [8 x i8] c"you win\00"
@str.9 = [9 x i8] c"you lose\00"
define i32 @play_game() {
%1 = alloca [13 x i32]
%2 = bitcast [13 x i32]* %1 to i8*
%3 = tail call i64 @time(i32* null)
%4 = trunc i64 %3 to i32
%5 = tail call i32 @srand(i32 %4)
br label %6
6: ; preds = %22, %0
%7 = phi i32 [ 1, %0 ], [ %24, %22 ]
br label %8
8: ; preds = %8, %6
%9 = tail call signext i8 (...) @getchar()
%10 = icmp eq i8 %9, 10
br i1 %10, label %11, label %8
11: ; preds = %8
%12 = tail call i32 (...) @roll_dice()
switch i32 %12, label %16 [
i32 2, label %25
i32 3, label %25
i32 12, label %25
i32 7, label %13
i32 11, label %13
]
13: ; preds = %11, %11
%14 = icmp eq i32 %7, 1
br i1 %14, label %25, label %15
15: ; preds = %13
switch i32 %12, label %16 [
i32 11, label %25
i32 7, label %25
]
16: ; preds = %15, %11
%17 = sext i32 %12 to i64
%18 = getelementptr inbounds [13 x i32], [13 x i32]* %1, i64 0, i64 %17
%19 = load i32, i32* %18
%20 = icmp eq i32 %19, 1
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i32 %12)
br i1 %20, label %30, label %22
22: ; preds = %16
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0), i32 %12)
store i32 1, i32* %18
%24 = add nuw nsw i32 %7, 1
br label %6
25: ; preds = %15, %15, %13, %11, %11, %11
%26 = phi i8* [ getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), %11 ], [ getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), %11 ], [ getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), %11 ], [ getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), %13 ], [ getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), %15 ], [ getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), %15 ]
%27 = phi i8* [ getelementptr inbounds ([9 x i8], [9 x i8]* @str.9, i64 0, i64 0), %11 ], [ getelementptr inbounds ([9 x i8], [9 x i8]* @str.9, i64 0, i64 0), %11 ], [ getelementptr inbounds ([9 x i8], [9 x i8]* @str.9, i64 0, i64 0), %11 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @str.8, i64 0, i64 0), %13 ], [ getelementptr inbounds ([9 x i8], [9 x i8]* @str.9, i64 0, i64 0), %15 ], [ getelementptr inbounds ([9 x i8], [9 x i8]* @str.9, i64 0, i64 0), %15 ]
%28 = phi i32 [ 0, %11 ], [ 0, %11 ], [ 0, %11 ], [ 1, %13 ], [ 0, %15 ], [ 0, %15 ]
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %26, i32 %12)
br label %30
30: ; preds = %16, %25
%31 = phi i8* [ %27, %25 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @str.8, i64 0, i64 0), %16 ]
%32 = phi i32 [ %28, %25 ], [ 1, %16 ]
%33 = tail call i32 @puts(i8* dereferenceable(1) %31)
ret i32 %32
}