#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*/ LC_ALL;
int /*<<< orphan*/ exibir_boneco(unsigned int);
int /*<<< orphan*/ exibir_mascara(char *);
int /*<<< orphan*/ exibir_resultado(int);
scalar_t__ existe_letra_na_palavra(char, char *);
int /*<<< orphan*/ free(char *);
char *init_mascara(int /*<<< orphan*/);
char *init_palavra(char *);
int /*<<< orphan*/ limpar_tela();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, char *);
int /*<<< orphan*/ setlocale(int /*<<< orphan*/, char *);
int /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ strlen(char *);
int /*<<< orphan*/ substituir_letra_na_mascara(char, char *, char *);
char toupper(char);
int main(int argc, char *argv[]) {
  setlocale(LC_ALL, "PORTUGUESE");
  char *palavra;
  char *mascara;
  char letra;
  unsigned int quantidade_erros = 0;
  bool ganhou = false;
  palavra = init_palavra(argv[1]);
  mascara = init_mascara(strlen(palavra));
  do {
    limpar_tela();
    exibir_boneco(quantidade_erros);
    printf("\n");
    exibir_mascara(mascara);
    printf("\n");
    printf("Digite uma letra:");
    scanf(" %c", &letra);
    letra = toupper(letra);
    if (existe_letra_na_palavra(letra, palavra)) {
      substituir_letra_na_mascara(letra, mascara, palavra);
    } else {
      quantidade_erros++;
    }
    if (!strcmp(palavra, mascara)) {
      ganhou = true;
    }
  } while (quantidade_erros < 6 && ganhou == false);
  limpar_tela();
  exibir_boneco(quantidade_erros);
  printf("\n");
  exibir_mascara(mascara);
  printf("\n");
  exibir_resultado(ganhou);
  free(palavra);
  free(mascara);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2dd3(%rip),%rax
mov    (%rax),%edi
lea    0xdea(%rip),%rsi
call   10d0 <setlocale@plt>
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1080 <init_palavra@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,%edi
call   1110 <init_mascara@plt>
mov    %rax,-0x20(%rbp)
mov    $0x0,%al
call   10b0 <limpar_tela@plt>
mov    -0x28(%rbp),%edi
call   1030 <exibir_boneco@plt>
lea    0xda7(%rip),%rdi
call   1070 <printf@plt>
mov    -0x20(%rbp),%rdi
call   10c0 <exibir_mascara@plt>
lea    0xd92(%rip),%rdi
call   1070 <printf@plt>
lea    0xd88(%rip),%rdi
call   1070 <printf@plt>
lea    0xd8e(%rip),%rdi
lea    -0x21(%rbp),%rsi
call   10e0 <scanf@plt>
movsbl -0x21(%rbp),%edi
call   1050 <toupper@plt>
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
mov    -0x18(%rbp),%rsi
movsbl %al,%edi
call   10f0 <existe_letra_na_palavra@plt>
cmp    $0x0,%rax
je     12d7 <main+0xe7>
mov    -0x21(%rbp),%al
mov    -0x20(%rbp),%rsi
mov    -0x18(%rbp),%rdx
movsbl %al,%edi
call   10a0 <substituir_letra_na_mascara@plt>
jmp    12e0 <main+0xf0>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%eax
jne    12fd <main+0x10d>
movl   $0x1,-0x2c(%rbp)
jmp    1302 <main+0x112>
xor    %eax,%eax
cmpl   $0x6,-0x28(%rbp)
mov    %al,-0x2d(%rbp)
jae    131b <main+0x12b>
cmpl   $0x0,-0x2c(%rbp)
sete   %al
mov    %al,-0x2d(%rbp)
mov    -0x2d(%rbp),%al
test   $0x1,%al
jne    124e <main+0x5e>
mov    $0x0,%al
call   10b0 <limpar_tela@plt>
mov    -0x28(%rbp),%edi
call   1030 <exibir_boneco@plt>
lea    0xccf(%rip),%rdi
call   1070 <printf@plt>
mov    -0x20(%rbp),%rdi
call   10c0 <exibir_mascara@plt>
lea    0xcba(%rip),%rdi
call   1070 <printf@plt>
mov    -0x2c(%rbp),%edi
call   1100 <exibir_resultado@plt>
mov    -0x18(%rbp),%rdi
call   1040 <free@plt>
mov    -0x20(%rbp),%rdi
call   1040 <free@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    0x2dcb(%rip),%rax
mov    (%rax),%edi
lea    0xde2(%rip),%rsi
call   10e0 <setlocale@plt>
mov    0x8(%rbx),%rdi
call   1090 <init_palavra@plt>
mov    %rax,%r14
mov    %rax,%rdi
call   1070 <strlen@plt>
mov    %eax,%edi
call   1120 <init_mascara@plt>
mov    %rax,%rbx
lea    0xdc3(%rip),%r15
lea    0xdce(%rip),%r12
lea    0x7(%rsp),%r13
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
call   10c0 <limpar_tela@plt>
mov    %ebp,%edi
call   1030 <exibir_boneco@plt>
mov    $0xa,%edi
call   1050 <putchar@plt>
mov    %rbx,%rdi
call   10d0 <exibir_mascara@plt>
mov    $0xa,%edi
call   1050 <putchar@plt>
mov    %r15,%rdi
call   1080 <printf@plt>
mov    %r12,%rdi
mov    %r13,%rsi
call   10f0 <scanf@plt>
movsbl 0x7(%rsp),%edi
call   1060 <toupper@plt>
mov    %al,0x7(%rsp)
movsbl %al,%edi
mov    %r14,%rsi
call   1100 <existe_letra_na_palavra@plt>
test   %rax,%rax
je     12d0 <main+0xd0>
movsbl 0x7(%rsp),%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   10b0 <substituir_letra_na_mascara@plt>
jmp    12d3 <main+0xd3>
nopl   (%rax)
add    $0x1,%ebp
mov    %r14,%rdi
mov    %rbx,%rsi
call   10a0 <strcmp@plt>
cmp    $0x5,%ebp
ja     12eb <main+0xeb>
test   %eax,%eax
jne    1260 <main+0x60>
xor    %r15d,%r15d
test   %eax,%eax
sete   %r15b
xor    %eax,%eax
call   10c0 <limpar_tela@plt>
mov    %ebp,%edi
call   1030 <exibir_boneco@plt>
mov    $0xa,%edi
call   1050 <putchar@plt>
mov    %rbx,%rdi
call   10d0 <exibir_mascara@plt>
mov    $0xa,%edi
call   1050 <putchar@plt>
mov    %r15d,%edi
call   1110 <exibir_resultado@plt>
mov    %r14,%rdi
call   1040 <free@plt>
mov    %rbx,%rdi
call   1040 <free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@LC_ALL = global i32 0
@.str = [11 x i8] c"PORTUGUESE\00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [18 x i8] c"Digite uma letra:\00"
@.str.3 = [4 x i8] c" %c\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* @LC_ALL
%12 = call i32 @setlocale(i32 %11, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %9
store i32 0, i32* %10
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call i8* @init_palavra(i8* %15)
store i8* %16, i8** %6
%17 = load i8*, i8** %6
%18 = call i32 @strlen(i8* %17)
%19 = call i8* @init_mascara(i32 %18)
store i8* %19, i8** %7
br label %20
20: ; preds = %57, %2
%21 = call i32 (...) @limpar_tela()
%22 = load i32, i32* %9
%23 = call i32 @exibir_boneco(i32 %22)
%24 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%25 = load i8*, i8** %7
%26 = call i32 @exibir_mascara(i8* %25)
%27 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%28 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
%29 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %8)
%30 = load i8, i8* %8
%31 = call signext i8 @toupper(i8 signext %30)
store i8 %31, i8* %8
%32 = load i8, i8* %8
%33 = load i8*, i8** %6
%34 = call i64 @existe_letra_na_palavra(i8 signext %32, i8* %33)
%35 = icmp ne i64 %34, 0
br i1 %35, label %36, label %41
36: ; preds = %20
%37 = load i8, i8* %8
%38 = load i8*, i8** %7
%39 = load i8*, i8** %6
%40 = call i32 @substituir_letra_na_mascara(i8 signext %37, i8* %38, i8* %39)
br label %44
41: ; preds = %20
%42 = load i32, i32* %9
%43 = add i32 %42, 1
store i32 %43, i32* %9
br label %44
44: ; preds = %41, %36
%45 = load i8*, i8** %6
%46 = load i8*, i8** %7
%47 = call i32 @strcmp(i8* %45, i8* %46)
%48 = icmp ne i32 %47, 0
br i1 %48, label %50, label %49
49: ; preds = %44
store i32 1, i32* %10
br label %50
50: ; preds = %49, %44
br label %51
51: ; preds = %50
%52 = load i32, i32* %9
%53 = icmp ult i32 %52, 6
br i1 %53, label %54, label %57
54: ; preds = %51
%55 = load i32, i32* %10
%56 = icmp eq i32 %55, 0
br label %57
57: ; preds = %54, %51
%58 = phi i1 [ false, %51 ], [ %56, %54 ]
br i1 %58, label %20, label %59
59: ; preds = %57
%60 = call i32 (...) @limpar_tela()
%61 = load i32, i32* %9
%62 = call i32 @exibir_boneco(i32 %61)
%63 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%64 = load i8*, i8** %7
%65 = call i32 @exibir_mascara(i8* %64)
%66 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%67 = load i32, i32* %10
%68 = call i32 @exibir_resultado(i32 %67)
%69 = load i8*, i8** %6
%70 = call i32 @free(i8* %69)
%71 = load i8*, i8** %7
%72 = call i32 @free(i8* %71)
ret i32 0
}

