#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*/ afficherMastermind();
int /*<<< orphan*/ afficherReponseMastermind(char *);
int /*<<< orphan*/ appuyezEntree(char *);
int /*<<< orphan*/ defaiteMastermindMulti();
int /*<<< orphan*/ defaiteMastermindSolo(int);
int /*<<< orphan*/ demanderCodeSecretMastermind(char *);
scalar_t__ gagnerMastermind(char *, char *);
int /*<<< orphan*/ initCodeSecretMastermind(char *);
int /*<<< orphan*/ initMastermind();
int /*<<< orphan*/ lireCodeMastermind(int, char *);
int /*<<< orphan*/ menuMastermind(int);
int /*<<< orphan*/ multi();
int /*<<< orphan*/ placerPionCouleurCoteMastermind(int, int, int);
int /*<<< orphan*/ placerPionMastermind(char *, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ system(char *);
int /*<<< orphan*/ verifierCodeMastermind(char *, char *, int *, int *);
int /*<<< orphan*/ victoireMastermindMulti();
int /*<<< orphan*/ victoireMastermindSolo(int, int);
void mastermind(int modeDeJeux) {
  int tentative;
  int ligActuelle;
  int nbBienPlace, nbMalPlace;
  char codeCouleur[4 + 1];
  char combinaisonEntree[500];
  tentative = 10;
  ligActuelle = 10 - 1;
  menuMastermind(modeDeJeux);
  initMastermind();
  if (modeDeJeux == 0)
    initCodeSecretMastermind(codeCouleur);
  else if (modeDeJeux == 1)
    demanderCodeSecretMastermind(codeCouleur);
  do {
    system("clear");
    if (modeDeJeux == 1)
      printf("Joueur 2 :\n\n");
    afficherMastermind();
    nbBienPlace = nbMalPlace = 0;
    lireCodeMastermind(tentative, combinaisonEntree);
    verifierCodeMastermind(codeCouleur, combinaisonEntree, &nbBienPlace,
                           &nbMalPlace);
    placerPionCouleurCoteMastermind(nbBienPlace, nbMalPlace, ligActuelle);
    placerPionMastermind(combinaisonEntree, ligActuelle);
    tentative--;
    ligActuelle--;
  } while (!gagnerMastermind(codeCouleur, combinaisonEntree) && tentative != 0);
  afficherReponseMastermind(codeCouleur);
  afficherMastermind();
  if (modeDeJeux == 0) {
    if (gagnerMastermind(codeCouleur, combinaisonEntree))
      victoireMastermindSolo(10 - tentative, modeDeJeux);
    else
      defaiteMastermindSolo(modeDeJeux);
  } else if (modeDeJeux == 1) {
    if (gagnerMastermind(codeCouleur, combinaisonEntree))
      victoireMastermindMulti();
    else
      defaiteMastermindMulti();
    appuyezEntree("Appuyez sur ENTREE pour revenir au menu : ");
    multi();
  }
}


x86 assembly (clang, -O0):
<mastermind>:
push   %rbp
mov    %rsp,%rbp
sub    $0x220,%rsp
mov    %edi,-0x4(%rbp)
movl   $0xa,-0x8(%rbp)
movl   $0x9,-0xc(%rbp)
mov    -0x4(%rbp),%edi
call   10d0 <menuMastermind@plt>
mov    $0x0,%al
call   10f0 <initMastermind@plt>
cmpl   $0x0,-0x4(%rbp)
jne    1273 <mastermind+0x43>
lea    -0x19(%rbp),%rdi
call   1030 <initCodeSecretMastermind@plt>
jmp    128b <mastermind+0x5b>
cmpl   $0x1,-0x4(%rbp)
jne    1286 <mastermind+0x56>
lea    -0x19(%rbp),%rdi
call   1080 <demanderCodeSecretMastermind@plt>
jmp    128b <mastermind+0x5b>
jmp    1290 <mastermind+0x60>
lea    0xd69(%rip),%rdi
call   1040 <system@plt>
cmpl   $0x1,-0x4(%rbp)
jne    12b2 <mastermind+0x82>
lea    0xd59(%rip),%rdi
call   1050 <printf@plt>
mov    $0x0,%al
call   10c0 <afficherMastermind@plt>
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x210(%rbp),%rsi
call   1110 <lireCodeMastermind@plt>
lea    -0x19(%rbp),%rdi
lea    -0x210(%rbp),%rsi
lea    -0x10(%rbp),%rdx
lea    -0x14(%rbp),%rcx
call   1150 <verifierCodeMastermind@plt>
mov    -0x10(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    -0xc(%rbp),%edx
call   10a0 <placerPionCouleurCoteMastermind@plt>
lea    -0x210(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1120 <placerPionMastermind@plt>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
lea    -0x19(%rbp),%rdi
lea    -0x210(%rbp),%rsi
call   1090 <gagnerMastermind@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x211(%rbp)
jne    134f <mastermind+0x11f>
cmpl   $0x0,-0x8(%rbp)
setne  %al
mov    %al,-0x211(%rbp)
mov    -0x211(%rbp),%al
test   $0x1,%al
jne    1290 <mastermind+0x60>
lea    -0x19(%rbp),%rdi
call   1130 <afficherReponseMastermind@plt>
mov    $0x0,%al
call   10c0 <afficherMastermind@plt>
cmpl   $0x0,-0x4(%rbp)
jne    13b3 <mastermind+0x183>
lea    -0x19(%rbp),%rdi
lea    -0x210(%rbp),%rsi
call   1090 <gagnerMastermind@plt>
cmp    $0x0,%rax
je     13a6 <mastermind+0x176>
mov    $0xa,%edi
sub    -0x8(%rbp),%edi
mov    -0x4(%rbp),%esi
call   1140 <victoireMastermindSolo@plt>
jmp    13ae <mastermind+0x17e>
mov    -0x4(%rbp),%edi
call   10e0 <defaiteMastermindSolo@plt>
jmp    1402 <mastermind+0x1d2>
cmpl   $0x1,-0x4(%rbp)
jne    13fd <mastermind+0x1cd>
lea    -0x19(%rbp),%rdi
lea    -0x210(%rbp),%rsi
call   1090 <gagnerMastermind@plt>
cmp    $0x0,%rax
je     13e3 <mastermind+0x1b3>
mov    $0x0,%al
call   10b0 <victoireMastermindMulti@plt>
jmp    13ea <mastermind+0x1ba>
mov    $0x0,%al
call   1070 <defaiteMastermindMulti@plt>
lea    0xc22(%rip),%rdi
call   1100 <appuyezEntree@plt>
mov    $0x0,%al
call   1060 <multi@plt>
jmp    1402 <mastermind+0x1d2>
add    $0x220,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mastermind>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x208,%rsp
mov    %edi,%r12d
call   10d0 <menuMastermind@plt>
xor    %eax,%eax
call   10f0 <initMastermind@plt>
test   %r12d,%r12d
je     1267 <mastermind+0x37>
cmp    $0x1,%r12d
jne    1271 <mastermind+0x41>
lea    0x3(%rsp),%rdi
call   1080 <demanderCodeSecretMastermind@plt>
jmp    1271 <mastermind+0x41>
lea    0x3(%rsp),%rdi
call   1030 <initCodeSecretMastermind@plt>
lea    0x10(%rsp),%rbx
lea    0x3(%rsp),%r13
xor    %r15d,%r15d
xchg   %ax,%ax
lea    0xa(%r15),%ebp
lea    0x9(%r15),%r14d
lea    0xd71(%rip),%rdi
call   1050 <system@plt>
cmp    $0x1,%r12d
jne    12a6 <mastermind+0x76>
lea    0xd90(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   10c0 <afficherMastermind@plt>
movl   $0x0,0x8(%rsp)
movl   $0x0,0xc(%rsp)
mov    %ebp,%edi
mov    %rbx,%rsi
call   1110 <lireCodeMastermind@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
lea    0xc(%rsp),%rdx
lea    0x8(%rsp),%rcx
call   1150 <verifierCodeMastermind@plt>
mov    0xc(%rsp),%edi
mov    0x8(%rsp),%esi
mov    %r14d,%edx
call   10a0 <placerPionCouleurCoteMastermind@plt>
mov    %rbx,%rdi
mov    %r14d,%esi
call   1120 <placerPionMastermind@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
call   1090 <gagnerMastermind@plt>
lea    -0x1(%r15),%ebp
test   %rax,%rax
jne    1318 <mastermind+0xe8>
cmp    $0xfffffff7,%r15d
mov    %ebp,%r15d
jne    1280 <mastermind+0x50>
lea    0x3(%rsp),%rdi
call   1130 <afficherReponseMastermind@plt>
xor    %eax,%eax
call   10c0 <afficherMastermind@plt>
test   %r12d,%r12d
je     1351 <mastermind+0x121>
cmp    $0x1,%r12d
jne    1395 <mastermind+0x165>
lea    0x3(%rsp),%rdi
lea    0x10(%rsp),%rsi
call   1090 <gagnerMastermind@plt>
test   %rax,%rax
je     137b <mastermind+0x14b>
xor    %eax,%eax
call   10b0 <victoireMastermindMulti@plt>
jmp    1382 <mastermind+0x152>
lea    0x3(%rsp),%rdi
lea    0x10(%rsp),%rsi
call   1090 <gagnerMastermind@plt>
test   %rax,%rax
je     1372 <mastermind+0x142>
neg    %ebp
mov    %ebp,%edi
xor    %esi,%esi
call   1140 <victoireMastermindSolo@plt>
jmp    1395 <mastermind+0x165>
xor    %edi,%edi
call   10e0 <defaiteMastermindSolo@plt>
jmp    1395 <mastermind+0x165>
xor    %eax,%eax
call   1070 <defaiteMastermindMulti@plt>
lea    0xc7d(%rip),%rdi
call   1100 <appuyezEntree@plt>
xor    %eax,%eax
call   1060 <multi@plt>
add    $0x208,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"clear\00"
@.str.1 = [13 x i8] c"Joueur 2 :\0A\0A\00"
@.str.2 = [43 x i8] c"Appuyez sur ENTREE pour revenir au menu : \00"
define void @mastermind(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca [5 x i8]
%8 = alloca [500 x i8]
store i32 %0, i32* %2
store i32 10, i32* %3
store i32 9, i32* %4
%9 = load i32, i32* %2
%10 = call i32 @menuMastermind(i32 %9)
%11 = call i32 (...) @initMastermind()
%12 = load i32, i32* %2
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %1
%15 = getelementptr inbounds [5 x i8], [5 x i8]* %7, i64 0, i64 0
%16 = call i32 @initCodeSecretMastermind(i8* %15)
br label %24
17: ; preds = %1
%18 = load i32, i32* %2
%19 = icmp eq i32 %18, 1
br i1 %19, label %20, label %23
20: ; preds = %17
%21 = getelementptr inbounds [5 x i8], [5 x i8]* %7, i64 0, i64 0
%22 = call i32 @demanderCodeSecretMastermind(i8* %21)
br label %23
23: ; preds = %20, %17
br label %24
24: ; preds = %23, %14
br label %25
25: ; preds = %58, %24
%26 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%27 = load i32, i32* %2
%28 = icmp eq i32 %27, 1
br i1 %28, label %29, label %31
29: ; preds = %25
%30 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
br label %31
31: ; preds = %29, %25
%32 = call i32 (...) @afficherMastermind()
store i32 0, i32* %6
store i32 0, i32* %5
%33 = load i32, i32* %3
%34 = getelementptr inbounds [500 x i8], [500 x i8]* %8, i64 0, i64 0
%35 = call i32 @lireCodeMastermind(i32 %33, i8* %34)
%36 = getelementptr inbounds [5 x i8], [5 x i8]* %7, i64 0, i64 0
%37 = getelementptr inbounds [500 x i8], [500 x i8]* %8, i64 0, i64 0
%38 = call i32 @verifierCodeMastermind(i8* %36, i8* %37, i32* %5, i32* %6)
%39 = load i32, i32* %5
%40 = load i32, i32* %6
%41 = load i32, i32* %4
%42 = call i32 @placerPionCouleurCoteMastermind(i32 %39, i32 %40, i32 %41)
%43 = getelementptr inbounds [500 x i8], [500 x i8]* %8, i64 0, i64 0
%44 = load i32, i32* %4
%45 = call i32 @placerPionMastermind(i8* %43, i32 %44)
%46 = load i32, i32* %3
%47 = add nsw i32 %46, -1
store i32 %47, i32* %3
%48 = load i32, i32* %4
%49 = add nsw i32 %48, -1
store i32 %49, i32* %4
br label %50
50: ; preds = %31
%51 = getelementptr inbounds [5 x i8], [5 x i8]* %7, i64 0, i64 0
%52 = getelementptr inbounds [500 x i8], [500 x i8]* %8, i64 0, i64 0
%53 = call i64 @gagnerMastermind(i8* %51, i8* %52)
%54 = icmp ne i64 %53, 0
br i1 %54, label %58, label %55
55: ; preds = %50
%56 = load i32, i32* %3
%57 = icmp ne i32 %56, 0
br label %58
58: ; preds = %55, %50
%59 = phi i1 [ false, %50 ], [ %57, %55 ]
br i1 %59, label %25, label %60
60: ; preds = %58
%61 = getelementptr inbounds [5 x i8], [5 x i8]* %7, i64 0, i64 0
%62 = call i32 @afficherReponseMastermind(i8* %61)
%63 = call i32 (...) @afficherMastermind()
%64 = load i32, i32* %2
%65 = icmp eq i32 %64, 0
br i1 %65, label %66, label %80
66: ; preds = %60
%67 = getelementptr inbounds [5 x i8], [5 x i8]* %7, i64 0, i64 0
%68 = getelementptr inbounds [500 x i8], [500 x i8]* %8, i64 0, i64 0
%69 = call i64 @gagnerMastermind(i8* %67, i8* %68)
%70 = icmp ne i64 %69, 0
br i1 %70, label %71, label %76
71: ; preds = %66
%72 = load i32, i32* %3
%73 = sub nsw i32 10, %72
%74 = load i32, i32* %2
%75 = call i32 @victoireMastermindSolo(i32 %73, i32 %74)
br label %79
76: ; preds = %66
%77 = load i32, i32* %2
%78 = call i32 @defaiteMastermindSolo(i32 %77)
br label %79
79: ; preds = %76, %71
br label %96
80: ; preds = %60
%81 = load i32, i32* %2
%82 = icmp eq i32 %81, 1
br i1 %82, label %83, label %95
83: ; preds = %80
%84 = getelementptr inbounds [5 x i8], [5 x i8]* %7, i64 0, i64 0
%85 = getelementptr inbounds [500 x i8], [500 x i8]* %8, i64 0, i64 0
%86 = call i64 @gagnerMastermind(i8* %84, i8* %85)
%87 = icmp ne i64 %86, 0
br i1 %87, label %88, label %90
88: ; preds = %83
%89 = call i32 (...) @victoireMastermindMulti()
br label %92
90: ; preds = %83
%91 = call i32 (...) @defaiteMastermindMulti()
br label %92
92: ; preds = %90, %88
%93 = call i32 @appuyezEntree(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0))
%94 = call i32 (...) @multi()
br label %95
95: ; preds = %92, %80
br label %96
96: ; preds = %95, %79
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"clear\00"
@.str.2 = [43 x i8] c"Appuyez sur ENTREE pour revenir au menu : \00"
@str = [12 x i8] c"Joueur 2 :\0A\00"
define void @mastermind(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca [5 x i8]
%5 = alloca [500 x i8]
%6 = bitcast i32* %2 to i8*
%7 = bitcast i32* %3 to i8*
%8 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 0
%9 = getelementptr inbounds [500 x i8], [500 x i8]* %5, i64 0, i64 0
%10 = tail call i32 @menuMastermind(i32 %0)
%11 = tail call i32 (...) @initMastermind()
%12 = icmp eq i32 %0, 0
br i1 %12, label %13, label %15
13: ; preds = %1
%14 = call i32 @initCodeSecretMastermind(i8* %8)
br label %19
15: ; preds = %1
%16 = icmp eq i32 %0, 1
br i1 %16, label %17, label %19
17: ; preds = %15
%18 = call i32 @demanderCodeSecretMastermind(i8* %8)
br label %19
19: ; preds = %15, %17, %13
%20 = icmp eq i32 %0, 1
br label %21
21: ; preds = %27, %19
%22 = phi i32 [ 10, %19 ], [ %35, %27 ]
%23 = phi i32 [ 9, %19 ], [ %36, %27 ]
%24 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br i1 %20, label %25, label %27
25: ; preds = %21
%26 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
br label %27
27: ; preds = %25, %21
%28 = call i32 (...) @afficherMastermind()
store i32 0, i32* %3
store i32 0, i32* %2
%29 = call i32 @lireCodeMastermind(i32 %22, i8* %9)
%30 = call i32 @verifierCodeMastermind(i8* %8, i8* %9, i32* %2, i32* %3)
%31 = load i32, i32* %2
%32 = load i32, i32* %3
%33 = call i32 @placerPionCouleurCoteMastermind(i32 %31, i32 %32, i32 %23)
%34 = call i32 @placerPionMastermind(i8* %9, i32 %23)
%35 = add nsw i32 %22, -1
%36 = add nsw i32 %23, -1
%37 = call i64 @gagnerMastermind(i8* %8, i8* %9)
%38 = icmp eq i64 %37, 0
%39 = icmp ne i32 %35, 0
%40 = select i1 %38, i1 %39, i1 false
br i1 %40, label %21, label %41
41: ; preds = %27
%42 = call i32 @afficherReponseMastermind(i8* %8)
%43 = call i32 (...) @afficherMastermind()
br i1 %12, label %44, label %52
44: ; preds = %41
%45 = call i64 @gagnerMastermind(i8* %8, i8* %9)
%46 = icmp eq i64 %45, 0
br i1 %46, label %50, label %47
47: ; preds = %44
%48 = sub i32 11, %22
%49 = call i32 @victoireMastermindSolo(i32 %48, i32 0)
br label %63
50: ; preds = %44
%51 = call i32 @defaiteMastermindSolo(i32 0)
br label %63
52: ; preds = %41
br i1 %20, label %53, label %63
53: ; preds = %52
%54 = call i64 @gagnerMastermind(i8* %8, i8* %9)
%55 = icmp eq i64 %54, 0
br i1 %55, label %58, label %56
56: ; preds = %53
%57 = call i32 (...) @victoireMastermindMulti()
br label %60
58: ; preds = %53
%59 = call i32 (...) @defaiteMastermindMulti()
br label %60
60: ; preds = %58, %56
%61 = call i32 @appuyezEntree(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0))
%62 = call i32 (...) @multi()
br label %63
63: ; preds = %52, %60, %47, %50
ret void
}