#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 buscarNivelxClave(char *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
int /*<<< orphan*/ impFotograma(int);
int /*<<< orphan*/ limpOut(int);
scalar_t__ mygetch();
int /*<<< orphan*/ printf(char *, char);
int /*<<< orphan*/ stdout;
int menuClave() {
  int cont = 0;
  int i, nivel;
  char clave[16];
  for (i = 0; i < 16; i++) {
    clave[i] = '\0';
  }
  limpOut(22);
  impFotograma(26);
  while (cont < 13) {
    fputs("\033[A", stdout);
    cont++;
  }
  cont = 0;
  while (cont < 20) {
    fputs("\033[C", stdout);
    cont++;
  }
  cont = 0;
  char ch;
  ch = (char)mygetch();
  while (ch != '\n') {
    if ((ch != 127) && (cont < 15)) {
      printf("%c ", ch);
      clave[cont] = ch;
      cont++;
    } else if ((ch == 127) && (cont > 0)) {
      fputs("\033[D\033[D \033[D", stdout);
      cont--;
      clave[cont] = '\0';
    }
    ch = (char)mygetch();
  }
  nivel = buscarNivelxClave(clave);
  return nivel;
}


x86 assembly (clang, -O0):
<menuClave>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x10,-0x8(%rbp)
jge    1197 <menuClave+0x37>
movslq -0x8(%rbp),%rax
movb   $0x0,-0x20(%rbp,%rax,1)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1176 <menuClave+0x16>
mov    $0x16,%edi
call   1070 <limpOut@plt>
mov    $0x1a,%edi
call   1060 <impFotograma@plt>
cmpl   $0xd,-0x4(%rbp)
jge    11d8 <menuClave+0x78>
mov    0x2e24(%rip),%rax
mov    (%rax),%esi
lea    0xe3b(%rip),%rdi
call   1050 <fputs@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    11ab <menuClave+0x4b>
movl   $0x0,-0x4(%rbp)
cmpl   $0x14,-0x4(%rbp)
jge    120c <menuClave+0xac>
mov    0x2df0(%rip),%rax
mov    (%rax),%esi
lea    0xe0b(%rip),%rdi
call   1050 <fputs@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    11df <menuClave+0x7f>
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1030 <mygetch@plt>
mov    %al,-0x21(%rbp)
movsbl -0x21(%rbp),%eax
cmp    $0xa,%eax
je     12bc <menuClave+0x15c>
movsbl -0x21(%rbp),%eax
cmp    $0x7f,%eax
je     126a <menuClave+0x10a>
cmpl   $0xf,-0x4(%rbp)
jge    126a <menuClave+0x10a>
lea    0xdc0(%rip),%rdi
movsbl -0x21(%rbp),%esi
call   1040 <printf@plt>
mov    -0x21(%rbp),%cl
movslq -0x4(%rbp),%rax
mov    %cl,-0x20(%rbp,%rax,1)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    12ad <menuClave+0x14d>
movsbl -0x21(%rbp),%eax
cmp    $0x7f,%eax
jne    12a8 <menuClave+0x148>
cmpl   $0x0,-0x4(%rbp)
jle    12a8 <menuClave+0x148>
mov    0x2d58(%rip),%rax
mov    (%rax),%esi
lea    0xd7b(%rip),%rdi
call   1050 <fputs@plt>
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x4(%rbp)
movslq -0x4(%rbp),%rax
movb   $0x0,-0x20(%rbp,%rax,1)
jmp    12ad <menuClave+0x14d>
mov    $0x0,%al
call   1030 <mygetch@plt>
mov    %al,-0x21(%rbp)
jmp    121d <menuClave+0xbd>
lea    -0x20(%rbp),%rdi
call   1080 <buscarNivelxClave@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<menuClave>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
mov    $0x16,%edi
call   1070 <limpOut@plt>
mov    $0x1a,%edi
call   1060 <impFotograma@plt>
mov    0x2e51(%rip),%r12
mov    (%r12),%esi
lea    0xe66(%rip),%rbx
mov    %rbx,%rdi
call   1050 <fputs@plt>
mov    (%r12),%esi
mov    %rbx,%rdi
call   1050 <fputs@plt>
mov    (%r12),%esi
mov    %rbx,%rdi
call   1050 <fputs@plt>
mov    (%r12),%esi
mov    %rbx,%rdi
call   1050 <fputs@plt>
mov    (%r12),%esi
mov    %rbx,%rdi
call   1050 <fputs@plt>
mov    (%r12),%esi
mov    %rbx,%rdi
call   1050 <fputs@plt>
mov    (%r12),%esi
mov    %rbx,%rdi
call   1050 <fputs@plt>
mov    (%r12),%esi
mov    %rbx,%rdi
call   1050 <fputs@plt>
mov    (%r12),%esi
mov    %rbx,%rdi
call   1050 <fputs@plt>
mov    (%r12),%esi
mov    %rbx,%rdi
call   1050 <fputs@plt>
mov    (%r12),%esi
mov    %rbx,%rdi
call   1050 <fputs@plt>
mov    (%r12),%esi
mov    %rbx,%rdi
call   1050 <fputs@plt>
mov    (%r12),%esi
mov    %rbx,%rdi
call   1050 <fputs@plt>
mov    (%r12),%esi
lea    0xdc7(%rip),%rbx
mov    %rbx,%rdi
call   1050 <fputs@plt>
mov    (%r12),%esi
mov    %rbx,%rdi
call   1050 <fputs@plt>
mov    (%r12),%esi
mov    %rbx,%rdi
call   1050 <fputs@plt>
mov    (%r12),%esi
mov    %rbx,%rdi
call   1050 <fputs@plt>
mov    (%r12),%esi
mov    %rbx,%rdi
call   1050 <fputs@plt>
mov    (%r12),%esi
mov    %rbx,%rdi
call   1050 <fputs@plt>
mov    (%r12),%esi
mov    %rbx,%rdi
call   1050 <fputs@plt>
mov    (%r12),%esi
mov    %rbx,%rdi
call   1050 <fputs@plt>
mov    (%r12),%esi
mov    %rbx,%rdi
call   1050 <fputs@plt>
mov    (%r12),%esi
mov    %rbx,%rdi
call   1050 <fputs@plt>
mov    (%r12),%esi
mov    %rbx,%rdi
call   1050 <fputs@plt>
mov    (%r12),%esi
mov    %rbx,%rdi
call   1050 <fputs@plt>
mov    (%r12),%esi
mov    %rbx,%rdi
call   1050 <fputs@plt>
mov    (%r12),%esi
mov    %rbx,%rdi
call   1050 <fputs@plt>
mov    (%r12),%esi
mov    %rbx,%rdi
call   1050 <fputs@plt>
mov    (%r12),%esi
mov    %rbx,%rdi
call   1050 <fputs@plt>
mov    (%r12),%esi
mov    %rbx,%rdi
call   1050 <fputs@plt>
mov    (%r12),%esi
mov    %rbx,%rdi
call   1050 <fputs@plt>
mov    (%r12),%esi
mov    %rbx,%rdi
call   1050 <fputs@plt>
mov    (%r12),%esi
mov    %rbx,%rdi
call   1050 <fputs@plt>
xor    %eax,%eax
call   1030 <mygetch@plt>
mov    %rax,%rbx
cmp    $0xa,%bl
jne    134e <menuClave+0x1ee>
mov    %rsp,%rdi
call   1080 <buscarNivelxClave@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
lea    0xcb3(%rip),%r15
lea    0xcb0(%rip),%r14
xor    %r13d,%r13d
jmp    1394 <menuClave+0x234>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsbl %bl,%esi
mov    %r15,%rdi
call   1040 <printf@plt>
movslq %r13d,%rax
mov    %bl,(%rsp,%rax,1)
add    $0x1,%r13d
xor    %eax,%eax
call   1030 <mygetch@plt>
mov    %rax,%rbx
cmp    $0xa,%bl
je     1338 <menuClave+0x1d8>
cmp    $0x7f,%bl
je     139f <menuClave+0x23f>
cmp    $0xe,%r13d
jle    1370 <menuClave+0x210>
cmp    $0x7f,%bl
jne    1385 <menuClave+0x225>
test   %r13d,%r13d
jle    1385 <menuClave+0x225>
mov    (%r12),%esi
mov    %r14,%rdi
call   1050 <fputs@plt>
add    $0xffffffff,%r13d
movb   $0x0,(%rsp,%r13,1)
jmp    1385 <menuClave+0x225>

