#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 palindrom_in_hex(int);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int z;
  scanf("%d", &z);
  if (palindrom_in_hex(z) == 1) {
    printf("%X", z);
    return 1;
  }
  do {
    z++;
  } while (palindrom_in_hex(z) == 0);
  printf("%X", z);
  return 2;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x8(%rbp),%edi
call   1030 <palindrom_in_hex@plt>
cmp    $0x1,%eax
jne    117b <main+0x4b>
mov    -0x8(%rbp),%esi
lea    0xe99(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11b0 <main+0x80>
jmp    1180 <main+0x50>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <palindrom_in_hex@plt>
cmp    $0x0,%eax
je     1180 <main+0x50>
mov    -0x8(%rbp),%esi
lea    0xe5f(%rip),%rdi
call   1040 <printf@plt>
movl   $0x2,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xec4(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%edi
call   1030 <palindrom_in_hex@plt>
mov    $0x1,%ebx
cmp    $0x1,%eax
je     1179 <main+0x49>
nopl   0x0(%rax)
mov    0xc(%rsp),%edi
add    $0x1,%edi
mov    %edi,0xc(%rsp)
call   1030 <palindrom_in_hex@plt>
test   %eax,%eax
je     1160 <main+0x30>
mov    $0x2,%ebx
mov    0xc(%rsp),%esi
lea    0xe7f(%rip),%rdi
call   1040 <printf@plt>
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
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
store i32 0, i32* %1
%3 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%4 = load i32, i32* %2
%5 = call i32 @palindrom_in_hex(i32 %4)
%6 = icmp eq i32 %5, 1
br i1 %6, label %7, label %10
7: ; preds = %0
%8 = load i32, i32* %2
%9 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %8)
store i32 1, i32* %1
br label %21
10: ; preds = %0
br label %11
11: ; preds = %14, %10
%12 = load i32, i32* %2
%13 = add nsw i32 %12, 1
store i32 %13, i32* %2
br label %14
14: ; preds = %11
%15 = load i32, i32* %2
%16 = call i32 @palindrom_in_hex(i32 %15)
%17 = icmp eq i32 %16, 0
br i1 %17, label %11, label %18
18: ; preds = %14
%19 = load i32, i32* %2
%20 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %19)
store i32 2, i32* %1
br label %21
21: ; preds = %18, %7
%22 = load i32, i32* %1
ret i32 %22
}

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 = bitcast i32* %1 to i8*
%3 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%4 = load i32, i32* %1
%5 = call i32 @palindrom_in_hex(i32 %4)
%6 = icmp eq i32 %5, 1
br i1 %6, label %12, label %7
7: ; preds = %0, %7
%8 = load i32, i32* %1
%9 = add nsw i32 %8, 1
store i32 %9, i32* %1
%10 = call i32 @palindrom_in_hex(i32 %9)
%11 = icmp eq i32 %10, 0
br i1 %11, label %7, label %12
12: ; preds = %7, %0
%13 = phi i32 [ 1, %0 ], [ 2, %7 ]
%14 = load i32, i32* %1
%15 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %14)
ret i32 %13
}