#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 */
unsigned char *create_tab(int);
scalar_t__ display(unsigned char *, int, int, int);
int /*<<< orphan*/ free(unsigned char *);
int /*<<< orphan*/ ia(unsigned char *, int);
int nb_alum(unsigned char *, int);
int /*<<< orphan*/ print_winner(int, int);
int user(unsigned char *, int);
int game(int size, int mode) {
  unsigned char *rows;
  int winner;
  if ((rows = create_tab(size)) == NULL)
    return (1);
  winner = 0;
  while (winner == 0) {
    if (display(rows, size, 1, mode) == 0 && mode == 0)
      ia(rows, size);
    else if (user(rows, size) == 1)
      return (1);
    winner = (nb_alum(rows, size) < 1) * 2;
    if (winner == 0) {
      if (display(rows, size, 2, mode) == 0 && mode < 2)
        ia(rows, size);
      else if (user(rows, size) == 1)
        return (1);
      winner = (nb_alum(rows, size) < 1);
    }
  }
  print_winner(mode, winner);
  free(rows);
  return (0);
}


x86 assembly (clang, -O0):
<game>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%edi
call   1090 <create_tab@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11a0 <game+0x30>
movl   $0x1,-0x4(%rbp)
jmp    12d0 <game+0x160>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jne    12b5 <game+0x145>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%ecx
mov    $0x1,%edx
call   1060 <display@plt>
cmp    $0x0,%rax
jne    11ea <game+0x7a>
cmpl   $0x0,-0xc(%rbp)
jne    11ea <game+0x7a>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1080 <ia@plt>
jmp    1210 <game+0xa0>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1070 <user@plt>
cmp    $0x1,%eax
jne    120b <game+0x9b>
movl   $0x1,-0x4(%rbp)
jmp    12d0 <game+0x160>
jmp    1210 <game+0xa0>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1050 <nb_alum@plt>
cmp    $0x1,%eax
setl   %al
and    $0x1,%al
movzbl %al,%eax
shl    $0x1,%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jne    12b0 <game+0x140>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%ecx
mov    $0x2,%edx
call   1060 <display@plt>
cmp    $0x0,%rax
jne    1270 <game+0x100>
cmpl   $0x2,-0xc(%rbp)
jge    1270 <game+0x100>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1080 <ia@plt>
jmp    1296 <game+0x126>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1070 <user@plt>
cmp    $0x1,%eax
jne    1291 <game+0x121>
movl   $0x1,-0x4(%rbp)
jmp    12d0 <game+0x160>
jmp    1296 <game+0x126>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1050 <nb_alum@plt>
cmp    $0x1,%eax
setl   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x1c(%rbp)
jmp    11a7 <game+0x37>
mov    -0xc(%rbp),%edi
mov    -0x1c(%rbp),%esi
call   1030 <print_winner@plt>
mov    -0x18(%rbp),%rdi
call   1040 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<game>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%r14d
mov    %edi,%ebp
call   1090 <create_tab@plt>
test   %rax,%rax
je     1231 <game+0xc1>
mov    %rax,%rbx
jmp    11b5 <game+0x45>
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    %ebp,%esi
call   1070 <user@plt>
cmp    $0x1,%eax
je     1231 <game+0xc1>
mov    %rbx,%rdi
mov    %ebp,%esi
call   1050 <nb_alum@plt>
test   %eax,%eax
jle    123f <game+0xcf>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    $0x1,%edx
mov    %r14d,%ecx
call   1060 <display@plt>
test   %r14d,%r14d
jne    11e0 <game+0x70>
test   %rax,%rax
jne    11e0 <game+0x70>
mov    %rbx,%rdi
mov    %ebp,%esi
call   1080 <ia@plt>
jmp    11ef <game+0x7f>
nopl   (%rax)
mov    %rbx,%rdi
mov    %ebp,%esi
call   1070 <user@plt>
cmp    $0x1,%eax
je     1231 <game+0xc1>
mov    %rbx,%rdi
mov    %ebp,%esi
call   1050 <nb_alum@plt>
test   %eax,%eax
jle    1238 <game+0xc8>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    $0x2,%edx
mov    %r14d,%ecx
call   1060 <display@plt>
cmp    $0x1,%r14d
jg     1190 <game+0x20>
test   %rax,%rax
jne    1190 <game+0x20>
mov    %rbx,%rdi
mov    %ebp,%esi
call   1080 <ia@plt>
jmp    11a3 <game+0x33>
mov    $0x1,%eax
jmp    1256 <game+0xe6>
mov    $0x2,%esi
jmp    1244 <game+0xd4>
mov    $0x1,%esi
mov    %r14d,%edi
call   1030 <print_winner@plt>
mov    %rbx,%rdi
call   1040 <free@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @game(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
%8 = load i32, i32* %4
%9 = call i8* @create_tab(i32 %8)
store i8* %9, i8** %6
%10 = icmp eq i8* %9, null
br i1 %10, label %11, label %12
11: ; preds = %2
store i32 1, i32* %3
br label %78
12: ; preds = %2
store i32 0, i32* %7
br label %13
13: ; preds = %71, %12
%14 = load i32, i32* %7
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %72
16: ; preds = %13
%17 = load i8*, i8** %6
%18 = load i32, i32* %4
%19 = load i32, i32* %5
%20 = call i64 @display(i8* %17, i32 %18, i32 1, i32 %19)
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %29
22: ; preds = %16
%23 = load i32, i32* %5
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %29
25: ; preds = %22
%26 = load i8*, i8** %6
%27 = load i32, i32* %4
%28 = call i32 @ia(i8* %26, i32 %27)
br label %36
29: ; preds = %22, %16
%30 = load i8*, i8** %6
%31 = load i32, i32* %4
%32 = call i32 @user(i8* %30, i32 %31)
%33 = icmp eq i32 %32, 1
br i1 %33, label %34, label %35
34: ; preds = %29
store i32 1, i32* %3
br label %78
35: ; preds = %29
br label %36
36: ; preds = %35, %25
%37 = load i8*, i8** %6
%38 = load i32, i32* %4
%39 = call i32 @nb_alum(i8* %37, i32 %38)
%40 = icmp slt i32 %39, 1
%41 = zext i1 %40 to i32
%42 = mul nsw i32 %41, 2
store i32 %42, i32* %7
%43 = load i32, i32* %7
%44 = icmp eq i32 %43, 0
br i1 %44, label %45, label %71
45: ; preds = %36
%46 = load i8*, i8** %6
%47 = load i32, i32* %4
%48 = load i32, i32* %5
%49 = call i64 @display(i8* %46, i32 %47, i32 2, i32 %48)
%50 = icmp eq i64 %49, 0
br i1 %50, label %51, label %58
51: ; preds = %45
%52 = load i32, i32* %5
%53 = icmp slt i32 %52, 2
br i1 %53, label %54, label %58
54: ; preds = %51
%55 = load i8*, i8** %6
%56 = load i32, i32* %4
%57 = call i32 @ia(i8* %55, i32 %56)
br label %65
58: ; preds = %51, %45
%59 = load i8*, i8** %6
%60 = load i32, i32* %4
%61 = call i32 @user(i8* %59, i32 %60)
%62 = icmp eq i32 %61, 1
br i1 %62, label %63, label %64
63: ; preds = %58
store i32 1, i32* %3
br label %78
64: ; preds = %58
br label %65
65: ; preds = %64, %54
%66 = load i8*, i8** %6
%67 = load i32, i32* %4
%68 = call i32 @nb_alum(i8* %66, i32 %67)
%69 = icmp slt i32 %68, 1
%70 = zext i1 %69 to i32
store i32 %70, i32* %7
br label %71
71: ; preds = %65, %36
br label %13
72: ; preds = %13
%73 = load i32, i32* %5
%74 = load i32, i32* %7
%75 = call i32 @print_winner(i32 %73, i32 %74)
%76 = load i8*, i8** %6
%77 = call i32 @free(i8* %76)
store i32 0, i32* %3
br label %78
78: ; preds = %72, %63, %34, %11
%79 = load i32, i32* %3
ret i32 %79
}

