#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_05(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\nInforme-a novamente!!!\n\n",
           palavra);
  } 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_05>:
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_05+0x3d>
jmp    119e <exercicio_05+0x5e>
lea    -0x9(%rbp),%rsi
lea    0xe9d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%al
test   $0x1,%al
jne    1148 <exercicio_05+0x8>
jmp    119e <exercicio_05+0x5e>
lea    0xed2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
cmpl   $0x4,-0x4(%rbp)
jg     11f2 <exercicio_05+0xb2>
movslq -0x4(%rbp),%rax
movsbl -0x9(%rbp,%rax,1),%esi
lea    0xed6(%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    11b3 <exercicio_05+0x73>
lea    0xead(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x4,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jl     124c <exercicio_05+0x10c>
movslq -0x4(%rbp),%rax
movsbl -0x9(%rbp,%rax,1),%esi
lea    0xe82(%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    1207 <exercicio_05+0xc7>
lea    -0xe(%rbp),%rdi
lea    -0x13(%rbp),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    127a <exercicio_05+0x13a>
lea    -0x9(%rbp),%rsi
lea    0xe64(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    128c <exercicio_05+0x14c>
lea    -0x9(%rbp),%rsi
lea    0xe79(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<exercicio_05>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xf98(%rip),%rdi
call   1040 <puts@plt>
lea    0xe82(%rip),%rdi
lea    0x9(%rsp),%rbx
mov    %rbx,%rsi
call   1080 <scanf@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
cmp    $0x5,%eax
je     11ed <exercicio_05+0x8d>
lea    0xe64(%rip),%r14
lea    0x9(%rsp),%rbx
lea    0xf5f(%rip),%r15
lea    0xe4e(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r15,%rdi
call   1040 <puts@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1080 <scanf@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
cmp    $0x5,%eax
jne    11c0 <exercicio_05+0x60>
lea    0xe61(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
movsbl 0x9(%rsp),%edi
call   1030 <putchar@plt>
mov    0x9(%rsp),%al
mov    %al,0x13(%rsp)
movsbl 0xa(%rsp),%edi
call   1030 <putchar@plt>
mov    0xa(%rsp),%al
mov    %al,0x14(%rsp)
movsbl 0xb(%rsp),%edi
call   1030 <putchar@plt>
mov    0xb(%rsp),%al
mov    %al,0x15(%rsp)
movsbl 0xc(%rsp),%edi
call   1030 <putchar@plt>
mov    0xc(%rsp),%al
mov    %al,0x16(%rsp)
movsbl 0xd(%rsp),%edi
call   1030 <putchar@plt>
mov    0xd(%rsp),%al
mov    %al,0x17(%rsp)
lea    0xe25(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
movsbl 0xd(%rsp),%edi
call   1030 <putchar@plt>
mov    0xd(%rsp),%al
mov    %al,0xe(%rsp)
movsbl 0xc(%rsp),%edi
call   1030 <putchar@plt>
mov    0xc(%rsp),%al
mov    %al,0xf(%rsp)
movsbl 0xb(%rsp),%edi
call   1030 <putchar@plt>
mov    0xb(%rsp),%al
mov    %al,0x10(%rsp)
movsbl 0xa(%rsp),%edi
call   1030 <putchar@plt>
mov    0xa(%rsp),%al
mov    %al,0x11(%rsp)
movsbl 0x9(%rsp),%edi
call   1030 <putchar@plt>
mov    0x9(%rsp),%al
mov    %al,0x12(%rsp)
lea    0x13(%rsp),%rdi
lea    0xe(%rsp),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
lea    0xdd7(%rip),%rax
lea    0xdfc(%rip),%rdi
cmove  %rax,%rdi
lea    0x9(%rsp),%rsi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
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 = [82 x i8] c"\0AERRO: a palavra informada (%s) n\C3\A3o possui 5 letras!!!\0A\0AInforme-a novamente!!!\0A\0A\00"
@.str.3 = [44 x i8] c"\0AA palavra da: ESQUERDA para: DIREITA -> \00"
@.str.4 = [3 x i8] c"%c\00"
@.str.5 = [44 x i8] c"\0AA palavra da: DIREITA para: ESQUERDA -> \00"
@.str.6 = [44 x i8] c"\0A\0AA palavra informada (%s) \C3\A9 pal\C3\ADndroma!\0A\00"
@.str.7 = [49 x i8] c"\0A\0AA palavra informada (%s) N\C3\83O \C3\A9 pal\C3\ADndroma!\0A\00"
define i32 @exercicio_05() {
%1 = alloca i32
%2 = alloca [5 x i8]
%3 = alloca [5 x i8]
%4 = alloca [5 x i8]
br label %5
5: ; preds = %16, %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 %17
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 ([82 x i8], [82 x i8]* @.str.2, i64 0, i64 0), i8* %14)
br label %16
16: ; preds = %13
br i1 true, label %5, label %17
17: ; preds = %16, %12
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %1
br label %19
19: ; preds = %36, %17
%20 = load i32, i32* %1
%21 = icmp sle i32 %20, 4
br i1 %21, label %22, label %39
22: ; preds = %19
%23 = load i32, i32* %1
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 %24
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %27)
%29 = load i32, i32* %1
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 %30
%32 = load i8, i8* %31
%33 = load i32, i32* %1
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 %34
store i8 %32, i8* %35
br label %36
36: ; preds = %22
%37 = load i32, i32* %1
%38 = add nsw i32 %37, 1
store i32 %38, i32* %1
br label %19
39: ; preds = %19
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.5, i64 0, i64 0))
store i32 4, i32* %1
br label %41
41: ; preds = %59, %39
%42 = load i32, i32* %1
%43 = icmp sge i32 %42, 0
br i1 %43, label %44, label %62
44: ; preds = %41
%45 = load i32, i32* %1
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 %46
%48 = load i8, i8* %47
%49 = sext i8 %48 to i32
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %49)
%51 = load i32, i32* %1
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 %52
%54 = load i8, i8* %53
%55 = load i32, i32* %1
%56 = sub nsw i32 4, %55
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 %57
store i8 %54, i8* %58
br label %59
59: ; preds = %44
%60 = load i32, i32* %1
%61 = add nsw i32 %60, -1
store i32 %61, i32* %1
br label %41
62: ; preds = %41
%63 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%64 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 0
%65 = call i64 @strcmp(i8* %63, i8* %64)
%66 = icmp eq i64 %65, 0
br i1 %66, label %67, label %70
67: ; preds = %62
%68 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.6, i64 0, i64 0), i8* %68)
br label %73
70: ; preds = %62
%71 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.7, i64 0, i64 0), i8* %71)
br label %73
73: ; preds = %70, %67
ret i32 0
}

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