#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 cases(char);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, long long *);
int strlen(char *);
int main() {
  long long int number;
  long long int replacer;
  char hexnumber[100];
  int check = 0;
  scanf("%lli", &number);
  if (number <= 16) {
    hexnumber[0] = number % 16;
    hexnumber[0] = cases(hexnumber[0]);
    printf("%c\n", hexnumber[0]);
    return 0;
  }
  do {
    replacer = number;
    for (int i = 0; replacer != 0; i++) {
      hexnumber[i] = replacer % 16;
      replacer /= 16;
      hexnumber[i] = cases(hexnumber[i]);
    }
    for (int i = 0; i < strlen(hexnumber) / 2; i++) {
      if (hexnumber[i] == hexnumber[strlen(hexnumber) - i - 1]) {
        check = 1;
      } else {
        check = 0;
        break;
      }
    }
    number++;
  } while (check == 0);
  printf("%s\n", hexnumber);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x84(%rbp)
lea    0xe9d(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1060 <scanf@plt>
cmpq   $0x10,-0x10(%rbp)
jg     11b4 <main+0x74>
mov    -0x10(%rbp),%rax
mov    $0x10,%ecx
cqto
idiv   %rcx
mov    %dl,%al
mov    %al,-0x80(%rbp)
movsbl -0x80(%rbp),%edi
call   1030 <cases@plt>
mov    %al,-0x80(%rbp)
movsbl -0x80(%rbp),%esi
lea    0xe64(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1311 <main+0x1d1>
jmp    11b9 <main+0x79>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x88(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1235 <main+0xf5>
mov    -0x18(%rbp),%rax
mov    $0x10,%ecx
cqto
idiv   %rcx
mov    %dl,%cl
movslq -0x88(%rbp),%rax
mov    %cl,-0x80(%rbp,%rax,1)
mov    -0x18(%rbp),%rax
mov    $0x10,%ecx
cqto
idiv   %rcx
mov    %rax,-0x18(%rbp)
movslq -0x88(%rbp),%rax
movsbl -0x80(%rbp,%rax,1),%edi
call   1030 <cases@plt>
mov    %al,%cl
movslq -0x88(%rbp),%rax
mov    %cl,-0x80(%rbp,%rax,1)
mov    -0x88(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x88(%rbp)
jmp    11cb <main+0x8b>
movl   $0x0,-0x8c(%rbp)
mov    -0x8c(%rbp),%eax
mov    %eax,-0x90(%rbp)
lea    -0x80(%rbp),%rdi
call   1040 <strlen@plt>
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x90(%rbp),%eax
cmp    %ecx,%eax
jge    12df <main+0x19f>
movslq -0x8c(%rbp),%rax
movsbl -0x80(%rbp,%rax,1),%eax
mov    %eax,-0x94(%rbp)
lea    -0x80(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x94(%rbp),%eax
sub    -0x8c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl -0x80(%rbp,%rcx,1),%ecx
cmp    %ecx,%eax
jne    12b7 <main+0x177>
movl   $0x1,-0x84(%rbp)
jmp    12c6 <main+0x186>
movl   $0x0,-0x84(%rbp)
jmp    12df <main+0x19f>
jmp    12cb <main+0x18b>
mov    -0x8c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8c(%rbp)
jmp    123f <main+0xff>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
cmpl   $0x0,-0x84(%rbp)
je     11b9 <main+0x79>
lea    -0x80(%rbp),%rsi
lea    0xd06(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x78,%rsp
lea    0xe9f(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1070 <scanf@plt>
mov    0x8(%rsp),%rax
cmp    $0x11,%rax
jge    11a5 <main+0x55>
lea    0xf(%rax),%ecx
test   %rax,%rax
cmovns %eax,%ecx
and    $0xf0,%ecx
sub    %ecx,%eax
movsbl %al,%edi
call   1040 <cases@plt>
movsbl %al,%esi
lea    0xe6c(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    126d <main+0x11d>
lea    0x10(%rsp),%r14
jmp    11be <main+0x6e>
nopl   0x0(%rax)
mov    0x8(%rsp),%rax
add    $0x1,%rax
mov    %rax,0x8(%rsp)
test   %rax,%rax
je     1202 <main+0xb2>
mov    %r14,%rbx
mov    %rax,%rbp
nopl   0x0(%rax)
lea    0xf(%rax),%r15
test   %rax,%rax
cmovs  %r15,%rbp
mov    %rbp,%rcx
and    $0xfffffffffffffff0,%rcx
sub    %rcx,%rax
mov    %al,(%rbx)
sar    $0x4,%rbp
movsbl %al,%edi
call   1040 <cases@plt>
mov    %al,(%rbx)
add    $0x1,%rbx
mov    %rbp,%rax
cmp    $0x1f,%r15
jae    11d0 <main+0x80>
mov    %r14,%rdi
call   1050 <strlen@plt>
cmp    $0x2,%eax
jl     11b0 <main+0x60>
mov    $0xffffffff,%ebp
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
movzbl 0x10(%rsp,%rbx,1),%r15d
mov    %r14,%rdi
call   1050 <strlen@plt>
add    %ebp,%eax
cltq
add    $0x1,%rbx
cmp    0x10(%rsp,%rax,1),%r15b
jne    11b0 <main+0x60>
mov    %r14,%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
sar    %ecx
movslq %ecx,%rax
add    $0xffffffff,%ebp
cmp    %rax,%rbx
jl     1220 <main+0xd0>
addq   $0x1,0x8(%rsp)
lea    0x10(%rsp),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x78,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%lli\00"
@.str.1 = [4 x i8] c"%c\0A\00"
@.str.2 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
%4 = alloca [100 x i8]
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %5
%8 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64* %2)
%9 = load i64, i64* %2
%10 = icmp sle i64 %9, 16
br i1 %10, label %11, label %24
11: ; preds = %0
%12 = load i64, i64* %2
%13 = srem i64 %12, 16
%14 = trunc i64 %13 to i8
%15 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
store i8 %14, i8* %15
%16 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%17 = load i8, i8* %16
%18 = call signext i8 @cases(i8 signext %17)
%19 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
store i8 %18, i8* %19
%20 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %22)
store i32 0, i32* %1
br label %88
24: ; preds = %0
br label %25
25: ; preds = %82, %24
%26 = load i64, i64* %2
store i64 %26, i64* %3
store i32 0, i32* %6
br label %27
27: ; preds = %47, %25
%28 = load i64, i64* %3
%29 = icmp ne i64 %28, 0
br i1 %29, label %30, label %50
30: ; preds = %27
%31 = load i64, i64* %3
%32 = srem i64 %31, 16
%33 = trunc i64 %32 to i8
%34 = load i32, i32* %6
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 %35
store i8 %33, i8* %36
%37 = load i64, i64* %3
%38 = sdiv i64 %37, 16
store i64 %38, i64* %3
%39 = load i32, i32* %6
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 %40
%42 = load i8, i8* %41
%43 = call signext i8 @cases(i8 signext %42)
%44 = load i32, i32* %6
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 %45
store i8 %43, i8* %46
br label %47
47: ; preds = %30
%48 = load i32, i32* %6
%49 = add nsw i32 %48, 1
store i32 %49, i32* %6
br label %27
50: ; preds = %27
store i32 0, i32* %7
br label %51
51: ; preds = %76, %50
%52 = load i32, i32* %7
%53 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%54 = call i32 @strlen(i8* %53)
%55 = sdiv i32 %54, 2
%56 = icmp slt i32 %52, %55
br i1 %56, label %57, label %79
57: ; preds = %51
%58 = load i32, i32* %7
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 %59
%61 = load i8, i8* %60
%62 = sext i8 %61 to i32
%63 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%64 = call i32 @strlen(i8* %63)
%65 = load i32, i32* %7
%66 = sub nsw i32 %64, %65
%67 = sub nsw i32 %66, 1
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 %68
%70 = load i8, i8* %69
%71 = sext i8 %70 to i32
%72 = icmp eq i32 %62, %71
br i1 %72, label %73, label %74
73: ; preds = %57
store i32 1, i32* %5
br label %75
74: ; preds = %57
store i32 0, i32* %5
br label %79
75: ; preds = %73
br label %76
76: ; preds = %75
%77 = load i32, i32* %7
%78 = add nsw i32 %77, 1
store i32 %78, i32* %7
br label %51
79: ; preds = %74, %51
%80 = load i64, i64* %2
%81 = add nsw i64 %80, 1
store i64 %81, i64* %2
br label %82
82: ; preds = %79
%83 = load i32, i32* %5
%84 = icmp eq i32 %83, 0
br i1 %84, label %25, label %85
85: ; preds = %82
%86 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%87 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %86)
store i32 0, i32* %1
br label %88
88: ; preds = %85, %11
%89 = load i32, i32* %1
ret i32 %89
}

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