#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 */
scalar_t__ malloc(int);
char *igbc_char_hex(char num) {
  char lower = num & 0x0F;
  char upper = (num >> 4) & 0x0F;
  char *out = (char *)malloc(2);
  switch (upper) {
  case 0x00:
    out[0] = '0';
    break;
  case 0x01:
    out[0] = '1';
    break;
  case 0x02:
    out[0] = '2';
    break;
  case 0x03:
    out[0] = '3';
    break;
  case 0x04:
    out[0] = '4';
    break;
  case 0x05:
    out[0] = '5';
    break;
  case 0x06:
    out[0] = '6';
    break;
  case 0x07:
    out[0] = '7';
    break;
  case 0x08:
    out[0] = '8';
    break;
  case 0x09:
    out[0] = '9';
    break;
  case 0x0A:
    out[0] = 'A';
    break;
  case 0x0B:
    out[0] = 'B';
    break;
  case 0x0C:
    out[0] = 'C';
    break;
  case 0x0D:
    out[0] = 'D';
    break;
  case 0x0E:
    out[0] = 'E';
    break;
  case 0x0F:
    out[0] = 'F';
    break;
  }
  switch (lower) {
  case 0x00:
    out[1] = '0';
    break;
  case 0x01:
    out[1] = '1';
    break;
  case 0x02:
    out[1] = '2';
    break;
  case 0x03:
    out[1] = '3';
    break;
  case 0x04:
    out[1] = '4';
    break;
  case 0x05:
    out[1] = '5';
    break;
  case 0x06:
    out[1] = '6';
    break;
  case 0x07:
    out[1] = '7';
    break;
  case 0x08:
    out[1] = '8';
    break;
  case 0x09:
    out[1] = '9';
    break;
  case 0x0A:
    out[1] = 'A';
    break;
  case 0x0B:
    out[1] = 'B';
    break;
  case 0x0C:
    out[1] = 'C';
    break;
  case 0x0D:
    out[1] = 'D';
    break;
  case 0x0E:
    out[1] = 'E';
    break;
  case 0x0F:
    out[1] = 'F';
    break;
  }
  return out;
}


