#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[30], continuar;
  int tamanho_texto, tamanho_texto1, tamanho_texto2, j, i;
  printf("Digite a palavra\n");
  scanf("%s", palavra);
  tamanho_texto = strlen(palavra);
  for (i = 0, j = tamanho_texto - 1; i < tamanho_texto / 2; i++, j--) {
    if (palavra[i] != palavra[j]) {
      printf("Nao é um palindromo\n");
    } else {
      printf("É um palindromo\n");
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
call   1040 <printf@plt>
lea    -0x30(%rbp),%rsi
lea    0xebc(%rip),%rdi
call   1050 <scanf@plt>
lea    -0x30(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x38(%rbp)
movl   $0x0,-0x48(%rbp)
mov    -0x38(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x44(%rbp)
mov    -0x48(%rbp),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x38(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x4c(%rbp),%eax
cmp    %ecx,%eax
jge    11e8 <main+0xb8>
movslq -0x48(%rbp),%rax
movsbl -0x30(%rbp,%rax,1),%eax
movslq -0x44(%rbp),%rcx
movsbl -0x30(%rbp,%rcx,1),%ecx
cmp    %ecx,%eax
je     11c0 <main+0x90>
lea    0xe5f(%rip),%rdi
call   1040 <printf@plt>
jmp    11cc <main+0x9c>
lea    0xe64(%rip),%rdi
call   1040 <printf@plt>
jmp    11d1 <main+0xa1>
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
mov    -0x44(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x44(%rbp)
jmp    1177 <main+0x47>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
lea    0xebe(%rip),%rdi
call   1030 <puts@plt>
lea    0xeaf(%rip),%rdi
mov    %rsp,%r12
mov    %r12,%rsi
call   1050 <scanf@plt>
mov    %r12,%rdi
call   1040 <strlen@plt>
cmp    $0x2,%eax
jl     11b5 <main+0x85>
mov    %eax,%r14d
mov    %eax,%eax
shr    %r14d
neg    %r14
lea    (%rax,%r12,1),%r15
add    $0xffffffffffffffff,%r15
xor    %ebx,%ebx
lea    0xe8f(%rip),%r13
lea    0xe99(%rip),%rbp
jmp    11a2 <main+0x72>
xchg   %ax,%ax
call   1030 <puts@plt>
add    $0x1,%r12
add    $0xffffffffffffffff,%rbx
cmp    %rbx,%r14
je     11b5 <main+0x85>
movzbl (%r12),%eax
mov    %r13,%rdi
cmp    (%r15,%rbx,1),%al
je     1190 <main+0x60>
mov    %rbp,%rdi
jmp    1190 <main+0x60>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%s\00"
@str = [17 x i8] c"Digite a palavra\00"
@str.4 = [17 x i8] c"\C3\89 um palindromo\00"
@str.5 = [21 x i8] c"Nao \C3\A9 um palindromo\00"
define i32 @main() {
%1 = alloca [30 x i8]
%2 = getelementptr inbounds [30 x i8], [30 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 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 %5 to i64
%10 = zext i32 %8 to i64
br label %11
11: ; preds = %7, %11
%12 = phi i64 [ 0, %7 ], [ %22, %11 ]
%13 = phi i64 [ %9, %7 ], [ %14, %11 ]
%14 = add nsw i64 %13, -1
%15 = getelementptr inbounds [30 x i8], [30 x i8]* %1, i64 0, i64 %12
%16 = load i8, i8* %15
%17 = getelementptr inbounds [30 x i8], [30 x i8]* %1, i64 0, i64 %14
%18 = load i8, i8* %17
%19 = icmp eq i8 %16, %18
%20 = select i1 %19, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @str.4, i64 0, i64 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @str.5, i64 0, i64 0)
%21 = call i32 @puts(i8* dereferenceable(1) %20)
%22 = add nuw nsw i64 %12, 1
%23 = icmp eq i64 %22, %10
br i1 %23, label %24, label %11
24: ; preds = %11, %0
ret i32 0
}