#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 *);
void main() {
  char palavra[20];
  printf("Informe a palavra de no maximo 20 caracteres: ");
  scanf("%s", palavra);
  int len = strlen(palavra);
  int flg = 1;
  for (int i = 0; i < (int)(len / 2); i++) {
    if (palavra[i] != palavra[(len - 1) - i]) {
      flg = 0;
      break;
    }
  }
  if (flg == 1) {
    printf("A palavra %s eh um palindromo!\n", palavra);
  } else {
    printf("A palavra %s nao eh um palindromo!\n", palavra);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
lea    0xec1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x20(%rbp),%rsi
lea    0xede(%rip),%rdi
call   1050 <scanf@plt>
lea    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x24(%rbp)
movl   $0x1,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x24(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x30(%rbp),%eax
cmp    %ecx,%eax
jge    11cf <main+0x9f>
movslq -0x2c(%rbp),%rax
movsbl -0x20(%rbp,%rax,1),%eax
mov    -0x24(%rbp),%ecx
sub    $0x1,%ecx
sub    -0x2c(%rbp),%ecx
movslq %ecx,%rcx
movsbl -0x20(%rbp,%rcx,1),%ecx
cmp    %ecx,%eax
je     11bc <main+0x8c>
movl   $0x0,-0x28(%rbp)
jmp    11cf <main+0x9f>
jmp    11c1 <main+0x91>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1170 <main+0x40>
cmpl   $0x1,-0x28(%rbp)
jne    11f0 <main+0xc0>
lea    -0x20(%rbp),%rsi
lea    0xe4e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1202 <main+0xd2>
lea    -0x20(%rbp),%rsi
lea    0xe57(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
lea    0xec4(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xee5(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
call   1050 <scanf@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
lea    0xece(%rip),%rdi
cmp    $0x2,%eax
jl     119d <main+0x6d>
mov    %eax,%ecx
shr    %ecx
add    $0xffffffff,%eax
xor    %edx,%edx
lea    0xed9(%rip),%r8
nopl   0x0(%rax)
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
mov    %rsp,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [47 x i8] c"Informe a palavra de no maximo 20 caracteres: \00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [32 x i8] c"A palavra %s eh um palindromo!\0A\00"
@.str.3 = [36 x i8] c"A palavra %s nao eh um palindromo!\0A\00"
define void @main() {
%1 = alloca [20 x i8]
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0))
%6 = getelementptr inbounds [20 x i8], [20 x i8]* %1, 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]* %1, i64 0, i64 0
%9 = call i32 @strlen(i8* %8)
store i32 %9, i32* %2
store i32 1, i32* %3
store i32 0, i32* %4
br label %10
10: ; preds = %32, %0
%11 = load i32, i32* %4
%12 = load i32, i32* %2
%13 = sdiv i32 %12, 2
%14 = icmp slt i32 %11, %13
br i1 %14, label %15, label %35
15: ; preds = %10
%16 = load i32, i32* %4
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 %17
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = load i32, i32* %2
%22 = sub nsw i32 %21, 1
%23 = load i32, i32* %4
%24 = sub nsw i32 %22, %23
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [20 x i8], [20 x i8]* %1, 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 %31
30: ; preds = %15
store i32 0, i32* %3
br label %35
31: ; preds = %15
br label %32
32: ; preds = %31
%33 = load i32, i32* %4
%34 = add nsw i32 %33, 1
store i32 %34, i32* %4
br label %10
35: ; preds = %30, %10
%36 = load i32, i32* %3
%37 = icmp eq i32 %36, 1
br i1 %37, label %38, label %41
38: ; preds = %35
%39 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i8* %39)
br label %44
41: ; preds = %35
%42 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0), i8* %42)
br label %44
44: ; preds = %41, %38
ret void
}

LLVM IR (-O2):
@.str = [47 x i8] c"Informe a palavra de no maximo 20 caracteres: \00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [32 x i8] c"A palavra %s eh um palindromo!\0A\00"
@.str.3 = [36 x i8] c"A palavra %s nao eh um palindromo!\0A\00"
define void @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 ([47 x i8], [47 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 = %12, %10, %0
%25 = phi i8* [ getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), %0 ], [ getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), %10 ], [ getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0), %12 ]
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %25, i8* %2)
ret void
}