#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 */
char *malloc(int);
int /*<<< orphan*/ memcpy(char *, char *, int);
int /*<<< orphan*/ sprintf(char *, char *, int);
int strlen(char *);
int checkForPalindrome(int possiblePalindrome) {
  char *strPalin = malloc(sizeof(char) * 255);
  sprintf(strPalin, "%d", possiblePalindrome);
  int palindromeLength = strlen(strPalin);
  int halfPalinLength = palindromeLength / 2;
  char *aSection = malloc(sizeof(char) * 255);
  char *bSection = malloc(sizeof(char) * 255);
  memcpy(aSection, strPalin, sizeof(char) * halfPalinLength);
  memcpy(bSection, strPalin + halfPalinLength, sizeof(char) * halfPalinLength);
  int a = 0;
  int b = halfPalinLength - 1;
  for (; a < halfPalinLength; ++a) {
    if (aSection[a] != bSection[b - a])
      return 0;
  }
  return !0;
}


x86 assembly (clang, -O0):
<checkForPalindrome>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    $0xff,%edi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%edx
lea    0xe99(%rip),%rsi
call   1060 <sprintf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x18(%rbp)
mov    $0xff,%edi
call   1050 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    $0xff,%edi
call   1050 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
movslq -0x18(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edx
call   1040 <memcpy@plt>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rsi
movslq -0x18(%rbp),%rax
add    %rax,%rsi
movslq -0x18(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edx
call   1040 <memcpy@plt>
movl   $0x0,-0x2c(%rbp)
mov    -0x18(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x30(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1237 <checkForPalindrome+0xf7>
mov    -0x20(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    -0x28(%rbp),%rcx
mov    -0x30(%rbp),%edx
sub    -0x2c(%rbp),%edx
movslq %edx,%rdx
movsbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
je     1224 <checkForPalindrome+0xe4>
movl   $0x0,-0x4(%rbp)
jmp    123e <checkForPalindrome+0xfe>
jmp    1229 <checkForPalindrome+0xe9>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11e7 <checkForPalindrome+0xa7>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<checkForPalindrome>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edi,%ebx
mov    $0xff,%edi
call   1050 <malloc@plt>
mov    %rax,%r15
lea    0xe9f(%rip),%rsi
mov    %rax,%rdi
mov    %ebx,%edx
call   1060 <sprintf@plt>
mov    %r15,%rdi
call   1030 <strlen@plt>
mov    %eax,%ebx
mov    %eax,%ebp
shr    $0x1f,%ebp
add    %eax,%ebp
sar    %ebp
mov    $0xff,%edi
call   1050 <malloc@plt>
mov    %rax,%r14
mov    $0xff,%edi
call   1050 <malloc@plt>
mov    %rax,%r12
movslq %ebp,%r13
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r13d,%edx
call   1040 <memcpy@plt>
add    %r13,%r15
mov    %r12,%rdi
mov    %r15,%rsi
mov    %r13d,%edx
call   1040 <memcpy@plt>
mov    $0x1,%eax
cmp    $0x2,%ebx
jl     11ee <checkForPalindrome+0xae>
mov    %ebp,%ecx
add    $0xffffffff,%ebp
xor    %edx,%edx
nopl   0x0(%rax,%rax,1)
movzbl (%r14,%rdx,1),%ebx
movslq %ebp,%rsi
cmp    (%r12,%rsi,1),%bl
jne    11ec <checkForPalindrome+0xac>
add    $0x1,%rdx
add    $0xffffffff,%ebp
cmp    %rdx,%rcx
jne    11d0 <checkForPalindrome+0x90>
jmp    11ee <checkForPalindrome+0xae>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
define i32 @checkForPalindrome(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
store i32 %0, i32* %3
%11 = call i8* @malloc(i32 255)
store i8* %11, i8** %4
%12 = load i8*, i8** %4
%13 = load i32, i32* %3
%14 = call i32 @sprintf(i8* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %13)
%15 = load i8*, i8** %4
%16 = call i32 @strlen(i8* %15)
store i32 %16, i32* %5
%17 = load i32, i32* %5
%18 = sdiv i32 %17, 2
store i32 %18, i32* %6
%19 = call i8* @malloc(i32 255)
store i8* %19, i8** %7
%20 = call i8* @malloc(i32 255)
store i8* %20, i8** %8
%21 = load i8*, i8** %7
%22 = load i8*, i8** %4
%23 = load i32, i32* %6
%24 = sext i32 %23 to i64
%25 = mul i64 1, %24
%26 = trunc i64 %25 to i32
%27 = call i32 @memcpy(i8* %21, i8* %22, i32 %26)
%28 = load i8*, i8** %8
%29 = load i8*, i8** %4
%30 = load i32, i32* %6
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %29, i64 %31
%33 = load i32, i32* %6
%34 = sext i32 %33 to i64
%35 = mul i64 1, %34
%36 = trunc i64 %35 to i32
%37 = call i32 @memcpy(i8* %28, i8* %32, i32 %36)
store i32 0, i32* %9
%38 = load i32, i32* %6
%39 = sub nsw i32 %38, 1
store i32 %39, i32* %10
br label %40
40: ; preds = %62, %1
%41 = load i32, i32* %9
%42 = load i32, i32* %6
%43 = icmp slt i32 %41, %42
br i1 %43, label %44, label %65
44: ; preds = %40
%45 = load i8*, i8** %7
%46 = load i32, i32* %9
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i8, i8* %45, i64 %47
%49 = load i8, i8* %48
%50 = sext i8 %49 to i32
%51 = load i8*, i8** %8
%52 = load i32, i32* %10
%53 = load i32, i32* %9
%54 = sub nsw i32 %52, %53
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds i8, i8* %51, i64 %55
%57 = load i8, i8* %56
%58 = sext i8 %57 to i32
%59 = icmp ne i32 %50, %58
br i1 %59, label %60, label %61
60: ; preds = %44
store i32 0, i32* %2
br label %66
61: ; preds = %44
br label %62
62: ; preds = %61
%63 = load i32, i32* %9
%64 = add nsw i32 %63, 1
store i32 %64, i32* %9
br label %40
65: ; preds = %40
store i32 1, i32* %2
br label %66
66: ; preds = %65, %60
%67 = load i32, i32* %2
ret i32 %67
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define i32 @checkForPalindrome(i32 %0) {
%2 = tail call dereferenceable_or_null(255) i8* @malloc(i32 255)
%3 = tail call i32 @sprintf(i8* dereferenceable(1) %2, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %0)
%4 = tail call i32 @strlen(i8* %2)
%5 = sdiv i32 %4, 2
%6 = tail call dereferenceable_or_null(255) i8* @malloc(i32 255)
%7 = tail call dereferenceable_or_null(255) i8* @malloc(i32 255)
%8 = sext i32 %5 to i64
%9 = tail call i32 @memcpy(i8* %6, i8* %2, i32 %5)
%10 = getelementptr inbounds i8, i8* %2, i64 %8
%11 = tail call i32 @memcpy(i8* %7, i8* %10, i32 %5)
%12 = icmp sgt i32 %4, 1
br i1 %12, label %13, label %29
13: ; preds = %1
%14 = zext i32 %5 to i64
br label %17
15: ; preds = %17
%16 = icmp eq i64 %28, %14
br i1 %16, label %29, label %17
17: ; preds = %13, %15
%18 = phi i64 [ 0, %13 ], [ %28, %15 ]
%19 = getelementptr inbounds i8, i8* %6, i64 %18
%20 = load i8, i8* %19
%21 = trunc i64 %18 to i32
%22 = xor i32 %21, -1
%23 = add i32 %5, %22
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %7, i64 %24
%26 = load i8, i8* %25
%27 = icmp eq i8 %20, %26
%28 = add nuw nsw i64 %18, 1
br i1 %27, label %15, label %29
29: ; preds = %17, %15, %1
%30 = phi i32 [ 1, %1 ], [ 1, %15 ], [ 0, %17 ]
ret i32 %30
}