#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 /*<<< orphan*/ artificial1();
int /*<<< orphan*/ artificial2();
int /*<<< orphan*/ artificial3();
int /*<<< orphan*/ fill();
int nb_of_cases(char);
int /*<<< orphan*/ player(char);
int /*<<< orphan*/ print_board();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main(void) {
  char play[] = "v^";
  int i = 0, choice;
  int possession1 = 0;
  int possession2 = 0;
  printf("\n\nWelcome to the 7 wonders of the world of the 7 colors\n"
         "*****************************************************\n\n"
         "Please choose a game mode :\n"
         " 1 : Human\n"
         " 2 : IA random\n"
         " 3 : IA random upgraded\n"
         " 4 : IA gloutonne\n");
  scanf("%d", &choice);
  printf("Current board state:\n");
  fill();
  print_board();
  while ((possession1 <= 50) & (possession2 <= 50)) {
    if (i % 2 == 1 && choice == 4) {
      artificial3();
    }
    if (i % 2 == 1 && choice == 3) {
      artificial2();
    }
    if (i % 2 == 1 && choice == 2) {
      artificial1();
    }
    if (i % 2 == 1 && choice == 1) {
      player(play[i % 2]);
    }
    if (i % 2 == 0) {
      player(play[i % 2]);
    }
    i++;
    possession1 = 100 * nb_of_cases(play[0]) / (25 * 25);
    possession2 = 100 * nb_of_cases(play[1]) / (25 * 25);
    printf("\nLe joueur v possède %d pourcent des cases\n", possession1);
    printf("Le joueur ^ possède %d pourcent des cases\n", possession2);
    if (possession1 > 50) {
      printf("Le joueur v a gagné");
    }
    if (possession2 > 50) {
      printf("Le joueur ^ a gagné");
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xe5a(%rip),%ax
mov    %ax,-0x7(%rbp)
mov    0xe52(%rip),%al
mov    %al,-0x5(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
lea    0xe34(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xef6(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   10b0 <scanf@plt>
lea    0xee9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1060 <fill@plt>
mov    $0x0,%al
call   1050 <print_board@plt>
cmpl   $0x32,-0x14(%rbp)
setle  %al
and    $0x1,%al
movzbl %al,%eax
cmpl   $0x32,-0x18(%rbp)
setle  %cl
and    $0x1,%cl
movzbl %cl,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     1385 <main+0x1f5>
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x1,%edx
jne    124b <main+0xbb>
cmpl   $0x4,-0x10(%rbp)
jne    124b <main+0xbb>
mov    $0x0,%al
call   10a0 <artificial3@plt>
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x1,%edx
jne    1270 <main+0xe0>
cmpl   $0x3,-0x10(%rbp)
jne    1270 <main+0xe0>
mov    $0x0,%al
call   1030 <artificial2@plt>
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x1,%edx
jne    1295 <main+0x105>
cmpl   $0x2,-0x10(%rbp)
jne    1295 <main+0x105>
mov    $0x0,%al
call   1090 <artificial1@plt>
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x1,%edx
jne    12cb <main+0x13b>
cmpl   $0x1,-0x10(%rbp)
jne    12cb <main+0x13b>
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
movslq %edx,%rax
movsbl -0x7(%rbp,%rax,1),%edi
call   1070 <player@plt>
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    12f7 <main+0x167>
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
movslq %edx,%rax
movsbl -0x7(%rbp,%rax,1),%edi
call   1070 <player@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
movsbl -0x7(%rbp),%edi
call   1080 <nb_of_cases@plt>
imul   $0x64,%eax,%eax
mov    $0x271,%ecx
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
movsbl -0x6(%rbp),%edi
call   1080 <nb_of_cases@plt>
imul   $0x64,%eax,%eax
mov    $0x271,%ecx
cltd
idiv   %ecx
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%esi
lea    0xdb4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%esi
lea    0xdd0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x32,-0x14(%rbp)
jle    1368 <main+0x1d8>
lea    0xde4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x32,-0x18(%rbp)
jle    1380 <main+0x1f0>
lea    0xde1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1202 <main+0x72>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xed4(%rip),%rdi
call   1030 <puts@plt>
lea    0xe42(%rip),%rdi
lea    0x4(%rsp),%rsi
call   10c0 <scanf@plt>
lea    0xf86(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1070 <fill@plt>
xor    %eax,%eax
call   1060 <print_board@plt>
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x4(%rsp),%eax
test   $0x1,%bpl
je     120a <main+0x6a>
cmp    $0x4,%eax
jne    120a <main+0x6a>
xor    %eax,%eax
call   10b0 <artificial3@plt>
mov    0x4(%rsp),%eax
test   $0x1,%bpl
je     1220 <main+0x80>
cmp    $0x3,%eax
jne    1220 <main+0x80>
xor    %eax,%eax
call   1040 <artificial2@plt>
mov    0x4(%rsp),%eax
test   $0x1,%bpl
je     1240 <main+0xa0>
cmp    $0x2,%eax
jne    1240 <main+0xa0>
xor    %eax,%eax
call   10a0 <artificial1@plt>
mov    $0x5e,%cl
cmpl   $0x1,0x4(%rsp)
je     1260 <main+0xc0>
jmp    1268 <main+0xc8>
nopl   (%rax)
test   $0x1,%bpl
je     124d <main+0xad>
mov    $0x5e,%cl
cmp    $0x1,%eax
je     1260 <main+0xc0>
mov    $0x76,%cl
test   $0x1,%bpl
jne    1268 <main+0xc8>
cs nopw 0x0(%rax,%rax,1)
nop
movzbl %cl,%edi
call   1080 <player@plt>
mov    $0x76,%edi
call   1090 <nb_of_cases@plt>
imul   $0x64,%eax,%r15d
movslq %r15d,%r14
imul   $0x68db8bad,%r14,%r13
mov    %r13,%rax
shr    $0x3f,%rax
sar    $0x28,%r13
add    %eax,%r13d
mov    $0x5e,%edi
call   1090 <nb_of_cases@plt>
imul   $0x64,%eax,%r12d
movslq %r12d,%rax
imul   $0x68db8bad,%rax,%rbx
mov    %rbx,%rax
shr    $0x3f,%rax
sar    $0x28,%rbx
add    %eax,%ebx
lea    0xd49(%rip),%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xd65(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
cmp    $0x7c83,%r14d
jl     12eb <main+0x14b>
lea    0xd78(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
cmp    $0x7c83,%r12d
jge    1306 <main+0x166>
add    $0x1,%ebp
cmp    $0x7c83,%r15d
jl     11f0 <main+0x50>
jmp    1314 <main+0x174>
lea    0xd64(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.play = [3 x i8] c"v^\00"
@.str = [208 x i8] c"\0A\0AWelcome to the 7 wonders of the world of the 7 colors\0A*****************************************************\0A\0APlease choose a game mode :\0A 1 : Human\0A 2 : IA random\0A 3 : IA random upgraded\0A 4 : IA gloutonne\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [22 x i8] c"Current board state:\0A\00"
@.str.3 = [45 x i8] c"\0ALe joueur v poss\C3\A8de %d pourcent des cases\0A\00"
@.str.4 = [44 x i8] c"Le joueur ^ poss\C3\A8de %d pourcent des cases\0A\00"
@.str.5 = [21 x i8] c"Le joueur v a gagn\C3\A9\00"
@.str.6 = [21 x i8] c"Le joueur ^ a gagn\C3\A9\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [3 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = bitcast [3 x i8]* %2 to i8*
store i32 0, i32* %3
store i32 0, i32* %5
store i32 0, i32* %6
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([208 x i8], [208 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 (...) @fill()
%12 = call i32 (...) @print_board()
br label %13
13: ; preds = %100, %0
%14 = load i32, i32* %5
%15 = icmp sle i32 %14, 50
%16 = zext i1 %15 to i32
%17 = load i32, i32* %6
%18 = icmp sle i32 %17, 50
%19 = zext i1 %18 to i32
%20 = and i32 %16, %19
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %101
22: ; preds = %13
%23 = load i32, i32* %3
%24 = srem i32 %23, 2
%25 = icmp eq i32 %24, 1
br i1 %25, label %26, label %31
26: ; preds = %22
%27 = load i32, i32* %4
%28 = icmp eq i32 %27, 4
br i1 %28, label %29, label %31
29: ; preds = %26
%30 = call i32 (...) @artificial3()
br label %31
31: ; preds = %29, %26, %22
%32 = load i32, i32* %3
%33 = srem i32 %32, 2
%34 = icmp eq i32 %33, 1
br i1 %34, label %35, label %40
35: ; preds = %31
%36 = load i32, i32* %4
%37 = icmp eq i32 %36, 3
br i1 %37, label %38, label %40
38: ; preds = %35
%39 = call i32 (...) @artificial2()
br label %40
40: ; preds = %38, %35, %31
%41 = load i32, i32* %3
%42 = srem i32 %41, 2
%43 = icmp eq i32 %42, 1
br i1 %43, label %44, label %49
44: ; preds = %40
%45 = load i32, i32* %4
%46 = icmp eq i32 %45, 2
br i1 %46, label %47, label %49
47: ; preds = %44
%48 = call i32 (...) @artificial1()
br label %49
49: ; preds = %47, %44, %40
%50 = load i32, i32* %3
%51 = srem i32 %50, 2
%52 = icmp eq i32 %51, 1
br i1 %52, label %53, label %63
53: ; preds = %49
%54 = load i32, i32* %4
%55 = icmp eq i32 %54, 1
br i1 %55, label %56, label %63
56: ; preds = %53
%57 = load i32, i32* %3
%58 = srem i32 %57, 2
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 %59
%61 = load i8, i8* %60
%62 = call i32 @player(i8 signext %61)
br label %63
63: ; preds = %56, %53, %49
%64 = load i32, i32* %3
%65 = srem i32 %64, 2
%66 = icmp eq i32 %65, 0
br i1 %66, label %67, label %74
67: ; preds = %63
%68 = load i32, i32* %3
%69 = srem i32 %68, 2
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 %70
%72 = load i8, i8* %71
%73 = call i32 @player(i8 signext %72)
br label %74
74: ; preds = %67, %63
%75 = load i32, i32* %3
%76 = add nsw i32 %75, 1
store i32 %76, i32* %3
%77 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 0
%78 = load i8, i8* %77
%79 = call i32 @nb_of_cases(i8 signext %78)
%80 = mul nsw i32 100, %79
%81 = sdiv i32 %80, 625
store i32 %81, i32* %5
%82 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 1
%83 = load i8, i8* %82
%84 = call i32 @nb_of_cases(i8 signext %83)
%85 = mul nsw i32 100, %84
%86 = sdiv i32 %85, 625
store i32 %86, i32* %6
%87 = load i32, i32* %5
%88 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.3, i64 0, i64 0), i32 %87)
%89 = load i32, i32* %6
%90 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.4, i64 0, i64 0), i32 %89)
%91 = load i32, i32* %5
%92 = icmp sgt i32 %91, 50
br i1 %92, label %93, label %95
93: ; preds = %74
%94 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0))
br label %95
95: ; preds = %93, %74
%96 = load i32, i32* %6
%97 = icmp sgt i32 %96, 50
br i1 %97, label %98, label %100
98: ; preds = %95
%99 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0))
br label %100
100: ; preds = %98, %95
br label %13
101: ; preds = %13
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [45 x i8] c"\0ALe joueur v poss\C3\A8de %d pourcent des cases\0A\00"
@.str.4 = [44 x i8] c"Le joueur ^ poss\C3\A8de %d pourcent des cases\0A\00"
@.str.5 = [21 x i8] c"Le joueur v a gagn\C3\A9\00"
@.str.6 = [21 x i8] c"Le joueur ^ a gagn\C3\A9\00"
@str = [207 x i8] c"\0A\0AWelcome to the 7 wonders of the world of the 7 colors\0A*****************************************************\0A\0APlease choose a game mode :\0A 1 : Human\0A 2 : IA random\0A 3 : IA random upgraded\0A 4 : IA gloutonne\00"
@str.7 = [21 x i8] c"Current board state:\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([207 x i8], [207 x i8]* @str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.7, i64 0, i64 0))
%6 = call i32 (...) @fill()
%7 = call i32 (...) @print_board()
br label %8
8: ; preds = %0, %58
%9 = phi i32 [ 0, %0 ], [ %42, %58 ]
%10 = and i32 %9, 1
%11 = icmp ne i32 %10, 0
%12 = load i32, i32* %1
%13 = icmp eq i32 %12, 4
%14 = select i1 %11, i1 %13, i1 false
br i1 %14, label %15, label %18
15: ; preds = %8
%16 = call i32 (...) @artificial3()
%17 = load i32, i32* %1
br label %18
18: ; preds = %15, %8
%19 = phi i32 [ %17, %15 ], [ %12, %8 ]
%20 = icmp eq i32 %19, 3
%21 = select i1 %11, i1 %20, i1 false
br i1 %21, label %22, label %25
22: ; preds = %18
%23 = call i32 (...) @artificial2()
%24 = load i32, i32* %1
br label %25
25: ; preds = %22, %18
%26 = phi i32 [ %24, %22 ], [ %19, %18 ]
%27 = icmp eq i32 %26, 2
%28 = select i1 %11, i1 %27, i1 false
br i1 %28, label %32, label %29
29: ; preds = %25
%30 = icmp eq i32 %26, 1
%31 = select i1 %11, i1 %30, i1 false
br i1 %31, label %38, label %36
32: ; preds = %25
%33 = call i32 (...) @artificial1()
%34 = load i32, i32* %1
%35 = icmp eq i32 %34, 1
br i1 %35, label %38, label %41
36: ; preds = %29
%37 = icmp eq i32 %10, 0
br i1 %37, label %38, label %41
38: ; preds = %36, %32, %29
%39 = phi i8 [ 94, %29 ], [ 94, %32 ], [ 118, %36 ]
%40 = call i32 @player(i8 signext %39)
br label %41
41: ; preds = %38, %32, %36
%42 = add nuw nsw i32 %9, 1
%43 = call i32 @nb_of_cases(i8 signext 118)
%44 = mul nsw i32 %43, 100
%45 = sdiv i32 %44, 625
%46 = call i32 @nb_of_cases(i8 signext 94)
%47 = mul nsw i32 %46, 100
%48 = sdiv i32 %47, 625
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.3, i64 0, i64 0), i32 %45)
%50 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.4, i64 0, i64 0), i32 %48)
%51 = icmp sgt i32 %44, 31874
br i1 %51, label %52, label %54
52: ; preds = %41
%53 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0))
br label %54
54: ; preds = %52, %41
%55 = icmp sgt i32 %47, 31874
br i1 %55, label %56, label %58
56: ; preds = %54
%57 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0))
br label %60
58: ; preds = %54
%59 = icmp slt i32 %44, 31875
br i1 %59, label %8, label %60
60: ; preds = %58, %56
ret i32 0
}