#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 */
scalar_t__ letras_iguales(char, char);
int longitud_palabra(char *);
int comprobar_palindromo(char *palabra) {
  char *primera_letra;
  char *ultima_letra;
  int p;
  p = longitud_palabra(palabra);
  ultima_letra = palabra + p - 1;
  primera_letra = palabra;
  while (primera_letra < ultima_letra) {
    if (letras_iguales(*primera_letra, *ultima_letra) == 0) {
      return 0;
    }
    primera_letra++;
    ultima_letra--;
  }
  return 1;
}


x86 assembly (clang, -O0):
<comprobar_palindromo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <longitud_palabra@plt>
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
add    %rcx,%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    11a9 <comprobar_palindromo+0x89>
mov    -0x18(%rbp),%rax
mov    (%rax),%cl
mov    -0x20(%rbp),%rax
movsbl %cl,%edi
movsbl (%rax),%esi
call   1040 <letras_iguales@plt>
cmp    $0x0,%rax
jne    118c <comprobar_palindromo+0x6c>
movl   $0x0,-0x4(%rbp)
jmp    11b0 <comprobar_palindromo+0x90>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x20(%rbp)
jmp    1153 <comprobar_palindromo+0x33>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<comprobar_palindromo>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
call   1030 <longitud_palabra@plt>
cltq
lea    (%rbx,%rax,1),%rbp
add    $0xffffffffffffffff,%rbp
mov    $0x1,%r14d
cmp    %rbx,%rbp
jbe    1177 <comprobar_palindromo+0x57>
add    $0x1,%rbx
cs nopw 0x0(%rax,%rax,1)
nop
movsbl -0x1(%rbx),%edi
movsbl 0x0(%rbp),%esi
call   1040 <letras_iguales@plt>
test   %rax,%rax
je     1174 <comprobar_palindromo+0x54>
add    $0xffffffffffffffff,%rbp
lea    0x1(%rbx),%rax
cmp    %rbp,%rbx
mov    %rax,%rbx
jb     1150 <comprobar_palindromo+0x30>
jmp    1177 <comprobar_palindromo+0x57>
xor    %r14d,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @comprobar_palindromo(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
store i8* %0, i8** %3
%7 = load i8*, i8** %3
%8 = call i32 @longitud_palabra(i8* %7)
store i32 %8, i32* %6
%9 = load i8*, i8** %3
%10 = load i32, i32* %6
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds i8, i8* %9, i64 %11
%13 = getelementptr inbounds i8, i8* %12, i64 -1
store i8* %13, i8** %5
%14 = load i8*, i8** %3
store i8* %14, i8** %4
br label %15
15: ; preds = %27, %1
%16 = load i8*, i8** %4
%17 = load i8*, i8** %5
%18 = icmp ult i8* %16, %17
br i1 %18, label %19, label %32
19: ; preds = %15
%20 = load i8*, i8** %4
%21 = load i8, i8* %20
%22 = load i8*, i8** %5
%23 = load i8, i8* %22
%24 = call i64 @letras_iguales(i8 signext %21, i8 signext %23)
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %27
26: ; preds = %19
store i32 0, i32* %2
br label %33
27: ; preds = %19
%28 = load i8*, i8** %4
%29 = getelementptr inbounds i8, i8* %28, i32 1
store i8* %29, i8** %4
%30 = load i8*, i8** %5
%31 = getelementptr inbounds i8, i8* %30, i32 -1
store i8* %31, i8** %5
br label %15
32: ; preds = %15
store i32 1, i32* %2
br label %33
33: ; preds = %32, %26
%34 = load i32, i32* %2
ret i32 %34
}

LLVM IR (-O2):
define i32 @comprobar_palindromo(i8* %0) {
%2 = tail call i32 @longitud_palabra(i8* %0)
%3 = sext i32 %2 to i64
%4 = getelementptr inbounds i8, i8* %0, i64 %3
%5 = getelementptr inbounds i8, i8* %4, i64 -1
%6 = icmp ugt i8* %5, %0
br i1 %6, label %10, label %18
7: ; preds = %10
%8 = getelementptr inbounds i8, i8* %11, i64 -1
%9 = icmp ult i8* %17, %8
br i1 %9, label %10, label %18
10: ; preds = %1, %7
%11 = phi i8* [ %8, %7 ], [ %5, %1 ]
%12 = phi i8* [ %17, %7 ], [ %0, %1 ]
%13 = load i8, i8* %12
%14 = load i8, i8* %11
%15 = tail call i64 @letras_iguales(i8 signext %13, i8 signext %14)
%16 = icmp eq i64 %15, 0
%17 = getelementptr inbounds i8, i8* %12, i64 1
br i1 %16, label %18, label %7
18: ; preds = %10, %7, %1
%19 = phi i32 [ 1, %1 ], [ 1, %7 ], [ 0, %10 ]
ret i32 %19
}