#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__ win(char *, char);
int end_game(char board[], char player) {
  if (win(board, player) != 0)
    return 1;
  else {
    int i;
    for (i = 0; i < 9; ++i) {
      if (board[i] == 0) {
        return 0;
      }
    }
  }
  return 1;
}


x86 assembly (clang, -O0):
<end_game>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %sil,%al
mov    %rdi,-0x10(%rbp)
mov    %al,-0x11(%rbp)
mov    -0x10(%rbp),%rdi
movsbl -0x11(%rbp),%esi
call   1030 <win@plt>
cmp    $0x0,%rax
je     1145 <end_game+0x35>
movl   $0x1,-0x4(%rbp)
jmp    1196 <end_game+0x86>
movl   $0x0,-0x18(%rbp)
cmpl   $0x9,-0x18(%rbp)
jge    118a <end_game+0x7a>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
jne    1177 <end_game+0x67>
movl   $0x0,-0x4(%rbp)
jmp    1196 <end_game+0x86>
jmp    117c <end_game+0x6c>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    114c <end_game+0x3c>
jmp    118f <end_game+0x7f>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<end_game>:
push   %rbx
mov    %rdi,%rbx
call   1030 <win@plt>
mov    %rax,%rcx
mov    $0x1,%eax
test   %rcx,%rcx
je     1128 <end_game+0x18>
pop    %rbx
ret
xor    %eax,%eax
cmpb   $0x0,(%rbx)
je     1126 <end_game+0x16>
cmpb   $0x0,0x1(%rbx)
je     1126 <end_game+0x16>
cmpb   $0x0,0x2(%rbx)
je     1126 <end_game+0x16>
cmpb   $0x0,0x3(%rbx)
je     1126 <end_game+0x16>
cmpb   $0x0,0x4(%rbx)
je     1126 <end_game+0x16>
cmpb   $0x0,0x5(%rbx)
je     1126 <end_game+0x16>
cmpb   $0x0,0x6(%rbx)
je     1126 <end_game+0x16>
cmpb   $0x0,0x7(%rbx)
je     1126 <end_game+0x16>
xor    %eax,%eax
cmpb   $0x0,0x8(%rbx)
setne  %al
pop    %rbx
ret

LLVM IR (-O0):
define i32 @end_game(i8* %0, i8 signext %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8
%6 = alloca i32
store i8* %0, i8** %4
store i8 %1, i8* %5
%7 = load i8*, i8** %4
%8 = load i8, i8* %5
%9 = call i64 @win(i8* %7, i8 signext %8)
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %2
store i32 1, i32* %3
br label %31
12: ; preds = %2
store i32 0, i32* %6
br label %13
13: ; preds = %26, %12
%14 = load i32, i32* %6
%15 = icmp slt i32 %14, 9
br i1 %15, label %16, label %29
16: ; preds = %13
%17 = load i8*, i8** %4
%18 = load i32, i32* %6
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %17, i64 %19
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %16
store i32 0, i32* %3
br label %31
25: ; preds = %16
br label %26
26: ; preds = %25
%27 = load i32, i32* %6
%28 = add nsw i32 %27, 1
store i32 %28, i32* %6
br label %13
29: ; preds = %13
br label %30
30: ; preds = %29
store i32 1, i32* %3
br label %31
31: ; preds = %30, %24, %11
%32 = load i32, i32* %3
ret i32 %32
}

LLVM IR (-O2):
define i32 @end_game(i8* %0, i8 signext %1) {
%3 = tail call i64 @win(i8* %0, i8 signext %1)
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %41
5: ; preds = %2
%6 = load i8, i8* %0
%7 = icmp eq i8 %6, 0
br i1 %7, label %41, label %8
8: ; preds = %5
%9 = getelementptr inbounds i8, i8* %0, i64 1
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, 0
br i1 %11, label %41, label %12
12: ; preds = %8
%13 = getelementptr inbounds i8, i8* %0, i64 2
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, 0
br i1 %15, label %41, label %16
16: ; preds = %12
%17 = getelementptr inbounds i8, i8* %0, i64 3
%18 = load i8, i8* %17
%19 = icmp eq i8 %18, 0
br i1 %19, label %41, label %20
20: ; preds = %16
%21 = getelementptr inbounds i8, i8* %0, i64 4
%22 = load i8, i8* %21
%23 = icmp eq i8 %22, 0
br i1 %23, label %41, label %24
24: ; preds = %20
%25 = getelementptr inbounds i8, i8* %0, i64 5
%26 = load i8, i8* %25
%27 = icmp eq i8 %26, 0
br i1 %27, label %41, label %28
28: ; preds = %24
%29 = getelementptr inbounds i8, i8* %0, i64 6
%30 = load i8, i8* %29
%31 = icmp eq i8 %30, 0
br i1 %31, label %41, label %32
32: ; preds = %28
%33 = getelementptr inbounds i8, i8* %0, i64 7
%34 = load i8, i8* %33
%35 = icmp eq i8 %34, 0
br i1 %35, label %41, label %36
36: ; preds = %32
%37 = getelementptr inbounds i8, i8* %0, i64 8
%38 = load i8, i8* %37
%39 = icmp ne i8 %38, 0
%40 = zext i1 %39 to i32
br label %41
41: ; preds = %36, %5, %8, %12, %16, %20, %24, %28, %32, %2
%42 = phi i32 [ 1, %2 ], [ 0, %5 ], [ 0, %8 ], [ 0, %12 ], [ 0, %16 ], [ 0, %20 ], [ 0, %24 ], [ 0, %28 ], [ 0, %32 ], [ %40, %36 ]
ret i32 %42
}