#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 checkpal(char word[], int position) {
  int len;
  len = strlen(word) - (position + 1);
  if (word[position] == word[len]) {
    if ((position + 1) == len || (position == len)) {
      return 1;
    }
    return checkpal(word, position + 1);
  } else
    return 0;
}


x86 assembly (clang, -O0):
<checkpal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
sub    %ecx,%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    -0x10(%rbp),%rcx
movslq -0x18(%rbp),%rdx
movsbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
jne    11a1 <checkpal+0x81>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
cmp    -0x18(%rbp),%eax
je     117e <checkpal+0x5e>
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jne    118a <checkpal+0x6a>
movl   $0x1,-0x4(%rbp)
jmp    11a8 <checkpal+0x88>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
add    $0x1,%esi
call   1040 <checkpal@plt>
mov    %eax,-0x4(%rbp)
jmp    11a8 <checkpal+0x88>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<checkpal>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rdi,%r15
movabs $0x100000000,%r14
movslq %esi,%r13
mov    %r13,%rbx
shl    $0x20,%rbx
lea    (%rdi,%r13,1),%r12
not    %r13
nopw   0x0(%rax,%rax,1)
mov    %r15,%rdi
call   1030 <strlen@plt>
movslq %eax,%rcx
movzbl (%r12),%eax
lea    (%r15,%rcx,1),%rdx
cmp    0x0(%r13,%rdx,1),%al
jne    1189 <checkpal+0x79>
add    %r13,%rcx
lea    (%rbx,%r14,1),%rdx
mov    %rdx,%rsi
sar    $0x20,%rsi
mov    $0x1,%eax
cmp    %rsi,%rcx
je     118b <checkpal+0x7b>
sar    $0x20,%rbx
add    $0x1,%r12
add    $0xffffffffffffffff,%r13
cmp    %rbx,%rcx
mov    %rdx,%rbx
jne    1140 <checkpal+0x30>
jmp    118b <checkpal+0x7b>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @checkpal(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
%7 = load i8*, i8** %4
%8 = call i32 @strlen(i8* %7)
%9 = load i32, i32* %5
%10 = add nsw i32 %9, 1
%11 = sub nsw i32 %8, %10
store i32 %11, i32* %6
%12 = load i8*, i8** %4
%13 = load i32, i32* %5
%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** %4
%19 = load i32, i32* %6
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8, i8* %18, i64 %20
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp eq i32 %17, %23
br i1 %24, label %25, label %40
25: ; preds = %2
%26 = load i32, i32* %5
%27 = add nsw i32 %26, 1
%28 = load i32, i32* %6
%29 = icmp eq i32 %27, %28
br i1 %29, label %34, label %30
30: ; preds = %25
%31 = load i32, i32* %5
%32 = load i32, i32* %6
%33 = icmp eq i32 %31, %32
br i1 %33, label %34, label %35
34: ; preds = %30, %25
store i32 1, i32* %3
br label %41
35: ; preds = %30
%36 = load i8*, i8** %4
%37 = load i32, i32* %5
%38 = add nsw i32 %37, 1
%39 = call i32 @checkpal(i8* %36, i32 %38)
store i32 %39, i32* %3
br label %41
40: ; preds = %2
store i32 0, i32* %3
br label %41
41: ; preds = %40, %35, %34
%42 = load i32, i32* %3
ret i32 %42
}

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