#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[]) {
  char lettre = 0;
  char motSecret[] = "MARRON";
  int lettreTrouvee[6] = {0};
  int coupsRestants = 10;
  int i = 0;
  printf("Bienvenue dans le Pendu !\n\n");
  while (coupsRestants > 0 && !gagne(lettreTrouvee)) {
    printf("\n\nIl vous reste %d coups a jouer", coupsRestants);
    printf("\nQuel est le mot secret ? ");
    for (i = 0; i < 6; i++) {
      if (lettreTrouvee[i])
        printf("%c", motSecret[i]);
      else
        printf("*");
    }
    printf("\nProposez une lettre : ");
    lettre = lireCaractere();
    if (!rechercheLettre(lettre, motSecret, lettreTrouvee)) {
      coupsRestants--;
    }
  }
  if (gagne(lettreTrouvee))
    printf("\n\nGagne ! Le mot secret etait bien : %s", motSecret);
  else
    printf("\n\nPerdu ! Le mot secret etait : %s", motSecret);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movb   $0x0,-0x11(%rbp)
mov    0xe90(%rip),%eax
mov    %eax,-0x18(%rbp)
mov    0xe8a(%rip),%ax
mov    %ax,-0x14(%rbp)
mov    0xe82(%rip),%al
mov    %al,-0x12(%rbp)
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1040 <memset@plt>
movl   $0xa,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
lea    0xe5b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
cmpl   $0x0,-0x34(%rbp)
mov    %al,-0x39(%rbp)
jle    11d7 <main+0x87>
lea    -0x30(%rbp),%rdi
call   1050 <gagne@plt>
cmp    $0x0,%rax
setne  %al
xor    $0xff,%al
mov    %al,-0x39(%rbp)
mov    -0x39(%rbp),%al
test   $0x1,%al
jne    11e7 <main+0x97>
jmp    12a5 <main+0x155>
mov    -0x34(%rbp),%esi
lea    0xe32(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe45(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x38(%rbp)
cmpl   $0x6,-0x38(%rbp)
jge    1263 <main+0x113>
movslq -0x38(%rbp),%rax
cmpl   $0x0,-0x30(%rbp,%rax,4)
je     1242 <main+0xf2>
movslq -0x38(%rbp),%rax
movsbl -0x18(%rbp,%rax,1),%esi
lea    0xe29(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1250 <main+0x100>
lea    0xe19(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1255 <main+0x105>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    120d <main+0xbd>
lea    0xdfa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1060 <lireCaractere@plt>
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
lea    -0x18(%rbp),%rsi
lea    -0x30(%rbp),%rdx
movsbl %al,%edi
call   1070 <rechercheLettre@plt>
cmp    $0x0,%eax
jne    12a0 <main+0x150>
mov    -0x34(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x34(%rbp)
jmp    11b3 <main+0x63>
lea    -0x30(%rbp),%rdi
call   1050 <gagne@plt>
cmp    $0x0,%rax
je     12cf <main+0x17f>
lea    -0x18(%rbp),%rsi
lea    0xdb9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12e1 <main+0x191>
lea    -0x18(%rbp),%rsi
lea    0xdca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
movl   $0x4e4f52,0xb(%rsp)
movl   $0x5252414d,0x8(%rsp)
52
xorps  %xmm0,%xmm0
movaps %xmm0,0x10(%rsp)
movq   $0x0,0x20(%rsp)
lea    0xf10(%rip),%rdi
call   1040 <puts@plt>
mov    $0xa,%ebx
lea    0x10(%rsp),%r14
lea    0xe7c(%rip),%r12
mov    $0x2a,%r15d
lea    0xe8a(%rip),%r13
lea    0x8(%rsp),%rbp
xchg   %ax,%ax
mov    %r14,%rdi
call   1060 <gagne@plt>
test   %rax,%rax
jne    128b <main+0x12b>
lea    0xe2f(%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>
cmpl   $0x0,0x24(%rsp)
movsbl 0xd(%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    0xde4(%rip),%rax
lea    0xdb5(%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.motSecret = [7 x i8] c"MARRON\00"
@.str = [28 x i8] c"Bienvenue 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 i8
%7 = alloca [7 x i8]
%8 = alloca [6 x i32]
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8 0, i8* %6
%11 = bitcast [7 x i8]* %7 to i8*
%12 = bitcast [6 x i32]* %8 to i8*
store i32 10, i32* %9
store i32 0, i32* %10
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
br label %14
14: ; preds = %61, %2
%15 = load i32, i32* %9
%16 = icmp sgt i32 %15, 0
br i1 %16, label %17, label %22
17: ; preds = %14
%18 = getelementptr inbounds [6 x i32], [6 x i32]* %8, 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* %9
%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* %10
br label %28
28: ; preds = %47, %24
%29 = load i32, i32* %10
%30 = icmp slt i32 %29, 6
br i1 %30, label %31, label %50
31: ; preds = %28
%32 = load i32, i32* %10
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [6 x i32], [6 x i32]* %8, 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* %10
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds [7 x i8], [7 x i8]* %7, 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* %10
%49 = add nsw i32 %48, 1
store i32 %49, i32* %10
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* %6
%53 = load i8, i8* %6
%54 = getelementptr inbounds [7 x i8], [7 x i8]* %7, i64 0, i64 0
%55 = getelementptr inbounds [6 x i32], [6 x i32]* %8, 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* %9
%60 = add nsw i32 %59, -1
store i32 %60, i32* %9
br label %61
61: ; preds = %58, %50
br label %14
62: ; preds = %22
%63 = getelementptr inbounds [6 x i32], [6 x i32]* %8, 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 [7 x i8], [7 x i8]* %7, 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 [7 x i8], [7 x i8]* %7, 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.motSecret = [7 x i8] c"MARRON\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 = [27 x i8] c"Bienvenue dans le Pendu !\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [7 x i8]
%4 = alloca [6 x i32]
%5 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 0
%6 = bitcast [6 x i32]* %4 to i8*
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
%8 = getelementptr inbounds [6 x i32], [6 x i32]* %4, i64 0, i64 0
%9 = getelementptr inbounds [6 x i32], [6 x i32]* %4, i64 0, i64 1
%10 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 1
%11 = getelementptr inbounds [6 x i32], [6 x i32]* %4, i64 0, i64 2
%12 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 2
%13 = getelementptr inbounds [6 x i32], [6 x i32]* %4, i64 0, i64 3
%14 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 3
%15 = getelementptr inbounds [6 x i32], [6 x i32]* %4, i64 0, i64 4
%16 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 4
%17 = getelementptr inbounds [6 x i32], [6 x i32]* %4, i64 0, i64 5
%18 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 5
br label %19
19: ; preds = %2, %23
%20 = phi i32 [ 10, %2 ], [ %67, %23 ]
%21 = call i64 @gagne(i32* %8)
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %69
23: ; preds = %19
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i32 %20)
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
%26 = load i32, i32* %8
%27 = icmp eq i32 %26, 0
%28 = load i8, i8* %5
%29 = sext i8 %28 to i32
%30 = select i1 %27, i32 42, i32 %29
%31 = call i32 @putchar(i32 %30)
%32 = load i32, i32* %9
%33 = icmp eq i32 %32, 0
%34 = load i8, i8* %10
%35 = sext i8 %34 to i32
%36 = select i1 %33, i32 42, i32 %35
%37 = call i32 @putchar(i32 %36)
%38 = load i32, i32* %11
%39 = icmp eq i32 %38, 0
%40 = load i8, i8* %12
%41 = sext i8 %40 to i32
%42 = select i1 %39, i32 42, i32 %41
%43 = call i32 @putchar(i32 %42)
%44 = load i32, i32* %13
%45 = icmp eq i32 %44, 0
%46 = load i8, i8* %14
%47 = sext i8 %46 to i32
%48 = select i1 %45, i32 42, i32 %47
%49 = call i32 @putchar(i32 %48)
%50 = load i32, i32* %15
%51 = icmp eq i32 %50, 0
%52 = load i8, i8* %16
%53 = sext i8 %52 to i32
%54 = select i1 %51, i32 42, i32 %53
%55 = call i32 @putchar(i32 %54)
%56 = load i32, i32* %17
%57 = icmp eq i32 %56, 0
%58 = load i8, i8* %18
%59 = sext i8 %58 to i32
%60 = select i1 %57, i32 42, i32 %59
%61 = call i32 @putchar(i32 %60)
%62 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0))
%63 = call signext i8 (...) @lireCaractere()
%64 = call i32 @rechercheLettre(i8 signext %63, i8* %5, i32* %8)
%65 = icmp eq i32 %64, 0
%66 = sext i1 %65 to i32
%67 = add nsw i32 %20, %66
%68 = icmp eq i32 %67, 0
br i1 %68, label %69, label %19
69: ; preds = %23, %19
%70 = call i64 @gagne(i32* %8)
%71 = icmp eq i64 %70, 0
%72 = select i1 %71, 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)
%73 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %72, i8* %5)
ret i32 0
}