#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 *);
int checkPalindrome(char *string) {
  int len, i = 0, j;
  if (NULL == string) {
    printf("\nhere\n");
    return 0;
  }
  len = strlen(string);
  j = len - 1;
  while (i < j) {
    if (string[i] != string[j]) {
      return 0;
    } else {
      i++;
      j--;
    }
  }
  return 1;
}


x86 assembly (clang, -O0):
<checkPalindrome>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
xor    %eax,%eax
cmp    -0x10(%rbp),%rax
jne    1157 <checkPalindrome+0x37>
lea    0xeba(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11c2 <checkPalindrome+0xa2>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11bb <checkPalindrome+0x9b>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    -0x10(%rbp),%rcx
movslq -0x1c(%rbp),%rdx
movsbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
je     11a4 <checkPalindrome+0x84>
movl   $0x0,-0x4(%rbp)
jmp    11c2 <checkPalindrome+0xa2>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1c(%rbp)
jmp    116c <checkPalindrome+0x4c>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<checkPalindrome>:
push   %r14
push   %rbx
push   %rax
test   %rdi,%rdi
je     116e <checkPalindrome+0x4e>
mov    %rdi,%r14
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cmp    $0x2,%ecx
jl     117c <checkPalindrome+0x5c>
mov    %ecx,%ecx
add    $0xfffffffffffffffe,%rcx
xor    %edx,%edx
cs nopw 0x0(%rax,%rax,1)
nop
movzbl (%r14,%rdx,1),%ebx
cmp    0x1(%r14,%rcx,1),%bl
jne    117a <checkPalindrome+0x5a>
add    $0x1,%rdx
lea    -0x1(%rcx),%rsi
cmp    %rcx,%rdx
mov    %rsi,%rcx
jl     1150 <checkPalindrome+0x30>
jmp    117c <checkPalindrome+0x5c>
lea    0xe8b(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@str = [6 x i8] c"\0Ahere\00"
define i32 @checkPalindrome(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %3, label %5
3: ; preds = %1
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str, i64 0, i64 0))
br label %23
5: ; preds = %1
%6 = tail call i32 @strlen(i8* %0)
%7 = icmp sgt i32 %6, 1
br i1 %7, label %8, label %23
8: ; preds = %5
%9 = zext i32 %6 to i64
%10 = add nsw i64 %9, -1
br label %14
11: ; preds = %14
%12 = add nsw i64 %16, -1
%13 = icmp slt i64 %22, %12
br i1 %13, label %14, label %23
14: ; preds = %8, %11
%15 = phi i64 [ 0, %8 ], [ %22, %11 ]
%16 = phi i64 [ %10, %8 ], [ %12, %11 ]
%17 = getelementptr inbounds i8, i8* %0, i64 %15
%18 = load i8, i8* %17
%19 = getelementptr inbounds i8, i8* %0, i64 %16
%20 = load i8, i8* %19
%21 = icmp eq i8 %18, %20
%22 = add nuw nsw i64 %15, 1
br i1 %21, label %11, label %23
23: ; preds = %14, %11, %5, %3
%24 = phi i32 [ 0, %3 ], [ 1, %5 ], [ 0, %14 ], [ 1, %11 ]
ret i32 %24
}