#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__ gagne(int *);
char lireCaractere();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ rechercheLettre(char, char *, int *);
int main(int argc, char *argv[]) {
  int coups = 10;
  char lettre = 0;
  char chaine[] = "ROUGE";
  int i = 0;
  int tableauGagne[5] = {0};
  printf("Bienvenu dans le pendu !\n\n");
  while (coups > 0 && !gagne(tableauGagne)) {
    printf("\n\nIl vous reste %d coups a jouer", coups);
    printf("\nQuel est le mot secret ? ");
    for (i = 0; i < 5; i++) {
      if (tableauGagne[i])
        printf("%c", chaine[i]);
      else
        printf("*");
    }
    printf("\nProposez une lettre : ");
    lettre = lireCaractere();
    if (!rechercheLettre(lettre, chaine, tableauGagne)) {
      coups--;
    }
  }
  if (gagne(tableauGagne))
    printf("\n\nGagne ! Le mot secret etait bien : %s", chaine);
  else
    printf("\n\nPerdu ! Le mot secret etait : %s", chaine);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0xa,-0x14(%rbp)
movb   $0x0,-0x15(%rbp)
mov    0xe89(%rip),%eax
mov    %eax,-0x1b(%rbp)
mov    0xe83(%rip),%ax
mov    %ax,-0x17(%rbp)
movl   $0x0,-0x20(%rbp)
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x14,%edx
call   1040 <memset@plt>
lea    0xe63(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
cmpl   $0x0,-0x14(%rbp)
mov    %al,-0x41(%rbp)
jle    11ce <main+0x7e>
lea    -0x40(%rbp),%rdi
call   1050 <gagne@plt>
cmp    $0x0,%rax
setne  %al
xor    $0xff,%al
mov    %al,-0x41(%rbp)
mov    -0x41(%rbp),%al
test   $0x1,%al
jne    11de <main+0x8e>
jmp    129c <main+0x14c>
mov    -0x14(%rbp),%esi
lea    0xe39(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe4c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x20(%rbp)
cmpl   $0x5,-0x20(%rbp)
jge    125a <main+0x10a>
movslq -0x20(%rbp),%rax
cmpl   $0x0,-0x40(%rbp,%rax,4)
je     1239 <main+0xe9>
movslq -0x20(%rbp),%rax
movsbl -0x1b(%rbp,%rax,1),%esi
lea    0xe30(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1247 <main+0xf7>
lea    0xe20(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    124c <main+0xfc>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1204 <main+0xb4>
lea    0xe01(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1060 <lireCaractere@plt>
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
lea    -0x1b(%rbp),%rsi
lea    -0x40(%rbp),%rdx
movsbl %al,%edi
call   1070 <rechercheLettre@plt>
cmp    $0x0,%eax
jne    1297 <main+0x147>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    11aa <main+0x5a>
lea    -0x40(%rbp),%rdi
call   1050 <gagne@plt>
cmp    $0x0,%rax
je     12c6 <main+0x176>
lea    -0x1b(%rbp),%rsi
lea    0xdc0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12d8 <main+0x188>
lea    -0x1b(%rbp),%rsi
lea    0xdd1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
movw   $0x45,0xc(%rsp)
movl   $0x47554f52,0x8(%rsp)
47
xorps  %xmm0,%xmm0
movaps %xmm0,0x10(%rsp)
movl   $0x0,0x20(%rsp)
lea    0xf11(%rip),%rdi
call   1040 <puts@plt>
mov    $0xa,%ebx
lea    0x10(%rsp),%r14
lea    0xe7d(%rip),%r12
mov    $0x2a,%r15d
lea    0xe8b(%rip),%r13
lea    0x8(%rsp),%rbp
nopl   0x0(%rax)
mov    %r14,%rdi
call   1060 <gagne@plt>
test   %rax,%rax
jne    1278 <main+0x118>
lea    0xe2e(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r12,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
cmpl   $0x0,0x10(%rsp)
movsbl 0x8(%rsp),%edi
cmove  %r15d,%edi
call   1030 <putchar@plt>
cmpl   $0x0,0x14(%rsp)
movsbl 0x9(%rsp),%edi
cmove  %r15d,%edi
call   1030 <putchar@plt>
cmpl   $0x0,0x18(%rsp)
movsbl 0xa(%rsp),%edi
cmove  %r15d,%edi
call   1030 <putchar@plt>
cmpl   $0x0,0x1c(%rsp)
movsbl 0xb(%rsp),%edi
cmove  %r15d,%edi
call   1030 <putchar@plt>
cmpl   $0x0,0x20(%rsp)
movsbl 0xc(%rsp),%edi
cmove  %r15d,%edi
call   1030 <putchar@plt>
mov    %r13,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1070 <lireCaractere@plt>
movsbl %al,%edi
mov    %rbp,%rsi
mov    %r14,%rdx
call   1080 <rechercheLettre@plt>
xor    %ecx,%ecx
test   %eax,%eax
sete   %cl
sub    %ecx,%ebx
jne    11c0 <main+0x60>
lea    0x10(%rsp),%rdi
call   1060 <gagne@plt>
test   %rax,%rax
lea    0xdf6(%rip),%rax
lea    0xdc7(%rip),%rdi
cmove  %rax,%rdi
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.chaine = [6 x i8] c"ROUGE\00"
@.str = [27 x i8] c"Bienvenu dans le pendu !\0A\0A\00"
@.str.1 = [33 x i8] c"\0A\0AIl vous reste %d coups a jouer\00"
@.str.2 = [27 x i8] c"\0AQuel est le mot secret ? \00"
@.str.3 = [3 x i8] c"%c\00"
@.str.4 = [2 x i8] c"*\00"
@.str.5 = [24 x i8] c"\0AProposez une lettre : \00"
@.str.6 = [40 x i8] c"\0A\0AGagne ! Le mot secret etait bien : %s\00"
@.str.7 = [35 x i8] c"\0A\0APerdu ! Le mot secret etait : %s\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8
%8 = alloca [6 x i8]
%9 = alloca i32
%10 = alloca [5 x i32]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 10, i32* %6
store i8 0, i8* %7
%11 = bitcast [6 x i8]* %8 to i8*
store i32 0, i32* %9
%12 = bitcast [5 x i32]* %10 to i8*
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
br label %14
14: ; preds = %61, %2
%15 = load i32, i32* %6
%16 = icmp sgt i32 %15, 0
br i1 %16, label %17, label %22
17: ; preds = %14
%18 = getelementptr inbounds [5 x i32], [5 x i32]* %10, i64 0, i64 0
%19 = call i64 @gagne(i32* %18)
%20 = icmp ne i64 %19, 0
%21 = xor i1 %20, true
br label %22
22: ; preds = %17, %14
%23 = phi i1 [ false, %14 ], [ %21, %17 ]
br i1 %23, label %24, label %62
24: ; preds = %22
%25 = load i32, i32* %6
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i32 %25)
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %9
br label %28
28: ; preds = %47, %24
%29 = load i32, i32* %9
%30 = icmp slt i32 %29, 5
br i1 %30, label %31, label %50
31: ; preds = %28
%32 = load i32, i32* %9
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [5 x i32], [5 x i32]* %10, i64 0, i64 %33
%35 = load i32, i32* %34
%36 = icmp ne i32 %35, 0
br i1 %36, label %37, label %44
37: ; preds = %31
%38 = load i32, i32* %9
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds [6 x i8], [6 x i8]* %8, i64 0, i64 %39
%41 = load i8, i8* %40
%42 = sext i8 %41 to i32
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %42)
br label %46
44: ; preds = %31
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %46
46: ; preds = %44, %37
br label %47
47: ; preds = %46
%48 = load i32, i32* %9
%49 = add nsw i32 %48, 1
store i32 %49, i32* %9
br label %28
50: ; preds = %28
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0))
%52 = call signext i8 (...) @lireCaractere()
store i8 %52, i8* %7
%53 = load i8, i8* %7
%54 = getelementptr inbounds [6 x i8], [6 x i8]* %8, i64 0, i64 0
%55 = getelementptr inbounds [5 x i32], [5 x i32]* %10, i64 0, i64 0
%56 = call i32 @rechercheLettre(i8 signext %53, i8* %54, i32* %55)
%57 = icmp ne i32 %56, 0
br i1 %57, label %61, label %58
58: ; preds = %50
%59 = load i32, i32* %6
%60 = add nsw i32 %59, -1
store i32 %60, i32* %6
br label %61
61: ; preds = %58, %50
br label %14
62: ; preds = %22
%63 = getelementptr inbounds [5 x i32], [5 x i32]* %10, i64 0, i64 0
%64 = call i64 @gagne(i32* %63)
%65 = icmp ne i64 %64, 0
br i1 %65, label %66, label %69
66: ; preds = %62
%67 = getelementptr inbounds [6 x i8], [6 x i8]* %8, i64 0, i64 0
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.6, i64 0, i64 0), i8* %67)
br label %72
69: ; preds = %62
%70 = getelementptr inbounds [6 x i8], [6 x i8]* %8, i64 0, i64 0
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.7, i64 0, i64 0), i8* %70)
br label %72
72: ; preds = %69, %66
ret i32 0
}

