#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];
  printf("Insira uma palavra: ");
  scanf("%s", palavra);
  int tamanho = strlen(palavra);
  for (int i = 0; i < tamanho / 2; i++) {
    if (palavra[i] != palavra[tamanho - i - 1]) {
      printf("\nA palavra inserida nao eh um palindromo.");
      return 0;
    }
  }
  printf("\nA palavra inserida eh um palindromo.");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
call   1040 <printf@plt>
lea    -0x20(%rbp),%rsi
lea    0xebf(%rip),%rdi
call   1050 <scanf@plt>
lea    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x24(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
cmp    %ecx,%eax
jge    11d9 <main+0xa9>
movslq -0x28(%rbp),%rax
movsbl -0x20(%rbp,%rax,1),%eax
mov    -0x24(%rbp),%ecx
sub    -0x28(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl -0x20(%rbp,%rcx,1),%ecx
cmp    %ecx,%eax
je     11c6 <main+0x96>
lea    0xe63(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11e5 <main+0xb5>
jmp    11cb <main+0x9b>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    116e <main+0x3e>
lea    0xe62(%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    0xec4(%rip),%rdi
call   1040 <printf@plt>
lea    0xecd(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
call   1050 <scanf@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
lea    0xee0(%rip),%rdi
cmp    $0x2,%eax
jl     119d <main+0x6d>
mov    %eax,%ecx
shr    %ecx
add    $0xffffffff,%eax
xor    %edx,%edx
lea    0xea1(%rip),%r8
nopw   0x0(%rax,%rax,1)
movzbl (%rsp,%rdx,1),%ebx
movslq %eax,%rsi
cmp    (%rsp,%rsi,1),%bl
jne    119a <main+0x6a>
add    $0x1,%rdx
add    $0xffffffff,%eax
cmp    %rdx,%rcx
jne    1180 <main+0x50>
jmp    119d <main+0x6d>
mov    %r8,%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [21 x i8] c"Insira uma palavra: \00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [42 x i8] c"\0AA palavra inserida nao eh um palindromo.\00"
@.str.3 = [38 x i8] c"\0AA palavra inserida eh um palindromo.\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [20 x i8]
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%6 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%8 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%9 = call i32 @strlen(i8* %8)
store i32 %9, i32* %3
store i32 0, i32* %4
br label %10
10: ; preds = %33, %0
%11 = load i32, i32* %4
%12 = load i32, i32* %3
%13 = sdiv i32 %12, 2
%14 = icmp slt i32 %11, %13
br i1 %14, label %15, label %36
15: ; preds = %10
%16 = load i32, i32* %4
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 %17
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = load i32, i32* %3
%22 = load i32, i32* %4
%23 = sub nsw i32 %21, %22
%24 = sub nsw i32 %23, 1
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 %25
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp ne i32 %20, %28
br i1 %29, label %30, label %32
30: ; preds = %15
%31 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %1
br label %38
32: ; preds = %15
br label %33
33: ; preds = %32
%34 = load i32, i32* %4
%35 = add nsw i32 %34, 1
store i32 %35, i32* %4
br label %10
36: ; preds = %10
%37 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0))
br label %38
38: ; preds = %36, %30
%39 = load i32, i32* %1
ret i32 %39
}

LLVM IR (-O2):
@.str = [21 x i8] c"Insira uma palavra: \00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [42 x i8] c"\0AA palavra inserida nao eh um palindromo.\00"
@.str.3 = [38 x i8] c"\0AA palavra inserida eh um palindromo.\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 ([21 x i8], [21 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 @strlen(i8* %2)
%6 = icmp sgt i32 %5, 1
br i1 %6, label %7, label %24
7: ; preds = %0
%8 = lshr i32 %5, 1
%9 = zext i32 %8 to i64
br label %12
10: ; preds = %12
%11 = icmp eq i64 %23, %9
br i1 %11, label %24, label %12
12: ; preds = %7, %10
%13 = phi i64 [ 0, %7 ], [ %23, %10 ]
%14 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 %13
%15 = load i8, i8* %14
%16 = trunc i64 %13 to i32
%17 = xor i32 %16, -1
%18 = add i32 %5, %17
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 %19
%21 = load i8, i8* %20
%22 = icmp eq i8 %15, %21
%23 = add nuw nsw i64 %13, 1
br i1 %22, label %10, label %24
24: ; preds = %10, %12, %0
%25 = phi i8* [ getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), %0 ], [ getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0), %12 ], [ getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), %10 ]
%26 = call i32 @printf(i8* dereferenceable(1) %25)
ret i32 0
}