LLVM IR (-O2):
define i32 @game(i32 %0, i32 %1) {
%3 = tail call i8* @create_tab(i32 %0)
%4 = icmp eq i8* %3, null
br i1 %4, label %36, label %5
5: ; preds = %2
%6 = icmp eq i32 %1, 0
%7 = icmp slt i32 %1, 2
br label %8
8: ; preds = %5, %29
%9 = tail call i64 @display(i8* %3, i32 %0, i32 1, i32 %1)
%10 = icmp eq i64 %9, 0
%11 = and i1 %6, %10
br i1 %11, label %12, label %14
12: ; preds = %8
%13 = tail call i32 @ia(i8* %3, i32 %0)
br label %17
14: ; preds = %8
%15 = tail call i32 @user(i8* %3, i32 %0)
%16 = icmp eq i32 %15, 1
br i1 %16, label %36, label %17
17: ; preds = %14, %12
%18 = tail call i32 @nb_alum(i8* %3, i32 %0)
%19 = icmp sgt i32 %18, 0
br i1 %19, label %20, label %32
20: ; preds = %17
%21 = tail call i64 @display(i8* %3, i32 %0, i32 2, i32 %1)
%22 = icmp eq i64 %21, 0
%23 = and i1 %7, %22
br i1 %23, label %24, label %26
24: ; preds = %20
%25 = tail call i32 @ia(i8* %3, i32 %0)
br label %29
26: ; preds = %20
%27 = tail call i32 @user(i8* %3, i32 %0)
%28 = icmp eq i32 %27, 1
br i1 %28, label %36, label %29
29: ; preds = %24, %26
%30 = tail call i32 @nb_alum(i8* %3, i32 %0)
%31 = icmp sgt i32 %30, 0
br i1 %31, label %8, label %32
32: ; preds = %17, %29
%33 = phi i32 [ 1, %29 ], [ 2, %17 ]
%34 = tail call i32 @print_winner(i32 %1, i32 %33)
%35 = tail call i32 @free(i8* %3)
br label %36
36: ; preds = %26, %14, %2, %32
%37 = phi i32 [ 0, %32 ], [ 1, %2 ], [ 1, %14 ], [ 1, %26 ]
ret i32 %37
}