#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 main(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):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0xd(%rbp),%rsi
lea    0xeba(%rip),%rdi
call   1060 <scanf@plt>
lea    -0xd(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x5,%eax
jne    1184 <main+0x44>
jmp    11a5 <main+0x65>
lea    -0xd(%rbp),%rsi
lea    0xe96(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%al
test   $0x1,%al
jne    114f <main+0xf>
jmp    11a5 <main+0x65>
lea    0xecb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x4,-0x8(%rbp)
jg     11f9 <main+0xb9>
movslq -0x8(%rbp),%rax
movsbl -0xd(%rbp,%rax,1),%esi
lea    0xecf(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movslq -0x8(%rbp),%rax
mov    -0xd(%rbp,%rax,1),%cl
movslq -0x8(%rbp),%rax
mov    %cl,-0x12(%rbp,%rax,1)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11ba <main+0x7a>
lea    0xea6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x4,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jl     1253 <main+0x113>
movslq -0x8(%rbp),%rax
movsbl -0xd(%rbp,%rax,1),%esi
lea    0xe7b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movslq -0x8(%rbp),%rax
mov    -0xd(%rbp,%rax,1),%cl
mov    $0x4,%eax
sub    -0x8(%rbp),%eax
cltq
mov    %cl,-0x17(%rbp,%rax,1)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
jmp    120e <main+0xce>
lea    -0x12(%rbp),%rdi
lea    -0x17(%rbp),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1281 <main+0x141>
lea    -0xd(%rbp),%rsi
lea    0xe5d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1293 <main+0x153>
lea    -0xd(%rbp),%rsi
lea    0xe72(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
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 <main+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 <main+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 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [5 x i8]
%4 = alloca [5 x i8]
%5 = alloca [5 x i8]
store i32 0, i32* %1
br label %6
6: ; preds = %17, %0
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%8 = getelementptr inbounds [5 x i8], [5 x i8]* %3, 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 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%11 = call i32 @strlen(i8* %10)
%12 = icmp eq i32 %11, 5
br i1 %12, label %13, label %14
13: ; preds = %6
br label %18
14: ; preds = %6
%15 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([82 x i8], [82 x i8]* @.str.2, i64 0, i64 0), i8* %15)
br label %17
17: ; preds = %14
br i1 true, label %6, label %18
18: ; preds = %17, %13
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %2
br label %20
20: ; preds = %37, %18
%21 = load i32, i32* %2
%22 = icmp sle i32 %21, 4
br i1 %22, label %23, label %40
23: ; preds = %20
%24 = load i32, i32* %2
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [5 x i8], [5 x i8]* %3, 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.4, i64 0, i64 0), i32 %28)
%30 = load i32, i32* %2
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 %31
%33 = load i8, i8* %32
%34 = load i32, i32* %2
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 %35
store i8 %33, i8* %36
br label %37
37: ; preds = %23
%38 = load i32, i32* %2
%39 = add nsw i32 %38, 1
store i32 %39, i32* %2
br label %20
40: ; preds = %20
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.5, i64 0, i64 0))
store i32 4, i32* %2
br label %42
42: ; preds = %60, %40
%43 = load i32, i32* %2
%44 = icmp sge i32 %43, 0
br i1 %44, label %45, label %63
45: ; preds = %42
%46 = load i32, i32* %2
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds [5 x i8], [5 x i8]* %3, 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.4, i64 0, i64 0), i32 %50)
%52 = load i32, i32* %2
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 %53
%55 = load i8, i8* %54
%56 = load i32, i32* %2
%57 = sub nsw i32 4, %56
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds [5 x i8], [5 x i8]* %5, i64 0, i64 %58
store i8 %55, i8* %59
br label %60
60: ; preds = %45
%61 = load i32, i32* %2
%62 = add nsw i32 %61, -1
store i32 %62, i32* %2
br label %42
63: ; preds = %42
%64 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 0
%65 = getelementptr inbounds [5 x i8], [5 x i8]* %5, 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]* %3, i64 0, i64 0
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.6, i64 0, i64 0), i8* %69)
br label %74
71: ; preds = %63
%72 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.7, 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 = [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 @main() {
%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
}