#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 *, ...);
void printHex(int val) {
  if (val < 10) {
    printf("%u", val);
  } else if (val == 10) {
    printf("A");
  } else if (val == 11) {
    printf("B");
  } else if (val == 12) {
    printf("C");
  } else if (val == 13) {
    printf("D");
  } else if (val == 14) {
    printf("E");
  } else if (val == 15) {
    printf("F");
  }
}


x86 assembly (clang, -O0):
<printHex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0xa,-0x4(%rbp)
jge    113b <printHex+0x2b>
mov    -0x4(%rbp),%esi
lea    0xed1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1202 <printHex+0xf2>
cmpl   $0xa,-0x4(%rbp)
jne    1158 <printHex+0x48>
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11fd <printHex+0xed>
cmpl   $0xb,-0x4(%rbp)
jne    1175 <printHex+0x65>
lea    0xe9c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11f8 <printHex+0xe8>
cmpl   $0xc,-0x4(%rbp)
jne    1192 <printHex+0x82>
lea    0xe81(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11f3 <printHex+0xe3>
cmpl   $0xd,-0x4(%rbp)
jne    11af <printHex+0x9f>
lea    0xe66(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11ee <printHex+0xde>
cmpl   $0xe,-0x4(%rbp)
jne    11cc <printHex+0xbc>
lea    0xe4b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11e9 <printHex+0xd9>
cmpl   $0xf,-0x4(%rbp)
jne    11e4 <printHex+0xd4>
lea    0xe30(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11e9 <printHex+0xd9>
jmp    11ee <printHex+0xde>
jmp    11f3 <printHex+0xe3>
jmp    11f8 <printHex+0xe8>
jmp    11fd <printHex+0xed>
jmp    1202 <printHex+0xf2>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printHex>:
mov    %edi,%esi
cmp    $0x9,%edi
jg     1135 <printHex+0x15>
lea    0xeea(%rip),%rdi
xor    %eax,%eax
jmp    1040 <printf@plt>
add    $0xfffffff6,%esi
cmp    $0x5,%esi
ja     1157 <printHex+0x37>
lea    0xebc(%rip),%rax
movslq (%rax,%rsi,4),%rcx
add    %rax,%rcx
jmp    *%rcx
mov    $0x41,%edi
jmp    1030 <putchar@plt>
ret
mov    $0x42,%edi
jmp    1030 <putchar@plt>
mov    $0x43,%edi
jmp    1030 <putchar@plt>
mov    $0x44,%edi
jmp    1030 <putchar@plt>
mov    $0x45,%edi
jmp    1030 <putchar@plt>
mov    $0x46,%edi
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"%u\00"
@.str.1 = [2 x i8] c"A\00"
@.str.2 = [2 x i8] c"B\00"
@.str.3 = [2 x i8] c"C\00"
@.str.4 = [2 x i8] c"D\00"
@.str.5 = [2 x i8] c"E\00"
@.str.6 = [2 x i8] c"F\00"
define void @printHex(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = icmp slt i32 %3, 10
br i1 %4, label %5, label %8
5: ; preds = %1
%6 = load i32, i32* %2
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %6)
br label %44
8: ; preds = %1
%9 = load i32, i32* %2
%10 = icmp eq i32 %9, 10
br i1 %10, label %11, label %13
11: ; preds = %8
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %43
13: ; preds = %8
%14 = load i32, i32* %2
%15 = icmp eq i32 %14, 11
br i1 %15, label %16, label %18
16: ; preds = %13
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %42
18: ; preds = %13
%19 = load i32, i32* %2
%20 = icmp eq i32 %19, 12
br i1 %20, label %21, label %23
21: ; preds = %18
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %41
23: ; preds = %18
%24 = load i32, i32* %2
%25 = icmp eq i32 %24, 13
br i1 %25, label %26, label %28
26: ; preds = %23
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %40
28: ; preds = %23
%29 = load i32, i32* %2
%30 = icmp eq i32 %29, 14
br i1 %30, label %31, label %33
31: ; preds = %28
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %39
33: ; preds = %28
%34 = load i32, i32* %2
%35 = icmp eq i32 %34, 15
br i1 %35, label %36, label %38
36: ; preds = %33
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
br label %38
38: ; preds = %36, %33
br label %39
39: ; preds = %38, %31
br label %40
40: ; preds = %39, %26
br label %41
41: ; preds = %40, %21
br label %42
42: ; preds = %41, %16
br label %43
43: ; preds = %42, %11
br label %44
44: ; preds = %43, %5
ret void
}

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