#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 strlen(char *);
int ispal(char *s) {
  char *t;
  t = s + strlen(s) - 1;
  for (t = s + strlen(s) - 1; s < t; s++, t--)
    if (*s != *t)
      return 0;
  return 1;
}


x86 assembly (clang, -O0):
<ispal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-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
add    %rcx,%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    11b8 <ispal+0xa8>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
mov    -0x18(%rbp),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     1196 <ispal+0x86>
movl   $0x0,-0x4(%rbp)
jmp    11bf <ispal+0xaf>
jmp    119b <ispal+0x8b>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
jmp    1166 <ispal+0x56>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ispal>:
push   %rbx
mov    %rdi,%rbx
call   1030 <strlen@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
cltq
lea    (%rbx,%rax,1),%rcx
add    $0xffffffffffffffff,%rcx
mov    $0x1,%eax
cmp    %rbx,%rcx
jbe    1158 <ispal+0x48>
add    $0x1,%rbx
nopl   0x0(%rax)
movzbl -0x1(%rbx),%edx
cmp    (%rcx),%dl
jne    115a <ispal+0x4a>
add    $0xffffffffffffffff,%rcx
lea    0x1(%rbx),%rdx
cmp    %rcx,%rbx
mov    %rdx,%rbx
jb     1140 <ispal+0x30>
pop    %rbx
ret
xor    %eax,%eax
pop    %rbx
ret

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

LLVM IR (-O2):
define i32 @ispal(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = tail call i32 @strlen(i8* %0)
%4 = sext i32 %3 to i64
%5 = getelementptr inbounds i8, i8* %0, i64 %4
%6 = getelementptr inbounds i8, i8* %5, i64 -1
%7 = icmp ugt i8* %6, %0
br i1 %7, label %11, label %18
8: ; preds = %11
%9 = getelementptr inbounds i8, i8* %12, i64 -1
%10 = icmp ult i8* %17, %9
br i1 %10, label %11, label %18
11: ; preds = %1, %8
%12 = phi i8* [ %9, %8 ], [ %6, %1 ]
%13 = phi i8* [ %17, %8 ], [ %0, %1 ]
%14 = load i8, i8* %13
%15 = load i8, i8* %12
%16 = icmp eq i8 %14, %15
%17 = getelementptr inbounds i8, i8* %13, i64 1
br i1 %16, label %8, label %18
18: ; preds = %11, %8, %1
%19 = phi i32 [ 1, %1 ], [ 1, %8 ], [ 0, %11 ]
ret i32 %19
}