#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*/ strcpy(char *, char const *);
int strlen(char const *);
int /*<<< orphan*/ strncpy(char *, char const *, int);
int is_palindrome_rec(const char *input) {
  char str[20];
  int x = strlen(input), isPalindrome = 1;
  strcpy(str, input);
  if (x <= 1)
    return 1;
  if (str[0] != str[x - 1])
    return 0;
  strncpy(str, input + 1, x - 2);
  str[x - 2] = '\0';
  return is_palindrome_rec(str);
}


x86 assembly (clang, -O0):
<is_palindrome_rec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x34(%rbp)
movl   $0x1,-0x38(%rbp)
lea    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <strcpy@plt>
cmpl   $0x1,-0x34(%rbp)
jg     1182 <is_palindrome_rec+0x42>
movl   $0x1,-0x4(%rbp)
jmp    11d8 <is_palindrome_rec+0x98>
movsbl -0x30(%rbp),%eax
mov    -0x34(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl -0x30(%rbp,%rcx,1),%ecx
cmp    %ecx,%eax
je     11a8 <is_palindrome_rec+0x68>
movl   $0x0,-0x4(%rbp)
jmp    11d8 <is_palindrome_rec+0x98>
lea    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rsi
add    $0x1,%rsi
mov    -0x34(%rbp),%edx
sub    $0x2,%edx
call   1030 <strncpy@plt>
mov    -0x34(%rbp),%eax
sub    $0x2,%eax
cltq
movb   $0x0,-0x30(%rbp,%rax,1)
lea    -0x30(%rbp),%rdi
call   1060 <is_palindrome_rec@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_palindrome_rec>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %rdi,%rbx
call   1050 <strlen@plt>
mov    %eax,%r14d
mov    %rsp,%rdi
mov    %rbx,%rsi
call   1040 <strcpy@plt>
mov    $0x1,%eax
cmp    $0x2,%r14d
jl     119e <is_palindrome_rec+0x5e>
mov    (%rsp),%cl
lea    -0x1(%r14),%edx
xor    %eax,%eax
cmp    (%rsp,%rdx,1),%cl
jne    119e <is_palindrome_rec+0x5e>
add    $0x1,%rbx
add    $0xfffffffe,%r14d
mov    %rsp,%r15
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %r14d,%edx
call   1030 <strncpy@plt>
movb   $0x0,(%rsp,%r14,1)
mov    %r15,%rdi
call   1060 <is_palindrome_rec@plt>
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

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