#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 hexadecimal(int);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ scanf(char *, int *);
int strlen(char *);
int main() {
  int number, number2, counter, counter2, check;
  char hex[16];
  scanf("%d", &number);
  do {
    for (counter = 0, number2 = number; number2 != 0; counter++) {
      hex[counter] = hexadecimal(number2 % 16);
      number2 /= 16;
    }
    hex[counter] = '\0';
    for (counter = 0, counter2 = strlen(hex) - 1, check = 1;
         counter < (strlen(hex) - 1); counter++, counter2--) {
      if (hex[counter] != hex[counter2]) {
        check = 0;
        number++;
      }
    }
  } while (!check);
  printf("%s \n", hex);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1060 <scanf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     11ae <main+0x6e>
mov    -0xc(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
mov    %edx,%edi
call   1050 <hexadecimal@plt>
mov    %al,%cl
movslq -0x10(%rbp),%rax
mov    %cl,-0x30(%rbp,%rax,1)
mov    -0xc(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    116c <main+0x2c>
movslq -0x10(%rbp),%rax
movb   $0x0,-0x30(%rbp,%rax,1)
movl   $0x0,-0x10(%rbp)
lea    -0x30(%rbp),%rdi
call   1030 <strlen@plt>
sub    $0x1,%eax
mov    %eax,-0x14(%rbp)
movl   $0x1,-0x18(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x34(%rbp)
lea    -0x30(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x34(%rbp),%eax
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1239 <main+0xf9>
movslq -0x10(%rbp),%rax
movsbl -0x30(%rbp,%rax,1),%eax
movslq -0x14(%rbp),%rcx
movsbl -0x30(%rbp,%rcx,1),%ecx
cmp    %ecx,%eax
je     121d <main+0xdd>
movl   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1222 <main+0xe2>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    11d4 <main+0x94>
jmp    123e <main+0xfe>
cmpl   $0x0,-0x18(%rbp)
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    115f <main+0x1f>
lea    -0x30(%rbp),%rsi
lea    0xda9(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x28,%rsp
lea    0xeaf(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
lea    0x10(%rsp),%r14
jmp    1179 <main+0x39>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
test   %r15d,%r15d
jne    1223 <main+0xe3>
mov    0xc(%rsp),%edi
xor    %ebx,%ebx
test   %edi,%edi
je     11bb <main+0x7b>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    0xf(%rdi),%r15d
test   %edi,%edi
mov    %edi,%ebp
cmovs  %r15d,%ebp
mov    %ebp,%eax
and    $0xfffffff0,%eax
sub    %eax,%edi
call   1050 <hexadecimal@plt>
mov    %al,0x10(%rsp,%rbx,1)
sar    $0x4,%ebp
add    $0x1,%rbx
mov    %ebp,%edi
cmp    $0x1e,%r15d
ja     1190 <main+0x50>
mov    %ebx,%eax
movb   $0x0,0x10(%rsp,%rax,1)
mov    %r14,%rdi
call   1030 <strlen@plt>
mov    %eax,%ebp
mov    %r14,%rdi
call   1030 <strlen@plt>
cmp    $0x2,%eax
jl     1223 <main+0xe3>
movslq %ebp,%rbp
add    $0xffffffffffffffff,%rbp
mov    $0x1,%r15d
xor    %ebx,%ebx
jmp    120e <main+0xce>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rbx
mov    %r14,%rdi
call   1030 <strlen@plt>
add    $0xffffffff,%eax
cltq
add    $0xffffffffffffffff,%rbp
cmp    %rax,%rbx
jge    1170 <main+0x30>
movzbl 0x10(%rsp,%rbx,1),%eax
cmp    0x10(%rsp,%rbp,1),%al
je     11f0 <main+0xb0>
addl   $0x1,0xc(%rsp)
xor    %r15d,%r15d
jmp    11f0 <main+0xb0>
lea    0xdd9(%rip),%rdi
lea    0x10(%rsp),%rsi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [5 x i8] c"%s \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca [16 x i8]
store i32 0, i32* %1
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
br label %9
9: ; preds = %61, %0
store i32 0, i32* %4
%10 = load i32, i32* %2
store i32 %10, i32* %3
br label %11
11: ; preds = %23, %9
%12 = load i32, i32* %3
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %26
14: ; preds = %11
%15 = load i32, i32* %3
%16 = srem i32 %15, 16
%17 = call signext i8 @hexadecimal(i32 %16)
%18 = load i32, i32* %4
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 %19
store i8 %17, i8* %20
%21 = load i32, i32* %3
%22 = sdiv i32 %21, 16
store i32 %22, i32* %3
br label %23
23: ; preds = %14
%24 = load i32, i32* %4
%25 = add nsw i32 %24, 1
store i32 %25, i32* %4
br label %11
26: ; preds = %11
%27 = load i32, i32* %4
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 %28
store i8 0, i8* %29
store i32 0, i32* %4
%30 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 0
%31 = call i32 @strlen(i8* %30)
%32 = sub nsw i32 %31, 1
store i32 %32, i32* %5
store i32 1, i32* %6
br label %33
33: ; preds = %55, %26
%34 = load i32, i32* %4
%35 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 0
%36 = call i32 @strlen(i8* %35)
%37 = sub nsw i32 %36, 1
%38 = icmp slt i32 %34, %37
br i1 %38, label %39, label %60
39: ; preds = %33
%40 = load i32, i32* %4
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 %41
%43 = load i8, i8* %42
%44 = sext i8 %43 to i32
%45 = load i32, i32* %5
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 %46
%48 = load i8, i8* %47
%49 = sext i8 %48 to i32
%50 = icmp ne i32 %44, %49
br i1 %50, label %51, label %54
51: ; preds = %39
store i32 0, i32* %6
%52 = load i32, i32* %2
%53 = add nsw i32 %52, 1
store i32 %53, i32* %2
br label %54
54: ; preds = %51, %39
br label %55
55: ; preds = %54
%56 = load i32, i32* %4
%57 = add nsw i32 %56, 1
store i32 %57, i32* %4
%58 = load i32, i32* %5
%59 = add nsw i32 %58, -1
store i32 %59, i32* %5
br label %33
60: ; preds = %33
br label %61
61: ; preds = %60
%62 = load i32, i32* %6
%63 = icmp ne i32 %62, 0
%64 = xor i1 %63, true
br i1 %64, label %9, label %65
65: ; preds = %61
%66 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 0
%67 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %66)
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [5 x i8] c"%s \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [16 x i8]
%3 = bitcast i32* %1 to i8*
%4 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 0
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
br label %6
6: ; preds = %48, %0
%7 = load i32, i32* %1
%8 = icmp eq i32 %7, 0
br i1 %8, label %19, label %9
9: ; preds = %6, %9
%10 = phi i64 [ %16, %9 ], [ 0, %6 ]
%11 = phi i32 [ %15, %9 ], [ %7, %6 ]
%12 = srem i32 %11, 16
%13 = call signext i8 @hexadecimal(i32 %12)
%14 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 %10
store i8 %13, i8* %14
%15 = sdiv i32 %11, 16
%16 = add nuw i64 %10, 1
%17 = add i32 %11, 15
%18 = icmp ult i32 %17, 31
br i1 %18, label %19, label %9
19: ; preds = %9, %6
%20 = phi i64 [ 0, %6 ], [ %16, %9 ]
%21 = and i64 %20, 4294967295
%22 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 %21
store i8 0, i8* %22
%23 = call i32 @strlen(i8* %4)
%24 = call i32 @strlen(i8* %4)
%25 = icmp sgt i32 %24, 1
br i1 %25, label %26, label %50
26: ; preds = %19
%27 = sext i32 %23 to i64
br label %28
28: ; preds = %26, %41
%29 = phi i64 [ 0, %26 ], [ %43, %41 ]
%30 = phi i64 [ %27, %26 ], [ %32, %41 ]
%31 = phi i32 [ 1, %26 ], [ %42, %41 ]
%32 = add nsw i64 %30, -1
%33 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 %29
%34 = load i8, i8* %33
%35 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 %32
%36 = load i8, i8* %35
%37 = icmp eq i8 %34, %36
br i1 %37, label %41, label %38
38: ; preds = %28
%39 = load i32, i32* %1
%40 = add nsw i32 %39, 1
store i32 %40, i32* %1
br label %41
41: ; preds = %28, %38
%42 = phi i32 [ 0, %38 ], [ %31, %28 ]
%43 = add nuw nsw i64 %29, 1
%44 = call i32 @strlen(i8* %4)
%45 = add nsw i32 %44, -1
%46 = sext i32 %45 to i64
%47 = icmp slt i64 %43, %46
br i1 %47, label %28, label %48
48: ; preds = %41
%49 = icmp eq i32 %42, 0
br i1 %49, label %6, label %50
50: ; preds = %19, %48
%51 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %4)
ret i32 0
}