LLVM IR (-O2):
@__const.main.chaine = [6 x i8] c"ROUGE\00"
@.str.1 = [33 x i8] c"\0A\0AIl vous reste %d coups a jouer\00"
@.str.2 = [27 x i8] c"\0AQuel est le mot secret ? \00"
@.str.5 = [24 x i8] c"\0AProposez une lettre : \00"
@.str.6 = [40 x i8] c"\0A\0AGagne ! Le mot secret etait bien : %s\00"
@.str.7 = [35 x i8] c"\0A\0APerdu ! Le mot secret etait : %s\00"
@str = [26 x i8] c"Bienvenu dans le pendu !\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [6 x i8]
%4 = alloca [5 x i32]
%5 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 0
%6 = bitcast [5 x i32]* %4 to i8*
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
%8 = getelementptr inbounds [5 x i32], [5 x i32]* %4, i64 0, i64 0
%9 = getelementptr inbounds [5 x i32], [5 x i32]* %4, i64 0, i64 1
%10 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 1
%11 = getelementptr inbounds [5 x i32], [5 x i32]* %4, i64 0, i64 2
%12 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 2
%13 = getelementptr inbounds [5 x i32], [5 x i32]* %4, i64 0, i64 3
%14 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 3
%15 = getelementptr inbounds [5 x i32], [5 x i32]* %4, i64 0, i64 4
%16 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 4
br label %17
17: ; preds = %2, %21
%18 = phi i32 [ 10, %2 ], [ %59, %21 ]
%19 = call i64 @gagne(i32* %8)
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %61
21: ; preds = %17
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i32 %18)
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
%24 = load i32, i32* %8
%25 = icmp eq i32 %24, 0
%26 = load i8, i8* %5
%27 = sext i8 %26 to i32
%28 = select i1 %25, i32 42, i32 %27
%29 = call i32 @putchar(i32 %28)
%30 = load i32, i32* %9
%31 = icmp eq i32 %30, 0
%32 = load i8, i8* %10
%33 = sext i8 %32 to i32
%34 = select i1 %31, i32 42, i32 %33
%35 = call i32 @putchar(i32 %34)
%36 = load i32, i32* %11
%37 = icmp eq i32 %36, 0
%38 = load i8, i8* %12
%39 = sext i8 %38 to i32
%40 = select i1 %37, i32 42, i32 %39
%41 = call i32 @putchar(i32 %40)
%42 = load i32, i32* %13
%43 = icmp eq i32 %42, 0
%44 = load i8, i8* %14
%45 = sext i8 %44 to i32
%46 = select i1 %43, i32 42, i32 %45
%47 = call i32 @putchar(i32 %46)
%48 = load i32, i32* %15
%49 = icmp eq i32 %48, 0
%50 = load i8, i8* %16
%51 = sext i8 %50 to i32
%52 = select i1 %49, i32 42, i32 %51
%53 = call i32 @putchar(i32 %52)
%54 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0))
%55 = call signext i8 (...) @lireCaractere()
%56 = call i32 @rechercheLettre(i8 signext %55, i8* %5, i32* %8)
%57 = icmp eq i32 %56, 0
%58 = sext i1 %57 to i32
%59 = add nsw i32 %18, %58
%60 = icmp eq i32 %59, 0
br i1 %60, label %61, label %17
61: ; preds = %21, %17
%62 = call i64 @gagne(i32* %8)
%63 = icmp eq i64 %62, 0
%64 = select i1 %63, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.6, i64 0, i64 0)
%65 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %64, i8* %5)
ret i32 0
}