#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 */
char hasPlayerWon(char **, int, int, int, int);
int isBoardFinished(char board[7][6], int x, int y) {
  signed char status;
  status = hasPlayerWon(board, x, y, 1, 0);
  if (status != 0) {
    return status;
  }
  status = hasPlayerWon(board, x, y, 0, 1);
  if (status != 0) {
    return status;
  }
  status = hasPlayerWon(board, x, y, 1, 1);
  if (status != 0) {
    return status;
  }
  status = hasPlayerWon(board, x, y, -1, 1);
  if (status != 0) {
    return status;
  }
  return 100;
}


x86 assembly (clang, -O0):
<isBoardFinished>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    $0x1,%ecx
xor    %r8d,%r8d
call   1030 <hasPlayerWon@plt>
mov    %al,-0x19(%rbp)
movsbl -0x19(%rbp),%eax
cmp    $0x0,%eax
je     1155 <isBoardFinished+0x45>
movsbl -0x19(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11f9 <isBoardFinished+0xe9>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
xor    %ecx,%ecx
mov    $0x1,%r8d
call   1030 <hasPlayerWon@plt>
mov    %al,-0x19(%rbp)
movsbl -0x19(%rbp),%eax
cmp    $0x0,%eax
je     1188 <isBoardFinished+0x78>
movsbl -0x19(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11f9 <isBoardFinished+0xe9>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    $0x1,%r8d
mov    %r8d,%ecx
call   1030 <hasPlayerWon@plt>
mov    %al,-0x19(%rbp)
movsbl -0x19(%rbp),%eax
cmp    $0x0,%eax
je     11bc <isBoardFinished+0xac>
movsbl -0x19(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11f9 <isBoardFinished+0xe9>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    $0xffffffff,%ecx
mov    $0x1,%r8d
call   1030 <hasPlayerWon@plt>
mov    %al,-0x19(%rbp)
movsbl -0x19(%rbp),%eax
cmp    $0x0,%eax
je     11f2 <isBoardFinished+0xe2>
movsbl -0x19(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11f9 <isBoardFinished+0xe9>
movl   $0x64,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isBoardFinished>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%r14d
mov    %esi,%ebp
mov    %rdi,%rbx
mov    $0x1,%ecx
xor    %r8d,%r8d
call   1030 <hasPlayerWon@plt>
test   %al,%al
jne    1187 <isBoardFinished+0x77>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %r14d,%edx
xor    %ecx,%ecx
mov    $0x1,%r8d
call   1030 <hasPlayerWon@plt>
test   %al,%al
jne    1187 <isBoardFinished+0x77>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %r14d,%edx
mov    $0x1,%ecx
mov    $0x1,%r8d
call   1030 <hasPlayerWon@plt>
test   %al,%al
jne    1187 <isBoardFinished+0x77>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %r14d,%edx
mov    $0xffffffff,%ecx
mov    $0x1,%r8d
call   1030 <hasPlayerWon@plt>
test   %al,%al
movzbl %al,%ecx
mov    $0x64,%eax
cmovne %ecx,%eax
movsbl %al,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @isBoardFinished([6 x i8]* %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca [6 x i8]*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8
store [6 x i8]* %0, [6 x i8]** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
%9 = load [6 x i8]*, [6 x i8]** %5
%10 = bitcast [6 x i8]* %9 to i8**
%11 = load i32, i32* %6
%12 = load i32, i32* %7
%13 = call signext i8 @hasPlayerWon(i8** %10, i32 %11, i32 %12, i32 1, i32 0)
store i8 %13, i8* %8
%14 = load i8, i8* %8
%15 = sext i8 %14 to i32
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %3
%18 = load i8, i8* %8
%19 = sext i8 %18 to i32
store i32 %19, i32* %4
br label %57
20: ; preds = %3
%21 = load [6 x i8]*, [6 x i8]** %5
%22 = bitcast [6 x i8]* %21 to i8**
%23 = load i32, i32* %6
%24 = load i32, i32* %7
%25 = call signext i8 @hasPlayerWon(i8** %22, i32 %23, i32 %24, i32 0, i32 1)
store i8 %25, i8* %8
%26 = load i8, i8* %8
%27 = sext i8 %26 to i32
%28 = icmp ne i32 %27, 0
br i1 %28, label %29, label %32
29: ; preds = %20
%30 = load i8, i8* %8
%31 = sext i8 %30 to i32
store i32 %31, i32* %4
br label %57
32: ; preds = %20
%33 = load [6 x i8]*, [6 x i8]** %5
%34 = bitcast [6 x i8]* %33 to i8**
%35 = load i32, i32* %6
%36 = load i32, i32* %7
%37 = call signext i8 @hasPlayerWon(i8** %34, i32 %35, i32 %36, i32 1, i32 1)
store i8 %37, i8* %8
%38 = load i8, i8* %8
%39 = sext i8 %38 to i32
%40 = icmp ne i32 %39, 0
br i1 %40, label %41, label %44
41: ; preds = %32
%42 = load i8, i8* %8
%43 = sext i8 %42 to i32
store i32 %43, i32* %4
br label %57
44: ; preds = %32
%45 = load [6 x i8]*, [6 x i8]** %5
%46 = bitcast [6 x i8]* %45 to i8**
%47 = load i32, i32* %6
%48 = load i32, i32* %7
%49 = call signext i8 @hasPlayerWon(i8** %46, i32 %47, i32 %48, i32 -1, i32 1)
store i8 %49, i8* %8
%50 = load i8, i8* %8
%51 = sext i8 %50 to i32
%52 = icmp ne i32 %51, 0
br i1 %52, label %53, label %56
53: ; preds = %44
%54 = load i8, i8* %8
%55 = sext i8 %54 to i32
store i32 %55, i32* %4
br label %57
56: ; preds = %44
store i32 100, i32* %4
br label %57
57: ; preds = %56, %53, %41, %29, %17
%58 = load i32, i32* %4
ret i32 %58
}

LLVM IR (-O2):
define i32 @isBoardFinished([6 x i8]* %0, i32 %1, i32 %2) {
%4 = bitcast [6 x i8]* %0 to i8**
%5 = tail call signext i8 @hasPlayerWon(i8** %4, i32 %1, i32 %2, i32 1, i32 0)
%6 = icmp eq i8 %5, 0
br i1 %6, label %7, label %17
7: ; preds = %3
%8 = tail call signext i8 @hasPlayerWon(i8** %4, i32 %1, i32 %2, i32 0, i32 1)
%9 = icmp eq i8 %8, 0
br i1 %9, label %10, label %17
10: ; preds = %7
%11 = tail call signext i8 @hasPlayerWon(i8** %4, i32 %1, i32 %2, i32 1, i32 1)
%12 = icmp eq i8 %11, 0
br i1 %12, label %13, label %17
13: ; preds = %10
%14 = tail call signext i8 @hasPlayerWon(i8** %4, i32 %1, i32 %2, i32 -1, i32 1)
%15 = icmp eq i8 %14, 0
%16 = select i1 %15, i8 100, i8 %14
br label %17
17: ; preds = %10, %7, %3, %13
%18 = phi i8 [ %16, %13 ], [ %5, %3 ], [ %8, %7 ], [ %11, %10 ]
%19 = sext i8 %18 to i32
ret i32 %19
}