#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*/ gets(char *);
int /*<<< orphan*/ printf(char *);
int strlen(char *);
main() {
  char palavra[20];
  int i = 0, j, pali = 1;
  printf("Entre com uma palavra: ");
  gets(palavra);
  j = strlen(palavra) - 1;
  while ((i < j) && (pali)) {
    if (palavra[i] != palavra[j])
      pali = 0;
    else {
      i++;
      j--;
    }
  }
  if (pali)
    printf("A palavra e palindrome\n");
  else
    printf("A palavra nao e palindrome\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x1,-0x2c(%rbp)
lea    0xeac(%rip),%rdi
call   1040 <printf@plt>
lea    -0x20(%rbp),%rdi
call   1050 <gets@plt>
lea    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
sub    $0x1,%eax
mov    %eax,-0x28(%rbp)
mov    -0x24(%rbp),%ecx
xor    %eax,%eax
cmp    -0x28(%rbp),%ecx
mov    %al,-0x2d(%rbp)
jge    118c <main+0x5c>
cmpl   $0x0,-0x2c(%rbp)
setne  %al
mov    %al,-0x2d(%rbp)
mov    -0x2d(%rbp),%al
test   $0x1,%al
jne    119c <main+0x6c>
jmp    11d9 <main+0xa9>
movslq -0x24(%rbp),%rax
movsbl -0x20(%rbp,%rax,1),%eax
movslq -0x28(%rbp),%rcx
movsbl -0x20(%rbp,%rcx,1),%ecx
cmp    %ecx,%eax
je     11c2 <main+0x92>
movl   $0x0,-0x2c(%rbp)
jmp    11d4 <main+0xa4>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x28(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x28(%rbp)
jmp    1171 <main+0x41>
cmpl   $0x0,-0x2c(%rbp)
je     11f4 <main+0xc4>
lea    0xe2e(%rip),%rdi
call   1040 <printf@plt>
jmp    1200 <main+0xd0>
lea    0xe35(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
lea    0xeb4(%rip),%rdi
call   1050 <printf@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1060 <gets@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cmp    $0x2,%eax
jl     11a6 <main+0x66>
add    $0xffffffff,%eax
xor    %ecx,%ecx
xchg   %ax,%ax
mov    %ecx,%edx
movzbl (%rsp,%rdx,1),%edx
cltq
movzbl (%rsp,%rax,1),%ebx
xor    %esi,%esi
cmp    %bl,%dl
sete   %sil
add    %esi,%ecx
sub    %esi,%eax
cmp    %eax,%ecx
jge    1190 <main+0x50>
cmp    %bl,%dl
je     1170 <main+0x30>
cmp    %bl,%dl
lea    0xe9a(%rip),%rax
lea    0xe78(%rip),%rdi
cmove  %rax,%rdi
jmp    11ad <main+0x6d>
lea    0xe86(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [24 x i8] c"Entre com uma palavra: \00"
@.str.1 = [24 x i8] c"A palavra e palindrome\0A\00"
@.str.2 = [28 x i8] c"A palavra nao e palindrome\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [20 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
store i32 1, i32* %5
%6 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%7 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%8 = call i32 @gets(i8* %7)
%9 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%10 = call i32 @strlen(i8* %9)
%11 = sub nsw i32 %10, 1
store i32 %11, i32* %4
br label %12
12: ; preds = %39, %0
%13 = load i32, i32* %3
%14 = load i32, i32* %4
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %19
16: ; preds = %12
%17 = load i32, i32* %5
%18 = icmp ne i32 %17, 0
br label %19
19: ; preds = %16, %12
%20 = phi i1 [ false, %12 ], [ %18, %16 ]
br i1 %20, label %21, label %40
21: ; preds = %19
%22 = load i32, i32* %3
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 %23
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = load i32, i32* %4
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 %28
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp ne i32 %26, %31
br i1 %32, label %33, label %34
33: ; preds = %21
store i32 0, i32* %5
br label %39
34: ; preds = %21
%35 = load i32, i32* %3
%36 = add nsw i32 %35, 1
store i32 %36, i32* %3
%37 = load i32, i32* %4
%38 = add nsw i32 %37, -1
store i32 %38, i32* %4
br label %39
39: ; preds = %34, %33
br label %12
40: ; preds = %19
%41 = load i32, i32* %5
%42 = icmp ne i32 %41, 0
br i1 %42, label %43, label %45
43: ; preds = %40
%44 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
br label %47
45: ; preds = %40
%46 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
br label %47
47: ; preds = %45, %43
%48 = load i32, i32* %1
ret i32 %48
}

LLVM IR (-O2):
@.str = [24 x i8] c"Entre com uma palavra: \00"
@str = [27 x i8] c"A palavra nao e palindrome\00"
@str.3 = [23 x i8] c"A palavra e palindrome\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 @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @gets(i8* %2)
%5 = call i32 @strlen(i8* %2)
%6 = icmp sgt i32 %5, 1
br i1 %6, label %7, label %27
7: ; preds = %0
%8 = add nsw i32 %5, -1
br label %9
9: ; preds = %7, %9
%10 = phi i32 [ %22, %9 ], [ %8, %7 ]
%11 = phi i32 [ %20, %9 ], [ 0, %7 ]
%12 = zext i32 %11 to i64
%13 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 %12
%14 = load i8, i8* %13
%15 = sext i32 %10 to i64
%16 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 %15
%17 = load i8, i8* %16
%18 = icmp eq i8 %14, %17
%19 = zext i1 %18 to i32
%20 = add nuw nsw i32 %11, %19
%21 = sext i1 %18 to i32
%22 = add nsw i32 %10, %21
%23 = icmp slt i32 %20, %22
%24 = and i1 %23, %18
br i1 %24, label %9, label %25
25: ; preds = %9
%26 = select i1 %18, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @str.3, i64 0, i64 0), i8* getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0)
br label %27
27: ; preds = %25, %0
%28 = phi i8* [ getelementptr inbounds ([23 x i8], [23 x i8]* @str.3, i64 0, i64 0), %0 ], [ %26, %25 ]
%29 = call i32 @puts(i8* dereferenceable(1) %28)
ret i32 0
}