#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 var, p;
  scanf("%d", &var);
  if (var == 0)
    printf("0");
  while (var) {
    p = var % 16;
    if (p <= 9)
      printf("%d", p);
    else
      printf("%c", p - 10 + 'A');
    var /= 16;
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jne    1157 <main+0x37>
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    115c <main+0x3c>
cmpl   $0x0,-0x8(%rbp)
je     11be <main+0x9e>
mov    -0x8(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
cmpl   $0x9,-0xc(%rbp)
jg     1194 <main+0x74>
mov    -0xc(%rbp),%esi
lea    0xe78(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11ab <main+0x8b>
mov    -0xc(%rbp),%esi
sub    $0xa,%esi
add    $0x41,%esi
lea    0xe61(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
jmp    115c <main+0x3c>
lea    0xe43(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%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),%esi
test   %esi,%esi
jne    1160 <main+0x30>
mov    $0x30,%edi
call   1030 <putchar@plt>
mov    0xc(%rsp),%esi
test   %esi,%esi
je     11b0 <main+0x80>
lea    0xe99(%rip),%rbx
jmp    1192 <main+0x62>
nopl   0x0(%rax)
add    $0x37,%esi
mov    %esi,%edi
call   1030 <putchar@plt>
mov    0xc(%rsp),%esi
lea    0xf(%rsi),%eax
test   %esi,%esi
cmovs  %eax,%esi
sar    $0x4,%esi
mov    %esi,0xc(%rsp)
cmp    $0x1e,%eax
jbe    11b0 <main+0x80>
lea    0xf(%rsi),%eax
test   %esi,%esi
cmovns %esi,%eax
and    $0xfffffff0,%eax
sub    %eax,%esi
cmp    $0x9,%esi
jg     1170 <main+0x40>
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    117a <main+0x4a>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [2 x i8] c"0\00"
@.str.2 = [3 x i8] c"%c\00"
@.str.3 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%5 = load i32, i32* %2
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %9
9: ; preds = %7, %0
br label %10
10: ; preds = %26, %9
%11 = load i32, i32* %2
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %29
13: ; preds = %10
%14 = load i32, i32* %2
%15 = srem i32 %14, 16
store i32 %15, i32* %3
%16 = load i32, i32* %3
%17 = icmp sle i32 %16, 9
br i1 %17, label %18, label %21
18: ; preds = %13
%19 = load i32, i32* %3
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %19)
br label %26
21: ; preds = %13
%22 = load i32, i32* %3
%23 = sub nsw i32 %22, 10
%24 = add nsw i32 %23, 65
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %24)
br label %26
26: ; preds = %21, %18
%27 = load i32, i32* %2
%28 = sdiv i32 %27, 16
store i32 %28, i32* %2
br label %10
29: ; preds = %10
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\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 = icmp eq i32 %4, 0
br i1 %5, label %6, label %10
6: ; preds = %0
%7 = call i32 @putchar(i32 48)
%8 = load i32, i32* %1
%9 = icmp eq i32 %8, 0
br i1 %9, label %26, label %10
10: ; preds = %0, %6
%11 = phi i32 [ %4, %0 ], [ %8, %6 ]
br label %12
12: ; preds = %10, %21
%13 = phi i32 [ %23, %21 ], [ %11, %10 ]
%14 = srem i32 %13, 16
%15 = icmp slt i32 %14, 10
br i1 %15, label %16, label %18
16: ; preds = %12
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %14)
br label %21
18: ; preds = %12
%19 = add nuw nsw i32 %14, 55
%20 = call i32 @putchar(i32 %19)
br label %21
21: ; preds = %18, %16
%22 = load i32, i32* %1
%23 = sdiv i32 %22, 16
store i32 %23, i32* %1
%24 = add i32 %22, 15
%25 = icmp ult i32 %24, 31
br i1 %25, label %26, label %12
26: ; preds = %21, %6
%27 = call i32 @putchar(i32 10)
ret i32 0
}