#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__ diagonally(char **, int, int);
scalar_t__ horizontal(char **, int, int);
int turn_name(int);
scalar_t__ vertical(char **, int, int);
int finish_game(char board[12][12], int columnName, int rowNumber) {
  int columnNumber, i, j;
  columnNumber = turn_name(columnName);
  if (diagonally(board, columnNumber - 1, rowNumber - 1) ||
      horizontal(board, columnNumber - 1, rowNumber - 1) ||
      vertical(board, columnNumber - 1, rowNumber - 1))
    return 1;
  else
    return 0;
}


x86 assembly (clang, -O0):
<finish_game>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    -0x14(%rbp),%edi
call   1060 <turn_name@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%esi
sub    $0x1,%esi
mov    -0x18(%rbp),%edx
sub    $0x1,%edx
call   1050 <diagonally@plt>
cmp    $0x0,%rax
jne    11ba <finish_game+0x7a>
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%esi
sub    $0x1,%esi
mov    -0x18(%rbp),%edx
sub    $0x1,%edx
call   1040 <horizontal@plt>
cmp    $0x0,%rax
jne    11ba <finish_game+0x7a>
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%esi
sub    $0x1,%esi
mov    -0x18(%rbp),%edx
sub    $0x1,%edx
call   1030 <vertical@plt>
cmp    $0x0,%rax
je     11c6 <finish_game+0x86>
movl   $0x1,-0x4(%rbp)
jmp    11cd <finish_game+0x8d>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<finish_game>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%ebx
mov    %rdi,%r14
mov    %esi,%edi
call   1060 <turn_name@plt>
mov    %eax,%ebp
add    $0xffffffff,%ebp
add    $0xffffffff,%ebx
mov    %r14,%rdi
mov    %ebp,%esi
mov    %ebx,%edx
call   1050 <diagonally@plt>
mov    $0x1,%r15d
test   %rax,%rax
jne    1199 <finish_game+0x59>
mov    %r14,%rdi
mov    %ebp,%esi
mov    %ebx,%edx
call   1040 <horizontal@plt>
test   %rax,%rax
jne    1199 <finish_game+0x59>
mov    %r14,%rdi
mov    %ebp,%esi
mov    %ebx,%edx
call   1030 <vertical@plt>
xor    %r15d,%r15d
test   %rax,%rax
setne  %r15b
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @finish_game([12 x i8]* %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca [12 x i8]*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store [12 x i8]* %0, [12 x i8]** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
%11 = load i32, i32* %6
%12 = call i32 @turn_name(i32 %11)
store i32 %12, i32* %8
%13 = load [12 x i8]*, [12 x i8]** %5
%14 = bitcast [12 x i8]* %13 to i8**
%15 = load i32, i32* %8
%16 = sub nsw i32 %15, 1
%17 = load i32, i32* %7
%18 = sub nsw i32 %17, 1
%19 = call i64 @diagonally(i8** %14, i32 %16, i32 %18)
%20 = icmp ne i64 %19, 0
br i1 %20, label %39, label %21
21: ; preds = %3
%22 = load [12 x i8]*, [12 x i8]** %5
%23 = bitcast [12 x i8]* %22 to i8**
%24 = load i32, i32* %8
%25 = sub nsw i32 %24, 1
%26 = load i32, i32* %7
%27 = sub nsw i32 %26, 1
%28 = call i64 @horizontal(i8** %23, i32 %25, i32 %27)
%29 = icmp ne i64 %28, 0
br i1 %29, label %39, label %30
30: ; preds = %21
%31 = load [12 x i8]*, [12 x i8]** %5
%32 = bitcast [12 x i8]* %31 to i8**
%33 = load i32, i32* %8
%34 = sub nsw i32 %33, 1
%35 = load i32, i32* %7
%36 = sub nsw i32 %35, 1
%37 = call i64 @vertical(i8** %32, i32 %34, i32 %36)
%38 = icmp ne i64 %37, 0
br i1 %38, label %39, label %40
39: ; preds = %30, %21, %3
store i32 1, i32* %4
br label %41
40: ; preds = %30
store i32 0, i32* %4
br label %41
41: ; preds = %40, %39
%42 = load i32, i32* %4
ret i32 %42
}

LLVM IR (-O2):
define i32 @finish_game([12 x i8]* %0, i32 %1, i32 %2) {
%4 = tail call i32 @turn_name(i32 %1)
%5 = bitcast [12 x i8]* %0 to i8**
%6 = add nsw i32 %4, -1
%7 = add nsw i32 %2, -1
%8 = tail call i64 @diagonally(i8** %5, i32 %6, i32 %7)
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %17
10: ; preds = %3
%11 = tail call i64 @horizontal(i8** %5, i32 %6, i32 %7)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %17
13: ; preds = %10
%14 = tail call i64 @vertical(i8** %5, i32 %6, i32 %7)
%15 = icmp ne i64 %14, 0
%16 = zext i1 %15 to i32
br label %17
17: ; preds = %13, %3, %10
%18 = phi i32 [ 1, %10 ], [ 1, %3 ], [ %16, %13 ]
ret i32 %18
}