#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 *, ...);
int /*<<< orphan*/ scanf(char *, char *);
int strlen(char *);
int main() {
  char palavras[15];
  char letra;
  int x, Nletras, i;
  i = 0;
  x = 0;
  printf("Digite sua palavra.");
  scanf("%s", palavras);
  scanf("%c", &letra);
  printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
  Nletras = strlen(palavras);
  for (x = 0; x < Nletras; x++) {
    printf(" _ ");
  }
  printf("Descubra a palavra\n\n");
  scanf("%c", &letra);
  for (i = 0; i < Nletras; i++) {
    if (letra == palavras[i]) {
      printf("%c", palavras[i]);
    } else if (i > Nletras) {
      printf("ERRRRRROOOOOWWWWW!!!!");
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x18(%rbp)
lea    0xeac(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x13(%rbp),%rsi
lea    0xeae(%rip),%rdi
call   1050 <scanf@plt>
lea    0xea5(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1050 <scanf@plt>
lea    0xe98(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x13(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x1c(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11c4 <main+0x94>
lea    0xe7b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    119c <main+0x6c>
lea    0xe63(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe3e(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1050 <scanf@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1258 <main+0x128>
movsbl -0x14(%rbp),%eax
movslq -0x20(%rbp),%rcx
movsbl -0x13(%rbp,%rcx,1),%ecx
cmp    %ecx,%eax
jne    1226 <main+0xf6>
movslq -0x20(%rbp),%rax
movsbl -0x13(%rbp,%rax,1),%esi
lea    0xdfd(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1245 <main+0x115>
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jle    1240 <main+0x110>
lea    0xe0a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1245 <main+0x115>
jmp    124a <main+0x11a>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11e9 <main+0xb9>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xea1(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xea7(%rip),%rdi
lea    0x1(%rsp),%rbx
mov    %rbx,%rsi
call   1070 <scanf@plt>
lea    0xe96(%rip),%rdi
mov    %rsp,%rsi
call   1070 <scanf@plt>
lea    0xe8e(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
test   %eax,%eax
jle    120b <main+0xbb>
mov    %eax,%r14d
lea    0xe6f(%rip),%rbx
mov    %eax,%ebp
nopl   (%rax)
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
add    $0xffffffff,%ebp
jne    11b0 <main+0x60>
lea    0xe67(%rip),%rdi
call   1040 <puts@plt>
lea    0xe45(%rip),%rdi
mov    %rsp,%rsi
call   1070 <scanf@plt>
test   %r14d,%r14d
jle    1226 <main+0xd6>
mov    %r14d,%ebx
xor    %ebp,%ebp
jmp    11f9 <main+0xa9>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%rbp
cmp    %rbp,%rbx
je     1226 <main+0xd6>
movsbl (%rsp),%edi
cmp    0x1(%rsp,%rbp,1),%dil
jne    11f0 <main+0xa0>
call   1030 <putchar@plt>
jmp    11f0 <main+0xa0>
lea    0xe1b(%rip),%rdi
call   1040 <puts@plt>
lea    0xdf9(%rip),%rdi
mov    %rsp,%rsi
call   1070 <scanf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [20 x i8] c"Digite sua palavra.\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [3 x i8] c"%c\00"
@.str.3 = [16 x i8] c"\0A\0A\0A\0A\0A\0A\0A\0A\0A\0A\0A\0A\0A\0A\0A\00"
@.str.4 = [4 x i8] c" _ \00"
@.str.5 = [21 x i8] c"Descubra a palavra\0A\0A\00"
@.str.6 = [22 x i8] c"ERRRRRROOOOOWWWWW!!!!\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [15 x i8]
%3 = alloca i8
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %6
store i32 0, i32* %4
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%8 = getelementptr inbounds [15 x i8], [15 x i8]* %2, i64 0, i64 0
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %8)
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %3)
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
%12 = getelementptr inbounds [15 x i8], [15 x i8]* %2, i64 0, i64 0
%13 = call i32 @strlen(i8* %12)
store i32 %13, i32* %5
store i32 0, i32* %4
br label %14
14: ; preds = %20, %0
%15 = load i32, i32* %4
%16 = load i32, i32* %5
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %23
18: ; preds = %14
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
br label %20
20: ; preds = %18
%21 = load i32, i32* %4
%22 = add nsw i32 %21, 1
store i32 %22, i32* %4
br label %14
23: ; preds = %14
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0))
%25 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %3)
store i32 0, i32* %6
br label %26
26: ; preds = %54, %23
%27 = load i32, i32* %6
%28 = load i32, i32* %5
%29 = icmp slt i32 %27, %28
br i1 %29, label %30, label %57
30: ; preds = %26
%31 = load i8, i8* %3
%32 = sext i8 %31 to i32
%33 = load i32, i32* %6
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [15 x i8], [15 x i8]* %2, i64 0, i64 %34
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
%38 = icmp eq i32 %32, %37
br i1 %38, label %39, label %46
39: ; preds = %30
%40 = load i32, i32* %6
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [15 x i8], [15 x i8]* %2, i64 0, i64 %41
%43 = load i8, i8* %42
%44 = sext i8 %43 to i32
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %44)
br label %53
46: ; preds = %30
%47 = load i32, i32* %6
%48 = load i32, i32* %5
%49 = icmp sgt i32 %47, %48
br i1 %49, label %50, label %52
50: ; preds = %46
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0))
br label %52
52: ; preds = %50, %46
br label %53
53: ; preds = %52, %39
br label %54
54: ; preds = %53
%55 = load i32, i32* %6
%56 = add nsw i32 %55, 1
store i32 %56, i32* %6
br label %26
57: ; preds = %26
ret i32 0
}

LLVM IR (-O2):
@.str = [20 x i8] c"Digite sua palavra.\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [3 x i8] c"%c\00"
@.str.4 = [4 x i8] c" _ \00"
@str = [15 x i8] c"\0A\0A\0A\0A\0A\0A\0A\0A\0A\0A\0A\0A\0A\0A\00"
@str.7 = [20 x i8] c"Descubra a palavra\0A\00"
define i32 @main() {
%1 = alloca [15 x i8]
%2 = alloca i8
%3 = getelementptr inbounds [15 x i8], [15 x i8]* %1, i64 0, i64 0
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %2)
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
%8 = call i32 @strlen(i8* %3)
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %32
10: ; preds = %0, %10
%11 = phi i32 [ %13, %10 ], [ 0, %0 ]
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%13 = add nuw nsw i32 %11, 1
%14 = icmp eq i32 %13, %8
br i1 %14, label %15, label %10
15: ; preds = %10
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.7, i64 0, i64 0))
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %2)
br i1 %9, label %18, label %35
18: ; preds = %15
%19 = zext i32 %8 to i64
br label %20
20: ; preds = %18, %29
%21 = phi i64 [ 0, %18 ], [ %30, %29 ]
%22 = load i8, i8* %2
%23 = getelementptr inbounds [15 x i8], [15 x i8]* %1, i64 0, i64 %21
%24 = load i8, i8* %23
%25 = icmp eq i8 %22, %24
br i1 %25, label %26, label %29
26: ; preds = %20
%27 = sext i8 %22 to i32
%28 = call i32 @putchar(i32 %27)
br label %29
29: ; preds = %20, %26
%30 = add nuw nsw i64 %21, 1
%31 = icmp eq i64 %30, %19
br i1 %31, label %35, label %20
32: ; preds = %0
%33 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.7, i64 0, i64 0))
%34 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %2)
br label %35
35: ; preds = %29, %32, %15
ret i32 0
}