#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 Pali_Hex(int decimal) {
  char arr_hexi[100];
  int i, length, palindrom_check = 1;
  sprintf(arr_hexi, "%x", decimal);
  length = strlen(arr_hexi);
  for (i = 0; i < length / 2; i++) {
    if (arr_hexi[i] != arr_hexi[length - 1 - i]) {
      palindrom_check = 0;
      break;
    }
  }
  return palindrom_check;
}


x86 assembly (clang, -O0):
<Pali_Hex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x1,-0x7c(%rbp)
lea    -0x70(%rbp),%rdi
mov    -0x4(%rbp),%edx
lea    0xebd(%rip),%rsi
call   1040 <sprintf@plt>
lea    -0x70(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x78(%rbp)
movl   $0x0,-0x74(%rbp)
mov    -0x74(%rbp),%eax
mov    %eax,-0x80(%rbp)
mov    -0x78(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x80(%rbp),%eax
cmp    %ecx,%eax
jge    11ba <Pali_Hex+0x9a>
movslq -0x74(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%eax
mov    -0x78(%rbp),%ecx
sub    $0x1,%ecx
sub    -0x74(%rbp),%ecx
movslq %ecx,%rcx
movsbl -0x70(%rbp,%rcx,1),%ecx
cmp    %ecx,%eax
je     11a7 <Pali_Hex+0x87>
movl   $0x0,-0x7c(%rbp)
jmp    11ba <Pali_Hex+0x9a>
jmp    11ac <Pali_Hex+0x8c>
mov    -0x74(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x74(%rbp)
jmp    115b <Pali_Hex+0x3b>
mov    -0x7c(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Pali_Hex>:
push   %rbx
sub    $0x70,%rsp
mov    %edi,%edx
lea    0xed2(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1040 <sprintf@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cmp    $0x2,%ecx
jl     117c <Pali_Hex+0x5c>
mov    %ecx,%edx
shr    %edx
add    $0xffffffff,%ecx
xor    %esi,%esi
cs nopw 0x0(%rax,%rax,1)
movzbl (%rsp,%rsi,1),%ebx
movslq %ecx,%rdi
cmp    (%rsp,%rdi,1),%bl
jne    117a <Pali_Hex+0x5a>
add    $0x1,%rsi
add    $0xffffffff,%ecx
cmp    %rsi,%rdx
jne    1160 <Pali_Hex+0x40>
jmp    117c <Pali_Hex+0x5c>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%x\00"
define i32 @Pali_Hex(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 %24
7: ; preds = %1
%8 = lshr i32 %5, 1
%9 = zext i32 %8 to i64
br label %12
10: ; preds = %12
%11 = icmp eq i64 %23, %9
br i1 %11, label %24, label %12
12: ; preds = %7, %10
%13 = phi i64 [ 0, %7 ], [ %23, %10 ]
%14 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %13
%15 = load i8, i8* %14
%16 = trunc i64 %13 to i32
%17 = xor i32 %16, -1
%18 = add i32 %5, %17
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %19
%21 = load i8, i8* %20
%22 = icmp eq i8 %15, %21
%23 = add nuw nsw i64 %13, 1
br i1 %22, label %10, label %24
24: ; preds = %10, %12, %1
%25 = phi i32 [ 1, %1 ], [ 0, %12 ], [ 1, %10 ]
ret i32 %25
}