#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*/ printf(char *, ...);
char readchar(char);
void dialog(char word[]) {
  char hidden_word[] = "*******";
  int lives = 10;
  char letter = 0;
  int change = 0;
  int i, check;
  printf("\n");
  while (check && lives) {
    check = 0;
    printf("The word is :  %s  (%d lives)\n", hidden_word, lives);
    letter = readchar(letter);
    for (i = 0; i < 7; i++) {
      if (word[i] == letter) {
        hidden_word[i] = word[i];
        change++;
      }
      if (word[i] != hidden_word[i])
        check++;
    }
    lives = (change) ? lives : (lives - 1);
    change = 0;
  }
  if (lives)
    printf("Congratulations !\nThe word was \"%s\"\n", hidden_word);
  else
    printf("\nYou failed\n");
}


x86 assembly (clang, -O0):
<dialog>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    0xecd(%rip),%rax
mov    %rax,-0x10(%rbp)
movl   $0xa,-0x14(%rbp)
movb   $0x0,-0x15(%rbp)
movl   $0x0,-0x1c(%rbp)
lea    0xefa(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
cmpl   $0x0,-0x24(%rbp)
mov    %al,-0x25(%rbp)
je     1170 <dialog+0x50>
cmpl   $0x0,-0x14(%rbp)
setne  %al
mov    %al,-0x25(%rbp)
mov    -0x25(%rbp),%al
test   $0x1,%al
jne    1180 <dialog+0x60>
jmp    1256 <dialog+0x136>
movl   $0x0,-0x24(%rbp)
lea    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movsbl -0x15(%rbp),%edi
call   1030 <readchar@plt>
mov    %al,-0x15(%rbp)
movl   $0x0,-0x20(%rbp)
cmpl   $0x7,-0x20(%rbp)
jge    1226 <dialog+0x106>
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
movsbl -0x15(%rbp),%ecx
cmp    %ecx,%eax
jne    11ed <dialog+0xcd>
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,1),%cl
movslq -0x20(%rbp),%rax
mov    %cl,-0x10(%rbp,%rax,1)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
movslq -0x20(%rbp),%rcx
movsbl -0x10(%rbp,%rcx,1),%ecx
cmp    %ecx,%eax
je     1213 <dialog+0xf3>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1218 <dialog+0xf8>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11af <dialog+0x8f>
cmpl   $0x0,-0x1c(%rbp)
je     123b <dialog+0x11b>
mov    -0x14(%rbp),%eax
mov    %eax,-0x2c(%rbp)
jmp    1244 <dialog+0x124>
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x1c(%rbp)
jmp    1157 <dialog+0x37>
cmpl   $0x0,-0x14(%rbp)
je     1277 <dialog+0x157>
lea    -0x10(%rbp),%rsi
lea    0xdbc(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1285 <dialog+0x165>
lea    0xdce(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dialog>:
push   %rax
movabs $0x2a2a2a2a2a2a2a,%rax
mov    %rax,(%rsp)
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xec0(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
pop    %rax
ret

LLVM IR (-O0):
@__const.dialog.hidden_word = [8 x i8] c"*******\00"
@.str = [2 x i8] c"\0A\00"
@.str.1 = [31 x i8] c"The word is : %s (%d lives)\0A\00"
@.str.2 = [37 x i8] c"Congratulations !\0AThe word was \22%s\22\0A\00"
@.str.3 = [13 x i8] c"\0AYou failed\0A\00"
define void @dialog(i8* %0) {
%2 = alloca i8*
%3 = alloca [8 x i8]
%4 = alloca i32
%5 = alloca i8
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %2
%9 = bitcast [8 x i8]* %3 to i8*
store i32 10, i32* %4
store i8 0, i8* %5
store i32 0, i32* %6
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %11
11: ; preds = %77, %1
%12 = load i32, i32* %8
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %11
%15 = load i32, i32* %4
%16 = icmp ne i32 %15, 0
br label %17
17: ; preds = %14, %11
%18 = phi i1 [ false, %11 ], [ %16, %14 ]
br i1 %18, label %19, label %79
19: ; preds = %17
store i32 0, i32* %8
%20 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 0
%21 = load i32, i32* %4
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i8* %20, i32 %21)
%23 = load i8, i8* %5
%24 = call signext i8 @readchar(i8 signext %23)
store i8 %24, i8* %5
store i32 0, i32* %7
br label %25
25: ; preds = %66, %19
%26 = load i32, i32* %7
%27 = icmp slt i32 %26, 7
br i1 %27, label %28, label %69
28: ; preds = %25
%29 = load i8*, i8** %2
%30 = load i32, i32* %7
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %29, i64 %31
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
%35 = load i8, i8* %5
%36 = sext i8 %35 to i32
%37 = icmp eq i32 %34, %36
br i1 %37, label %38, label %49
38: ; preds = %28
%39 = load i8*, i8** %2
%40 = load i32, i32* %7
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i8, i8* %39, i64 %41
%43 = load i8, i8* %42
%44 = load i32, i32* %7
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 %45
store i8 %43, i8* %46
%47 = load i32, i32* %6
%48 = add nsw i32 %47, 1
store i32 %48, i32* %6
br label %49
49: ; preds = %38, %28
%50 = load i8*, i8** %2
%51 = load i32, i32* %7
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds i8, i8* %50, i64 %52
%54 = load i8, i8* %53
%55 = sext i8 %54 to i32
%56 = load i32, i32* %7
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 %57
%59 = load i8, i8* %58
%60 = sext i8 %59 to i32
%61 = icmp ne i32 %55, %60
br i1 %61, label %62, label %65
62: ; preds = %49
%63 = load i32, i32* %8
%64 = add nsw i32 %63, 1
store i32 %64, i32* %8
br label %65
65: ; preds = %62, %49
br label %66
66: ; preds = %65
%67 = load i32, i32* %7
%68 = add nsw i32 %67, 1
store i32 %68, i32* %7
br label %25
69: ; preds = %25
%70 = load i32, i32* %6
%71 = icmp ne i32 %70, 0
br i1 %71, label %72, label %74
72: ; preds = %69
%73 = load i32, i32* %4
br label %77
74: ; preds = %69
%75 = load i32, i32* %4
%76 = sub nsw i32 %75, 1
br label %77
77: ; preds = %74, %72
%78 = phi i32 [ %73, %72 ], [ %76, %74 ]
store i32 %78, i32* %4
store i32 0, i32* %6
br label %11
79: ; preds = %17
%80 = load i32, i32* %4
%81 = icmp ne i32 %80, 0
br i1 %81, label %82, label %85
82: ; preds = %79
%83 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 0
%84 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i8* %83)
br label %87
85: ; preds = %79
%86 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
br label %87
87: ; preds = %85, %82
ret void
}

LLVM IR (-O2):
@.str.2 = [37 x i8] c"Congratulations !\0AThe word was \22%s\22\0A\00"
define void @dialog(i8* nocapture %0) {
%2 = alloca i64
%3 = bitcast i64* %2 to i8*
store i64 11868309606246954, i64* %2
%4 = tail call i32 @putchar(i32 10)
%5 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i64* %2)
ret void
}