#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 *);
int strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
int isPalindrome(char word[]) {
  char newWord[50];
  if (strlen(word) == 0 || strlen(word) == 1)
    return 1;
  if (word[0] != word[strlen(word) - 1])
    return 0;
  printf("%s\n", word);
  strncpy(newWord, word + 1, strlen(word) - 2);
  return isPalindrome(newWord);
}


x86 assembly (clang, -O0):
<isPalindrome>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x0,%eax
je     1170 <isPalindrome+0x30>
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x1,%eax
jne    117c <isPalindrome+0x3c>
movl   $0x1,-0x4(%rbp)
jmp    1209 <isPalindrome+0xc9>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x54(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x60(%rbp),%rcx
mov    %eax,%edx
mov    -0x54(%rbp),%eax
sub    $0x1,%edx
movslq %edx,%rdx
movsbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
je     11be <isPalindrome+0x7e>
movl   $0x0,-0x4(%rbp)
jmp    1209 <isPalindrome+0xc9>
mov    -0x10(%rbp),%rsi
lea    0xe37(%rip),%rdi
call   1050 <printf@plt>
lea    -0x50(%rbp),%rax
mov    %rax,-0x70(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x68(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x70(%rbp),%rdi
mov    -0x68(%rbp),%rsi
mov    %eax,%edx
sub    $0x2,%edx
call   1030 <strncpy@plt>
lea    -0x50(%rbp),%rdi
call   1060 <isPalindrome@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isPalindrome>:
push   %rbp
push   %r14
push   %rbx
sub    $0x40,%rsp
mov    %rdi,%rbx
call   1040 <strlen@plt>
mov    $0x1,%ebp
test   %eax,%eax
je     11b2 <isPalindrome+0x72>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cmp    $0x1,%eax
je     11b2 <isPalindrome+0x72>
mov    (%rbx),%r14b
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
xor    %ebp,%ebp
cmp    -0x1(%rax,%rbx,1),%r14b
jne    11b2 <isPalindrome+0x72>
lea    0xe7d(%rip),%rdi
mov    %rbx,%rsi
call   1050 <printf@plt>
lea    0x1(%rbx),%rbp
mov    %rbx,%rdi
call   1040 <strlen@plt>
lea    -0x2(%rax),%edx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1030 <strncpy@plt>
mov    %rbx,%rdi
call   1060 <isPalindrome@plt>
mov    %eax,%ebp
mov    %ebp,%eax
add    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%s\0A\00"
define i32 @isPalindrome(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca [50 x i8]
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = call i32 @strlen(i8* %5)
%7 = icmp eq i32 %6, 0
br i1 %7, label %12, label %8
8: ; preds = %1
%9 = load i8*, i8** %3
%10 = call i32 @strlen(i8* %9)
%11 = icmp eq i32 %10, 1
br i1 %11, label %12, label %13
12: ; preds = %8, %1
store i32 1, i32* %2
br label %40
13: ; preds = %8
%14 = load i8*, i8** %3
%15 = getelementptr inbounds i8, i8* %14, i64 0
%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 = sext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %18, i64 %22
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp ne i32 %17, %25
br i1 %26, label %27, label %28
27: ; preds = %13
store i32 0, i32* %2
br label %40
28: ; preds = %13
%29 = load i8*, i8** %3
%30 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %29)
%31 = getelementptr inbounds [50 x i8], [50 x i8]* %4, i64 0, i64 0
%32 = load i8*, i8** %3
%33 = getelementptr inbounds i8, i8* %32, i64 1
%34 = load i8*, i8** %3
%35 = call i32 @strlen(i8* %34)
%36 = sub nsw i32 %35, 2
%37 = call i32 @strncpy(i8* %31, i8* %33, i32 %36)
%38 = getelementptr inbounds [50 x i8], [50 x i8]* %4, i64 0, i64 0
%39 = call i32 @isPalindrome(i8* %38)
store i32 %39, i32* %2
br label %40
40: ; preds = %28, %27, %12
%41 = load i32, i32* %2
ret i32 %41
}

LLVM IR (-O2):
@.str = [4 x i8] c"%s\0A\00"
define i32 @isPalindrome(i8* %0) {
%2 = alloca [50 x i8]
%3 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%4 = tail call i32 @strlen(i8* %0)
%5 = icmp eq i32 %4, 0
br i1 %5, label %24, label %6
6: ; preds = %1
%7 = tail call i32 @strlen(i8* %0)
%8 = icmp eq i32 %7, 1
br i1 %8, label %24, label %9
9: ; preds = %6
%10 = load i8, i8* %0
%11 = tail call i32 @strlen(i8* %0)
%12 = add nsw i32 %11, -1
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %0, i64 %13
%15 = load i8, i8* %14
%16 = icmp eq i8 %10, %15
br i1 %16, label %17, label %24
17: ; preds = %9
%18 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %0)
%19 = getelementptr inbounds i8, i8* %0, i64 1
%20 = tail call i32 @strlen(i8* %0)
%21 = add nsw i32 %20, -2
%22 = call i32 @strncpy(i8* %3, i8* %19, i32 %21)
%23 = call i32 @isPalindrome(i8* %3)
br label %24
24: ; preds = %9, %1, %6, %17
%25 = phi i32 [ %23, %17 ], [ 1, %6 ], [ 1, %1 ], [ 0, %9 ]
ret i32 %25
}