#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 *);
scalar_t__ strcmp(char *, char *);
int strlen(char *);
int exercicio_01(void) {
  int i;
  char palavra[5], teste1[5], teste2[5];
  do {
    printf("Digite uma palavra com 5 letras:\n");
    scanf("%s", palavra);
    if (strlen(palavra) == 5)
      break;
    printf("\nERRO: a palavra informada (%s) não possui 5 letras!!!\n",
           palavra);
    printf("\nInforme-a novamente!!!\n\n");
  } while (1);
  printf("\nA palavra da: ESQUERDA  para: DIREITA  -> ");
  for (i = 0; i <= 4; ++i) {
    printf("%c", palavra[i]);
    teste1[i] = palavra[i];
  }
  printf("\nA palavra da: DIREITA   para: ESQUERDA -> ");
  for (i = 4; i >= 0; --i) {
    printf("%c", palavra[i]);
    teste2[4 - i] = palavra[i];
  }
  if (strcmp(teste1, teste2) == 0)
    printf("\n\nA palavra informada (%s) é palíndroma!\n", palavra);
  else
    printf("\n\nA palavra informada (%s) NÃO é palíndroma!\n", palavra);
  return 0;
}


x86 assembly (clang, -O0):
<exercicio_01>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xeb1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x9(%rbp),%rsi
lea    0xec1(%rip),%rdi
call   1060 <scanf@plt>
lea    -0x9(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x5,%eax
jne    117d <exercicio_01+0x3d>
jmp    11ac <exercicio_01+0x6c>
lea    -0x9(%rbp),%rsi
lea    0xe9d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xec8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%al
test   $0x1,%al
jne    1148 <exercicio_01+0x8>
jmp    11ac <exercicio_01+0x6c>
lea    0xec5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
cmpl   $0x4,-0x4(%rbp)
jg     1200 <exercicio_01+0xc0>
movslq -0x4(%rbp),%rax
movsbl -0x9(%rbp,%rax,1),%esi
lea    0xec9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movslq -0x4(%rbp),%rax
mov    -0x9(%rbp,%rax,1),%cl
movslq -0x4(%rbp),%rax
mov    %cl,-0xe(%rbp,%rax,1)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    11c1 <exercicio_01+0x81>
lea    0xea0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x4,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jl     125a <exercicio_01+0x11a>
movslq -0x4(%rbp),%rax
movsbl -0x9(%rbp,%rax,1),%esi
lea    0xe75(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movslq -0x4(%rbp),%rax
mov    -0x9(%rbp,%rax,1),%cl
mov    $0x4,%eax
sub    -0x4(%rbp),%eax
cltq
mov    %cl,-0x13(%rbp,%rax,1)
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x4(%rbp)
jmp    1215 <exercicio_01+0xd5>
lea    -0xe(%rbp),%rdi
lea    -0x13(%rbp),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1288 <exercicio_01+0x148>
lea    -0x9(%rbp),%rsi
lea    0xe57(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    129a <exercicio_01+0x15a>
lea    -0x9(%rbp),%rsi
lea    0xe6c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<exercicio_01>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xf7d(%rip),%rdi
call   1040 <puts@plt>
lea    0xe80(%rip),%rdi
lea    0x1(%rsp),%rbx
mov    %rbx,%rsi
call   1080 <scanf@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
cmp    $0x5,%eax
je     11f5 <exercicio_01+0x95>
lea    0xe62(%rip),%r14
lea    0x1(%rsp),%rbx
lea    0xf65(%rip),%r15
lea    0xf3d(%rip),%r12
lea    0xe45(%rip),%r13
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r15,%rdi
call   1040 <puts@plt>
mov    %r12,%rdi
call   1040 <puts@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
call   1080 <scanf@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
cmp    $0x5,%eax
jne    11c0 <exercicio_01+0x60>
lea    0xe40(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
movsbl 0x1(%rsp),%edi
call   1030 <putchar@plt>
mov    0x1(%rsp),%al
mov    %al,0xb(%rsp)
movsbl 0x2(%rsp),%edi
call   1030 <putchar@plt>
mov    0x2(%rsp),%al
mov    %al,0xc(%rsp)
movsbl 0x3(%rsp),%edi
call   1030 <putchar@plt>
mov    0x3(%rsp),%al
mov    %al,0xd(%rsp)
movsbl 0x4(%rsp),%edi
call   1030 <putchar@plt>
mov    0x4(%rsp),%al
mov    %al,0xe(%rsp)
movsbl 0x5(%rsp),%edi
call   1030 <putchar@plt>
mov    0x5(%rsp),%al
mov    %al,0xf(%rsp)
lea    0xe04(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
movsbl 0x5(%rsp),%edi
call   1030 <putchar@plt>
mov    0x5(%rsp),%al
mov    %al,0x6(%rsp)
movsbl 0x4(%rsp),%edi
call   1030 <putchar@plt>
mov    0x4(%rsp),%al
mov    %al,0x7(%rsp)
movsbl 0x3(%rsp),%edi
call   1030 <putchar@plt>
mov    0x3(%rsp),%al
mov    %al,0x8(%rsp)
movsbl 0x2(%rsp),%edi
call   1030 <putchar@plt>
mov    0x2(%rsp),%al
mov    %al,0x9(%rsp)
movsbl 0x1(%rsp),%edi
call   1030 <putchar@plt>
mov    0x1(%rsp),%al
mov    %al,0xa(%rsp)
lea    0xb(%rsp),%rdi
lea    0x6(%rsp),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
lea    0xdb6(%rip),%rax
lea    0xddb(%rip),%rdi
cmove  %rax,%rdi
lea    0x1(%rsp),%rsi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [34 x i8] c"Digite uma palavra com 5 letras:\0A\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [57 x i8] c"\0AERRO: a palavra informada (%s) n\C3\A3o possui 5 letras!!!\0A\00"
@.str.3 = [26 x i8] c"\0AInforme-a novamente!!!\0A\0A\00"
@.str.4 = [44 x i8] c"\0AA palavra da: ESQUERDA para: DIREITA -> \00"
@.str.5 = [3 x i8] c"%c\00"
@.str.6 = [44 x i8] c"\0AA palavra da: DIREITA para: ESQUERDA -> \00"
@.str.7 = [44 x i8] c"\0A\0AA palavra informada (%s) \C3\A9 pal\C3\ADndroma!\0A\00"
@.str.8 = [49 x i8] c"\0A\0AA palavra informada (%s) N\C3\83O \C3\A9 pal\C3\ADndroma!\0A\00"
define i32 @exercicio_01() {
%1 = alloca i32
%2 = alloca [5 x i8]
%3 = alloca [5 x i8]
%4 = alloca [5 x i8]
br label %5
5: ; preds = %17, %0
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%7 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %7)
%9 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
%10 = call i32 @strlen(i8* %9)
%11 = icmp eq i32 %10, 5
br i1 %11, label %12, label %13
12: ; preds = %5
br label %18
13: ; preds = %5
%14 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.2, i64 0, i64 0), i8* %14)
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
br label %17
17: ; preds = %13
br i1 true, label %5, label %18
18: ; preds = %17, %12
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %1
br label %20
20: ; preds = %37, %18
%21 = load i32, i32* %1
%22 = icmp sle i32 %21, 4
br i1 %22, label %23, label %40
23: ; preds = %20
%24 = load i32, i32* %1
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 %25
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 %28)
%30 = load i32, i32* %1
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 %31
%33 = load i8, i8* %32
%34 = load i32, i32* %1
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 %35
store i8 %33, i8* %36
br label %37
37: ; preds = %23
%38 = load i32, i32* %1
%39 = add nsw i32 %38, 1
store i32 %39, i32* %1
br label %20
40: ; preds = %20
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.6, i64 0, i64 0))
store i32 4, i32* %1
br label %42
42: ; preds = %60, %40
%43 = load i32, i32* %1
%44 = icmp sge i32 %43, 0
br i1 %44, label %45, label %63
45: ; preds = %42
%46 = load i32, i32* %1
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 %47
%49 = load i8, i8* %48
%50 = sext i8 %49 to i32
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 %50)
%52 = load i32, i32* %1
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 %53
%55 = load i8, i8* %54
%56 = load i32, i32* %1
%57 = sub nsw i32 4, %56
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 %58
store i8 %55, i8* %59
br label %60
60: ; preds = %45
%61 = load i32, i32* %1
%62 = add nsw i32 %61, -1
store i32 %62, i32* %1
br label %42
63: ; preds = %42
%64 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%65 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 0
%66 = call i64 @strcmp(i8* %64, i8* %65)
%67 = icmp eq i64 %66, 0
br i1 %67, label %68, label %71
68: ; preds = %63
%69 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.7, i64 0, i64 0), i8* %69)
br label %74
71: ; preds = %63
%72 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.8, i64 0, i64 0), i8* %72)
br label %74
74: ; preds = %71, %68
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [57 x i8] c"\0AERRO: a palavra informada (%s) n\C3\A3o possui 5 letras!!!\0A\00"
@.str.4 = [44 x i8] c"\0AA palavra da: ESQUERDA para: DIREITA -> \00"
@.str.6 = [44 x i8] c"\0AA palavra da: DIREITA para: ESQUERDA -> \00"
@.str.7 = [44 x i8] c"\0A\0AA palavra informada (%s) \C3\A9 pal\C3\ADndroma!\0A\00"
@.str.8 = [49 x i8] c"\0A\0AA palavra informada (%s) N\C3\83O \C3\A9 pal\C3\ADndroma!\0A\00"
@str = [33 x i8] c"Digite uma palavra com 5 letras:\00"
@str.9 = [25 x i8] c"\0AInforme-a novamente!!!\0A\00"
define i32 @exercicio_01() {
%1 = alloca [5 x i8]
%2 = alloca [5 x i8]
%3 = alloca [5 x i8]
%4 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%9 = call i32 @strlen(i8* %4)
%10 = icmp eq i32 %9, 5
br i1 %10, label %18, label %11
11: ; preds = %0, %11
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @.str.2, i64 0, i64 0), i8* %4)
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.9, i64 0, i64 0))
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%16 = call i32 @strlen(i8* %4)
%17 = icmp eq i32 %16, 5
br i1 %17, label %18, label %11
18: ; preds = %11, %0
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.4, i64 0, i64 0))
%20 = load i8, i8* %4
%21 = sext i8 %20 to i32
%22 = call i32 @putchar(i32 %21)
%23 = load i8, i8* %4
store i8 %23, i8* %5
%24 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 1
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = call i32 @putchar(i32 %26)
%28 = load i8, i8* %24
%29 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 1
store i8 %28, i8* %29
%30 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 2
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = call i32 @putchar(i32 %32)
%34 = load i8, i8* %30
%35 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 2
store i8 %34, i8* %35
%36 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 3
%37 = load i8, i8* %36
%38 = sext i8 %37 to i32
%39 = call i32 @putchar(i32 %38)
%40 = load i8, i8* %36
%41 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 3
store i8 %40, i8* %41
%42 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 4
%43 = load i8, i8* %42
%44 = sext i8 %43 to i32
%45 = call i32 @putchar(i32 %44)
%46 = load i8, i8* %42
%47 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 4
store i8 %46, i8* %47
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.6, i64 0, i64 0))
%49 = load i8, i8* %42
%50 = sext i8 %49 to i32
%51 = call i32 @putchar(i32 %50)
%52 = load i8, i8* %42
store i8 %52, i8* %6
%53 = load i8, i8* %36
%54 = sext i8 %53 to i32
%55 = call i32 @putchar(i32 %54)
%56 = load i8, i8* %36
%57 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 1
store i8 %56, i8* %57
%58 = load i8, i8* %30
%59 = sext i8 %58 to i32
%60 = call i32 @putchar(i32 %59)
%61 = load i8, i8* %30
%62 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 2
store i8 %61, i8* %62
%63 = load i8, i8* %24
%64 = sext i8 %63 to i32
%65 = call i32 @putchar(i32 %64)
%66 = load i8, i8* %24
%67 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 3
store i8 %66, i8* %67
%68 = load i8, i8* %4
%69 = sext i8 %68 to i32
%70 = call i32 @putchar(i32 %69)
%71 = load i8, i8* %4
%72 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 4
store i8 %71, i8* %72
%73 = call i64 @strcmp(i8* %5, i8* %6)
%74 = icmp eq i64 %73, 0
%75 = select i1 %74, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.8, i64 0, i64 0)
%76 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %75, i8* %4)
ret i32 0
}