void init_bin2hex(char bin2hex_table[256][2]) {
  unsigned i = 0;
  for (i = 0; i < 256; i++) {
    bin2hex_table[i][0] = (((i >> 4) & 0x0F) <= 0x09)
                              ? (((i >> 4) & 0x0F) + '0')
                              : (((i >> 4) & 0x0F) + 'a' - 10);
    bin2hex_table[i][1] =
        (((i)&0x0F) <= 0x09) ? (((i)&0x0F) + '0') : (((i)&0x0F) + 'a' - 10);
  }
  return;
}


x86 assembly (clang, -O0):
<init_bin2hex>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x100,-0xc(%rbp)
jae    11b7 <init_bin2hex+0xb7>
mov    -0xc(%rbp),%eax
shr    $0x4,%eax
and    $0xf,%eax
cmp    $0x9,%eax
ja     1149 <init_bin2hex+0x49>
mov    -0xc(%rbp),%eax
shr    $0x4,%eax
and    $0xf,%eax
add    $0x30,%eax
mov    %eax,-0x10(%rbp)
jmp    115b <init_bin2hex+0x5b>
mov    -0xc(%rbp),%eax
shr    $0x4,%eax
and    $0xf,%eax
add    $0x61,%eax
sub    $0xa,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %al,%dl
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
mov    %dl,(%rax,%rcx,2)
mov    -0xc(%rbp),%eax
and    $0xf,%eax
cmp    $0x9,%eax
ja     118a <init_bin2hex+0x8a>
mov    -0xc(%rbp),%eax
and    $0xf,%eax
add    $0x30,%eax
mov    %eax,-0x14(%rbp)
jmp    1199 <init_bin2hex+0x99>
mov    -0xc(%rbp),%eax
and    $0xf,%eax
add    $0x61,%eax
sub    $0xa,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %al,%dl
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
mov    %dl,0x1(%rax,%rcx,2)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1116 <init_bin2hex+0x16>
pop    %rbp
ret

