#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*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, int *);
int strlen(char *);
int main() {
  int number, index = 0, lenght, newnumber, breaker = 0, i;
  char hex[10];
  scanf("%d", &number);
  newnumber = number;
  for (i = 0; i < 10; i++)
    hex[i] = 0;
  while (1) {
    number = newnumber;
    while (number > 0) {
      hex[index] = number % 16 + 48;
      number = number / 16;
      index++;
    }
    lenght = strlen(hex) - 1;
    for (index = 0; index < strlen(hex) - 1 / 2; index++, lenght--) {
      if (hex[index] != hex[lenght]) {
        newnumber++;
        breaker = 0;
        break;
      } else
        breaker = 1;
    }
    if (breaker == 1)
      break;
  }
  printf("%X", newnumber);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x18(%rbp)
lea    0xeac(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0xa,-0x1c(%rbp)
jge    118b <main+0x5b>
movslq -0x1c(%rbp),%rax
movb   $0x0,-0x26(%rbp,%rax,1)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    116a <main+0x3a>
jmp    1190 <main+0x60>
mov    -0x14(%rbp),%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jle    11d4 <main+0xa4>
mov    -0x8(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
add    $0x30,%edx
mov    %dl,%cl
movslq -0xc(%rbp),%rax
mov    %cl,-0x26(%rbp,%rax,1)
mov    -0x8(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1196 <main+0x66>
lea    -0x26(%rbp),%rdi
call   1030 <strlen@plt>
sub    $0x1,%eax
mov    %eax,-0x10(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x2c(%rbp)
lea    -0x26(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
sub    $0x0,%ecx
cmp    %ecx,%eax
jge    125b <main+0x12b>
movslq -0xc(%rbp),%rax
movsbl -0x26(%rbp,%rax,1),%eax
movslq -0x10(%rbp),%rcx
movsbl -0x26(%rbp,%rcx,1),%ecx
cmp    %ecx,%eax
je     1238 <main+0x108>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
jmp    125b <main+0x12b>
movl   $0x1,-0x18(%rbp)
jmp    1244 <main+0x114>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
jmp    11ea <main+0xba>
cmpl   $0x1,-0x18(%rbp)
jne    126a <main+0x13a>
jmp    126f <main+0x13f>
jmp    1190 <main+0x60>
mov    -0x14(%rbp),%esi
lea    0xd8a(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
lea    0xebf(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%r15d
movq   $0x0,0x8(%rsp)
movw   $0x0,0x10(%rsp)
xor    %ebx,%ebx
lea    0x8(%rsp),%r14
jmp    118b <main+0x5b>
nopl   0x0(%rax)
mov    %r14,%rdi
call   1030 <strlen@plt>
mov    %eax,%ebp
mov    %r14,%rdi
call   1030 <strlen@plt>
mov    $0x0,%ebx
test   %eax,%eax
jg     11be <main+0x8e>
mov    %r15d,0x4(%rsp)
test   %r15d,%r15d
jle    1170 <main+0x40>
lea    (%rsp,%rbx,1),%rax
add    $0x8,%rax
mov    %r15d,%ecx
mov    %ecx,%edx
mov    %edx,%ebx
and    $0xf,%bl
or     $0x30,%bl
mov    %bl,(%rax)
shr    $0x4,%ecx
add    $0x1,%rax
cmp    $0xf,%edx
ja     11a0 <main+0x70>
mov    %ecx,0x4(%rsp)
jmp    1170 <main+0x40>
movslq %ebp,%rbp
add    $0xffffffffffffffff,%rbp
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
movzbl 0x8(%rsp,%rbx,1),%eax
cmp    0x8(%rsp,%rbp,1),%al
jne    11f4 <main+0xc4>
add    $0x1,%rbx
mov    %r14,%rdi
call   1030 <strlen@plt>
cltq
add    $0xffffffffffffffff,%rbp
cmp    %rax,%rbx
jl     11d0 <main+0xa0>
jmp    11fa <main+0xca>
add    $0x1,%r15d
jmp    118b <main+0x5b>
lea    0xe02(%rip),%rdi
mov    %r15d,%esi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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