void vOneTwo(unsigned char *psIn, unsigned int uiLength, unsigned char *psOut) {
  static unsigned char aucHexToChar[17] = "0123456789ABCDEF";
  unsigned int uiCounter;
  for (uiCounter = 0; uiCounter < uiLength; uiCounter++) {
    psOut[2 * uiCounter] = aucHexToChar[(psIn[uiCounter] >> 4)];
    psOut[2 * uiCounter + 1] = aucHexToChar[(psIn[uiCounter] & 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
jae    1187 <vOneTwo+0x87>
mov    -0x8(%rbp),%rax
mov    -0x1c(%rbp),%ecx
movzbl (%rax,%rcx,1),%eax
sar    $0x4,%eax
movslq %eax,%rcx
lea    0x2ef6(%rip),%rax
mov    (%rax,%rcx,1),%dl
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
shl    $0x1,%ecx
mov    %ecx,%ecx
mov    %dl,(%rax,%rcx,1)
mov    -0x8(%rbp),%rax
mov    -0x1c(%rbp),%ecx
movzbl (%rax,%rcx,1),%eax
and    $0xf,%eax
movslq %eax,%rcx
lea    0x2ecc(%rip),%rax
mov    (%rax,%rcx,1),%dl
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
shl    $0x1,%ecx
add    $0x1,%ecx
mov    %ecx,%ecx
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
je     114f <vOneTwo+0x4f>
mov    %esi,%r8d
add    %r8,%r8
xor    %ecx,%ecx
lea    0xeed(%rip),%r9
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movzbl (%rdi),%eax
shr    $0x4,%rax
movzbl (%rax,%r9,1),%eax
mov    %ecx,%esi
mov    %al,(%rdx,%rsi,1)
movzbl (%rdi),%eax
and    $0xf,%eax
movzbl (%rax,%r9,1),%eax
lea    0x1(%rcx),%esi
mov    %al,(%rdx,%rsi,1)
add    $0x1,%rdi
add    $0x2,%rcx
cmp    %rcx,%r8
jne    1120 <vOneTwo+0x20>
ret

LLVM IR (-O0):
@vOneTwo.aucHexToChar = internal global [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 = %44, %3
%9 = load i32, i32* %7
%10 = load i32, i32* %5
%11 = icmp ult i32 %9, %10
br i1 %11, label %12, label %47
12: ; preds = %8
%13 = load i8*, i8** %4
%14 = load i32, i32* %7
%15 = zext 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 = sext i32 %19 to i64
%21 = getelementptr inbounds [17 x i8], [17 x i8]* @vOneTwo.aucHexToChar, i64 0, i64 %20
%22 = load i8, i8* %21
%23 = load i8*, i8** %6
%24 = load i32, i32* %7
%25 = mul i32 2, %24
%26 = zext i32 %25 to i64
%27 = getelementptr inbounds i8, i8* %23, i64 %26
store i8 %22, i8* %27
%28 = load i8*, i8** %4
%29 = load i32, i32* %7
%30 = zext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %28, i64 %30
%32 = load i8, i8* %31
%33 = zext i8 %32 to i32
%34 = and i32 %33, 15
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [17 x i8], [17 x i8]* @vOneTwo.aucHexToChar, i64 0, i64 %35
%37 = load i8, i8* %36
%38 = load i8*, i8** %6
%39 = load i32, i32* %7
%40 = mul i32 2, %39
%41 = add i32 %40, 1
%42 = zext i32 %41 to i64
%43 = getelementptr inbounds i8, i8* %38, i64 %42
store i8 %37, i8* %43
br label %44
44: ; preds = %12
%45 = load i32, i32* %7
%46 = add i32 %45, 1
store i32 %46, i32* %7
br label %8
47: ; 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 eq i32 %1, 0
br i1 %4, label %29, label %5
5: ; preds = %3
%6 = zext i32 %1 to i64
br label %7
7: ; preds = %5, %7
%8 = phi i64 [ 0, %5 ], [ %27, %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 = trunc i64 %8 to i32
%16 = shl i32 %15, 1
%17 = zext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %2, i64 %17
store i8 %14, i8* %18
%19 = load i8, i8* %9
%20 = and i8 %19, 15
%21 = zext i8 %20 to i64
%22 = getelementptr inbounds [17 x i8], [17 x i8]* @vOneTwo.aucHexToChar, i64 0, i64 %21
%23 = load i8, i8* %22
%24 = or i32 %16, 1
%25 = zext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %2, i64 %25
store i8 %23, i8* %26
%27 = add nuw nsw i64 %8, 1
%28 = icmp eq i64 %27, %6
br i1 %28, label %29, label %7
29: ; preds = %7, %3
ret void
}