x86 assembly (clang, -O0):
<igbc_char_hex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
mov    -0x1(%rbp),%al
and    $0xf,%al
mov    %al,-0x2(%rbp)
mov    -0x1(%rbp),%al
shr    $0x4,%al
mov    %al,-0x3(%rbp)
mov    $0x2,%edi
call   1030 <malloc@plt>
mov    %rax,-0x10(%rbp)
movsbl -0x3(%rbp),%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0xf,%eax
ja     121f <igbc_char_hex+0x10f>
mov    -0x18(%rbp),%rax
lea    0xea5(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x10(%rbp),%rax
movb   $0x30,(%rax)
jmp    121f <igbc_char_hex+0x10f>
mov    -0x10(%rbp),%rax
movb   $0x31,(%rax)
jmp    121f <igbc_char_hex+0x10f>
mov    -0x10(%rbp),%rax
movb   $0x32,(%rax)
jmp    121f <igbc_char_hex+0x10f>
mov    -0x10(%rbp),%rax
movb   $0x33,(%rax)
jmp    121f <igbc_char_hex+0x10f>
mov    -0x10(%rbp),%rax
movb   $0x34,(%rax)
jmp    121f <igbc_char_hex+0x10f>
mov    -0x10(%rbp),%rax
movb   $0x35,(%rax)
jmp    121f <igbc_char_hex+0x10f>
mov    -0x10(%rbp),%rax
movb   $0x36,(%rax)
jmp    121f <igbc_char_hex+0x10f>
mov    -0x10(%rbp),%rax
movb   $0x37,(%rax)
jmp    121f <igbc_char_hex+0x10f>
mov    -0x10(%rbp),%rax
movb   $0x38,(%rax)
jmp    121f <igbc_char_hex+0x10f>
mov    -0x10(%rbp),%rax
movb   $0x39,(%rax)
jmp    121f <igbc_char_hex+0x10f>
mov    -0x10(%rbp),%rax
movb   $0x41,(%rax)
jmp    121f <igbc_char_hex+0x10f>
mov    -0x10(%rbp),%rax
movb   $0x42,(%rax)
jmp    121f <igbc_char_hex+0x10f>
mov    -0x10(%rbp),%rax
movb   $0x43,(%rax)
jmp    121f <igbc_char_hex+0x10f>
mov    -0x10(%rbp),%rax
movb   $0x44,(%rax)
jmp    121f <igbc_char_hex+0x10f>
mov    -0x10(%rbp),%rax
movb   $0x45,(%rax)
jmp    121f <igbc_char_hex+0x10f>
mov    -0x10(%rbp),%rax
movb   $0x46,(%rax)
movsbl -0x2(%rbp),%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0xf,%eax
ja     1311 <igbc_char_hex+0x201>
mov    -0x20(%rbp),%rax
lea    0xe03(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x10(%rbp),%rax
movb   $0x30,0x1(%rax)
jmp    1311 <igbc_char_hex+0x201>
mov    -0x10(%rbp),%rax
movb   $0x31,0x1(%rax)
jmp    1311 <igbc_char_hex+0x201>
mov    -0x10(%rbp),%rax
movb   $0x32,0x1(%rax)
jmp    1311 <igbc_char_hex+0x201>
mov    -0x10(%rbp),%rax
movb   $0x33,0x1(%rax)
jmp    1311 <igbc_char_hex+0x201>
mov    -0x10(%rbp),%rax
movb   $0x34,0x1(%rax)
jmp    1311 <igbc_char_hex+0x201>
mov    -0x10(%rbp),%rax
movb   $0x35,0x1(%rax)
jmp    1311 <igbc_char_hex+0x201>
mov    -0x10(%rbp),%rax
movb   $0x36,0x1(%rax)
jmp    1311 <igbc_char_hex+0x201>
mov    -0x10(%rbp),%rax
movb   $0x37,0x1(%rax)
jmp    1311 <igbc_char_hex+0x201>
mov    -0x10(%rbp),%rax
movb   $0x38,0x1(%rax)
jmp    1311 <igbc_char_hex+0x201>
mov    -0x10(%rbp),%rax
movb   $0x39,0x1(%rax)
jmp    1311 <igbc_char_hex+0x201>
mov    -0x10(%rbp),%rax
movb   $0x41,0x1(%rax)
jmp    1311 <igbc_char_hex+0x201>
mov    -0x10(%rbp),%rax
movb   $0x42,0x1(%rax)
jmp    1311 <igbc_char_hex+0x201>
mov    -0x10(%rbp),%rax
movb   $0x43,0x1(%rax)
jmp    1311 <igbc_char_hex+0x201>
mov    -0x10(%rbp),%rax
movb   $0x44,0x1(%rax)
jmp    1311 <igbc_char_hex+0x201>
mov    -0x10(%rbp),%rax
movb   $0x45,0x1(%rax)
jmp    1311 <igbc_char_hex+0x201>
mov    -0x10(%rbp),%rax
movb   $0x46,0x1(%rax)
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<igbc_char_hex>:
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebx
movzbl %bl,%r14d
and    $0xf,%ebx
shr    $0x4,%r14
mov    $0x2,%edi
call   1030 <malloc@plt>
lea    0xece(%rip),%rcx
mov    (%r14,%rcx,1),%dl
mov    %dl,(%rax)
mov    (%rbx,%rcx,1),%cl
mov    %cl,0x1(%rax)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i8* @igbc_char_hex(i8 signext %0) {
%2 = alloca i8
%3 = alloca i8
%4 = alloca i8
%5 = alloca i8*
store i8 %0, i8* %2
%6 = load i8, i8* %2
%7 = sext i8 %6 to i32
%8 = and i32 %7, 15
%9 = trunc i32 %8 to i8
store i8 %9, i8* %3
%10 = load i8, i8* %2
%11 = sext i8 %10 to i32
%12 = ashr i32 %11, 4
%13 = and i32 %12, 15
%14 = trunc i32 %13 to i8
store i8 %14, i8* %4
%15 = call i64 @malloc(i32 2)
%16 = inttoptr i64 %15 to i8*
store i8* %16, i8** %5
%17 = load i8, i8* %4
%18 = sext i8 %17 to i32
switch i32 %18, label %67 [
i32 0, label %19
i32 1, label %22
i32 2, label %25
i32 3, label %28
i32 4, label %31
i32 5, label %34
i32 6, label %37
i32 7, label %40
i32 8, label %43
i32 9, label %46
i32 10, label %49
i32 11, label %52
i32 12, label %55
i32 13, label %58
i32 14, label %61
i32 15, label %64
]
19: ; preds = %1
%20 = load i8*, i8** %5
%21 = getelementptr inbounds i8, i8* %20, i64 0
store i8 48, i8* %21
br label %67
22: ; preds = %1
%23 = load i8*, i8** %5
%24 = getelementptr inbounds i8, i8* %23, i64 0
store i8 49, i8* %24
br label %67
25: ; preds = %1
%26 = load i8*, i8** %5
%27 = getelementptr inbounds i8, i8* %26, i64 0
store i8 50, i8* %27
br label %67
28: ; preds = %1
%29 = load i8*, i8** %5
%30 = getelementptr inbounds i8, i8* %29, i64 0
store i8 51, i8* %30
br label %67
31: ; preds = %1
%32 = load i8*, i8** %5
%33 = getelementptr inbounds i8, i8* %32, i64 0
store i8 52, i8* %33
br label %67
34: ; preds = %1
%35 = load i8*, i8** %5
%36 = getelementptr inbounds i8, i8* %35, i64 0
store i8 53, i8* %36
br label %67
37: ; preds = %1
%38 = load i8*, i8** %5
%39 = getelementptr inbounds i8, i8* %38, i64 0
store i8 54, i8* %39
br label %67
40: ; preds = %1
%41 = load i8*, i8** %5
%42 = getelementptr inbounds i8, i8* %41, i64 0
store i8 55, i8* %42
br label %67
43: ; preds = %1
%44 = load i8*, i8** %5
%45 = getelementptr inbounds i8, i8* %44, i64 0
store i8 56, i8* %45
br label %67
46: ; preds = %1
%47 = load i8*, i8** %5
%48 = getelementptr inbounds i8, i8* %47, i64 0
store i8 57, i8* %48
br label %67
49: ; preds = %1
%50 = load i8*, i8** %5
%51 = getelementptr inbounds i8, i8* %50, i64 0
store i8 65, i8* %51
br label %67
52: ; preds = %1
%53 = load i8*, i8** %5
%54 = getelementptr inbounds i8, i8* %53, i64 0
store i8 66, i8* %54
br label %67
55: ; preds = %1
%56 = load i8*, i8** %5
%57 = getelementptr inbounds i8, i8* %56, i64 0
store i8 67, i8* %57
br label %67
58: ; preds = %1
%59 = load i8*, i8** %5
%60 = getelementptr inbounds i8, i8* %59, i64 0
store i8 68, i8* %60
br label %67
61: ; preds = %1
%62 = load i8*, i8** %5
%63 = getelementptr inbounds i8, i8* %62, i64 0
store i8 69, i8* %63
br label %67
64: ; preds = %1
%65 = load i8*, i8** %5
%66 = getelementptr inbounds i8, i8* %65, i64 0
store i8 70, i8* %66
br label %67
67: ; preds = %1, %64, %61, %58, %55, %52, %49, %46, %43, %40, %37, %34, %31, %28, %25, %22, %19
%68 = load i8, i8* %3
%69 = sext i8 %68 to i32
switch i32 %69, label %118 [
i32 0, label %70
i32 1, label %73
i32 2, label %76
i32 3, label %79
i32 4, label %82
i32 5, label %85
i32 6, label %88
i32 7, label %91
i32 8, label %94
i32 9, label %97
i32 10, label %100
i32 11, label %103
i32 12, label %106
i32 13, label %109
i32 14, label %112
i32 15, label %115
]
70: ; preds = %67
%71 = load i8*, i8** %5
%72 = getelementptr inbounds i8, i8* %71, i64 1
store i8 48, i8* %72
br label %118
73: ; preds = %67
%74 = load i8*, i8** %5
%75 = getelementptr inbounds i8, i8* %74, i64 1
store i8 49, i8* %75
br label %118
76: ; preds = %67
%77 = load i8*, i8** %5
%78 = getelementptr inbounds i8, i8* %77, i64 1
store i8 50, i8* %78
br label %118
79: ; preds = %67
%80 = load i8*, i8** %5
%81 = getelementptr inbounds i8, i8* %80, i64 1
store i8 51, i8* %81
br label %118
82: ; preds = %67
%83 = load i8*, i8** %5
%84 = getelementptr inbounds i8, i8* %83, i64 1
store i8 52, i8* %84
br label %118
85: ; preds = %67
%86 = load i8*, i8** %5
%87 = getelementptr inbounds i8, i8* %86, i64 1
store i8 53, i8* %87
br label %118
88: ; preds = %67
%89 = load i8*, i8** %5
%90 = getelementptr inbounds i8, i8* %89, i64 1
store i8 54, i8* %90
br label %118
91: ; preds = %67
%92 = load i8*, i8** %5
%93 = getelementptr inbounds i8, i8* %92, i64 1
store i8 55, i8* %93
br label %118
94: ; preds = %67
%95 = load i8*, i8** %5
%96 = getelementptr inbounds i8, i8* %95, i64 1
store i8 56, i8* %96
br label %118
97: ; preds = %67
%98 = load i8*, i8** %5
%99 = getelementptr inbounds i8, i8* %98, i64 1
store i8 57, i8* %99
br label %118
100: ; preds = %67
%101 = load i8*, i8** %5
%102 = getelementptr inbounds i8, i8* %101, i64 1
store i8 65, i8* %102
br label %118
103: ; preds = %67
%104 = load i8*, i8** %5
%105 = getelementptr inbounds i8, i8* %104, i64 1
store i8 66, i8* %105
br label %118
106: ; preds = %67
%107 = load i8*, i8** %5
%108 = getelementptr inbounds i8, i8* %107, i64 1
store i8 67, i8* %108
br label %118
109: ; preds = %67
%110 = load i8*, i8** %5
%111 = getelementptr inbounds i8, i8* %110, i64 1
store i8 68, i8* %111
br label %118
112: ; preds = %67
%113 = load i8*, i8** %5
%114 = getelementptr inbounds i8, i8* %113, i64 1
store i8 69, i8* %114
br label %118
115: ; preds = %67
%116 = load i8*, i8** %5
%117 = getelementptr inbounds i8, i8* %116, i64 1
store i8 70, i8* %117
br label %118
118: ; preds = %67, %115, %112, %109, %106, %103, %100, %97, %94, %91, %88, %85, %82, %79, %76, %73, %70
%119 = load i8*, i8** %5
ret i8* %119
}

LLVM IR (-O2):
@switch.table.igbc_char_hex.1 = [16 x i8] c"0123456789ABCDEF"
define i8* @igbc_char_hex(i8 signext %0) {
%2 = and i8 %0, 15
%3 = lshr i8 %0, 4
%4 = tail call i64 @malloc(i32 2)
%5 = inttoptr i64 %4 to i8*
%6 = zext i8 %3 to i64
%7 = getelementptr inbounds [16 x i8], [16 x i8]* @switch.table.igbc_char_hex.1, i64 0, i64 %6
%8 = load i8, i8* %7
store i8 %8, i8* %5
%9 = zext i8 %2 to i64
%10 = getelementptr inbounds [16 x i8], [16 x i8]* @switch.table.igbc_char_hex.1, i64 0, i64 %9
%11 = load i8, i8* %10
%12 = getelementptr inbounds i8, i8* %5, i64 1
store i8 %11, i8* %12
ret i8* %5
}