#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*/ clrscr();
int /*<<< orphan*/ divider();
int /*<<< orphan*/ printf(char *, ...);
int rollDice();
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ sleep(unsigned int);
void main() {
  int cont = 1;
  int points, roll;
  int winnings = 0;
  while (cont == 1) {
    clrscr();
    divider();
    printf("Bet: $1\n");
    divider();
    sleep((unsigned int)1);
    roll = rollDice();
    if ((roll == 7) || (roll == 11)) {
      winnings += 1;
      divider();
      printf("You win!\n");
    } else if ((roll == 2) || (roll == 3) || (roll == 12)) {
      winnings -= 1;
      divider();
      printf("You lose.\n");
    } else {
      points = roll;
      roll = 0;
      while ((roll != points) && (roll != 7)) {
        roll = rollDice();
      }
      if (roll == points) {
        winnings += 1;
        divider();
        printf("You win!\n");
      } else {
        winnings -= 1;
        divider();
        printf("You lose.\n");
      }
    }
    divider();
    sleep((unsigned int)1);
    printf("Winnings: $%d\n", winnings);
    divider();
    sleep((unsigned int)1);
    printf("Would you like to continue? (1 = yes, 0 = no) ");
    scanf("%d", &cont);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x1,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0x1,-0x4(%rbp)
jne    1323 <main+0x1c3>
mov    $0x0,%al
call   1030 <clrscr@plt>
mov    $0x0,%al
call   1040 <divider@plt>
lea    0xe6b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1040 <divider@plt>
mov    $0x1,%edi
call   1080 <sleep@plt>
mov    $0x0,%al
call   1060 <rollDice@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x7,-0xc(%rbp)
je     11cb <main+0x6b>
cmpl   $0xb,-0xc(%rbp)
jne    11ee <main+0x8e>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    $0x0,%al
call   1040 <divider@plt>
lea    0xe27(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    12cd <main+0x16d>
cmpl   $0x2,-0xc(%rbp)
je     120c <main+0xac>
cmpl   $0x3,-0xc(%rbp)
je     120c <main+0xac>
cmpl   $0xc,-0xc(%rbp)
jne    122f <main+0xcf>
mov    -0x10(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    $0x0,%al
call   1040 <divider@plt>
lea    0xdf0(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    12c8 <main+0x168>
mov    -0xc(%rbp),%eax
mov    %eax,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%ecx
xor    %eax,%eax
cmp    -0x8(%rbp),%ecx
mov    %al,-0x11(%rbp)
je     1257 <main+0xf7>
cmpl   $0x7,-0xc(%rbp)
setne  %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    1267 <main+0x107>
jmp    1276 <main+0x116>
mov    $0x0,%al
call   1060 <rollDice@plt>
mov    %eax,-0xc(%rbp)
jmp    123c <main+0xdc>
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jne    12a5 <main+0x145>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    $0x0,%al
call   1040 <divider@plt>
lea    0xd70(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    12c3 <main+0x163>
mov    -0x10(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    $0x0,%al
call   1040 <divider@plt>
lea    0xd57(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    12c8 <main+0x168>
jmp    12cd <main+0x16d>
mov    $0x0,%al
call   1040 <divider@plt>
mov    $0x1,%edi
call   1080 <sleep@plt>
mov    -0x10(%rbp),%esi
lea    0xd36(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1040 <divider@plt>
mov    $0x1,%edi
call   1080 <sleep@plt>
lea    0xd26(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xd47(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1070 <scanf@plt>
jmp    1176 <main+0x16>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
movl   $0x1,0x4(%rsp)
lea    0xe85(%rip),%r12
lea    0xead(%rip),%r13
lea    0x4(%rsp),%rbx
xor    %ebp,%ebp
jmp    120f <main+0x9f>
nopw   0x0(%rax,%rax,1)
mov    $0xffffffff,%eax
lea    0xe9d(%rip),%r15
add    %eax,%ebp
xor    %eax,%eax
call   1050 <divider@plt>
mov    %r15,%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1050 <divider@plt>
mov    $0x1,%edi
call   1090 <sleep@plt>
lea    0xe2b(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
call   1050 <divider@plt>
mov    $0x1,%edi
call   1090 <sleep@plt>
mov    %r12,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
call   1080 <scanf@plt>
cmpl   $0x1,0x4(%rsp)
jne    12b4 <main+0x144>
xor    %eax,%eax
call   1030 <clrscr@plt>
xor    %eax,%eax
call   1050 <divider@plt>
lea    0xe1d(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1050 <divider@plt>
mov    $0x1,%edi
call   1090 <sleep@plt>
xor    %eax,%eax
call   1070 <rollDice@plt>
mov    %eax,%r14d
cmp    $0xc,%eax
ja     1280 <main+0x110>
mov    $0x100c,%eax
bt     %r14d,%eax
jb     11a0 <main+0x30>
mov    $0x880,%eax
bt     %r14d,%eax
mov    $0x1,%eax
lea    0xde6(%rip),%r15
jb     11ac <main+0x3c>
mov    %r14d,%eax
test   %r14d,%r14d
je     1291 <main+0x121>
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1070 <rollDice@plt>
cmp    %r14d,%eax
je     1291 <main+0x121>
cmp    $0x7,%eax
jne    1280 <main+0x110>
xor    %ecx,%ecx
cmp    %r14d,%eax
sete   %cl
lea    -0x1(%rcx,%rcx,1),%eax
lea    0xda5(%rip),%r15
lea    0xda8(%rip),%rcx
cmove  %rcx,%r15
jmp    11ac <main+0x3c>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"Bet: $1\0A\00"
@.str.1 = [10 x i8] c"You win!\0A\00"
@.str.2 = [11 x i8] c"You lose.\0A\00"
@.str.3 = [15 x i8] c"Winnings: $%d\0A\00"
@.str.4 = [47 x i8] c"Would you like to continue? (1 = yes, 0 = no) \00"
@.str.5 = [3 x i8] c"%d\00"
define void @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 1, i32* %1
store i32 0, i32* %4
br label %5
5: ; preds = %68, %0
%6 = load i32, i32* %1
%7 = icmp eq i32 %6, 1
br i1 %7, label %8, label %77
8: ; preds = %5
%9 = call i32 (...) @clrscr()
%10 = call i32 (...) @divider()
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%12 = call i32 (...) @divider()
%13 = call i32 @sleep(i32 1)
%14 = call i32 (...) @rollDice()
store i32 %14, i32* %3
%15 = load i32, i32* %3
%16 = icmp eq i32 %15, 7
br i1 %16, label %20, label %17
17: ; preds = %8
%18 = load i32, i32* %3
%19 = icmp eq i32 %18, 11
br i1 %19, label %20, label %25
20: ; preds = %17, %8
%21 = load i32, i32* %4
%22 = add nsw i32 %21, 1
store i32 %22, i32* %4
%23 = call i32 (...) @divider()
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
br label %68
25: ; preds = %17
%26 = load i32, i32* %3
%27 = icmp eq i32 %26, 2
br i1 %27, label %34, label %28
28: ; preds = %25
%29 = load i32, i32* %3
%30 = icmp eq i32 %29, 3
br i1 %30, label %34, label %31
31: ; preds = %28
%32 = load i32, i32* %3
%33 = icmp eq i32 %32, 12
br i1 %33, label %34, label %39
34: ; preds = %31, %28, %25
%35 = load i32, i32* %4
%36 = sub nsw i32 %35, 1
store i32 %36, i32* %4
%37 = call i32 (...) @divider()
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
br label %67
39: ; preds = %31
%40 = load i32, i32* %3
store i32 %40, i32* %2
store i32 0, i32* %3
br label %41
41: ; preds = %50, %39
%42 = load i32, i32* %3
%43 = load i32, i32* %2
%44 = icmp ne i32 %42, %43
br i1 %44, label %45, label %48
45: ; preds = %41
%46 = load i32, i32* %3
%47 = icmp ne i32 %46, 7
br label %48
48: ; preds = %45, %41
%49 = phi i1 [ false, %41 ], [ %47, %45 ]
br i1 %49, label %50, label %52
50: ; preds = %48
%51 = call i32 (...) @rollDice()
store i32 %51, i32* %3
br label %41
52: ; preds = %48
%53 = load i32, i32* %3
%54 = load i32, i32* %2
%55 = icmp eq i32 %53, %54
br i1 %55, label %56, label %61
56: ; preds = %52
%57 = load i32, i32* %4
%58 = add nsw i32 %57, 1
store i32 %58, i32* %4
%59 = call i32 (...) @divider()
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
br label %66
61: ; preds = %52
%62 = load i32, i32* %4
%63 = sub nsw i32 %62, 1
store i32 %63, i32* %4
%64 = call i32 (...) @divider()
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
br label %66
66: ; preds = %61, %56
br label %67
67: ; preds = %66, %34
br label %68
68: ; preds = %67, %20
%69 = call i32 (...) @divider()
%70 = call i32 @sleep(i32 1)
%71 = load i32, i32* %4
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 %71)
%73 = call i32 (...) @divider()
%74 = call i32 @sleep(i32 1)
%75 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.4, i64 0, i64 0))
%76 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %1)
br label %5
77: ; preds = %5
ret void
}

LLVM IR (-O2):
@.str.3 = [15 x i8] c"Winnings: $%d\0A\00"
@.str.4 = [47 x i8] c"Would you like to continue? (1 = yes, 0 = no) \00"
@.str.5 = [3 x i8] c"%d\00"
@str = [8 x i8] c"Bet: $1\00"
@str.8 = [10 x i8] c"You lose.\00"
@str.9 = [9 x i8] c"You win!\00"
define void @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 1, i32* %1
br label %3
3: ; preds = %0, %22
%4 = phi i32 [ 0, %0 ], [ %25, %22 ]
%5 = call i32 (...) @clrscr()
%6 = call i32 (...) @divider()
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str, i64 0, i64 0))
%8 = call i32 (...) @divider()
%9 = call i32 @sleep(i32 1)
%10 = call i32 (...) @rollDice()
switch i32 %10, label %12 [
i32 11, label %22
i32 7, label %22
i32 12, label %11
i32 3, label %11
i32 2, label %11
i32 0, label %17
]
11: ; preds = %3, %3, %3
br label %22
12: ; preds = %3, %12
%13 = call i32 (...) @rollDice()
%14 = icmp ne i32 %13, %10
%15 = icmp ne i32 %13, 7
%16 = and i1 %14, %15
br i1 %16, label %12, label %17
17: ; preds = %12, %3
%18 = phi i32 [ %10, %3 ], [ %13, %12 ]
%19 = icmp eq i32 %18, %10
%20 = select i1 %19, i32 1, i32 -1
%21 = select i1 %19, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @str.9, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @str.8, i64 0, i64 0)
br label %22
22: ; preds = %17, %3, %3, %11
%23 = phi i32 [ -1, %11 ], [ 1, %3 ], [ 1, %3 ], [ %20, %17 ]
%24 = phi i8* [ getelementptr inbounds ([10 x i8], [10 x i8]* @str.8, i64 0, i64 0), %11 ], [ getelementptr inbounds ([9 x i8], [9 x i8]* @str.9, i64 0, i64 0), %3 ], [ getelementptr inbounds ([9 x i8], [9 x i8]* @str.9, i64 0, i64 0), %3 ], [ %21, %17 ]
%25 = add nsw i32 %4, %23
%26 = call i32 (...) @divider()
%27 = call i32 @puts(i8* dereferenceable(1) %24)
%28 = call i32 (...) @divider()
%29 = call i32 @sleep(i32 1)
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 %25)
%31 = call i32 (...) @divider()
%32 = call i32 @sleep(i32 1)
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str.4, i64 0, i64 0))
%34 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %1)
%35 = load i32, i32* %1
%36 = icmp eq i32 %35, 1
br i1 %36, label %3, label %37
37: ; preds = %22
ret void
}