#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 */
scalar_t__ play_game();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
int main(void) {
  char play_again;
  int wins = 0;
  int losses = 0;
  printf("this is game of craps.\n");
  printf("please hit enter to start the game!\n");
  do {
    if (play_game())
      wins++;
    else
      losses++;
    printf("play again? (y/n): \n");
    scanf(" %c", &play_again);
  } while (play_again == 'y' || play_again == 'Y');
  printf("wins: %3d   losses: %3d\n", wins, losses);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
lea    0xeac(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1050 <play_game@plt>
cmp    $0x0,%rax
je     1188 <main+0x58>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1191 <main+0x61>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
lea    0xea5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeac(%rip),%rdi
lea    -0x5(%rbp),%rsi
call   1040 <scanf@plt>
movsbl -0x5(%rbp),%ecx
mov    $0x1,%al
cmp    $0x79,%ecx
mov    %al,-0x11(%rbp)
je     11ce <main+0x9e>
movsbl -0x5(%rbp),%eax
cmp    $0x59,%eax
sete   %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    1169 <main+0x39>
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    0xe70(%rip),%rdi
mov    $0x0,%al
call   1030 <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
lea    0xeca(%rip),%rdi
call   1030 <puts@plt>
lea    0xed5(%rip),%rdi
call   1030 <puts@plt>
lea    0xeed(%rip),%r14
lea    0xe8e(%rip),%r15
lea    0xf(%rsp),%r12
xor    %ebx,%ebx
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1060 <play_game@plt>
xor    %ecx,%ecx
xor    %edx,%edx
test   %rax,%rax
sete   %cl
setne  %dl
add    %edx,%ebx
add    %ecx,%ebp
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1050 <scanf@plt>
movzbl 0xf(%rsp),%eax
and    $0xdf,%al
cmp    $0x59,%al
je     1180 <main+0x40>
lea    0xe47(%rip),%rdi
mov    %ebx,%esi
mov    %ebp,%edx
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 = [24 x i8] c"this is game of craps.\0A\00"
@.str.1 = [37 x i8] c"please hit enter to start the game!\0A\00"
@.str.2 = [21 x i8] c"play again? (y/n): \0A\00"
@.str.3 = [4 x i8] c" %c\00"
@.str.4 = [25 x i8] c"wins: %3d losses: %3d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
store i32 0, i32* %4
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0))
br label %7
7: ; preds = %27, %0
%8 = call i64 (...) @play_game()
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %7
%11 = load i32, i32* %3
%12 = add nsw i32 %11, 1
store i32 %12, i32* %3
br label %16
13: ; preds = %7
%14 = load i32, i32* %4
%15 = add nsw i32 %14, 1
store i32 %15, i32* %4
br label %16
16: ; preds = %13, %10
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%18 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %2)
br label %19
19: ; preds = %16
%20 = load i8, i8* %2
%21 = sext i8 %20 to i32
%22 = icmp eq i32 %21, 121
br i1 %22, label %27, label %23
23: ; preds = %19
%24 = load i8, i8* %2
%25 = sext i8 %24 to i32
%26 = icmp eq i32 %25, 89
br label %27
27: ; preds = %23, %19
%28 = phi i1 [ true, %19 ], [ %26, %23 ]
br i1 %28, label %7, label %29
29: ; preds = %27
%30 = load i32, i32* %3
%31 = load i32, i32* %4
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i32 %30, i32 %31)
ret i32 0
}

LLVM IR (-O2):
@.str.3 = [4 x i8] c" %c\00"
@.str.4 = [25 x i8] c"wins: %3d losses: %3d\0A\00"
@str = [23 x i8] c"this is game of craps.\00"
@str.5 = [36 x i8] c"please hit enter to start the game!\00"
@str.6 = [20 x i8] c"play again? (y/n): \00"
define i32 @main() {
%1 = alloca i8
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str.5, i64 0, i64 0))
br label %4
4: ; preds = %4, %0
%5 = phi i32 [ 0, %0 ], [ %11, %4 ]
%6 = phi i32 [ 0, %0 ], [ %13, %4 ]
%7 = call i64 (...) @play_game()
%8 = icmp eq i64 %7, 0
%9 = xor i1 %8, true
%10 = zext i1 %9 to i32
%11 = add nuw nsw i32 %5, %10
%12 = zext i1 %8 to i32
%13 = add nuw nsw i32 %6, %12
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.6, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %1)
%16 = load i8, i8* %1
%17 = and i8 %16, -33
%18 = icmp eq i8 %17, 89
br i1 %18, label %4, label %19
19: ; preds = %4
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i32 %11, i32 %13)
ret i32 0
}