#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*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
char *single_digit_hex_to_bin(char hex_dig) {
  switch (hex_dig) {
  case '0':
    return "0000";
    break;
  case '1':
    return "0001";
    break;
  case '2':
    return "0010";
    break;
  case '3':
    return "0011";
    break;
  case '4':
    return "0100";
    break;
  case '5':
    return "0101";
    break;
  case '6':
    return "0110";
    break;
  case '7':
    return "0111";
    break;
  case '8':
    return "1000";
    break;
  case '9':
    return "1001";
    break;
  case 'A':
  case 'a':
    return "1010";
    break;
  case 'B':
  case 'b':
    return "1011";
    break;
  case 'C':
  case 'c':
    return "1100";
    break;
  case 'D':
  case 'd':
    return "1101";
    break;
  case 'E':
  case 'e':
    return "1110";
    break;
  case 'F':
  case 'f':
    return "1111";
    break;
  default:
    fprintf(stderr,
            "you inputted a non-digit character in one of your number string");
    return "";
    break;
  }
}


x86 assembly (clang, -O0):
<single_digit_hex_to_bin>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dil,%al
mov    %al,-0x9(%rbp)
movsbl -0x9(%rbp),%eax
add    $0xffffffd0,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x36,%eax
ja     1248 <single_digit_hex_to_bin+0x138>
mov    -0x18(%rbp),%rax
lea    0xec1(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xf8d(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1268 <single_digit_hex_to_bin+0x158>
lea    0xf82(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1268 <single_digit_hex_to_bin+0x158>
lea    0xf77(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1268 <single_digit_hex_to_bin+0x158>
lea    0xf6c(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1268 <single_digit_hex_to_bin+0x158>
lea    0xf61(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1268 <single_digit_hex_to_bin+0x158>
lea    0xf56(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1268 <single_digit_hex_to_bin+0x158>
lea    0xf4b(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1268 <single_digit_hex_to_bin+0x158>
lea    0xf40(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1268 <single_digit_hex_to_bin+0x158>
lea    0xf35(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1268 <single_digit_hex_to_bin+0x158>
lea    0xf2a(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1268 <single_digit_hex_to_bin+0x158>
lea    0xf1f(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1268 <single_digit_hex_to_bin+0x158>
lea    0xf14(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1268 <single_digit_hex_to_bin+0x158>
lea    0xf09(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1268 <single_digit_hex_to_bin+0x158>
lea    0xefe(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1268 <single_digit_hex_to_bin+0x158>
lea    0xef3(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1268 <single_digit_hex_to_bin+0x158>
lea    0xee8(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1268 <single_digit_hex_to_bin+0x158>
mov    0x2d91(%rip),%rax
mov    (%rax),%edi
lea    0xed4(%rip),%rsi
call   1030 <fprintf@plt>
lea    0xe7c(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<single_digit_hex_to_bin>:
push   %rax
add    $0xffffffd0,%edi
cmp    $0x37,%edi
jae    1129 <single_digit_hex_to_bin+0x19>
movabs $0x7e0000007e03ff,%rax
bt     %rdi,%rax
jb     1147 <single_digit_hex_to_bin+0x37>
mov    0x2eb0(%rip),%rax
mov    (%rax),%edi
lea    0xf17(%rip),%rsi
call   1030 <fprintf@plt>
lea    0xebf(%rip),%rax
pop    %rcx
ret
movslq %edi,%rax
lea    0xf3f(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [5 x i8] c"0000\00"
@.str.1 = [5 x i8] c"0001\00"
@.str.2 = [5 x i8] c"0010\00"
@.str.3 = [5 x i8] c"0011\00"
@.str.4 = [5 x i8] c"0100\00"
@.str.5 = [5 x i8] c"0101\00"
@.str.6 = [5 x i8] c"0110\00"
@.str.7 = [5 x i8] c"0111\00"
@.str.8 = [5 x i8] c"1000\00"
@.str.9 = [5 x i8] c"1001\00"
@.str.10 = [5 x i8] c"1010\00"
@.str.11 = [5 x i8] c"1011\00"
@.str.12 = [5 x i8] c"1100\00"
@.str.13 = [5 x i8] c"1101\00"
@.str.14 = [5 x i8] c"1110\00"
@.str.15 = [5 x i8] c"1111\00"
@stderr = global i32 0
@.str.16 = [64 x i8] c"you inputted a non-digit character in one of your number string\00"
@.str.17 = [1 x i8] zeroinitializer
define i8* @single_digit_hex_to_bin(i8 signext %0) {
%2 = alloca i8*
%3 = alloca i8
store i8 %0, i8* %3
%4 = load i8, i8* %3
%5 = sext i8 %4 to i32
switch i32 %5, label %22 [
i32 48, label %6
i32 49, label %7
i32 50, label %8
i32 51, label %9
i32 52, label %10
i32 53, label %11
i32 54, label %12
i32 55, label %13
i32 56, label %14
i32 57, label %15
i32 65, label %16
i32 97, label %16
i32 66, label %17
i32 98, label %17
i32 67, label %18
i32 99, label %18
i32 68, label %19
i32 100, label %19
i32 69, label %20
i32 101, label %20
i32 70, label %21
i32 102, label %21
]
6: ; preds = %1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %2
br label %25
7: ; preds = %1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %25
8: ; preds = %1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %25
9: ; preds = %1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8** %2
br label %25
10: ; preds = %1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8** %2
br label %25
11: ; preds = %1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8** %2
br label %25
12: ; preds = %1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8** %2
br label %25
13: ; preds = %1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i8** %2
br label %25
14: ; preds = %1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), i8** %2
br label %25
15: ; preds = %1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), i8** %2
br label %25
16: ; preds = %1, %1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0), i8** %2
br label %25
17: ; preds = %1, %1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0), i8** %2
br label %25
18: ; preds = %1, %1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0), i8** %2
br label %25
19: ; preds = %1, %1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.13, i64 0, i64 0), i8** %2
br label %25
20: ; preds = %1, %1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.14, i64 0, i64 0), i8** %2
br label %25
21: ; preds = %1, %1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.15, i64 0, i64 0), i8** %2
br label %25
22: ; preds = %1
%23 = load i32, i32* @stderr
%24 = call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.16, i64 0, i64 0))
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.17, i64 0, i64 0), i8** %2
br label %25
25: ; preds = %22, %21, %20, %19, %18, %17, %16, %15, %14, %13, %12, %11, %10, %9, %8, %7, %6
%26 = load i8*, i8** %2
ret i8* %26
}

LLVM IR (-O2):
@.str = [5 x i8] c"0000\00"
@.str.1 = [5 x i8] c"0001\00"
@.str.2 = [5 x i8] c"0010\00"
@.str.3 = [5 x i8] c"0011\00"
@.str.4 = [5 x i8] c"0100\00"
@.str.5 = [5 x i8] c"0101\00"
@.str.6 = [5 x i8] c"0110\00"
@.str.7 = [5 x i8] c"0111\00"
@.str.8 = [5 x i8] c"1000\00"
@.str.9 = [5 x i8] c"1001\00"
@.str.10 = [5 x i8] c"1010\00"
@.str.11 = [5 x i8] c"1011\00"
@.str.12 = [5 x i8] c"1100\00"
@.str.13 = [5 x i8] c"1101\00"
@.str.14 = [5 x i8] c"1110\00"
@.str.15 = [5 x i8] c"1111\00"
@stderr = global i32 0
@.str.16 = [64 x i8] c"you inputted a non-digit character in one of your number string\00"
@.str.17 = [1 x i8] zeroinitializer
@reltable.single_digit_hex_to_bin = [55 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str to i64), i64 ptrtoint ([55 x i32]* @reltable.single_digit_hex_to_bin to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.1 to i64), i64 ptrtoint ([55 x i32]* @reltable.single_digit_hex_to_bin to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.2 to i64), i64 ptrtoint ([55 x i32]* @reltable.single_digit_hex_to_bin to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.3 to i64), i64 ptrtoint ([55 x i32]* @reltable.single_digit_hex_to_bin to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.4 to i64), i64 ptrtoint ([55 x i32]* @reltable.single_digit_hex_to_bin to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.5 to i64), i64 ptrtoint ([55 x i32]* @reltable.single_digit_hex_to_bin to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.6 to i64), i64 ptrtoint ([55 x i32]* @reltable.single_digit_hex_to_bin to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.7 to i64), i64 ptrtoint ([55 x i32]* @reltable.single_digit_hex_to_bin to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.8 to i64), i64 ptrtoint ([55 x i32]* @reltable.single_digit_hex_to_bin to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.9 to i64), i64 ptrtoint ([55 x i32]* @reltable.single_digit_hex_to_bin to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str to i64), i64 ptrtoint ([55 x i32]* @reltable.single_digit_hex_to_bin to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str to i64), i64 ptrtoint ([55 x i32]* @reltable.single_digit_hex_to_bin to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str to i64), i64 ptrtoint ([55 x i32]* @reltable.single_digit_hex_to_bin to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str to i64), i64 ptrtoint ([55 x i32]* @reltable.single_digit_hex_to_bin to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str to i64), i64 ptrtoint ([55 x i32]* @reltable.single_digit_hex_to_bin to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str to i64), i64 ptrtoint ([55 x i32]* @reltable.single_digit_hex_to_bin to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str to i64), i64 ptrtoint ([55 x i32]* @reltable.single_digit_hex_to_bin to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.10 to i64), i64 ptrtoint ([55 x i32]* @reltable.single_digit_hex_to_bin to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.11 to i64), i64 ptrtoint ([55 x i32]* @reltable.single_digit_hex_to_bin to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.12 to i64), i64 ptrtoint ([55 x i32]* @reltable.single_digit_hex_to_bin to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.13 to i64), i64 ptrtoint ([55 x i32]* @reltable.single_digit_hex_to_bin to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.14 to i64), i64 ptrtoint ([55 x i32]* @reltable.single_digit_hex_to_bin to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.15 to i64), i64 ptrtoint ([55 x i32]* @reltable.single_digit_hex_to_bin to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str to i64), i64 ptrtoint ([55 x i32]* @reltable.single_digit_hex_to_bin to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str to i64), i64 ptrtoint ([55 x i32]* @reltable.single_digit_hex_to_bin to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str to i64), i64 ptrtoint ([55 x i32]* @reltable.single_digit_hex_to_bin to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str to i64), i64 ptrtoint ([55 x i32]* @reltable.single_digit_hex_to_bin to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str to i64), i64 ptrtoint ([55 x i32]* @reltable.single_digit_hex_to_bin to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str to i64), i64 ptrtoint ([55 x i32]* @reltable.single_digit_hex_to_bin to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str to i64), i64 ptrtoint ([55 x i32]* @reltable.single_digit_hex_to_bin to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str to i64), i64 ptrtoint ([55 x i32]* @reltable.single_digit_hex_to_bin to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str to i64), i64 ptrtoint ([55 x i32]* @reltable.single_digit_hex_to_bin to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str to i64), i64 ptrtoint ([55 x i32]* @reltable.single_digit_hex_to_bin to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str to i64), i64 ptrtoint ([55 x i32]* @reltable.single_digit_hex_to_bin to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str to i64), i64 ptrtoint ([55 x i32]* @reltable.single_digit_hex_to_bin to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str to i64), i64 ptrtoint ([55 x i32]* @reltable.single_digit_hex_to_bin to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str to i64), i64 ptrtoint ([55 x i32]* @reltable.single_digit_hex_to_bin to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str to i64), i64 ptrtoint ([55 x i32]* @reltable.single_digit_hex_to_bin to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str to i64), i64 ptrtoint ([55 x i32]* @reltable.single_digit_hex_to_bin to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str to i64), i64 ptrtoint ([55 x i32]* @reltable.single_digit_hex_to_bin to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str to i64), i64 ptrtoint ([55 x i32]* @reltable.single_digit_hex_to_bin to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str to i64), i64 ptrtoint ([55 x i32]* @reltable.single_digit_hex_to_bin to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str to i64), i64 ptrtoint ([55 x i32]* @reltable.single_digit_hex_to_bin to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str to i64), i64 ptrtoint ([55 x i32]* @reltable.single_digit_hex_to_bin to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str to i64), i64 ptrtoint ([55 x i32]* @reltable.single_digit_hex_to_bin to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str to i64), i64 ptrtoint ([55 x i32]* @reltable.single_digit_hex_to_bin to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str to i64), i64 ptrtoint ([55 x i32]* @reltable.single_digit_hex_to_bin to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str to i64), i64 ptrtoint ([55 x i32]* @reltable.single_digit_hex_to_bin to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str to i64), i64 ptrtoint ([55 x i32]* @reltable.single_digit_hex_to_bin to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.10 to i64), i64 ptrtoint ([55 x i32]* @reltable.single_digit_hex_to_bin to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.11 to i64), i64 ptrtoint ([55 x i32]* @reltable.single_digit_hex_to_bin to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.12 to i64), i64 ptrtoint ([55 x i32]* @reltable.single_digit_hex_to_bin to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.13 to i64), i64 ptrtoint ([55 x i32]* @reltable.single_digit_hex_to_bin to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.14 to i64), i64 ptrtoint ([55 x i32]* @reltable.single_digit_hex_to_bin to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.15 to i64), i64 ptrtoint ([55 x i32]* @reltable.single_digit_hex_to_bin to i64)) to i32)]
define i8* @single_digit_hex_to_bin(i8 signext %0) {
%2 = sext i8 %0 to i32
%3 = add nsw i32 %2, -48
%4 = icmp ult i32 %3, 55
br i1 %4, label %8, label %5
5: ; preds = %8, %1
%6 = load i32, i32* @stderr
%7 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.16, i64 0, i64 0))
br label %17
8: ; preds = %1
%9 = zext i32 %3 to i64
%10 = lshr i64 35465847073801215, %9
%11 = and i64 %10, 1
%12 = icmp eq i64 %11, 0
br i1 %12, label %5, label %13
13: ; preds = %8
%14 = sext i32 %3 to i64
%15 = shl i64 %14, 2
%16 = call i8* @llvm.load.relative.i64(i8* bitcast ([55 x i32]* @reltable.single_digit_hex_to_bin to i8*), i64 %15)
br label %17
17: ; preds = %13, %5
%18 = phi i8* [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.17, i64 0, i64 0), %5 ], [ %16, %13 ]
ret i8* %18
}