#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 printhexa(int value) {
  switch (value) {
  case 10:
    printf("A");
    break;
  case 11:
    printf("B");
    break;
  case 12:
    printf("C");
    break;
  case 13:
    printf("D");
    break;
  case 14:
    printf("E");
    break;
  case 15:
    printf("F");
    break;
  default:
    printf("%d", value);
    break;
  }
}


x86 assembly (clang, -O0):
<printhexa>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xfffffff6,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x5,%eax
ja     11b6 <printhexa+0xa6>
mov    -0x10(%rbp),%rax
lea    0xec5(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xecd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11c7 <printhexa+0xb7>
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11c7 <printhexa+0xb7>
lea    0xeab(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11c7 <printhexa+0xb7>
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11c7 <printhexa+0xb7>
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11c7 <printhexa+0xb7>
lea    0xe78(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11c7 <printhexa+0xb7>
mov    -0x4(%rbp),%esi
lea    0xe64(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printhexa>:
mov    %edi,%esi
lea    -0xa(%rsi),%eax
cmp    $0x5,%eax
ja     1144 <printhexa+0x24>
lea    0xecf(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x41,%edi
jmp    1030 <putchar@plt>
lea    0xecd(%rip),%rdi
xor    %eax,%eax
jmp    1040 <printf@plt>
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 = [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 = [3 x i8] c"%d\00"
define void @printhexa(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
switch i32 %3, label %16 [
i32 10, label %4
i32 11, label %6
i32 12, label %8
i32 13, label %10
i32 14, label %12
i32 15, label %14
]
4: ; preds = %1
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %19
6: ; preds = %1
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %19
8: ; preds = %1
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %19
10: ; preds = %1
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %19
12: ; preds = %1
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %19
14: ; preds = %1
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %19
16: ; preds = %1
%17 = load i32, i32* %2
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32 %17)
br label %19
19: ; preds = %16, %14, %12, %10, %8, %6, %4
ret void
}

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