#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 */
typedef int uint8_t;

/* Variables and functions */
uint8_t nibble_to_ascii(uint8_t val) {
  switch (val) {
  case 0x0:
    return '0';
  case 0x1:
    return '1';
  case 0x2:
    return '2';
  case 0x3:
    return '3';
  case 0x4:
    return '4';
  case 0x5:
    return '5';
  case 0x6:
    return '6';
  case 0x7:
    return '7';
  case 0x8:
    return '8';
  case 0x9:
    return '9';
  case 0xA:
    return 'A';
  case 0xB:
    return 'B';
  case 0xC:
    return 'C';
  case 0xD:
    return 'D';
  case 0xE:
    return 'E';
  case 0xF:
    return 'F';
  }
  return '0';
}


x86 assembly (clang, -O0):
<nibble_to_ascii>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %rax,-0x10(%rbp)
sub    $0xf,%rax
ja     11ec <nibble_to_ascii+0xec>
mov    -0x10(%rbp),%rax
lea    0xedd(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x30,-0x4(%rbp)
jmp    11f3 <nibble_to_ascii+0xf3>
movl   $0x31,-0x4(%rbp)
jmp    11f3 <nibble_to_ascii+0xf3>
movl   $0x32,-0x4(%rbp)
jmp    11f3 <nibble_to_ascii+0xf3>
movl   $0x33,-0x4(%rbp)
jmp    11f3 <nibble_to_ascii+0xf3>
movl   $0x34,-0x4(%rbp)
jmp    11f3 <nibble_to_ascii+0xf3>
movl   $0x35,-0x4(%rbp)
jmp    11f3 <nibble_to_ascii+0xf3>
movl   $0x36,-0x4(%rbp)
jmp    11f3 <nibble_to_ascii+0xf3>
movl   $0x37,-0x4(%rbp)
jmp    11f3 <nibble_to_ascii+0xf3>
movl   $0x38,-0x4(%rbp)
jmp    11f3 <nibble_to_ascii+0xf3>
movl   $0x39,-0x4(%rbp)
jmp    11f3 <nibble_to_ascii+0xf3>
movl   $0x41,-0x4(%rbp)
jmp    11f3 <nibble_to_ascii+0xf3>
movl   $0x42,-0x4(%rbp)
jmp    11f3 <nibble_to_ascii+0xf3>
movl   $0x43,-0x4(%rbp)
jmp    11f3 <nibble_to_ascii+0xf3>
movl   $0x44,-0x4(%rbp)
jmp    11f3 <nibble_to_ascii+0xf3>
movl   $0x45,-0x4(%rbp)
jmp    11f3 <nibble_to_ascii+0xf3>
movl   $0x46,-0x4(%rbp)
jmp    11f3 <nibble_to_ascii+0xf3>
movl   $0x30,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<nibble_to_ascii>:
add    $0xffffffff,%edi
mov    $0x30,%eax
cmp    $0xe,%edi
ja     111a <nibble_to_ascii+0x1a>
movslq %edi,%rax
lea    0xee9(%rip),%rcx
mov    (%rcx,%rax,4),%eax
ret

LLVM IR (-O0):
define i32 @nibble_to_ascii(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
switch i32 %4, label %21 [
i32 0, label %5
i32 1, label %6
i32 2, label %7
i32 3, label %8
i32 4, label %9
i32 5, label %10
i32 6, label %11
i32 7, label %12
i32 8, label %13
i32 9, label %14
i32 10, label %15
i32 11, label %16
i32 12, label %17
i32 13, label %18
i32 14, label %19
i32 15, label %20
]
5: ; preds = %1
store i32 48, i32* %2
br label %22
6: ; preds = %1
store i32 49, i32* %2
br label %22
7: ; preds = %1
store i32 50, i32* %2
br label %22
8: ; preds = %1
store i32 51, i32* %2
br label %22
9: ; preds = %1
store i32 52, i32* %2
br label %22
10: ; preds = %1
store i32 53, i32* %2
br label %22
11: ; preds = %1
store i32 54, i32* %2
br label %22
12: ; preds = %1
store i32 55, i32* %2
br label %22
13: ; preds = %1
store i32 56, i32* %2
br label %22
14: ; preds = %1
store i32 57, i32* %2
br label %22
15: ; preds = %1
store i32 65, i32* %2
br label %22
16: ; preds = %1
store i32 66, i32* %2
br label %22
17: ; preds = %1
store i32 67, i32* %2
br label %22
18: ; preds = %1
store i32 68, i32* %2
br label %22
19: ; preds = %1
store i32 69, i32* %2
br label %22
20: ; preds = %1
store i32 70, i32* %2
br label %22
21: ; preds = %1
store i32 48, i32* %2
br label %22
22: ; preds = %21, %20, %19, %18, %17, %16, %15, %14, %13, %12, %11, %10, %9, %8, %7, %6, %5
%23 = load i32, i32* %2
ret i32 %23
}

LLVM IR (-O2):
@switch.table.nibble_to_ascii = [15 x i32] [i32 49, i32 50, i32 51, i32 52, i32 53, i32 54, i32 55, i32 56, i32 57, i32 65, i32 66, i32 67, i32 68, i32 69, i32 70]
define i32 @nibble_to_ascii(i32 %0) {
%2 = add i32 %0, -1
%3 = icmp ult i32 %2, 15
br i1 %3, label %4, label %8
4: ; preds = %1
%5 = sext i32 %2 to i64
%6 = getelementptr inbounds [15 x i32], [15 x i32]* @switch.table.nibble_to_ascii, i64 0, i64 %5
%7 = load i32, i32* %6
br label %8
8: ; preds = %4, %1
%9 = phi i32 [ 48, %1 ], [ %7, %4 ]
ret i32 %9
}