#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*/ sprintf(char *, char *, int);
int strlen(char *);
int IsHeximalPal(int n) {
  int i;
  char string[100];
  sprintf(string, "%x", n);
  for (i = 0; i < (strlen(string) / 2); i++) {
    if (string[i] != string[strlen(string) - i - 1])
      break;
  }
  if (i == strlen(string) / 2)
    return 1;
  else
    return 0;
}


x86 assembly (clang, -O0):
<IsHeximalPal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %edi,-0x8(%rbp)
lea    -0x70(%rbp),%rdi
mov    -0x8(%rbp),%edx
lea    0xec4(%rip),%rsi
call   1040 <sprintf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x74(%rbp)
lea    -0x70(%rbp),%rdi
call   1030 <strlen@plt>
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x74(%rbp),%eax
cmp    %ecx,%eax
jge    11b4 <IsHeximalPal+0x94>
movslq -0xc(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%eax
mov    %eax,-0x78(%rbp)
lea    -0x70(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x78(%rbp),%eax
sub    -0xc(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl -0x70(%rbp,%rcx,1),%ecx
cmp    %ecx,%eax
je     11a1 <IsHeximalPal+0x81>
jmp    11b4 <IsHeximalPal+0x94>
jmp    11a6 <IsHeximalPal+0x86>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1148 <IsHeximalPal+0x28>
mov    -0xc(%rbp),%eax
mov    %eax,-0x7c(%rbp)
lea    -0x70(%rbp),%rdi
call   1030 <strlen@plt>
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x7c(%rbp),%eax
cmp    %ecx,%eax
jne    11e4 <IsHeximalPal+0xc4>
movl   $0x1,-0x4(%rbp)
jmp    11eb <IsHeximalPal+0xcb>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<IsHeximalPal>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x68,%rsp
mov    %edi,%edx
lea    0xecd(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1040 <sprintf@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
xor    %ebx,%ebx
cmp    $0x2,%eax
jl     1197 <IsHeximalPal+0x77>
mov    $0xffffffff,%ebp
xor    %ebx,%ebx
mov    %rsp,%r14
nopw   0x0(%rax,%rax,1)
movzbl (%rsp,%rbx,1),%r15d
mov    %r14,%rdi
call   1030 <strlen@plt>
add    %ebp,%eax
cltq
cmp    (%rsp,%rax,1),%r15b
jne    1197 <IsHeximalPal+0x77>
add    $0x1,%rbx
mov    %r14,%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
sar    %ecx
movslq %ecx,%rax
add    $0xffffffff,%ebp
cmp    %rax,%rbx
jl     1160 <IsHeximalPal+0x40>
mov    %rsp,%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
sar    %ecx
xor    %eax,%eax
cmp    %ecx,%ebx
sete   %al
add    $0x68,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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