#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 palavra[20];
  int i, j, tam, palindromo = 0;
  printf("\nEntre com a palavra: ");
  scanf("%s", palavra);
  printf("\n");
  tam = strlen(palavra);
  j = tam - 1;
  for (i = 0; i < tam; i++) {
    if (palavra[i] == palavra[j])
      palindromo++;
    j--;
  }
  if (palindromo == tam)
    printf("\n%s é um palindromo.", palavra);
  else
    printf("\n%s NÃO é um palíndromo", palavra);
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x30(%rbp)
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x20(%rbp),%rsi
lea    0xeb8(%rip),%rdi
call   1050 <scanf@plt>
lea    0xeaf(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x28(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    11d4 <main+0xa4>
movslq -0x24(%rbp),%rax
movsbl -0x20(%rbp,%rax,1),%eax
movslq -0x28(%rbp),%rcx
movsbl -0x20(%rbp,%rcx,1),%ecx
cmp    %ecx,%eax
jne    11bd <main+0x8d>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
mov    -0x28(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x28(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    118e <main+0x5e>
mov    -0x30(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jne    11f7 <main+0xc7>
lea    -0x20(%rbp),%rsi
lea    0xe31(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1209 <main+0xd9>
lea    -0x20(%rbp),%rsi
lea    0xe30(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe0a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
lea    0xec3(%rip),%rdi
xor    %ebp,%ebp
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xeca(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
call   1060 <scanf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jle    127a <main+0x13a>
mov    %eax,%edx
cmp    $0x8,%eax
jae    1196 <main+0x56>
xor    %r8d,%r8d
mov    %rdx,%rsi
xor    %ebp,%ebp
jmp    124e <main+0x10e>
mov    %edx,%r8d
and    $0xfffffff8,%r8d
mov    %rdx,%rsi
sub    %r8,%rsi
lea    (%rdx,%rbx,1),%rdi
add    $0xfffffffffffffffc,%rdi
pxor   %xmm0,%xmm0
xor    %ebp,%ebp
movdqa 0xe47(%rip),%xmm2
pxor   %xmm1,%xmm1
nopl   (%rax)
movq   (%rsp,%rbp,1),%xmm3
punpcklbw %xmm3,%xmm3
punpcklwd %xmm3,%xmm3
movd   0x4(%rsp,%rbp,1),%xmm4
punpcklbw %xmm4,%xmm4
punpcklwd %xmm4,%xmm4
movd   (%rdi),%xmm5
punpcklbw %xmm5,%xmm5
movd   -0x4(%rdi),%xmm6
punpcklbw %xmm6,%xmm6
pshufd $0xc4,%xmm5,%xmm5
pshuflw $0xe7,%xmm5,%xmm5
pshufhw $0xc5,%xmm5,%xmm5
pcmpeqb %xmm3,%xmm5
pand   %xmm2,%xmm5
paddd  %xmm5,%xmm0
pshufd $0xc4,%xmm6,%xmm3
pshuflw $0xe7,%xmm3,%xmm3
pshufhw $0xc5,%xmm3,%xmm3
pcmpeqb %xmm4,%xmm3
pand   %xmm2,%xmm3
paddd  %xmm3,%xmm1
add    $0x8,%rbp
add    $0xfffffffffffffff8,%rdi
cmp    %rbp,%r8
jne    11c0 <main+0x80>
paddd  %xmm0,%xmm1
pshufd $0xee,%xmm1,%xmm0
paddd  %xmm1,%xmm0
pshufd $0x55,%xmm0,%xmm1
paddd  %xmm0,%xmm1
movd   %xmm1,%ebp
cmp    %rdx,%r8
je     127a <main+0x13a>
lea    (%rsp,%r8,1),%rdi
sub    %rdx,%r8
lea    (%rsi,%rbx,1),%rdx
add    $0xffffffffffffffff,%rdx
xor    %esi,%esi
nop
movzbl (%rdi),%ebx
xor    %ecx,%ecx
cmp    (%rdx,%rsi,1),%bl
sete   %cl
add    %ecx,%ebp
add    $0x1,%rdi
add    $0xffffffffffffffff,%rsi
cmp    %rsi,%r8
jne    1260 <main+0x120>
cmp    %eax,%ebp
lea    0xda7(%rip),%rax
lea    0xdb6(%rip),%rdi
cmove  %rax,%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [23 x i8] c"\0AEntre com a palavra: \00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [22 x i8] c"\0A%s \C3\A9 um palindromo.\00"
@.str.4 = [27 x i8] c"\0A%s N\C3\83O \C3\A9 um pal\C3\ADndromo\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [20 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %6
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%8 = getelementptr inbounds [20 x i8], [20 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 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%11 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%12 = call i32 @strlen(i8* %11)
store i32 %12, i32* %5
%13 = load i32, i32* %5
%14 = sub nsw i32 %13, 1
store i32 %14, i32* %4
store i32 0, i32* %3
br label %15
15: ; preds = %37, %0
%16 = load i32, i32* %3
%17 = load i32, i32* %5
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %40
19: ; preds = %15
%20 = load i32, i32* %3
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 %21
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = load i32, i32* %4
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 %26
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = icmp eq i32 %24, %29
br i1 %30, label %31, label %34
31: ; preds = %19
%32 = load i32, i32* %6
%33 = add nsw i32 %32, 1
store i32 %33, i32* %6
br label %34
34: ; preds = %31, %19
%35 = load i32, i32* %4
%36 = add nsw i32 %35, -1
store i32 %36, i32* %4
br label %37
37: ; preds = %34
%38 = load i32, i32* %3
%39 = add nsw i32 %38, 1
store i32 %39, i32* %3
br label %15
40: ; preds = %15
%41 = load i32, i32* %6
%42 = load i32, i32* %5
%43 = icmp eq i32 %41, %42
br i1 %43, label %44, label %47
44: ; preds = %40
%45 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* %45)
br label %50
47: ; preds = %40
%48 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i8* %48)
br label %50
50: ; preds = %47, %44
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [23 x i8] c"\0AEntre com a palavra: \00"
@.str.1 = [3 x i8] c"%s\00"
@.str.3 = [22 x i8] c"\0A%s \C3\A9 um palindromo.\00"
@.str.4 = [27 x i8] c"\0A%s N\C3\83O \C3\A9 um pal\C3\ADndromo\00"
define i32 @main() {
%1 = alloca [20 x i8]
%2 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%5 = call i32 @putchar(i32 10)
%6 = call i32 @strlen(i8* %2)
%7 = icmp sgt i32 %6, 0
br i1 %7, label %8, label %66
8: ; preds = %0
%9 = zext i32 %6 to i64
%10 = zext i32 %6 to i64
%11 = icmp ult i32 %6, 8
br i1 %11, label %48, label %12
12: ; preds = %8
%13 = and i64 %10, 4294967288
%14 = sub nsw i64 %9, %13
br label %15
15: ; preds = %15, %12
%16 = phi i64 [ 0, %12 ], [ %42, %15 ]
%17 = phi <4 x i32> [ zeroinitializer, %12 ], [ %40, %15 ]
%18 = phi <4 x i32> [ zeroinitializer, %12 ], [ %41, %15 ]
%19 = xor i64 %16, -1
%20 = add i64 %19, %9
%21 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 %16
%22 = bitcast i8* %21 to <4 x i8>*
%23 = load <4 x i8>, <4 x i8>* %22
%24 = getelementptr inbounds i8, i8* %21, i64 4
%25 = bitcast i8* %24 to <4 x i8>*
%26 = load <4 x i8>, <4 x i8>* %25
%27 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 %20
%28 = getelementptr inbounds i8, i8* %27, i64 -3
%29 = bitcast i8* %28 to <4 x i8>*
%30 = load <4 x i8>, <4 x i8>* %29
%31 = shufflevector <4 x i8> %30, <4 x i8> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>
%32 = getelementptr inbounds i8, i8* %27, i64 -7
%33 = bitcast i8* %32 to <4 x i8>*
%34 = load <4 x i8>, <4 x i8>* %33
%35 = shufflevector <4 x i8> %34, <4 x i8> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>
%36 = icmp eq <4 x i8> %23, %31
%37 = icmp eq <4 x i8> %26, %35
%38 = zext <4 x i1> %36 to <4 x i32>
%39 = zext <4 x i1> %37 to <4 x i32>
%40 = add <4 x i32> %17, %38
%41 = add <4 x i32> %18, %39
%42 = add nuw i64 %16, 8
%43 = icmp eq i64 %42, %13
br i1 %43, label %44, label %15
44: ; preds = %15
%45 = add <4 x i32> %41, %40
%46 = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %45)
%47 = icmp eq i64 %13, %10
br i1 %47, label %66, label %48
48: ; preds = %8, %44
%49 = phi i64 [ 0, %8 ], [ %13, %44 ]
%50 = phi i64 [ %9, %8 ], [ %14, %44 ]
%51 = phi i32 [ 0, %8 ], [ %46, %44 ]
br label %52
52: ; preds = %48, %52
%53 = phi i64 [ %64, %52 ], [ %49, %48 ]
%54 = phi i64 [ %56, %52 ], [ %50, %48 ]
%55 = phi i32 [ %63, %52 ], [ %51, %48 ]
%56 = add nsw i64 %54, -1
%57 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 %53
%58 = load i8, i8* %57
%59 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 %56
%60 = load i8, i8* %59
%61 = icmp eq i8 %58, %60
%62 = zext i1 %61 to i32
%63 = add nuw nsw i32 %55, %62
%64 = add nuw nsw i64 %53, 1
%65 = icmp eq i64 %64, %10
br i1 %65, label %66, label %52
66: ; preds = %52, %44, %0
%67 = phi i32 [ 0, %0 ], [ %46, %44 ], [ %63, %52 ]
%68 = icmp eq i32 %67, %6
%69 = select i1 %68, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0)
%70 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %69, i8* %2)
%71 = call i32 @putchar(i32 10)
ret i32 0
}