#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 /*<<< orphan*/ scanf(char *, int *);
int main() {
  int ch[10000];
  char ch1[16] = {'0', '1', '2', '3', '4', '5', '6', '7',
                  '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
  int a, i = 0, j, m;
  scanf("%d", &a);
  while (a) {
    ch[i] = a % 16;
    a /= 16;
    i++;
  }
  for (j = i - 1; j >= 0; j--) {
    m = ch[j];
    printf("%c", ch1[m]);
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x9c70,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xec7(%rip),%rax
mov    %rax,-0x9c60(%rbp)
mov    0xec1(%rip),%rax
mov    %rax,-0x9c58(%rbp)
movl   $0x0,-0x9c68(%rbp)
lea    0xeb1(%rip),%rdi
lea    -0x9c64(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,-0x9c64(%rbp)
je     11bc <main+0x9c>
mov    -0x9c64(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
movslq -0x9c68(%rbp),%rax
mov    %edx,-0x9c50(%rbp,%rax,4)
mov    -0x9c64(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
mov    %eax,-0x9c64(%rbp)
mov    -0x9c68(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x9c68(%rbp)
jmp    116b <main+0x4b>
mov    -0x9c68(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x9c6c(%rbp)
cmpl   $0x0,-0x9c6c(%rbp)
jl     121d <main+0xfd>
movslq -0x9c6c(%rbp),%rax
mov    -0x9c50(%rbp,%rax,4),%eax
mov    %eax,-0x9c70(%rbp)
movslq -0x9c70(%rbp),%rax
movsbl -0x9c60(%rbp,%rax,1),%esi
ff
lea    0xe11(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x9c6c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x9c6c(%rbp)
jmp    11cb <main+0xab>
lea    0xdf2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x9c70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x9c58,%rsp
lea    0xedf(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
mov    0xc(%rsp),%ecx
test   %ecx,%ecx
je     11ac <main+0x8c>
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
nop
lea    0xf(%rcx),%edx
test   %ecx,%ecx
mov    %ecx,%esi
cmovs  %edx,%esi
mov    %esi,%edi
and    $0xfffffff0,%edi
sub    %edi,%ecx
mov    %ecx,0x10(%rsp,%rax,4)
mov    %esi,%ecx
sar    $0x4,%ecx
add    $0x1,%rax
cmp    $0x1f,%edx
jae    1150 <main+0x30>
mov    %ecx,0xc(%rsp)
test   %eax,%eax
jle    11ac <main+0x8c>
mov    %eax,%ebx
add    $0x1,%rbx
lea    0xe78(%rip),%r14
nopl   0x0(%rax,%rax,1)
lea    -0x2(%rbx),%eax
movslq 0x10(%rsp,%rax,4),%rax
movsbl (%rax,%r14,1),%edi
call   1030 <putchar@plt>
add    $0xffffffffffffffff,%rbx
cmp    $0x1,%rbx
ja     1190 <main+0x70>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x9c58,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@__const.main.ch1 = [16 x i8] c"0123456789ABCDEF"
@.str = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca [10000 x i32]
%2 = alloca i32
%3 = bitcast [10000 x i32]* %1 to i8*
%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 eq i32 %6, 0
br i1 %7, label %34, label %13
8: ; preds = %13
%9 = trunc i64 %19 to i32
store i32 %18, i32* %2
%10 = icmp sgt i32 %9, 0
br i1 %10, label %11, label %34
11: ; preds = %8
%12 = and i64 %19, 4294967295
br label %22
13: ; preds = %0, %13
%14 = phi i64 [ %19, %13 ], [ 0, %0 ]
%15 = phi i32 [ %18, %13 ], [ %6, %0 ]
%16 = srem i32 %15, 16
%17 = getelementptr inbounds [10000 x i32], [10000 x i32]* %1, i64 0, i64 %14
store i32 %16, i32* %17
%18 = sdiv i32 %15, 16
%19 = add nuw i64 %14, 1
%20 = add i32 %15, 15
%21 = icmp ult i32 %20, 31
br i1 %21, label %8, label %13
22: ; preds = %11, %22
%23 = phi i64 [ %12, %11 ], [ %24, %22 ]
%24 = add nsw i64 %23, -1
%25 = and i64 %24, 4294967295
%26 = getelementptr inbounds [10000 x i32], [10000 x i32]* %1, i64 0, i64 %25
%27 = load i32, i32* %26
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [16 x i8], [16 x i8]* @__const.main.ch1, i64 0, i64 %28
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = call i32 @putchar(i32 %31)
%33 = icmp ugt i64 %23, 1
br i1 %33, label %22, label %34
34: ; preds = %22, %0, %8
%35 = call i32 @putchar(i32 10)
ret i32 0
}