#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 testerColonneGagnanteMorpion(int, int);
int testerDiagonaleDebutEnHautaDroiteMorpion(int, int);
int testerDiagonaleDebutEnHautaGaucheMorpion(int, int);
int testerLigneGagnanteMorpion(int, int);
int gagnerMorpion(int estUnTest) {
  int indexJoueur;
  for (indexJoueur = 1; indexJoueur <= 2; indexJoueur++) {
    if (testerLigneGagnanteMorpion(indexJoueur, estUnTest) == 1)
      return indexJoueur;
    else if (testerColonneGagnanteMorpion(indexJoueur, estUnTest) == 1)
      return indexJoueur;
    else if (testerDiagonaleDebutEnHautaGaucheMorpion(indexJoueur, estUnTest) ==
             1)
      return indexJoueur;
    else if (testerDiagonaleDebutEnHautaDroiteMorpion(indexJoueur, estUnTest) ==
             1)
      return indexJoueur;
  }
  return 0;
}


x86 assembly (clang, -O0):
<gagnerMorpion>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
cmpl   $0x2,-0xc(%rbp)
jg     11fa <gagnerMorpion+0xba>
mov    -0xc(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1060 <testerLigneGagnanteMorpion@plt>
cmp    $0x1,%eax
jne    117b <gagnerMorpion+0x3b>
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1201 <gagnerMorpion+0xc1>
mov    -0xc(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1050 <testerColonneGagnanteMorpion@plt>
cmp    $0x1,%eax
jne    119a <gagnerMorpion+0x5a>
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1201 <gagnerMorpion+0xc1>
mov    -0xc(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1030 <testerDiagonaleDebutEnHautaGaucheMorpion@plt>
cmp    $0x1,%eax
jne    11b9 <gagnerMorpion+0x79>
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1201 <gagnerMorpion+0xc1>
mov    -0xc(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1040 <testerDiagonaleDebutEnHautaDroiteMorpion@plt>
cmp    $0x1,%eax
jne    11d8 <gagnerMorpion+0x98>
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1201 <gagnerMorpion+0xc1>
jmp    11dd <gagnerMorpion+0x9d>
jmp    11e2 <gagnerMorpion+0xa2>
jmp    11e7 <gagnerMorpion+0xa7>
jmp    11ec <gagnerMorpion+0xac>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1152 <gagnerMorpion+0x12>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gagnerMorpion>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebx
mov    $0x1,%ebp
mov    $0x1,%edi
mov    %ebx,%esi
call   1060 <testerLigneGagnanteMorpion@plt>
cmp    $0x1,%eax
je     11fe <gagnerMorpion+0xbe>
mov    $0x1,%ebp
mov    $0x1,%edi
mov    %ebx,%esi
call   1050 <testerColonneGagnanteMorpion@plt>
cmp    $0x1,%eax
je     11fe <gagnerMorpion+0xbe>
mov    $0x1,%ebp
mov    $0x1,%edi
mov    %ebx,%esi
call   1030 <testerDiagonaleDebutEnHautaGaucheMorpion@plt>
cmp    $0x1,%eax
je     11fe <gagnerMorpion+0xbe>
mov    $0x1,%ebp
mov    $0x1,%edi
mov    %ebx,%esi
call   1040 <testerDiagonaleDebutEnHautaDroiteMorpion@plt>
cmp    $0x1,%eax
je     11fe <gagnerMorpion+0xbe>
mov    $0x2,%ebp
mov    $0x2,%edi
mov    %ebx,%esi
call   1060 <testerLigneGagnanteMorpion@plt>
cmp    $0x1,%eax
je     11fe <gagnerMorpion+0xbe>
mov    $0x2,%ebp
mov    $0x2,%edi
mov    %ebx,%esi
call   1050 <testerColonneGagnanteMorpion@plt>
cmp    $0x1,%eax
je     11fe <gagnerMorpion+0xbe>
mov    $0x2,%ebp
mov    $0x2,%edi
mov    %ebx,%esi
call   1030 <testerDiagonaleDebutEnHautaGaucheMorpion@plt>
cmp    $0x1,%eax
je     11fe <gagnerMorpion+0xbe>
mov    $0x2,%edi
mov    %ebx,%esi
call   1040 <testerDiagonaleDebutEnHautaDroiteMorpion@plt>
xor    %ebp,%ebp
cmp    $0x1,%eax
sete   %bpl
add    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @gagnerMorpion(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
store i32 1, i32* %4
br label %5
5: ; preds = %40, %1
%6 = load i32, i32* %4
%7 = icmp sle i32 %6, 2
br i1 %7, label %8, label %43
8: ; preds = %5
%9 = load i32, i32* %4
%10 = load i32, i32* %3
%11 = call i32 @testerLigneGagnanteMorpion(i32 %9, i32 %10)
%12 = icmp eq i32 %11, 1
br i1 %12, label %13, label %15
13: ; preds = %8
%14 = load i32, i32* %4
store i32 %14, i32* %2
br label %44
15: ; preds = %8
%16 = load i32, i32* %4
%17 = load i32, i32* %3
%18 = call i32 @testerColonneGagnanteMorpion(i32 %16, i32 %17)
%19 = icmp eq i32 %18, 1
br i1 %19, label %20, label %22
20: ; preds = %15
%21 = load i32, i32* %4
store i32 %21, i32* %2
br label %44
22: ; preds = %15
%23 = load i32, i32* %4
%24 = load i32, i32* %3
%25 = call i32 @testerDiagonaleDebutEnHautaGaucheMorpion(i32 %23, i32 %24)
%26 = icmp eq i32 %25, 1
br i1 %26, label %27, label %29
27: ; preds = %22
%28 = load i32, i32* %4
store i32 %28, i32* %2
br label %44
29: ; preds = %22
%30 = load i32, i32* %4
%31 = load i32, i32* %3
%32 = call i32 @testerDiagonaleDebutEnHautaDroiteMorpion(i32 %30, i32 %31)
%33 = icmp eq i32 %32, 1
br i1 %33, label %34, label %36
34: ; preds = %29
%35 = load i32, i32* %4
store i32 %35, i32* %2
br label %44
36: ; preds = %29
br label %37
37: ; preds = %36
br label %38
38: ; preds = %37
br label %39
39: ; preds = %38
br label %40
40: ; preds = %39
%41 = load i32, i32* %4
%42 = add nsw i32 %41, 1
store i32 %42, i32* %4
br label %5
43: ; preds = %5
store i32 0, i32* %2
br label %44
44: ; preds = %43, %34, %27, %20, %13
%45 = load i32, i32* %2
ret i32 %45
}

LLVM IR (-O2):
define i32 @gagnerMorpion(i32 %0) {
%2 = tail call i32 @testerLigneGagnanteMorpion(i32 1, i32 %0)
%3 = icmp eq i32 %2, 1
br i1 %3, label %26, label %4
4: ; preds = %1
%5 = tail call i32 @testerColonneGagnanteMorpion(i32 1, i32 %0)
%6 = icmp eq i32 %5, 1
br i1 %6, label %26, label %7
7: ; preds = %4
%8 = tail call i32 @testerDiagonaleDebutEnHautaGaucheMorpion(i32 1, i32 %0)
%9 = icmp eq i32 %8, 1
br i1 %9, label %26, label %10
10: ; preds = %7
%11 = tail call i32 @testerDiagonaleDebutEnHautaDroiteMorpion(i32 1, i32 %0)
%12 = icmp eq i32 %11, 1
br i1 %12, label %26, label %13
13: ; preds = %10
%14 = tail call i32 @testerLigneGagnanteMorpion(i32 2, i32 %0)
%15 = icmp eq i32 %14, 1
br i1 %15, label %26, label %16
16: ; preds = %13
%17 = tail call i32 @testerColonneGagnanteMorpion(i32 2, i32 %0)
%18 = icmp eq i32 %17, 1
br i1 %18, label %26, label %19
19: ; preds = %16
%20 = tail call i32 @testerDiagonaleDebutEnHautaGaucheMorpion(i32 2, i32 %0)
%21 = icmp eq i32 %20, 1
br i1 %21, label %26, label %22
22: ; preds = %19
%23 = tail call i32 @testerDiagonaleDebutEnHautaDroiteMorpion(i32 2, i32 %0)
%24 = icmp eq i32 %23, 1
%25 = select i1 %24, i32 2, i32 0
br label %26
26: ; preds = %22, %19, %16, %13, %10, %7, %4, %1
%27 = phi i32 [ 1, %1 ], [ 1, %4 ], [ 1, %7 ], [ 1, %10 ], [ 2, %13 ], [ 2, %16 ], [ 2, %19 ], [ %25, %22 ]
ret i32 %27
}