LLVM IR (-O0):
@.str = [4 x i8] c"\1B[A\00"
@stdout = global i32 0
@.str.1 = [4 x i8] c"\1B[C\00"
@.str.2 = [4 x i8] c"%c \00"
@.str.3 = [11 x i8] c"\1B[D\1B[D \1B[D\00"
define i32 @menuClave() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [16 x i8]
%5 = alloca i8
store i32 0, i32* %1
store i32 0, i32* %2
br label %6
6: ; preds = %13, %0
%7 = load i32, i32* %2
%8 = icmp slt i32 %7, 16
br i1 %8, label %9, label %16
9: ; preds = %6
%10 = load i32, i32* %2
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 %11
store i8 0, i8* %12
br label %13
13: ; preds = %9
%14 = load i32, i32* %2
%15 = add nsw i32 %14, 1
store i32 %15, i32* %2
br label %6
16: ; preds = %6
%17 = call i32 @limpOut(i32 22)
%18 = call i32 @impFotograma(i32 26)
br label %19
19: ; preds = %22, %16
%20 = load i32, i32* %1
%21 = icmp slt i32 %20, 13
br i1 %21, label %22, label %27
22: ; preds = %19
%23 = load i32, i32* @stdout
%24 = call i32 @fputs(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %23)
%25 = load i32, i32* %1
%26 = add nsw i32 %25, 1
store i32 %26, i32* %1
br label %19
27: ; preds = %19
store i32 0, i32* %1
br label %28
28: ; preds = %31, %27
%29 = load i32, i32* %1
%30 = icmp slt i32 %29, 20
br i1 %30, label %31, label %36
31: ; preds = %28
%32 = load i32, i32* @stdout
%33 = call i32 @fputs(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %32)
%34 = load i32, i32* %1
%35 = add nsw i32 %34, 1
store i32 %35, i32* %1
br label %28
36: ; preds = %28
store i32 0, i32* %1
%37 = call i64 (...) @mygetch()
%38 = trunc i64 %37 to i8
store i8 %38, i8* %5
br label %39
39: ; preds = %75, %36
%40 = load i8, i8* %5
%41 = sext i8 %40 to i32
%42 = icmp ne i32 %41, 10
br i1 %42, label %43, label %78
43: ; preds = %39
%44 = load i8, i8* %5
%45 = sext i8 %44 to i32
%46 = icmp ne i32 %45, 127
br i1 %46, label %47, label %59
47: ; preds = %43
%48 = load i32, i32* %1
%49 = icmp slt i32 %48, 15
br i1 %49, label %50, label %59
50: ; preds = %47
%51 = load i8, i8* %5
%52 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8 signext %51)
%53 = load i8, i8* %5
%54 = load i32, i32* %1
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 %55
store i8 %53, i8* %56
%57 = load i32, i32* %1
%58 = add nsw i32 %57, 1
store i32 %58, i32* %1
br label %75
59: ; preds = %47, %43
%60 = load i8, i8* %5
%61 = sext i8 %60 to i32
%62 = icmp eq i32 %61, 127
br i1 %62, label %63, label %74
63: ; preds = %59
%64 = load i32, i32* %1
%65 = icmp sgt i32 %64, 0
br i1 %65, label %66, label %74
66: ; preds = %63
%67 = load i32, i32* @stdout
%68 = call i32 @fputs(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 %67)
%69 = load i32, i32* %1
%70 = add nsw i32 %69, -1
store i32 %70, i32* %1
%71 = load i32, i32* %1
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 %72
store i8 0, i8* %73
br label %74
74: ; preds = %66, %63, %59
br label %75
75: ; preds = %74, %50
%76 = call i64 (...) @mygetch()
%77 = trunc i64 %76 to i8
store i8 %77, i8* %5
br label %39
78: ; preds = %39
%79 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 0
%80 = call i32 @buscarNivelxClave(i8* %79)
store i32 %80, i32* %3
%81 = load i32, i32* %3
ret i32 %81
}

