#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 dec_to_hex(int);
int strlen(char *);
int is_it_palindrome(int num, char num_hex[16]) {
  int counter_1 = 0, counter_2 = 0;
  while (num != 0) {
    num_hex[counter_1] = dec_to_hex(num % 16);
    num = num / 16;
    counter_1++;
  }
  num_hex[counter_1] = '\0';
  for (counter_1 = 0, counter_2 = strlen(num_hex) - 1;
       counter_1 < (strlen(num_hex) - 1); counter_1++, counter_2--) {
    if (num_hex[counter_1] != num_hex[counter_2]) {
      return 0;
    }
  }
  return 1;
}


x86 assembly (clang, -O0):
<is_it_palindrome>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     1182 <is_it_palindrome+0x62>
mov    -0x8(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
mov    %edx,%edi
call   1040 <dec_to_hex@plt>
mov    %al,%dl
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x8(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    113d <is_it_palindrome+0x1d>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
sub    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    120b <is_it_palindrome+0xeb>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    -0x10(%rbp),%rcx
movslq -0x18(%rbp),%rdx
movsbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
je     11ef <is_it_palindrome+0xcf>
movl   $0x0,-0x4(%rbp)
jmp    1212 <is_it_palindrome+0xf2>
jmp    11f4 <is_it_palindrome+0xd4>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
jmp    11a4 <is_it_palindrome+0x84>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_it_palindrome>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r15
test   %edi,%edi
je     115f <is_it_palindrome+0x3f>
xor    %ebp,%ebp
lea    0xf(%rdi),%r14d
test   %edi,%edi
mov    %edi,%ebx
cmovs  %r14d,%ebx
mov    %ebx,%eax
and    $0xfffffff0,%eax
sub    %eax,%edi
call   1040 <dec_to_hex@plt>
mov    %al,(%r15,%rbp,1)
sar    $0x4,%ebx
add    $0x1,%rbp
mov    %ebx,%edi
cmp    $0x1e,%r14d
ja     1130 <is_it_palindrome+0x10>
mov    %ebp,%eax
jmp    1161 <is_it_palindrome+0x41>
xor    %eax,%eax
movb   $0x0,(%r15,%rax,1)
mov    %r15,%rdi
call   1030 <strlen@plt>
mov    %eax,%ebp
mov    %r15,%rdi
call   1030 <strlen@plt>
mov    $0x1,%r14d
cmp    $0x2,%eax
jl     11ba <is_it_palindrome+0x9a>
movslq %ebp,%rbp
add    $0xffffffffffffffff,%rbp
xor    %ebx,%ebx
nopl   0x0(%rax)
movzbl (%r15,%rbx,1),%eax
cmp    (%r15,%rbp,1),%al
jne    11b7 <is_it_palindrome+0x97>
add    $0x1,%rbx
mov    %r15,%rdi
call   1030 <strlen@plt>
add    $0xffffffff,%eax
cltq
add    $0xffffffffffffffff,%rbp
cmp    %rax,%rbx
jl     1190 <is_it_palindrome+0x70>
jmp    11ba <is_it_palindrome+0x9a>
xor    %r14d,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @is_it_palindrome(i32 %0, i8* %1) {
%3 = icmp eq i32 %0, 0
br i1 %3, label %16, label %4
4: ; preds = %2, %4
%5 = phi i64 [ %11, %4 ], [ 0, %2 ]
%6 = phi i32 [ %10, %4 ], [ %0, %2 ]
%7 = srem i32 %6, 16
%8 = tail call signext i8 @dec_to_hex(i32 %7)
%9 = getelementptr inbounds i8, i8* %1, i64 %5
store i8 %8, i8* %9
%10 = sdiv i32 %6, 16
%11 = add nuw i64 %5, 1
%12 = add i32 %6, 15
%13 = icmp ult i32 %12, 31
br i1 %13, label %14, label %4
14: ; preds = %4
%15 = and i64 %11, 4294967295
br label %16
16: ; preds = %14, %2
%17 = phi i64 [ 0, %2 ], [ %15, %14 ]
%18 = getelementptr inbounds i8, i8* %1, i64 %17
store i8 0, i8* %18
%19 = tail call i32 @strlen(i8* %1)
%20 = tail call i32 @strlen(i8* %1)
%21 = icmp sgt i32 %20, 1
br i1 %21, label %22, label %39
22: ; preds = %16
%23 = sext i32 %19 to i64
br label %29
24: ; preds = %29
%25 = tail call i32 @strlen(i8* %1)
%26 = add nsw i32 %25, -1
%27 = sext i32 %26 to i64
%28 = icmp slt i64 %38, %27
br i1 %28, label %29, label %39
29: ; preds = %22, %24
%30 = phi i64 [ 0, %22 ], [ %38, %24 ]
%31 = phi i64 [ %23, %22 ], [ %32, %24 ]
%32 = add nsw i64 %31, -1
%33 = getelementptr inbounds i8, i8* %1, i64 %30
%34 = load i8, i8* %33
%35 = getelementptr inbounds i8, i8* %1, i64 %32
%36 = load i8, i8* %35
%37 = icmp eq i8 %34, %36
%38 = add nuw nsw i64 %30, 1
br i1 %37, label %24, label %39
39: ; preds = %29, %24, %16
%40 = phi i32 [ 1, %16 ], [ 1, %24 ], [ 0, %29 ]
ret i32 %40
}