#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);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int palcheck(int n) {
  char hex[100];
  char reverse[100];
  int i;
  sprintf(hex, "%X", n);
  strcpy(reverse, hex);
  for (i = 0; i < strlen(hex); ++i) {
    reverse[strlen(hex) - i - 1] = hex[i];
  }
  if (strcmp(reverse, hex) == 0)
    return 1;
  else
    return 0;
}


x86 assembly (clang, -O0):
<palcheck>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
mov    %edi,-0x8(%rbp)
lea    -0x70(%rbp),%rdi
mov    -0x8(%rbp),%edx
lea    0xea4(%rip),%rsi
call   1060 <sprintf@plt>
lea    -0xe0(%rbp),%rdi
lea    -0x70(%rbp),%rsi
call   1030 <strcpy@plt>
movl   $0x0,-0xe4(%rbp)
mov    -0xe4(%rbp),%eax
mov    %eax,-0xe8(%rbp)
lea    -0x70(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0xe8(%rbp),%eax
cmp    %ecx,%eax
jge    11e6 <palcheck+0xa6>
movslq -0xe4(%rbp),%rax
mov    -0x70(%rbp,%rax,1),%al
mov    %al,-0xe9(%rbp)
lea    -0x70(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0xe9(%rbp),%cl
sub    -0xe4(%rbp),%eax
sub    $0x1,%eax
cltq
mov    %cl,-0xe0(%rbp,%rax,1)
mov    -0xe4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xe4(%rbp)
jmp    117b <palcheck+0x3b>
lea    -0xe0(%rbp),%rdi
lea    -0x70(%rbp),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    120c <palcheck+0xcc>
movl   $0x1,-0x4(%rbp)
jmp    1213 <palcheck+0xd3>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<palcheck>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0xd8,%rsp
mov    %edi,%edx
lea    0xeaa(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1060 <sprintf@plt>
lea    0x70(%rsp),%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jle    11bc <palcheck+0x7c>
mov    $0xffffffff,%ebp
xor    %ebx,%ebx
mov    %rsp,%r14
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movzbl (%rsp,%rbx,1),%r15d
mov    %r14,%rdi
call   1040 <strlen@plt>
add    %ebp,%eax
cltq
mov    %r15b,0x70(%rsp,%rax,1)
add    $0x1,%rbx
mov    %r14,%rdi
call   1040 <strlen@plt>
cltq
add    $0xffffffff,%ebp
cmp    %rax,%rbx
jl     1190 <palcheck+0x50>
lea    0x70(%rsp),%rdi
mov    %rsp,%rsi
call   1050 <strcmp@plt>
xor    %ecx,%ecx
test   %rax,%rax
sete   %cl
mov    %ecx,%eax
add    $0xd8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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