x86 assembly (clang, -O2):
<init_bin2hex>:
movdqa 0xef8(%rip),%xmm0
movdqa 0xf00(%rip),%xmm1
movdqa 0xf07(%rip),%xmm8
movdqa 0xf0e(%rip),%xmm9
movdqa 0xf15(%rip),%xmm11
movdqa 0xf1c(%rip),%xmm13
xor    %eax,%eax
movdqa 0xf31(%rip),%xmm12
movdqa 0xf88(%rip),%xmm15
movdqa 0xf70(%rip),%xmm5
movdqa %xmm13,%xmm6
movdqa 0xf03(%rip),%xmm3
pxor   %xmm3,%xmm6
movdqa %xmm12,%xmm7
pcmpgtd %xmm6,%xmm7
movdqa %xmm11,%xmm4
pxor   %xmm3,%xmm4
movdqa %xmm12,%xmm10
pcmpgtd %xmm4,%xmm10
movdqa %xmm7,%xmm14
shufps $0x88,%xmm10,%xmm14
pcmpeqd %xmm12,%xmm6
pcmpeqd %xmm12,%xmm4
shufps $0xdd,%xmm4,%xmm6
andps  %xmm14,%xmm6
shufps $0xdd,%xmm10,%xmm7
orps   %xmm6,%xmm7
movdqa %xmm9,%xmm4
pxor   %xmm3,%xmm4
movdqa %xmm12,%xmm6
pcmpgtd %xmm4,%xmm6
movdqa %xmm8,%xmm2
pxor   %xmm3,%xmm2
movdqa %xmm12,%xmm3
pcmpgtd %xmm2,%xmm3
pcmpeqd %xmm12,%xmm4
pcmpeqd %xmm12,%xmm2
shufps $0xdd,%xmm2,%xmm4
movdqa %xmm6,%xmm2
shufps $0x88,%xmm3,%xmm2
andps  %xmm2,%xmm4
movdqa %xmm0,%xmm2
psrld  $0x4,%xmm2
shufps $0xdd,%xmm3,%xmm6
movdqa %xmm1,%xmm3
psrld  $0x4,%xmm3
orps   %xmm4,%xmm6
movdqa %xmm2,%xmm4
movdqa 0xe7c(%rip),%xmm10
por    %xmm10,%xmm4
movdqa 0xe7e(%rip),%xmm14
paddd  %xmm14,%xmm2
pand   %xmm6,%xmm4
pandn  %xmm2,%xmm6
movdqa %xmm3,%xmm2
por    %xmm10,%xmm2
paddd  %xmm14,%xmm3
por    %xmm4,%xmm6
pand   %xmm7,%xmm2
pandn  %xmm3,%xmm7
por    %xmm2,%xmm7
movdqa 0xe5b(%rip),%xmm2
pand   %xmm2,%xmm7
pand   %xmm2,%xmm6
packuswb %xmm6,%xmm7
movdqa %xmm1,%xmm2
movdqa 0xe53(%rip),%xmm4
pand   %xmm4,%xmm2
movdqa %xmm0,%xmm3
pand   %xmm4,%xmm3
movdqa %xmm5,%xmm4
pcmpgtd %xmm2,%xmm4
movdqa %xmm2,%xmm6
por    %xmm10,%xmm6
paddd  %xmm14,%xmm2
pand   %xmm4,%xmm6
pandn  %xmm2,%xmm4
movdqa %xmm5,%xmm2
pcmpgtd %xmm3,%xmm2
por    %xmm6,%xmm4
movdqa %xmm3,%xmm6
por    %xmm10,%xmm6
paddd  %xmm14,%xmm3
pand   %xmm2,%xmm6
pandn  %xmm3,%xmm2
por    %xmm6,%xmm2
packuswb %xmm2,%xmm4
packuswb %xmm7,%xmm7
packuswb %xmm4,%xmm4
punpcklbw %xmm4,%xmm7
movdqu %xmm7,(%rdi,%rax,2)
add    $0x8,%rax
paddq  %xmm15,%xmm13
paddq  %xmm15,%xmm11
paddq  %xmm15,%xmm9
paddq  %xmm15,%xmm8
movdqa 0xdfe(%rip),%xmm2
paddd  %xmm2,%xmm1
paddd  %xmm2,%xmm0
cmp    $0x100,%rax
jne    1150 <init_bin2hex+0x50>
ret

LLVM IR (-O0):
define void @init_bin2hex([2 x i8]* %0) {
%2 = alloca [2 x i8]*
%3 = alloca i32
store [2 x i8]* %0, [2 x i8]** %2
store i32 0, i32* %3
store i32 0, i32* %3
br label %4
4: ; preds = %51, %1
%5 = load i32, i32* %3
%6 = icmp ult i32 %5, 256
br i1 %6, label %7, label %54
7: ; preds = %4
%8 = load i32, i32* %3
%9 = lshr i32 %8, 4
%10 = and i32 %9, 15
%11 = icmp ule i32 %10, 9
br i1 %11, label %12, label %17
12: ; preds = %7
%13 = load i32, i32* %3
%14 = lshr i32 %13, 4
%15 = and i32 %14, 15
%16 = add i32 %15, 48
br label %23
17: ; preds = %7
%18 = load i32, i32* %3
%19 = lshr i32 %18, 4
%20 = and i32 %19, 15
%21 = add i32 %20, 97
%22 = sub i32 %21, 10
br label %23
23: ; preds = %17, %12
%24 = phi i32 [ %16, %12 ], [ %22, %17 ]
%25 = trunc i32 %24 to i8
%26 = load [2 x i8]*, [2 x i8]** %2
%27 = load i32, i32* %3
%28 = zext i32 %27 to i64
%29 = getelementptr inbounds [2 x i8], [2 x i8]* %26, i64 %28
%30 = getelementptr inbounds [2 x i8], [2 x i8]* %29, i64 0, i64 0
store i8 %25, i8* %30
%31 = load i32, i32* %3
%32 = and i32 %31, 15
%33 = icmp ule i32 %32, 9
br i1 %33, label %34, label %38
34: ; preds = %23
%35 = load i32, i32* %3
%36 = and i32 %35, 15
%37 = add i32 %36, 48
br label %43
38: ; preds = %23
%39 = load i32, i32* %3
%40 = and i32 %39, 15
%41 = add i32 %40, 97
%42 = sub i32 %41, 10
br label %43
43: ; preds = %38, %34
%44 = phi i32 [ %37, %34 ], [ %42, %38 ]
%45 = trunc i32 %44 to i8
%46 = load [2 x i8]*, [2 x i8]** %2
%47 = load i32, i32* %3
%48 = zext i32 %47 to i64
%49 = getelementptr inbounds [2 x i8], [2 x i8]* %46, i64 %48
%50 = getelementptr inbounds [2 x i8], [2 x i8]* %49, i64 0, i64 1
store i8 %45, i8* %50
br label %51
51: ; preds = %43
%52 = load i32, i32* %3
%53 = add i32 %52, 1
store i32 %53, i32* %3
br label %4
54: ; preds = %4
ret void
}

