#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 deci_hexa(long n) {
  long c, r, b = 16;
  if (n == 0)
    return 0;
  c = n / b;
  r = n - b * c;
  n = c;
  deci_hexa(n);
  if (r == 10)
    printf("A");
  else if (r == 11)
    printf("B");
  else if (r == 12)
    printf("C");
  else if (r == 13)
    printf("D");
  else if (r == 14)
    printf("E");
  else if (r == 15)
    printf("F");
  else
    printf("%ld", r);
}


x86 assembly (clang, -O0):
<deci_hexa>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
movq   $0x10,-0x28(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    114b <deci_hexa+0x2b>
movl   $0x0,-0x4(%rbp)
jmp    125d <deci_hexa+0x13d>
mov    -0x10(%rbp),%rax
cqto
idivq  -0x28(%rbp)
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%rcx
imul   -0x18(%rbp),%rcx
sub    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <deci_hexa@plt>
cmpq   $0xa,-0x20(%rbp)
jne    119c <deci_hexa+0x7c>
lea    0xe70(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    125d <deci_hexa+0x13d>
cmpq   $0xb,-0x20(%rbp)
jne    11ba <deci_hexa+0x9a>
lea    0xe54(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1258 <deci_hexa+0x138>
cmpq   $0xc,-0x20(%rbp)
jne    11d8 <deci_hexa+0xb8>
lea    0xe38(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1253 <deci_hexa+0x133>
cmpq   $0xd,-0x20(%rbp)
jne    11f6 <deci_hexa+0xd6>
lea    0xe1c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    124e <deci_hexa+0x12e>
cmpq   $0xe,-0x20(%rbp)
jne    1214 <deci_hexa+0xf4>
lea    0xe00(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1249 <deci_hexa+0x129>
cmpq   $0xf,-0x20(%rbp)
jne    1232 <deci_hexa+0x112>
lea    0xde4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1244 <deci_hexa+0x124>
mov    -0x20(%rbp),%rsi
lea    0xdcf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1249 <deci_hexa+0x129>
jmp    124e <deci_hexa+0x12e>
jmp    1253 <deci_hexa+0x133>
jmp    1258 <deci_hexa+0x138>
jmp    125d <deci_hexa+0x13d>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<deci_hexa>:
push   %r14
push   %rbx
push   %rax
test   %rdi,%rdi
je     11da <deci_hexa+0xaa>
mov    %rdi,%r14
lea    0xf(%rdi),%rbx
test   %rdi,%rdi
cmovns %rdi,%rbx
mov    %rbx,%rdi
sar    $0x4,%rdi
and    $0xfffffffffffffff0,%rbx
call   1050 <deci_hexa@plt>
mov    %rbx,%rax
neg    %rax
add    %r14,%rax
add    $0xfffffffffffffff6,%rax
cmp    $0x5,%rax
ja     11c6 <deci_hexa+0x96>
lea    0xe8b(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x41,%edi
call   1030 <putchar@plt>
jmp    11da <deci_hexa+0xaa>
mov    $0x42,%edi
call   1030 <putchar@plt>
jmp    11da <deci_hexa+0xaa>
mov    $0x43,%edi
call   1030 <putchar@plt>
jmp    11da <deci_hexa+0xaa>
mov    $0x44,%edi
call   1030 <putchar@plt>
jmp    11da <deci_hexa+0xaa>
mov    $0x45,%edi
call   1030 <putchar@plt>
jmp    11da <deci_hexa+0xaa>
mov    $0x46,%edi
call   1030 <putchar@plt>
jmp    11da <deci_hexa+0xaa>
sub    %rbx,%r14
lea    0xe48(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [2 x i8] c"A\00"
@.str.1 = [2 x i8] c"B\00"
@.str.2 = [2 x i8] c"C\00"
@.str.3 = [2 x i8] c"D\00"
@.str.4 = [2 x i8] c"E\00"
@.str.5 = [2 x i8] c"F\00"
@.str.6 = [4 x i8] c"%ld\00"
define i32 @deci_hexa(i64 %0) {
%2 = alloca i32
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
store i64 %0, i64* %3
store i64 16, i64* %6
%7 = load i64, i64* %3
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %10
9: ; preds = %1
store i32 0, i32* %2
br label %59
10: ; preds = %1
%11 = load i64, i64* %3
%12 = load i64, i64* %6
%13 = sdiv i64 %11, %12
store i64 %13, i64* %4
%14 = load i64, i64* %3
%15 = load i64, i64* %6
%16 = load i64, i64* %4
%17 = mul nsw i64 %15, %16
%18 = sub nsw i64 %14, %17
store i64 %18, i64* %5
%19 = load i64, i64* %4
store i64 %19, i64* %3
%20 = load i64, i64* %3
%21 = call i32 @deci_hexa(i64 %20)
%22 = load i64, i64* %5
%23 = icmp eq i64 %22, 10
br i1 %23, label %24, label %26
24: ; preds = %10
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %59
26: ; preds = %10
%27 = load i64, i64* %5
%28 = icmp eq i64 %27, 11
br i1 %28, label %29, label %31
29: ; preds = %26
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %58
31: ; preds = %26
%32 = load i64, i64* %5
%33 = icmp eq i64 %32, 12
br i1 %33, label %34, label %36
34: ; preds = %31
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %57
36: ; preds = %31
%37 = load i64, i64* %5
%38 = icmp eq i64 %37, 13
br i1 %38, label %39, label %41
39: ; preds = %36
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %56
41: ; preds = %36
%42 = load i64, i64* %5
%43 = icmp eq i64 %42, 14
br i1 %43, label %44, label %46
44: ; preds = %41
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %55
46: ; preds = %41
%47 = load i64, i64* %5
%48 = icmp eq i64 %47, 15
br i1 %48, label %49, label %51
49: ; preds = %46
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %54
51: ; preds = %46
%52 = load i64, i64* %5
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i64 %52)
br label %54
54: ; preds = %51, %49
br label %55
55: ; preds = %54, %44
br label %56
56: ; preds = %55, %39
br label %57
57: ; preds = %56, %34
br label %58
58: ; preds = %57, %29
br label %59
59: ; preds = %9, %58, %24
%60 = load i32, i32* %2
ret i32 %60
}

LLVM IR (-O2):
@.str.6 = [4 x i8] c"%ld\00"
define i32 @deci_hexa(i64 %0) {
%2 = icmp eq i64 %0, 0
br i1 %2, label %22, label %3
3: ; preds = %1
%4 = sdiv i64 %0, 16
%5 = mul i64 %4, -16
%6 = add i64 %5, %0
%7 = tail call i32 @deci_hexa(i64 %4)
switch i64 %6, label %20 [
i64 10, label %8
i64 11, label %10
i64 12, label %12
i64 13, label %14
i64 14, label %16
i64 15, label %18
]
8: ; preds = %3
%9 = tail call i32 @putchar(i32 65)
br label %22
10: ; preds = %3
%11 = tail call i32 @putchar(i32 66)
br label %22
12: ; preds = %3
%13 = tail call i32 @putchar(i32 67)
br label %22
14: ; preds = %3
%15 = tail call i32 @putchar(i32 68)
br label %22
16: ; preds = %3
%17 = tail call i32 @putchar(i32 69)
br label %22
18: ; preds = %3
%19 = tail call i32 @putchar(i32 70)
br label %22
20: ; preds = %3
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i64 %6)
br label %22
22: ; preds = %8, %12, %16, %20, %18, %14, %10, %1
ret i32 0
}