#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 *, char);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int num;
  scanf("%d", &num);
  char hexa[100];
  int i = 0, j;
  while (num != 0) {
    int temp = 0;
    temp = num % 16;
    if (temp < 10) {
      hexa[i] = temp + 48;
      i++;
    } else {
      hexa[i] = temp + 55;
      i++;
    }
    num = num / 16;
  }
  for (j = i - 1; j >= 0; j--)
    printf("%c", hexa[j]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xec7(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x0,-0x74(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     11bc <main+0x9c>
movl   $0x0,-0x7c(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
mov    %edx,-0x7c(%rbp)
cmpl   $0xa,-0x7c(%rbp)
jge    1190 <main+0x70>
mov    -0x7c(%rbp),%eax
add    $0x30,%eax
mov    %al,%cl
movslq -0x74(%rbp),%rax
mov    %cl,-0x70(%rbp,%rax,1)
mov    -0x74(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x74(%rbp)
jmp    11a9 <main+0x89>
mov    -0x7c(%rbp),%eax
add    $0x37,%eax
mov    %al,%cl
movslq -0x74(%rbp),%rax
mov    %cl,-0x70(%rbp,%rax,1)
mov    -0x74(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x74(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
jmp    1149 <main+0x29>
mov    -0x74(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x78(%rbp)
cmpl   $0x0,-0x78(%rbp)
jl     11f2 <main+0xd2>
movslq -0x78(%rbp),%rax
lea    0xe29(%rip),%rdi
movsbl -0x70(%rbp,%rax,1),%esi
call   1030 <printf@plt>
mov    -0x78(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x78(%rbp)
jmp    11c5 <main+0xa5>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x78,%rsp
lea    0xed2(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
mov    0xc(%rsp),%ecx
test   %ecx,%ecx
je     11ba <main+0x9a>
xor    %eax,%eax
mov    $0x30,%edx
nopw   0x0(%rax,%rax,1)
lea    0xf(%rcx),%esi
test   %ecx,%ecx
mov    %ecx,%ebx
cmovs  %esi,%ebx
mov    %ebx,%edi
and    $0xfffffff0,%edi
sub    %edi,%ecx
cmp    $0xa,%ecx
mov    $0x37,%edi
cmovl  %edx,%edi
add    %cl,%dil
mov    %dil,0x10(%rsp,%rax,1)
add    $0x1,%rax
mov    %ebx,%ecx
sar    $0x4,%ecx
cmp    $0x1f,%esi
jae    1150 <main+0x30>
mov    %ecx,0xc(%rsp)
test   %eax,%eax
jle    11ba <main+0x9a>
mov    %eax,%ebx
add    $0x1,%rbx
lea    0xe6c(%rip),%r14
nopw   0x0(%rax,%rax,1)
lea    -0x2(%rbx),%eax
movsbl 0x10(%rsp,%rax,1),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
add    $0xffffffffffffffff,%rbx
cmp    $0x1,%rbx
ja     11a0 <main+0x80>
xor    %eax,%eax
add    $0x78,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [3 x i8] c"%c\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i8]
%3 = bitcast i32* %1 to i8*
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%6 = load i32, i32* %1
%7 = icmp eq i32 %6, 0
br i1 %7, label %34, label %13
8: ; preds = %13
%9 = trunc i64 %22 to i32
store i32 %23, i32* %1
%10 = icmp sgt i32 %9, 0
br i1 %10, label %11, label %34
11: ; preds = %8
%12 = and i64 %22, 4294967295
br label %26
13: ; preds = %0, %13
%14 = phi i64 [ %22, %13 ], [ 0, %0 ]
%15 = phi i32 [ %23, %13 ], [ %6, %0 ]
%16 = srem i32 %15, 16
%17 = icmp slt i32 %16, 10
%18 = trunc i32 %16 to i8
%19 = select i1 %17, i8 48, i8 55
%20 = add nsw i8 %19, %18
%21 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %14
store i8 %20, i8* %21
%22 = add nuw i64 %14, 1
%23 = sdiv i32 %15, 16
%24 = add i32 %15, 15
%25 = icmp ult i32 %24, 31
br i1 %25, label %8, label %13
26: ; preds = %11, %26
%27 = phi i64 [ %12, %11 ], [ %28, %26 ]
%28 = add nsw i64 %27, -1
%29 = and i64 %28, 4294967295
%30 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %29
%31 = load i8, i8* %30
%32 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8 signext %31)
%33 = icmp ugt i64 %27, 1
br i1 %33, label %26, label %34
34: ; preds = %26, %0, %8
ret i32 0
}