void vOneTwo(const unsigned char *psIn, int iLength, unsigned char *psOut) {
  static const unsigned char aucHexToChar[17] = "0123456789ABCDEF";
  int iCounter;
  for (iCounter = 0; iCounter < iLength; iCounter++) {
    psOut[2 * iCounter] = aucHexToChar[((psIn[iCounter] >> 4)) & 0x0F];
    psOut[2 * iCounter + 1] = aucHexToChar[(psIn[iCounter] & 0x0F)];
  }
}


x86 assembly (clang, -O0):
<vOneTwo>:
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    118e <vOneTwo+0x8e>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
sar    $0x4,%eax
and    $0xf,%eax
movslq %eax,%rcx
lea    0xec2(%rip),%rax
mov    (%rax,%rcx,1),%dl
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
shl    $0x1,%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
and    $0xf,%eax
movslq %eax,%rcx
lea    0xe96(%rip),%rax
mov    (%rax,%rcx,1),%dl
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
shl    $0x1,%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1116 <vOneTwo+0x16>
pop    %rbp
ret

x86 assembly (clang, -O2):
<vOneTwo>:
test   %esi,%esi
jle    1137 <vOneTwo+0x37>
mov    %esi,%r8d
xor    %ecx,%ecx
lea    0xef0(%rip),%rsi
movzbl (%rdi,%rcx,1),%eax
shr    $0x4,%rax
movzbl (%rax,%rsi,1),%eax
mov    %al,(%rdx,%rcx,2)
movzbl (%rdi,%rcx,1),%eax
and    $0xf,%eax
movzbl (%rax,%rsi,1),%eax
mov    %al,0x1(%rdx,%rcx,2)
add    $0x1,%rcx
cmp    %rcx,%r8
jne    1110 <vOneTwo+0x10>
ret

LLVM IR (-O0):
@vOneTwo.aucHexToChar = internal constant [17 x i8] c"0123456789ABCDEF\00"
define void @vOneTwo(i8* %0, i32 %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
store i8* %2, i8** %6
store i32 0, i32* %7
br label %8
8: ; preds = %45, %3
%9 = load i32, i32* %7
%10 = load i32, i32* %5
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %48
12: ; preds = %8
%13 = load i8*, i8** %4
%14 = load i32, i32* %7
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %13, i64 %15
%17 = load i8, i8* %16
%18 = zext i8 %17 to i32
%19 = ashr i32 %18, 4
%20 = and i32 %19, 15
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [17 x i8], [17 x i8]* @vOneTwo.aucHexToChar, i64 0, i64 %21
%23 = load i8, i8* %22
%24 = load i8*, i8** %6
%25 = load i32, i32* %7
%26 = mul nsw i32 2, %25
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* %24, i64 %27
store i8 %23, i8* %28
%29 = load i8*, i8** %4
%30 = load i32, i32* %7
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %29, i64 %31
%33 = load i8, i8* %32
%34 = zext i8 %33 to i32
%35 = and i32 %34, 15
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [17 x i8], [17 x i8]* @vOneTwo.aucHexToChar, i64 0, i64 %36
%38 = load i8, i8* %37
%39 = load i8*, i8** %6
%40 = load i32, i32* %7
%41 = mul nsw i32 2, %40
%42 = add nsw i32 %41, 1
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i8, i8* %39, i64 %43
store i8 %38, i8* %44
br label %45
45: ; preds = %12
%46 = load i32, i32* %7
%47 = add nsw i32 %46, 1
store i32 %47, i32* %7
br label %8
48: ; preds = %8
ret void
}

LLVM IR (-O2):
@vOneTwo.aucHexToChar = internal unnamed_addr constant [17 x i8] c"0123456789ABCDEF\00"
define void @vOneTwo(i8* nocapture %0, i32 %1, i8* nocapture writeonly %2) {
%4 = icmp sgt i32 %1, 0
br i1 %4, label %5, label %26
5: ; preds = %3
%6 = zext i32 %1 to i64
br label %7
7: ; preds = %5, %7
%8 = phi i64 [ 0, %5 ], [ %24, %7 ]
%9 = getelementptr inbounds i8, i8* %0, i64 %8
%10 = load i8, i8* %9
%11 = lshr i8 %10, 4
%12 = zext i8 %11 to i64
%13 = getelementptr inbounds [17 x i8], [17 x i8]* @vOneTwo.aucHexToChar, i64 0, i64 %12
%14 = load i8, i8* %13
%15 = shl nuw nsw i64 %8, 1
%16 = getelementptr inbounds i8, i8* %2, i64 %15
store i8 %14, i8* %16
%17 = load i8, i8* %9
%18 = and i8 %17, 15
%19 = zext i8 %18 to i64
%20 = getelementptr inbounds [17 x i8], [17 x i8]* @vOneTwo.aucHexToChar, i64 0, i64 %19
%21 = load i8, i8* %20
%22 = or i64 %15, 1
%23 = getelementptr inbounds i8, i8* %2, i64 %22
store i8 %21, i8* %23
%24 = add nuw nsw i64 %8, 1
%25 = icmp eq i64 %24, %6
br i1 %25, label %26, label %7
26: ; preds = %7, %3
ret void
}