#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 strlen(char *);
int capicua(char *str) {
  char *head = str;
  char *tail = str + strlen(str) - 1;
  int isPalindrome = 1;
  while (head < tail) {
    if (*head != *tail) {
      isPalindrome = 0;
      break;
    }
    ++head;
    --tail;
  }
  return isPalindrome;
}


x86 assembly (clang, -O0):
<capicua>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
movl   $0x1,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    119d <capicua+0x8d>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
mov    -0x18(%rbp),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     1180 <capicua+0x70>
movl   $0x0,-0x1c(%rbp)
jmp    119d <capicua+0x8d>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
jmp    1150 <capicua+0x40>
mov    -0x1c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<capicua>:
push   %rbx
mov    %rdi,%rbx
call   1030 <strlen@plt>
cltq
lea    (%rbx,%rax,1),%rcx
add    $0xffffffffffffffff,%rcx
mov    $0x1,%eax
cmp    %rbx,%rcx
jbe    1158 <capicua+0x48>
add    $0x1,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movzbl -0x1(%rbx),%edx
cmp    (%rcx),%dl
jne    115a <capicua+0x4a>
add    $0xffffffffffffffff,%rcx
lea    0x1(%rbx),%rdx
cmp    %rcx,%rbx
mov    %rdx,%rbx
jb     1140 <capicua+0x30>
pop    %rbx
ret
xor    %eax,%eax
pop    %rbx
ret

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

LLVM IR (-O2):
define i32 @capicua(i8* %0) {
%2 = tail call i32 @strlen(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 %17
7: ; preds = %10
%8 = getelementptr inbounds i8, i8* %11, i64 -1
%9 = icmp ult i8* %16, %8
br i1 %9, label %10, label %17
10: ; preds = %1, %7
%11 = phi i8* [ %8, %7 ], [ %5, %1 ]
%12 = phi i8* [ %16, %7 ], [ %0, %1 ]
%13 = load i8, i8* %12
%14 = load i8, i8* %11
%15 = icmp eq i8 %13, %14
%16 = getelementptr inbounds i8, i8* %12, i64 1
br i1 %15, label %7, label %17
17: ; preds = %7, %10, %1
%18 = phi i32 [ 1, %1 ], [ 0, %10 ], [ 1, %7 ]
ret i32 %18
}