#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 palindrom(char *s) {
  int i;
  for (i = 0; i < strlen(s) / 2; i++) {
    if (*(s + i) != *(s + (strlen(s) - 1 - i))) {
      return 0;
    }
  }
  return 1;
}


x86 assembly (clang, -O0):
<palindrom>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
cmp    %ecx,%eax
jge    11a4 <palindrom+0x94>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x28(%rbp),%rcx
mov    %eax,%edx
mov    -0x1c(%rbp),%eax
sub    $0x1,%edx
sub    -0x14(%rbp),%edx
movslq %edx,%rdx
movsbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
je     1191 <palindrom+0x81>
movl   $0x0,-0x4(%rbp)
jmp    11ab <palindrom+0x9b>
jmp    1196 <palindrom+0x86>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1123 <palindrom+0x13>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<palindrom>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdi,%r15
call   1030 <strlen@plt>
mov    $0x1,%r14d
cmp    $0x2,%eax
jl     117c <palindrom+0x6c>
mov    $0xffffffff,%ebp
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movzbl (%r15,%rbx,1),%r12d
mov    %r15,%rdi
call   1030 <strlen@plt>
add    %ebp,%eax
cltq
cmp    (%r15,%rax,1),%r12b
jne    1179 <palindrom+0x69>
add    $0x1,%rbx
mov    %r15,%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
sar    %ecx
movslq %ecx,%rax
add    $0xffffffff,%ebp
cmp    %rax,%rbx
jl     1140 <palindrom+0x30>
jmp    117c <palindrom+0x6c>
xor    %r14d,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @palindrom(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = icmp sgt i32 %2, 1
br i1 %3, label %9, label %22
4: ; preds = %9
%5 = tail call i32 @strlen(i8* %0)
%6 = sdiv i32 %5, 2
%7 = sext i32 %6 to i64
%8 = icmp slt i64 %21, %7
br i1 %8, label %9, label %22
9: ; preds = %1, %4
%10 = phi i64 [ %21, %4 ], [ 0, %1 ]
%11 = trunc i64 %10 to i32
%12 = getelementptr inbounds i8, i8* %0, i64 %10
%13 = load i8, i8* %12
%14 = tail call i32 @strlen(i8* %0)
%15 = xor i32 %11, -1
%16 = add i32 %14, %15
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %0, i64 %17
%19 = load i8, i8* %18
%20 = icmp eq i8 %13, %19
%21 = add nuw nsw i64 %10, 1
br i1 %20, label %4, label %22
22: ; preds = %9, %4, %1
%23 = phi i32 [ 1, %1 ], [ 1, %4 ], [ 0, %9 ]
ret i32 %23
}