LLVM IR (-O2):
define void @init_bin2hex([2 x i8]* nocapture writeonly %0) {
br label %2
2: ; preds = %2, %1
%3 = phi i64 [ 0, %1 ], [ %21, %2 ]
%4 = phi <8 x i64> [ <i64 0, i64 1, i64 2, i64 3, i64 4, i64 5, i64 6, i64 7>, %1 ], [ %22, %2 ]
%5 = phi <8 x i32> [ <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>, %1 ], [ %23, %2 ]
%6 = lshr <8 x i32> %5, <i32 4, i32 4, i32 4, i32 4, i32 4, i32 4, i32 4, i32 4>
%7 = icmp ult <8 x i64> %4, <i64 160, i64 160, i64 160, i64 160, i64 160, i64 160, i64 160, i64 160>
%8 = or <8 x i32> %6, <i32 48, i32 48, i32 48, i32 48, i32 48, i32 48, i32 48, i32 48>
%9 = add nuw nsw <8 x i32> %6, <i32 87, i32 87, i32 87, i32 87, i32 87, i32 87, i32 87, i32 87>
%10 = select <8 x i1> %7, <8 x i32> %8, <8 x i32> %9
%11 = trunc <8 x i32> %10 to <8 x i8>
%12 = and <8 x i32> %5, <i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15>
%13 = icmp ult <8 x i32> %12, <i32 10, i32 10, i32 10, i32 10, i32 10, i32 10, i32 10, i32 10>
%14 = or <8 x i32> %12, <i32 48, i32 48, i32 48, i32 48, i32 48, i32 48, i32 48, i32 48>
%15 = add nuw nsw <8 x i32> %12, <i32 87, i32 87, i32 87, i32 87, i32 87, i32 87, i32 87, i32 87>
%16 = select <8 x i1> %13, <8 x i32> %14, <8 x i32> %15
%17 = trunc <8 x i32> %16 to <8 x i8>
%18 = getelementptr inbounds [2 x i8], [2 x i8]* %0, i64 %3, i64 0
%19 = bitcast i8* %18 to <16 x i8>*
%20 = shufflevector <8 x i8> %11, <8 x i8> %17, <16 x i32> <i32 0, i32 8, i32 1, i32 9, i32 2, i32 10, i32 3, i32 11, i32 4, i32 12, i32 5, i32 13, i32 6, i32 14, i32 7, i32 15>
store <16 x i8> %20, <16 x i8>* %19
%21 = add nuw i64 %3, 8
%22 = add <8 x i64> %4, <i64 8, i64 8, i64 8, i64 8, i64 8, i64 8, i64 8, i64 8>
%23 = add <8 x i32> %5, <i32 8, i32 8, i32 8, i32 8, i32 8, i32 8, i32 8, i32 8>
%24 = icmp eq i64 %21, 256
br i1 %24, label %25, label %2
25: ; preds = %2
ret void
}