#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 /*<<< orphan*/ srand(unsigned int);
scalar_t__ time(int /*<<< orphan*/ *);
int main(void) {
  int win = 0, lose = 0;
  char flag = 'n';
  srand((unsigned)time(NULL));
  do {
    if (play_game()) {
      win++;
      printf("you win!\n");
    } else {
      lose++;
      printf("you lose!\n");
    }
    printf("play again(y or n): ");
    scanf(" %c", &flag);
  } while (flag == 'y');
  printf("you win %d\tlose %d\n", win, lose);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movb   $0x6e,-0xd(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
mov    $0x0,%al
call   1070 <play_game@plt>
cmp    $0x0,%rax
je     11ae <main+0x5e>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
lea    0xe5e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11c5 <main+0x75>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
lea    0xe4c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe49(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe50(%rip),%rdi
lea    -0xd(%rbp),%rsi
call   1060 <scanf@plt>
movsbl -0xd(%rbp),%eax
cmp    $0x79,%eax
je     1181 <main+0x31>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xe31(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
movb   $0x6e,0x7(%rsp)
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
lea    0xeb2(%rip),%r13
lea    0xe74(%rip),%r14
lea    0xe82(%rip),%r15
lea    0x7(%rsp),%r12
xor    %ebx,%ebx
xor    %ebp,%ebp
nopl   0x0(%rax)
xor    %eax,%eax
call   1080 <play_game@plt>
xor    %ecx,%ecx
xor    %edx,%edx
test   %rax,%rax
sete   %cl
setne  %dl
mov    %r13,%rdi
lea    0xe6f(%rip),%rax
cmove  %rax,%rdi
add    %edx,%ebx
add    %ecx,%ebp
call   1030 <puts@plt>
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1070 <scanf@plt>
cmpb   $0x79,0x7(%rsp)
je     11a0 <main+0x40>
lea    0xe2b(%rip),%rdi
mov    %ebx,%esi
mov    %ebp,%edx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"you win!\0A\00"
@.str.1 = [11 x i8] c"you lose!\0A\00"
@.str.2 = [21 x i8] c"play again(y or n): \00"
@.str.3 = [4 x i8] c" %c\00"
@.str.4 = [20 x i8] c"you win %d\09lose %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
store i8 110, i8* %4
%5 = call i64 @time(i32* null)
%6 = trunc i64 %5 to i32
%7 = call i32 @srand(i32 %6)
br label %8
8: ; preds = %22, %0
%9 = call i64 (...) @play_game()
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %15
11: ; preds = %8
%12 = load i32, i32* %2
%13 = add nsw i32 %12, 1
store i32 %13, i32* %2
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
br label %19
15: ; preds = %8
%16 = load i32, i32* %3
%17 = add nsw i32 %16, 1
store i32 %17, i32* %3
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
br label %19
19: ; preds = %15, %11
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%21 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %4)
br label %22
22: ; preds = %19
%23 = load i8, i8* %4
%24 = sext i8 %23 to i32
%25 = icmp eq i32 %24, 121
br i1 %25, label %8, label %26
26: ; preds = %22
%27 = load i32, i32* %2
%28 = load i32, i32* %3
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i32 %27, i32 %28)
ret i32 0
}

LLVM IR (-O2):
@.str.2 = [21 x i8] c"play again(y or n): \00"
@.str.3 = [4 x i8] c" %c\00"
@.str.4 = [20 x i8] c"you win %d\09lose %d\0A\00"
@str = [10 x i8] c"you lose!\00"
@str.5 = [9 x i8] c"you win!\00"
define i32 @main() {
%1 = alloca i8
store i8 110, i8* %1
%2 = tail call i64 @time(i32* null)
%3 = trunc i64 %2 to i32
%4 = tail call i32 @srand(i32 %3)
br label %5
5: ; preds = %5, %0
%6 = phi i32 [ 0, %0 ], [ %13, %5 ]
%7 = phi i32 [ 0, %0 ], [ %15, %5 ]
%8 = call i64 (...) @play_game()
%9 = icmp eq i64 %8, 0
%10 = select i1 %9, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @str, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @str.5, i64 0, i64 0)
%11 = xor i1 %9, true
%12 = zext i1 %11 to i32
%13 = add nuw nsw i32 %6, %12
%14 = zext i1 %9 to i32
%15 = add nuw nsw i32 %7, %14
%16 = call i32 @puts(i8* dereferenceable(1) %10)
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) 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* %1)
%19 = load i8, i8* %1
%20 = icmp eq i8 %19, 121
br i1 %20, label %5, label %21
21: ; preds = %5
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i32 %13, i32 %15)
ret i32 0
}