LLVM IR (-O2):
@LC_ALL = global i32 0
@.str = [11 x i8] c"PORTUGUESE\00"
@.str.2 = [18 x i8] c"Digite uma letra:\00"
@.str.3 = [4 x i8] c" %c\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8
%4 = load i32, i32* @LC_ALL
%5 = tail call i32 @setlocale(i32 %4, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%6 = getelementptr inbounds i8*, i8** %1, i64 1
%7 = load i8*, i8** %6
%8 = tail call i8* @init_palavra(i8* %7)
%9 = tail call i32 @strlen(i8* %8)
%10 = tail call i8* @init_mascara(i32 %9)
br label %11
11: ; preds = %29, %2
%12 = phi i32 [ 0, %2 ], [ %30, %29 ]
%13 = call i32 (...) @limpar_tela()
%14 = call i32 @exibir_boneco(i32 %12)
%15 = call i32 @putchar(i32 10)
%16 = call i32 @exibir_mascara(i8* %10)
%17 = call i32 @putchar(i32 10)
%18 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
%19 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %3)
%20 = load i8, i8* %3
%21 = call signext i8 @toupper(i8 signext %20)
store i8 %21, i8* %3
%22 = call i64 @existe_letra_na_palavra(i8 signext %21, i8* %8)
%23 = icmp eq i64 %22, 0
br i1 %23, label %27, label %24
24: ; preds = %11
%25 = load i8, i8* %3
%26 = call i32 @substituir_letra_na_mascara(i8 signext %25, i8* %10, i8* %8)
br label %29
27: ; preds = %11
%28 = add nuw nsw i32 %12, 1
br label %29
29: ; preds = %27, %24
%30 = phi i32 [ %12, %24 ], [ %28, %27 ]
%31 = call i32 @strcmp(i8* dereferenceable(1) %8, i8* dereferenceable(1) %10)
%32 = icmp eq i32 %31, 0
%33 = xor i1 %32, true
%34 = icmp ult i32 %30, 6
%35 = select i1 %34, i1 %33, i1 false
br i1 %35, label %11, label %36
36: ; preds = %29
%37 = zext i1 %32 to i32
%38 = call i32 (...) @limpar_tela()
%39 = call i32 @exibir_boneco(i32 %30)
%40 = call i32 @putchar(i32 10)
%41 = call i32 @exibir_mascara(i8* %10)
%42 = call i32 @putchar(i32 10)
%43 = call i32 @exibir_resultado(i32 %37)
%44 = call i32 @free(i8* %8)
%45 = call i32 @free(i8* %10)
ret i32 0
}