#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*/ checking_palindr(char *, int);
int convert_hex(char *, int);
int /*<<< orphan*/ printf(char *, char);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  char hex[200];
  int b;
  scanf("%d", &b);
  if (b < 0)
    b = -b;
  int extent = convert_hex(hex, b);
  while (!checking_palindr(hex, extent)) {
    b += 1;
    extent = convert_hex(hex, b);
  }
  while (extent > 0) {
    extent--;
    printf("%c", hex[extent]);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xea7(%rip),%rdi
lea    -0xd4(%rbp),%rsi
call   1050 <scanf@plt>
cmpl   $0x0,-0xd4(%rbp)
jge    1180 <main+0x40>
xor    %eax,%eax
sub    -0xd4(%rbp),%eax
mov    %eax,-0xd4(%rbp)
lea    -0xd0(%rbp),%rdi
mov    -0xd4(%rbp),%esi
call   1040 <convert_hex@plt>
mov    %eax,-0xd8(%rbp)
lea    -0xd0(%rbp),%rdi
mov    -0xd8(%rbp),%esi
call   1060 <checking_palindr@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11bf <main+0x7f>
jmp    11eb <main+0xab>
mov    -0xd4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xd4(%rbp)
lea    -0xd0(%rbp),%rdi
mov    -0xd4(%rbp),%esi
call   1040 <convert_hex@plt>
mov    %eax,-0xd8(%rbp)
jmp    1198 <main+0x58>
jmp    11f0 <main+0xb0>
cmpl   $0x0,-0xd8(%rbp)
jle    122c <main+0xec>
mov    -0xd8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xd8(%rbp)
movslq -0xd8(%rbp),%rax
lea    0xde9(%rip),%rdi
movsbl -0xd0(%rbp,%rax,1),%esi
ff
call   1030 <printf@plt>
jmp    11f0 <main+0xb0>
mov    -0x4(%rbp),%eax
add    $0xe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0xd8,%rsp
lea    0xeaf(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%esi
test   %esi,%esi
jns    1169 <main+0x29>
neg    %esi
mov    %esi,0xc(%rsp)
lea    0x10(%rsp),%r14
mov    %r14,%rdi
call   1040 <convert_hex@plt>
mov    %eax,%ebx
mov    %r14,%rdi
mov    %eax,%esi
call   1060 <checking_palindr@plt>
test   %eax,%eax
jne    11b3 <main+0x73>
lea    0x10(%rsp),%r14
nopl   0x0(%rax,%rax,1)
mov    0xc(%rsp),%esi
add    $0x1,%esi
mov    %esi,0xc(%rsp)
mov    %r14,%rdi
call   1040 <convert_hex@plt>
mov    %eax,%ebx
mov    %r14,%rdi
mov    %eax,%esi
call   1060 <checking_palindr@plt>
test   %eax,%eax
je     1190 <main+0x50>
test   %ebx,%ebx
jle    11ea <main+0xaa>
mov    %ebx,%ebx
add    $0x1,%rbx
lea    0xe3f(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    -0x2(%rbx),%eax
movsbl 0x10(%rsp,%rax,1),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
add    $0xffffffffffffffff,%rbx
cmp    $0x1,%rbx
ja     11d0 <main+0x90>
xor    %eax,%eax
add    $0xd8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [3 x i8] c"%c\00"
define i32 @main() {
%1 = alloca [200 x i8]
%2 = alloca i32
%3 = getelementptr inbounds [200 x i8], [200 x i8]* %1, i64 0, i64 0
%4 = bitcast i32* %2 to i8*
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%6 = load i32, i32* %2
%7 = icmp slt i32 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %0
%9 = sub nsw i32 0, %6
store i32 %9, i32* %2
br label %10
10: ; preds = %8, %0
%11 = phi i32 [ %9, %8 ], [ %6, %0 ]
%12 = call i32 @convert_hex(i8* %3, i32 %11)
%13 = call i32 @checking_palindr(i8* %3, i32 %12)
%14 = icmp eq i32 %13, 0
br i1 %14, label %20, label %15
15: ; preds = %20, %10
%16 = phi i32 [ %12, %10 ], [ %23, %20 ]
%17 = icmp sgt i32 %16, 0
br i1 %17, label %18, label %34
18: ; preds = %15
%19 = zext i32 %16 to i64
br label %26
20: ; preds = %10, %20
%21 = load i32, i32* %2
%22 = add nsw i32 %21, 1
store i32 %22, i32* %2
%23 = call i32 @convert_hex(i8* %3, i32 %22)
%24 = call i32 @checking_palindr(i8* %3, i32 %23)
%25 = icmp eq i32 %24, 0
br i1 %25, label %20, label %15
26: ; preds = %18, %26
%27 = phi i64 [ %19, %18 ], [ %28, %26 ]
%28 = add nsw i64 %27, -1
%29 = and i64 %28, 4294967295
%30 = getelementptr inbounds [200 x i8], [200 x i8]* %1, i64 0, i64 %29
%31 = load i8, i8* %30
%32 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8 signext %31)
%33 = icmp ugt i64 %27, 1
br i1 %33, label %26, label %34
34: ; preds = %26, %15
ret i32 0
}