#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 *);
scalar_t__ tolower(char);
int checkPalindrome(char *str) {
  char *startPointer = str;
  char *endPointer = str + strlen(str) - 1;
  while (startPointer < endPointer) {
    while (*startPointer == ' ')
      startPointer++;
    while (*endPointer == ' ')
      endPointer--;
    if (tolower(*startPointer) != tolower(*endPointer))
      return 0;
    startPointer++;
    endPointer--;
  }
  return 1;
}


x86 assembly (clang, -O0):
<checkPalindrome>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%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,-0x20(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    1208 <checkPalindrome+0xe8>
jmp    116c <checkPalindrome+0x4c>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
jne    118d <checkPalindrome+0x6d>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    116c <checkPalindrome+0x4c>
jmp    1192 <checkPalindrome+0x72>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
jne    11b3 <checkPalindrome+0x93>
mov    -0x20(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x20(%rbp)
jmp    1192 <checkPalindrome+0x72>
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
call   1040 <tolower@plt>
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%edi
call   1040 <tolower@plt>
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
cmp    %rcx,%rax
je     11eb <checkPalindrome+0xcb>
movl   $0x0,-0x4(%rbp)
jmp    120f <checkPalindrome+0xef>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x20(%rbp)
jmp    1159 <checkPalindrome+0x39>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<checkPalindrome>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1030 <strlen@plt>
cltq
lea    (%rbx,%rax,1),%rbp
add    $0xffffffffffffffff,%rbp
mov    $0x1,%r14d
cmp    %rbx,%rbp
jbe    118d <checkPalindrome+0x6d>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    (%rbx),%al
add    $0x1,%rbx
cmp    $0x20,%al
je     1150 <checkPalindrome+0x30>
nopw   0x0(%rax,%rax,1)
cmpb   $0x20,0x0(%rbp)
lea    -0x1(%rbp),%rbp
je     1160 <checkPalindrome+0x40>
movsbl %al,%edi
call   1040 <tolower@plt>
mov    %rax,%r15
movsbl 0x1(%rbp),%edi
call   1040 <tolower@plt>
cmp    %rax,%r15
jne    118a <checkPalindrome+0x6a>
cmp    %rbp,%rbx
jb     1150 <checkPalindrome+0x30>
jmp    118d <checkPalindrome+0x6d>
xor    %r14d,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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