#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*/ ckfree(char, char);
scalar_t__ ckwin(char);
int /*<<< orphan*/ printf(char *, ...);
int ckgame(char player1, char player2) {
  if (ckwin(player1)) {
    printf("%c is the winner\n\n", player1);
    return (1);
  }
  if (ckwin(player2)) {
    printf("%c is the winner\n\n", player2);
    return (2);
  }
  if (!ckfree(player1, player2)) {
    printf("No winners\n\n");
    return (3);
  }
  return (0);
}


x86 assembly (clang, -O0):
<ckgame>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %sil,%al
mov    %dil,%cl
mov    %cl,-0x5(%rbp)
mov    %al,-0x6(%rbp)
movsbl -0x5(%rbp),%edi
call   1050 <ckwin@plt>
cmp    $0x0,%rax
je     1175 <ckgame+0x45>
movsbl -0x5(%rbp),%esi
lea    0xe9e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11df <ckgame+0xaf>
movsbl -0x6(%rbp),%edi
call   1050 <ckwin@plt>
cmp    $0x0,%rax
je     11a6 <ckgame+0x76>
movsbl -0x6(%rbp),%esi
lea    0xe6d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x2,-0x4(%rbp)
jmp    11df <ckgame+0xaf>
mov    -0x5(%rbp),%al
movsbl %al,%edi
movsbl -0x6(%rbp),%esi
call   1040 <ckfree@plt>
cmp    $0x0,%eax
jne    11d8 <ckgame+0xa8>
lea    0xe4e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x3,-0x4(%rbp)
jmp    11df <ckgame+0xaf>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ckgame>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %edi,%ebx
call   1060 <ckwin@plt>
test   %rax,%rax
je     1169 <ckgame+0x29>
movsbl %bl,%esi
lea    0xea5(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%eax
jmp    11b3 <ckgame+0x73>
movsbl %bpl,%ebp
mov    %ebp,%edi
call   1060 <ckwin@plt>
test   %rax,%rax
je     1190 <ckgame+0x50>
lea    0xe80(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x2,%eax
jmp    11b3 <ckgame+0x73>
movsbl %bl,%edi
mov    %ebp,%esi
call   1050 <ckfree@plt>
mov    %eax,%ecx
xor    %eax,%eax
test   %ecx,%ecx
jne    11b3 <ckgame+0x73>
lea    0xe6a(%rip),%rdi
call   1030 <puts@plt>
mov    $0x3,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [19 x i8] c"%c is the winner\0A\0A\00"
@.str.1 = [13 x i8] c"No winners\0A\0A\00"
define i32 @ckgame(i8 signext %0, i8 signext %1) {
%3 = alloca i32
%4 = alloca i8
%5 = alloca i8
store i8 %0, i8* %4
store i8 %1, i8* %5
%6 = load i8, i8* %4
%7 = call i64 @ckwin(i8 signext %6)
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %13
9: ; preds = %2
%10 = load i8, i8* %4
%11 = sext i8 %10 to i32
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %11)
store i32 1, i32* %3
br label %29
13: ; preds = %2
%14 = load i8, i8* %5
%15 = call i64 @ckwin(i8 signext %14)
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %21
17: ; preds = %13
%18 = load i8, i8* %5
%19 = sext i8 %18 to i32
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %19)
store i32 2, i32* %3
br label %29
21: ; preds = %13
%22 = load i8, i8* %4
%23 = load i8, i8* %5
%24 = call i32 @ckfree(i8 signext %22, i8 signext %23)
%25 = icmp ne i32 %24, 0
br i1 %25, label %28, label %26
26: ; preds = %21
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
store i32 3, i32* %3
br label %29
28: ; preds = %21
store i32 0, i32* %3
br label %29
29: ; preds = %28, %26, %17, %9
%30 = load i32, i32* %3
ret i32 %30
}

LLVM IR (-O2):
@.str = [19 x i8] c"%c is the winner\0A\0A\00"
@str = [12 x i8] c"No winners\0A\00"
define i32 @ckgame(i8 signext %0, i8 signext %1) {
%3 = tail call i64 @ckwin(i8 signext %0)
%4 = icmp eq i64 %3, 0
br i1 %4, label %8, label %5
5: ; preds = %2
%6 = sext i8 %0 to i32
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %6)
br label %19
8: ; preds = %2
%9 = tail call i64 @ckwin(i8 signext %1)
%10 = icmp eq i64 %9, 0
br i1 %10, label %14, label %11
11: ; preds = %8
%12 = sext i8 %1 to i32
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %12)
br label %19
14: ; preds = %8
%15 = tail call i32 @ckfree(i8 signext %0, i8 signext %1)
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %14
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
br label %19
19: ; preds = %14, %17, %11, %5
%20 = phi i32 [ 1, %5 ], [ 2, %11 ], [ 3, %17 ], [ 0, %14 ]
ret i32 %20
}