LLVM IR (-O2):
@.str = [4 x i8] c"\1B[A\00"
@stdout = global i32 0
@.str.1 = [4 x i8] c"\1B[C\00"
@.str.2 = [4 x i8] c"%c \00"
@.str.3 = [11 x i8] c"\1B[D\1B[D \1B[D\00"
define i32 @menuClave() {
%1 = alloca [16 x i8]
%2 = getelementptr inbounds [16 x i8], [16 x i8]* %1, i64 0, i64 0
%3 = getelementptr inbounds [16 x i8], [16 x i8]* %1, i64 0, i64 0
%4 = tail call i32 @limpOut(i32 22)
%5 = tail call i32 @impFotograma(i32 26)
%6 = load i32, i32* @stdout
%7 = tail call i32 @fputs(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %6)
%8 = load i32, i32* @stdout
%9 = tail call i32 @fputs(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %8)
%10 = load i32, i32* @stdout
%11 = tail call i32 @fputs(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = load i32, i32* @stdout
%13 = tail call i32 @fputs(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %12)
%14 = load i32, i32* @stdout
%15 = tail call i32 @fputs(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %14)
%16 = load i32, i32* @stdout
%17 = tail call i32 @fputs(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %16)
%18 = load i32, i32* @stdout
%19 = tail call i32 @fputs(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %18)
%20 = load i32, i32* @stdout
%21 = tail call i32 @fputs(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %20)
%22 = load i32, i32* @stdout
%23 = tail call i32 @fputs(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %22)
%24 = load i32, i32* @stdout
%25 = tail call i32 @fputs(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %24)
%26 = load i32, i32* @stdout
%27 = tail call i32 @fputs(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %26)
%28 = load i32, i32* @stdout
%29 = tail call i32 @fputs(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %28)
%30 = load i32, i32* @stdout
%31 = tail call i32 @fputs(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %30)
%32 = load i32, i32* @stdout
%33 = tail call i32 @fputs(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %32)
%34 = load i32, i32* @stdout
%35 = tail call i32 @fputs(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %34)
%36 = load i32, i32* @stdout
%37 = tail call i32 @fputs(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %36)
%38 = load i32, i32* @stdout
%39 = tail call i32 @fputs(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %38)
%40 = load i32, i32* @stdout
%41 = tail call i32 @fputs(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %40)
%42 = load i32, i32* @stdout
%43 = tail call i32 @fputs(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %42)
%44 = load i32, i32* @stdout
%45 = tail call i32 @fputs(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %44)
%46 = load i32, i32* @stdout
%47 = tail call i32 @fputs(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %46)
%48 = load i32, i32* @stdout
%49 = tail call i32 @fputs(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %48)
%50 = load i32, i32* @stdout
%51 = tail call i32 @fputs(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %50)
%52 = load i32, i32* @stdout
%53 = tail call i32 @fputs(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %52)
%54 = load i32, i32* @stdout
%55 = tail call i32 @fputs(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %54)
%56 = load i32, i32* @stdout
%57 = tail call i32 @fputs(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %56)
%58 = load i32, i32* @stdout
%59 = tail call i32 @fputs(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %58)
%60 = load i32, i32* @stdout
%61 = tail call i32 @fputs(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %60)
%62 = load i32, i32* @stdout
%63 = tail call i32 @fputs(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %62)
%64 = load i32, i32* @stdout
%65 = tail call i32 @fputs(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %64)
%66 = load i32, i32* @stdout
%67 = tail call i32 @fputs(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %66)
%68 = load i32, i32* @stdout
%69 = tail call i32 @fputs(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %68)
%70 = load i32, i32* @stdout
%71 = tail call i32 @fputs(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %70)
%72 = tail call i64 (...) @mygetch()
%73 = trunc i64 %72 to i8
%74 = icmp eq i8 %73, 10
br i1 %74, label %101, label %75
75: ; preds = %0, %96
%76 = phi i8 [ %99, %96 ], [ %73, %0 ]
%77 = phi i32 [ %97, %96 ], [ 0, %0 ]
%78 = icmp ne i8 %76, 127
%79 = icmp slt i32 %77, 15
%80 = select i1 %78, i1 %79, i1 false
br i1 %80, label %81, label %86
81: ; preds = %75
%82 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8 signext %76)
%83 = sext i32 %77 to i64
%84 = getelementptr inbounds [16 x i8], [16 x i8]* %1, i64 0, i64 %83
store i8 %76, i8* %84
%85 = add nsw i32 %77, 1
br label %96
86: ; preds = %75
%87 = icmp eq i8 %76, 127
%88 = icmp sgt i32 %77, 0
%89 = select i1 %87, i1 %88, i1 false
br i1 %89, label %90, label %96
90: ; preds = %86
%91 = load i32, i32* @stdout
%92 = tail call i32 @fputs(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 %91)
%93 = add nsw i32 %77, -1
%94 = zext i32 %93 to i64
%95 = getelementptr inbounds [16 x i8], [16 x i8]* %1, i64 0, i64 %94
store i8 0, i8* %95
br label %96
96: ; preds = %86, %90, %81
%97 = phi i32 [ %85, %81 ], [ %93, %90 ], [ %77, %86 ]
%98 = tail call i64 (...) @mygetch()
%99 = trunc i64 %98 to i8
%100 = icmp eq i8 %99, 10
br i1 %100, label %101, label %75
101: ; preds = %96, %0
%102 = call i32 @buscarNivelxClave(i8* %3)
ret i32 %102
}