#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, char);
bool recursive_palindrome(char *str, int n, int length) {
  printf("ilk: %c\nson: %c\n", str[n], str[length - n]);
  if (str[n] != str[length - n])
    return false;
  else if (n == length / 2)
    return true;
  return recursive_palindrome(str, n + 1, length);
}


x86 assembly (clang, -O0):
<recursive_palindrome>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
sub    -0x14(%rbp),%ecx
movslq %ecx,%rcx
lea    0xeaf(%rip),%rdi
movsbl %dl,%esi
movsbl (%rax,%rcx,1),%edx
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    -0x10(%rbp),%rcx
mov    -0x18(%rbp),%edx
sub    -0x14(%rbp),%edx
movslq %edx,%rdx
movsbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
je     118e <recursive_palindrome+0x6e>
movl   $0x0,-0x4(%rbp)
jmp    11d2 <recursive_palindrome+0xb2>
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
cmp    %ecx,%eax
jne    11b8 <recursive_palindrome+0x98>
movl   $0x1,-0x4(%rbp)
jmp    11d2 <recursive_palindrome+0xb2>
jmp    11bd <recursive_palindrome+0x9d>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
add    $0x1,%esi
mov    -0x18(%rbp),%edx
call   1030 <recursive_palindrome@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<recursive_palindrome>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r15d
mov    %rdi,%r12
movslq %esi,%rbp
movsbl (%rdi,%rbp,1),%esi
mov    %edx,%eax
sub    %ebp,%eax
movslq %eax,%rbx
movsbl (%rdi,%rbx,1),%edx
lea    0xec6(%rip),%rdi
call   1030 <printf@plt>
mov    (%r12,%rbp,1),%al
xor    %r14d,%r14d
cmp    (%r12,%rbx,1),%al
jne    11b1 <recursive_palindrome+0xa1>
mov    %r15d,%eax
shr    $0x1f,%eax
add    %r15d,%eax
sar    %eax
movslq %r15d,%rcx
movslq %eax,%r13
neg    %r13
lea    (%r12,%rbp,1),%rbx
add    $0x1,%rbx
neg    %rbp
add    %rcx,%r12
add    $0xffffffffffffffff,%r12
lea    0xe87(%rip),%r15
nopl   0x0(%rax)
cmp    %rbp,%r13
je     11ab <recursive_palindrome+0x9b>
movsbl (%rbx),%esi
movsbl (%r12,%rbp,1),%edx
mov    %r15,%rdi
call   1030 <printf@plt>
movzbl (%rbx),%eax
lea    -0x1(%rbp),%rcx
add    $0x1,%rbx
cmp    (%r12,%rbp,1),%al
mov    %rcx,%rbp
je     1180 <recursive_palindrome+0x70>
jmp    11b1 <recursive_palindrome+0xa1>
mov    $0x1,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [17 x i8] c"ilk: %c\0Ason: %c\0A\00"
define i32 @recursive_palindrome(i8* %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
%8 = load i8*, i8** %5
%9 = load i32, i32* %6
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds i8, i8* %8, i64 %10
%12 = load i8, i8* %11
%13 = load i8*, i8** %5
%14 = load i32, i32* %7
%15 = load i32, i32* %6
%16 = sub nsw i32 %14, %15
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %13, i64 %17
%19 = load i8, i8* %18
%20 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8 signext %12, i8 signext %19)
%21 = load i8*, i8** %5
%22 = load i32, i32* %6
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %21, i64 %23
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = load i8*, i8** %5
%28 = load i32, i32* %7
%29 = load i32, i32* %6
%30 = sub nsw i32 %28, %29
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %27, i64 %31
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
%35 = icmp ne i32 %26, %34
br i1 %35, label %36, label %37
36: ; preds = %3
store i32 0, i32* %4
br label %50
37: ; preds = %3
%38 = load i32, i32* %6
%39 = load i32, i32* %7
%40 = sdiv i32 %39, 2
%41 = icmp eq i32 %38, %40
br i1 %41, label %42, label %43
42: ; preds = %37
store i32 1, i32* %4
br label %50
43: ; preds = %37
br label %44
44: ; preds = %43
%45 = load i8*, i8** %5
%46 = load i32, i32* %6
%47 = add nsw i32 %46, 1
%48 = load i32, i32* %7
%49 = call i32 @recursive_palindrome(i8* %45, i32 %47, i32 %48)
store i32 %49, i32* %4
br label %50
50: ; preds = %44, %42, %36
%51 = load i32, i32* %4
ret i32 %51
}

LLVM IR (-O2):
@.str = [17 x i8] c"ilk: %c\0Ason: %c\0A\00"
define i32 @recursive_palindrome(i8* nocapture %0, i32 %1, i32 %2) {
%4 = sext i32 %1 to i64
%5 = getelementptr inbounds i8, i8* %0, i64 %4
%6 = load i8, i8* %5
%7 = sub nsw i32 %2, %1
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds i8, i8* %0, i64 %8
%10 = load i8, i8* %9
%11 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8 signext %6, i8 signext %10)
%12 = load i8, i8* %5
%13 = load i8, i8* %9
%14 = icmp eq i8 %12, %13
br i1 %14, label %15, label %33
15: ; preds = %3
%16 = sdiv i32 %2, 2
%17 = sext i32 %2 to i64
%18 = sext i32 %16 to i64
br label %29
19: ; preds = %29
%20 = getelementptr inbounds i8, i8* %0, i64 %32
%21 = load i8, i8* %20
%22 = sub nsw i64 %17, %32
%23 = getelementptr inbounds i8, i8* %0, i64 %22
%24 = load i8, i8* %23
%25 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8 signext %21, i8 signext %24)
%26 = load i8, i8* %20
%27 = load i8, i8* %23
%28 = icmp eq i8 %26, %27
br i1 %28, label %29, label %33
29: ; preds = %15, %19
%30 = phi i64 [ %4, %15 ], [ %32, %19 ]
%31 = icmp eq i64 %30, %18
%32 = add nsw i64 %30, 1
br i1 %31, label %33, label %19
33: ; preds = %19, %29, %3
%34 = phi i32 [ 0, %3 ], [ 1, %29 ], [ 0, %19 ]
ret i32 %34
}