#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;
typedef int uint64_t;

/* Variables and functions */
void bin2HexLower(uint8_t *in, uint64_t inLen, uint8_t *out) {
  static uint8_t nibbleToHex[16] = {0x30, 0x31, 0x32, 0x33, 0x34, 0x35,
                                    0x36, 0x37, 0x38, 0x39, 0x61, 0x62,
                                    0x63, 0x64, 0x65, 0x66};
  for (int i = 0; i < inLen; i++) {
    out[i * 2] = nibbleToHex[(in[i]) >> 4];
    out[i * 2 + 1] = nibbleToHex[(0x0f & in[i])];
  };
}


x86 assembly (clang, -O0):
<bin2HexLower>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1189 <bin2HexLower+0x89>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
sar    $0x4,%eax
movslq %eax,%rcx
lea    0x2ef6(%rip),%rax
mov    (%rax,%rcx,4),%edx
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
shl    $0x1,%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
and    $0xf,%eax
movslq %eax,%rcx
lea    0x2ecb(%rip),%rax
mov    (%rax,%rcx,4),%edx
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
shl    $0x1,%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1116 <bin2HexLower+0x16>
pop    %rbp
ret

x86 assembly (clang, -O2):
<bin2HexLower>:
test   %esi,%esi
jle    1134 <bin2HexLower+0x34>
mov    %esi,%r8d
xor    %ecx,%ecx
lea    0xef0(%rip),%rsi
mov    (%rdi,%rcx,4),%eax
sar    $0x4,%eax
cltq
mov    (%rsi,%rax,4),%eax
mov    %eax,(%rdx,%rcx,8)
mov    (%rdi,%rcx,4),%eax
and    $0xf,%eax
mov    (%rsi,%rax,4),%eax
mov    %eax,0x4(%rdx,%rcx,8)
add    $0x1,%rcx
cmp    %rcx,%r8
jne    1110 <bin2HexLower+0x10>
ret

LLVM IR (-O0):
@bin2HexLower.nibbleToHex = internal global [16 x i32] [i32 48, i32 49, i32 50, i32 51, i32 52, i32 53, i32 54, i32 55, i32 56, i32 57, i32 97, i32 98, i32 99, i32 100, i32 101, i32 102]
define void @bin2HexLower(i32* %0, i32 %1, i32* %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
store i32* %2, i32** %6
store i32 0, i32* %7
br label %8
8: ; preds = %42, %3
%9 = load i32, i32* %7
%10 = load i32, i32* %5
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %45
12: ; preds = %8
%13 = load i32*, i32** %4
%14 = load i32, i32* %7
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i32, i32* %13, i64 %15
%17 = load i32, i32* %16
%18 = ashr i32 %17, 4
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [16 x i32], [16 x i32]* @bin2HexLower.nibbleToHex, i64 0, i64 %19
%21 = load i32, i32* %20
%22 = load i32*, i32** %6
%23 = load i32, i32* %7
%24 = mul nsw i32 %23, 2
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i32, i32* %22, i64 %25
store i32 %21, i32* %26
%27 = load i32*, i32** %4
%28 = load i32, i32* %7
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i32, i32* %27, i64 %29
%31 = load i32, i32* %30
%32 = and i32 15, %31
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [16 x i32], [16 x i32]* @bin2HexLower.nibbleToHex, i64 0, i64 %33
%35 = load i32, i32* %34
%36 = load i32*, i32** %6
%37 = load i32, i32* %7
%38 = mul nsw i32 %37, 2
%39 = add nsw i32 %38, 1
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i32, i32* %36, i64 %40
store i32 %35, i32* %41
br label %42
42: ; preds = %12
%43 = load i32, i32* %7
%44 = add nsw i32 %43, 1
store i32 %44, i32* %7
br label %8
45: ; preds = %8
ret void
}

LLVM IR (-O2):
@bin2HexLower.nibbleToHex = internal unnamed_addr constant [16 x i32] [i32 48, i32 49, i32 50, i32 51, i32 52, i32 53, i32 54, i32 55, i32 56, i32 57, i32 97, i32 98, i32 99, i32 100, i32 101, i32 102]
define void @bin2HexLower(i32* nocapture %0, i32 %1, i32* nocapture writeonly %2) {
%4 = icmp sgt i32 %1, 0
br i1 %4, label %5, label %7
5: ; preds = %3
%6 = zext i32 %1 to i64
br label %8
7: ; preds = %8, %3
ret void
8: ; preds = %5, %8
%9 = phi i64 [ 0, %5 ], [ %25, %8 ]
%10 = getelementptr inbounds i32, i32* %0, i64 %9
%11 = load i32, i32* %10
%12 = ashr i32 %11, 4
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [16 x i32], [16 x i32]* @bin2HexLower.nibbleToHex, i64 0, i64 %13
%15 = load i32, i32* %14
%16 = shl nuw nsw i64 %9, 1
%17 = getelementptr inbounds i32, i32* %2, i64 %16
store i32 %15, i32* %17
%18 = load i32, i32* %10
%19 = and i32 %18, 15
%20 = zext i32 %19 to i64
%21 = getelementptr inbounds [16 x i32], [16 x i32]* @bin2HexLower.nibbleToHex, i64 0, i64 %20
%22 = load i32, i32* %21
%23 = or i64 %16, 1
%24 = getelementptr inbounds i32, i32* %2, i64 %23
store i32 %22, i32* %24
%25 = add nuw nsw i64 %9, 1
%26 = icmp eq i64 %25, %6
br i1 %26, label %7, label %8
}