#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 */
scalar_t__ malloc(int);
int /*<<< orphan*/ strcmp(char *, char *);
int strlen(char *);
int ispal(char *a) {
  if (strlen(a) == 1)
    return 1;
  char *c = (char *)malloc(sizeof(char) * strlen(a));
  int d;
  for (d = 0; d < strlen(a); d++)
    c[d] = a[strlen(a) - d - 1];
  if (!strcmp(a, c))
    return 1;
  return 0;
}


x86 assembly (clang, -O0):
<ispal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x1,%eax
jne    115a <ispal+0x2a>
movl   $0x1,-0x4(%rbp)
jmp    11fc <ispal+0xcc>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
cmp    %ecx,%eax
jge    11d3 <ispal+0xa3>
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
sub    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    117b <ispal+0x4b>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11f5 <ispal+0xc5>
movl   $0x1,-0x4(%rbp)
jmp    11fc <ispal+0xcc>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ispal>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r15
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cmp    $0x1,%ecx
je     11af <ispal+0x7f>
mov    %r15,%rdi
call   1030 <strlen@plt>
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,%r14
mov    %r15,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
jle    119b <ispal+0x6b>
mov    $0xffffffff,%ebp
xor    %ebx,%ebx
mov    %r15,%rdi
call   1030 <strlen@plt>
add    %ebp,%eax
cltq
movzbl (%r15,%rax,1),%eax
mov    %al,(%r14,%rbx,1)
add    $0x1,%rbx
mov    %r15,%rdi
call   1030 <strlen@plt>
cltq
add    $0xffffffff,%ebp
cmp    %rax,%rbx
jl     1170 <ispal+0x40>
mov    %r15,%rdi
mov    %r14,%rsi
call   1040 <strcmp@plt>
mov    %eax,%ecx
xor    %eax,%eax
test   %ecx,%ecx
sete   %al
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @ispal(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = call i32 @strlen(i8* %6)
%8 = icmp eq i32 %7, 1
br i1 %8, label %9, label %10
9: ; preds = %1
store i32 1, i32* %2
br label %47
10: ; preds = %1
%11 = load i8*, i8** %3
%12 = call i32 @strlen(i8* %11)
%13 = sext i32 %12 to i64
%14 = mul i64 1, %13
%15 = trunc i64 %14 to i32
%16 = call i64 @malloc(i32 %15)
%17 = inttoptr i64 %16 to i8*
store i8* %17, i8** %4
store i32 0, i32* %5
br label %18
18: ; preds = %37, %10
%19 = load i32, i32* %5
%20 = load i8*, i8** %3
%21 = call i32 @strlen(i8* %20)
%22 = icmp slt i32 %19, %21
br i1 %22, label %23, label %40
23: ; preds = %18
%24 = load i8*, i8** %3
%25 = load i8*, i8** %3
%26 = call i32 @strlen(i8* %25)
%27 = load i32, i32* %5
%28 = sub nsw i32 %26, %27
%29 = sub nsw i32 %28, 1
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %24, i64 %30
%32 = load i8, i8* %31
%33 = load i8*, i8** %4
%34 = load i32, i32* %5
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8, i8* %33, i64 %35
store i8 %32, i8* %36
br label %37
37: ; preds = %23
%38 = load i32, i32* %5
%39 = add nsw i32 %38, 1
store i32 %39, i32* %5
br label %18
40: ; preds = %18
%41 = load i8*, i8** %3
%42 = load i8*, i8** %4
%43 = call i32 @strcmp(i8* %41, i8* %42)
%44 = icmp ne i32 %43, 0
br i1 %44, label %46, label %45
45: ; preds = %40
store i32 1, i32* %2
br label %47
46: ; preds = %40
store i32 0, i32* %2
br label %47
47: ; preds = %46, %45, %9
%48 = load i32, i32* %2
ret i32 %48
}

LLVM IR (-O2):
define i32 @ispal(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = icmp eq i32 %2, 1
br i1 %3, label %28, label %4
4: ; preds = %1
%5 = tail call i32 @strlen(i8* %0)
%6 = tail call i64 @malloc(i32 %5)
%7 = inttoptr i64 %6 to i8*
%8 = tail call i32 @strlen(i8* %0)
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %24
10: ; preds = %4, %10
%11 = phi i64 [ %20, %10 ], [ 0, %4 ]
%12 = trunc i64 %11 to i32
%13 = tail call i32 @strlen(i8* %0)
%14 = xor i32 %12, -1
%15 = add i32 %13, %14
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %0, i64 %16
%18 = load i8, i8* %17
%19 = getelementptr inbounds i8, i8* %7, i64 %11
store i8 %18, i8* %19
%20 = add nuw nsw i64 %11, 1
%21 = tail call i32 @strlen(i8* %0)
%22 = sext i32 %21 to i64
%23 = icmp slt i64 %20, %22
br i1 %23, label %10, label %24
24: ; preds = %10, %4
%25 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(1) %7)
%26 = icmp eq i32 %25, 0
%27 = zext i1 %26 to i32
br label %28
28: ; preds = %1, %24
%29 = phi i32 [ %27, %24 ], [ 1, %1 ]
ret i32 %29
}