#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 *, char *);
int strlen(char *);
void palindrome(char *str) {
  for (int k = strlen(str) - 1, j = 0; j < k / 2; j++) {
    if (str[j] != str[k - j]) {
      printf("A palavra %s nao e palindroma.", str);
      return;
    }
  }
  printf("A palavra %s e palindroma.", str);
}


x86 assembly (clang, -O0):
<palindrome>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
sub    $0x1,%eax
mov    %eax,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
cmp    %ecx,%eax
jge    11ad <palindrome+0x8d>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    -0x8(%rbp),%rcx
mov    -0xc(%rbp),%edx
sub    -0x10(%rbp),%edx
movslq %edx,%rdx
movsbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
je     119a <palindrome+0x7a>
mov    -0x8(%rbp),%rsi
lea    0xe70(%rip),%rdi
call   1040 <printf@plt>
jmp    11bd <palindrome+0x9d>
jmp    119f <palindrome+0x7f>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1142 <palindrome+0x22>
mov    -0x8(%rbp),%rsi
lea    0xe67(%rip),%rdi
call   1040 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<palindrome>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
call   1030 <strlen@plt>
cmp    $0x3,%eax
jl     1156 <palindrome+0x36>
add    $0xffffffff,%eax
mov    %eax,%ecx
shr    %eax
add    %r14,%rcx
xor    %edx,%edx
nopl   (%rax)
movzbl (%r14,%rdx,1),%ebx
cmp    (%rcx),%bl
jne    115f <palindrome+0x3f>
add    $0x1,%rdx
add    $0xffffffffffffffff,%rcx
cmp    %rdx,%rax
jne    1140 <palindrome+0x20>
lea    0xec2(%rip),%rdi
jmp    1166 <palindrome+0x46>
lea    0xe9a(%rip),%rdi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <printf@plt>

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

LLVM IR (-O2):
@.str = [31 x i8] c"A palavra %s nao e palindroma.\00"
@.str.1 = [27 x i8] c"A palavra %s e palindroma.\00"
define void @palindrome(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = add nsw i32 %2, -1
%4 = icmp sgt i32 %2, 2
br i1 %4, label %5, label %22
5: ; preds = %1
%6 = lshr i32 %3, 1
%7 = zext i32 %3 to i64
%8 = zext i32 %6 to i64
br label %11
9: ; preds = %11
%10 = icmp eq i64 %19, %8
br i1 %10, label %22, label %11
11: ; preds = %5, %9
%12 = phi i64 [ 0, %5 ], [ %19, %9 ]
%13 = getelementptr inbounds i8, i8* %0, i64 %12
%14 = load i8, i8* %13
%15 = sub nsw i64 %7, %12
%16 = getelementptr inbounds i8, i8* %0, i64 %15
%17 = load i8, i8* %16
%18 = icmp eq i8 %14, %17
%19 = add nuw nsw i64 %12, 1
br i1 %18, label %9, label %20
20: ; preds = %11
%21 = tail call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %24
22: ; preds = %9, %1
%23 = tail call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %24
24: ; preds = %20, %22
ret void
}