#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 /*<<< orphan*/ puts(char *);
int rand();
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ srand(unsigned int);
scalar_t__ time(int /*<<< orphan*/ *);
int main() {
  int bet, roll, point;
  char c;
  srand((unsigned)time(NULL));
  printf("Enter your bet: ");
  scanf("%d", &bet);
  puts("\n\tRolling them bones...\n");
  roll = rand() % 11 + 2;
  printf("\t\t\t%d\n\n", roll);
  switch (roll) {
  case 7:
  case 11:
    printf(" - You win!\n");
    bet *= 2;
    break;
  case 2:
  case 3:
  case 12:
    printf(" - Craps! You lose!\n");
    bet = 0;
    break;
  default:
    point = roll;
    printf(" - Your point is now %d.\n", point);
    while (1) {
      roll = rand() % 11 + 2;
      printf("\tYou rolled %d, point is %d.\n", roll, point);
      if (roll == point) {
        printf("\tYou win!\n");
        bet *= 2;
        break;
      }
      if (roll == 7) {
        printf("\tSeven out, you lose");
        bet = 0;
        break;
      }
    }
  }
  printf("\n\n\tYou now have $%d.", bet);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
xor    %eax,%eax
mov    %eax,-0x20(%rbp)
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
mov    -0x20(%rbp),%eax
lea    0xe74(%rip),%rdi
mov    %al,-0x19(%rbp)
call   1040 <printf@plt>
lea    0xe76(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1070 <scanf@plt>
lea    0xe69(%rip),%rdi
call   1030 <puts@plt>
mov    -0x19(%rbp),%al
call   1080 <rand@plt>
mov    %eax,%esi
mov    -0x19(%rbp),%al
movslq %esi,%rcx
imul   $0x2e8ba2e9,%rcx,%rdx
mov    %rdx,%rcx
shr    $0x3f,%rcx
sar    $0x21,%rdx
add    %ecx,%edx
mov    %edx,%ecx
lea    (%rcx,%rcx,4),%edi
mov    %edi,%edx
lea    (%rcx,%rdx,2),%ecx
neg    %ecx
mov    %ecx,%edx
mov    %esi,%ecx
lea    0x2(%rcx,%rdx,1),%ecx
mov    %ecx,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe38(%rip),%rdi
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
add    $0xfffffffe,%eax
sub    $0x2,%eax
jb     1260 <main+0x100>
jmp    1211 <main+0xb1>
mov    -0x18(%rbp),%eax
sub    $0x7,%eax
je     1244 <main+0xe4>
jmp    1222 <main+0xc2>
mov    -0x18(%rbp),%eax
sub    $0xb,%eax
je     1244 <main+0xe4>
jmp    1233 <main+0xd3>
mov    -0x18(%rbp),%eax
sub    $0xc,%eax
je     1260 <main+0x100>
jmp    127a <main+0x11a>
lea    0xdea(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1310 <main+0x1b0>
lea    0xddb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x8(%rbp)
jmp    1310 <main+0x1b0>
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%esi
lea    0xdcd(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1080 <rand@plt>
mov    $0xb,%ecx
cltd
idiv   %ecx
add    $0x2,%edx
mov    %edx,-0xc(%rbp)
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    0xdbe(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jne    12e2 <main+0x182>
lea    0xdc2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    130b <main+0x1ab>
cmpl   $0x7,-0xc(%rbp)
jne    1306 <main+0x1a6>
lea    0xda7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x8(%rbp)
jmp    130b <main+0x1ab>
jmp    1291 <main+0x131>
jmp    1310 <main+0x1b0>
mov    -0x8(%rbp),%esi
lea    0xd95(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
lea    0xe7f(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe82(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1070 <scanf@plt>
lea    0xe74(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1080 <rand@plt>
cltq
imul   $0x2e8ba2e9,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x21,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,4),%edx
lea    (%rcx,%rdx,2),%ecx
mov    %eax,%r12d
sub    %ecx,%r12d
neg    %ecx
lea    (%rax,%rcx,1),%r15d
add    $0x2,%r15d
lea    0xe4e(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0xa,%r12d
ja     122c <main+0xcc>
mov    $0x403,%eax
bt     %r12d,%eax
jae    1215 <main+0xb5>
lea    0xe96(%rip),%rdi
call   1030 <puts@plt>
movl   $0x0,0xc(%rsp)
xor    %ebx,%ebx
jmp    12c8 <main+0x168>
mov    $0x220,%eax
bt     %r12d,%eax
jae    122c <main+0xcc>
lea    0xe84(%rip),%rdi
jmp    12b9 <main+0x159>
lea    0xe02(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe0b(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %eax,%eax
call   1080 <rand@plt>
cltq
imul   $0x2e8ba2e9,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x21,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,4),%edx
lea    (%rcx,%rdx,2),%ecx
mov    %eax,%ebx
sub    %ecx,%ebx
neg    %ecx
lea    (%rax,%rcx,1),%ebp
add    $0x2,%ebp
mov    %r14,%rdi
mov    %ebp,%esi
mov    %r15d,%edx
xor    %eax,%eax
call   1040 <printf@plt>
cmp    %r12d,%ebx
je     12b2 <main+0x152>
cmp    $0x7,%ebp
jne    1250 <main+0xf0>
lea    0xdce(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <printf@plt>
movl   $0x0,0xc(%rsp)
jmp    12c8 <main+0x168>
lea    0xdfe(%rip),%rdi
call   1030 <puts@plt>
mov    0xc(%rsp),%ebx
add    %ebx,%ebx
mov    %ebx,0xc(%rsp)
lea    0xdb3(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [17 x i8] c"Enter your bet: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [25 x i8] c"\0A\09Rolling them bones...\0A\00"
@.str.3 = [8 x i8] c"\09\09\09%d\0A\0A\00"
@.str.4 = [13 x i8] c" - You win!\0A\00"
@.str.5 = [21 x i8] c" - Craps! You lose!\0A\00"
@.str.6 = [26 x i8] c" - Your point is now %d.\0A\00"
@.str.7 = [30 x i8] c"\09You rolled %d, point is %d.\0A\00"
@.str.8 = [11 x i8] c"\09You win!\0A\00"
@.str.9 = [21 x i8] c"\09Seven out, you lose\00"
@.str.10 = [21 x i8] c"\0A\0A\09You now have $%d.\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8
store i32 0, i32* %1
%6 = call i64 @time(i32* null)
%7 = trunc i64 %6 to i32
%8 = call i32 @srand(i32 %7)
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%11 = call i32 @puts(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 (...) @rand()
%13 = srem i32 %12, 11
%14 = add nsw i32 %13, 2
store i32 %14, i32* %3
%15 = load i32, i32* %3
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %15)
%17 = load i32, i32* %3
switch i32 %17, label %24 [
i32 7, label %18
i32 11, label %18
i32 2, label %22
i32 3, label %22
i32 12, label %22
]
18: ; preds = %0, %0
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%20 = load i32, i32* %2
%21 = mul nsw i32 %20, 2
store i32 %21, i32* %2
br label %49
22: ; preds = %0, %0, %0
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %2
br label %49
24: ; preds = %0
%25 = load i32, i32* %3
store i32 %25, i32* %4
%26 = load i32, i32* %4
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0), i32 %26)
br label %28
28: ; preds = %24, %47
%29 = call i32 (...) @rand()
%30 = srem i32 %29, 11
%31 = add nsw i32 %30, 2
store i32 %31, i32* %3
%32 = load i32, i32* %3
%33 = load i32, i32* %4
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.7, i64 0, i64 0), i32 %32, i32 %33)
%35 = load i32, i32* %3
%36 = load i32, i32* %4
%37 = icmp eq i32 %35, %36
br i1 %37, label %38, label %42
38: ; preds = %28
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0))
%40 = load i32, i32* %2
%41 = mul nsw i32 %40, 2
store i32 %41, i32* %2
br label %48
42: ; preds = %28
%43 = load i32, i32* %3
%44 = icmp eq i32 %43, 7
br i1 %44, label %45, label %47
45: ; preds = %42
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.9, i64 0, i64 0))
store i32 0, i32* %2
br label %48
47: ; preds = %42
br label %28
48: ; preds = %45, %38
br label %49
49: ; preds = %48, %22, %18
%50 = load i32, i32* %2
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.10, i64 0, i64 0), i32 %50)
ret i32 0
}

LLVM IR (-O2):
@.str = [17 x i8] c"Enter your bet: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [25 x i8] c"\0A\09Rolling them bones...\0A\00"
@.str.3 = [8 x i8] c"\09\09\09%d\0A\0A\00"
@.str.6 = [26 x i8] c" - Your point is now %d.\0A\00"
@.str.7 = [30 x i8] c"\09You rolled %d, point is %d.\0A\00"
@.str.9 = [21 x i8] c"\09Seven out, you lose\00"
@.str.10 = [21 x i8] c"\0A\0A\09You now have $%d.\00"
@str = [20 x i8] c" - Craps! You lose!\00"
@str.11 = [12 x i8] c" - You win!\00"
@str.12 = [10 x i8] c"\09You win!\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i64 @time(i32* null)
%4 = trunc i64 %3 to i32
%5 = tail call i32 @srand(i32 %4)
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 (...) @rand()
%10 = srem i32 %9, 11
%11 = add nsw i32 %10, 2
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %11)
switch i32 %10, label %19 [
i32 5, label %13
i32 9, label %13
i32 0, label %17
i32 1, label %17
i32 10, label %17
]
13: ; preds = %0, %0
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.11, i64 0, i64 0))
%15 = load i32, i32* %1
%16 = shl nsw i32 %15, 1
store i32 %16, i32* %1
br label %35
17: ; preds = %0, %0, %0
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
store i32 0, i32* %1
br label %35
19: ; preds = %0
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0), i32 %11)
br label %21
21: ; preds = %31, %19
%22 = call i32 (...) @rand()
%23 = srem i32 %22, 11
%24 = add nsw i32 %23, 2
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.7, i64 0, i64 0), i32 %24, i32 %11)
%26 = icmp eq i32 %23, %10
br i1 %26, label %27, label %31
27: ; preds = %21
%28 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.12, i64 0, i64 0))
%29 = load i32, i32* %1
%30 = shl nsw i32 %29, 1
store i32 %30, i32* %1
br label %35
31: ; preds = %21
%32 = icmp eq i32 %24, 7
br i1 %32, label %33, label %21
33: ; preds = %31
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.9, i64 0, i64 0))
store i32 0, i32* %1
br label %35
35: ; preds = %27, %33, %17, %13
%36 = phi i32 [ %30, %27 ], [ 0, %33 ], [ 0, %17 ], [ %16, %13 ]
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.10, i64 0, i64 0), i32 %36)
ret i32 0
}