#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*/ borrar_pantalla();
int desocultar(char *, char *, char);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ ocultar(char *, char *);
char pedir_letra();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
int strlen(char *);
int main() {
  char secreta[100];
  char oculta[100];
  char letra;
  int intentos = 5;
  int asteriscos;
  int quitadas;
  printf("hola somos Mariana Nicolas y Salva\n");
  printf("Introduce la palabra para adivinar: ");
  scanf("%s", secreta);
  borrar_pantalla();
  ocultar(secreta, oculta);
  asteriscos = strlen(secreta);
  while (intentos > 0) {
    printf("\nJuego del Ahorcado, te quedan %d intentos\n", intentos);
    printf("La palabra oculta es %s\n", oculta);
    letra = pedir_letra();
    quitadas = desocultar(secreta, oculta, letra);
    asteriscos = asteriscos - quitadas;
    if (quitadas == 0)
      intentos = intentos - 1;
    if (asteriscos == 0) {
      printf("ENHORABUENA, GANASTE!!!!! la palabra correcta era %s\n", secreta);
      exit(0);
    }
  }
  printf("ERES UN PERDEDOR!!!!!!!! la palabra secreta era %s\n", secreta);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x5,-0xe8(%rbp)
lea    0xe5d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x70(%rbp),%rsi
lea    0xe86(%rip),%rdi
call   1070 <scanf@plt>
mov    $0x0,%al
call   1080 <borrar_pantalla@plt>
lea    -0x70(%rbp),%rdi
lea    -0xe0(%rbp),%rsi
call   1050 <ocultar@plt>
lea    -0x70(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0xec(%rbp)
cmpl   $0x0,-0xe8(%rbp)
jle    12a7 <main+0x127>
mov    -0xe8(%rbp),%esi
lea    0xe44(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0xe0(%rbp),%rsi
lea    0xe5b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1060 <pedir_letra@plt>
mov    %al,-0xe1(%rbp)
lea    -0x70(%rbp),%rdi
lea    -0xe0(%rbp),%rsi
movsbl -0xe1(%rbp),%edx
call   10a0 <desocultar@plt>
mov    %eax,-0xf0(%rbp)
mov    -0xec(%rbp),%eax
sub    -0xf0(%rbp),%eax
mov    %eax,-0xec(%rbp)
cmpl   $0x0,-0xf0(%rbp)
jne    127c <main+0xfc>
mov    -0xe8(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0xe8(%rbp)
cmpl   $0x0,-0xec(%rbp)
jne    12a2 <main+0x122>
lea    -0x70(%rbp),%rsi
lea    0xdfd(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %edi,%edi
call   1090 <exit@plt>
jmp    11ee <main+0x6e>
lea    -0x70(%rbp),%rsi
lea    0xe15(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xd8,%rsp
lea    0xf2f(%rip),%rdi
call   1030 <puts@plt>
lea    0xe4c(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe63(%rip),%rdi
mov    %rsp,%r14
mov    %r14,%rsi
call   1080 <scanf@plt>
xor    %eax,%eax
call   1090 <borrar_pantalla@plt>
lea    0x70(%rsp),%r15
mov    %r14,%rdi
mov    %r15,%rsi
call   1060 <ocultar@plt>
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %eax,%ebp
mov    $0x5,%ebx
lea    0xe2e(%rip),%r12
lea    0xe53(%rip),%r13
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
test   %ebx,%ebx
jle    1264 <main+0xd4>
mov    %r12,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r13,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1070 <pedir_letra@plt>
movsbl %al,%edx
mov    %r14,%rdi
mov    %r15,%rsi
call   10b0 <desocultar@plt>
cmp    $0x1,%eax
sbb    $0x0,%ebx
sub    %eax,%ebp
jne    1210 <main+0x80>
lea    0xe1a(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %edi,%edi
call   10a0 <exit@plt>
lea    0xe38(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0xd8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [36 x i8] c"hola somos Mariana Nicolas y Salva\0A\00"
@.str.1 = [37 x i8] c"Introduce la palabra para adivinar: \00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [44 x i8] c"\0AJuego del Ahorcado, te quedan %d intentos\0A\00"
@.str.4 = [25 x i8] c"La palabra oculta es %s\0A\00"
@.str.5 = [54 x i8] c"ENHORABUENA, GANASTE!!!!! la palabra correcta era %s\0A\00"
@.str.6 = [52 x i8] c"ERES UN PERDEDOR!!!!!!!! la palabra secreta era %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i8]
%3 = alloca [100 x i8]
%4 = alloca i8
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
store i32 5, i32* %5
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0))
%10 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %10)
%12 = call i32 (...) @borrar_pantalla()
%13 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%14 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%15 = call i32 @ocultar(i8* %13, i8* %14)
%16 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%17 = call i32 @strlen(i8* %16)
store i32 %17, i32* %6
br label %18
18: ; preds = %46, %0
%19 = load i32, i32* %5
%20 = icmp sgt i32 %19, 0
br i1 %20, label %21, label %47
21: ; preds = %18
%22 = load i32, i32* %5
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.3, i64 0, i64 0), i32 %22)
%24 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i8* %24)
%26 = call signext i8 (...) @pedir_letra()
store i8 %26, i8* %4
%27 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%28 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%29 = load i8, i8* %4
%30 = call i32 @desocultar(i8* %27, i8* %28, i8 signext %29)
store i32 %30, i32* %7
%31 = load i32, i32* %6
%32 = load i32, i32* %7
%33 = sub nsw i32 %31, %32
store i32 %33, i32* %6
%34 = load i32, i32* %7
%35 = icmp eq i32 %34, 0
br i1 %35, label %36, label %39
36: ; preds = %21
%37 = load i32, i32* %5
%38 = sub nsw i32 %37, 1
store i32 %38, i32* %5
br label %39
39: ; preds = %36, %21
%40 = load i32, i32* %6
%41 = icmp eq i32 %40, 0
br i1 %41, label %42, label %46
42: ; preds = %39
%43 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.5, i64 0, i64 0), i8* %43)
%45 = call i32 @exit(i32 0)
unreachable
46: ; preds = %39
br label %18
47: ; preds = %18
%48 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.6, i64 0, i64 0), i8* %48)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [37 x i8] c"Introduce la palabra para adivinar: \00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [44 x i8] c"\0AJuego del Ahorcado, te quedan %d intentos\0A\00"
@.str.4 = [25 x i8] c"La palabra oculta es %s\0A\00"
@.str.5 = [54 x i8] c"ENHORABUENA, GANASTE!!!!! la palabra correcta era %s\0A\00"
@.str.6 = [52 x i8] c"ERES UN PERDEDOR!!!!!!!! la palabra secreta era %s\0A\00"
@str = [35 x i8] c"hola somos Mariana Nicolas y Salva\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = alloca [100 x i8]
%3 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str, i64 0, i64 0))
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %3)
%8 = call i32 (...) @borrar_pantalla()
%9 = call i32 @ocultar(i8* %3, i8* %4)
%10 = call i32 @strlen(i8* %3)
br label %11
11: ; preds = %15, %0
%12 = phi i32 [ 5, %0 ], [ %23, %15 ]
%13 = phi i32 [ %10, %0 ], [ %20, %15 ]
%14 = icmp sgt i32 %12, 0
br i1 %14, label %15, label %28
15: ; preds = %11
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.3, i64 0, i64 0), i32 %12)
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i8* %4)
%18 = call signext i8 (...) @pedir_letra()
%19 = call i32 @desocultar(i8* %3, i8* %4, i8 signext %18)
%20 = sub nsw i32 %13, %19
%21 = icmp eq i32 %19, 0
%22 = sext i1 %21 to i32
%23 = add nsw i32 %12, %22
%24 = icmp eq i32 %20, 0
br i1 %24, label %25, label %11
25: ; preds = %15
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @.str.5, i64 0, i64 0), i8* %3)
%27 = call i32 @exit(i32 0)
unreachable
28: ; preds = %11
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @.str.6, i64 0, i64 0), i8* %3)
ret i32 0
}