#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 *);
int strlen(char *);
palind(char *s) {
  if (strlen(s) == 1) {
    printf("Palindrome\n");
  } else if (strlen(s) == 2 && *(s) == *(s + 1)) {
    printf("Palindrome\n");
  } else if (*(s) == *(s + strlen(s) - 1)) {
    s = s + 1;
    *(s + strlen(s) - 1) = '\0';
    palind(s);
  } else
    printf("Not a palindrome.\n");
}


x86 assembly (clang, -O0):
<palind>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x1,%eax
jne    115f <palind+0x2f>
lea    0xeab(%rip),%rdi
call   1040 <printf@plt>
jmp    121c <palind+0xec>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x2,%eax
jne    1199 <palind+0x69>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
mov    -0x10(%rbp),%rcx
movsbl 0x1(%rcx),%ecx
cmp    %ecx,%eax
jne    1199 <palind+0x69>
lea    0xe71(%rip),%rdi
call   1040 <printf@plt>
jmp    1217 <palind+0xe7>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x20(%rbp),%rcx
mov    %eax,%edx
mov    -0x14(%rbp),%eax
movslq %edx,%rdx
movsbl -0x1(%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
jne    1206 <palind+0xd6>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
movslq %ecx,%rcx
movb   $0x0,-0x1(%rax,%rcx,1)
mov    -0x10(%rbp),%rdi
call   1050 <palind@plt>
jmp    1212 <palind+0xe2>
lea    0xdff(%rip),%rdi
call   1040 <printf@plt>
jmp    1217 <palind+0xe7>
jmp    121c <palind+0xec>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<palind>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdi,%rbx
call   1040 <strlen@plt>
cmp    $0x1,%eax
je     1199 <palind+0x79>
lea    0xed6(%rip),%r14
lea    0xebd(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbx,%rdi
call   1040 <strlen@plt>
movzbl (%rbx),%ebp
cmp    $0x2,%eax
jne    1166 <palind+0x46>
cmp    0x1(%rbx),%bpl
je     11a5 <palind+0x85>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
cmp    -0x1(%rbx,%rax,1),%bpl
jne    11a2 <palind+0x82>
lea    0x1(%rbx),%r15
mov    %r15,%rdi
call   1040 <strlen@plt>
cltq
movb   $0x0,(%rbx,%rax,1)
mov    %r15,%rdi
call   1040 <strlen@plt>
mov    %r15,%rbx
cmp    $0x1,%eax
jne    1150 <palind+0x30>
lea    0xe72(%rip),%r14
jmp    11a5 <palind+0x85>
mov    %r12,%r14
mov    %r14,%rdi
call   1030 <puts@plt>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@str = [18 x i8] c"Not a palindrome.\00"
@str.3 = [11 x i8] c"Palindrome\00"
define i32 @palind(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = icmp eq i32 %2, 1
br i1 %3, label %4, label %7
4: ; preds = %25, %1
%5 = phi i32 [ undef, %1 ], [ %30, %25 ]
%6 = xor i1 %3, true
br label %33
7: ; preds = %1, %25
%8 = phi i1 [ true, %25 ], [ false, %1 ]
%9 = phi i32 [ %30, %25 ], [ undef, %1 ]
%10 = phi i8* [ %26, %25 ], [ %0, %1 ]
%11 = tail call i32 @strlen(i8* %10)
%12 = icmp eq i32 %11, 2
%13 = load i8, i8* %10
br i1 %12, label %14, label %18
14: ; preds = %7
%15 = getelementptr inbounds i8, i8* %10, i64 1
%16 = load i8, i8* %15
%17 = icmp eq i8 %13, %16
br i1 %17, label %33, label %18
18: ; preds = %7, %14
%19 = tail call i32 @strlen(i8* %10)
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8, i8* %10, i64 -1
%22 = getelementptr inbounds i8, i8* %21, i64 %20
%23 = load i8, i8* %22
%24 = icmp eq i8 %13, %23
br i1 %24, label %25, label %33
25: ; preds = %18
%26 = getelementptr inbounds i8, i8* %10, i64 1
%27 = tail call i32 @strlen(i8* %26)
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %10, i64 %28
store i8 0, i8* %29
%30 = select i1 %8, i32 %9, i32 undef
%31 = tail call i32 @strlen(i8* %26)
%32 = icmp eq i32 %31, 1
br i1 %32, label %4, label %7
33: ; preds = %18, %14, %4
%34 = phi i8* [ getelementptr inbounds ([11 x i8], [11 x i8]* @str.3, i64 0, i64 0), %4 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @str.3, i64 0, i64 0), %14 ], [ getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0), %18 ]
%35 = phi i32 [ %5, %4 ], [ %9, %14 ], [ %9, %18 ]
%36 = phi i1 [ %6, %4 ], [ %8, %14 ], [ %8, %18 ]
%37 = tail call i32 @puts(i8* dereferenceable(1) %34)
%38 = select i1 %36, i32 %35, i32 undef
ret i32 %38
}