#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 */
int hexDigitToNibble(unsigned char);
unsigned char *dehexify(unsigned char *dest, unsigned char *hexData,
                        int byteLen) {
  unsigned char *p = dest;
  while (byteLen--) {
    *dest++ =
        (hexDigitToNibble(hexData[0]) << 4) | hexDigitToNibble(hexData[1]);
    hexData += 2;
  }
  return p;
}


x86 assembly (clang, -O0):
<dehexify>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x14(%rbp)
cmp    $0x0,%eax
je     1189 <dehexify+0x79>
mov    -0x10(%rbp),%rax
movzbl (%rax),%edi
call   1030 <hexDigitToNibble@plt>
shl    $0x4,%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
movzbl 0x1(%rax),%edi
call   1030 <hexDigitToNibble@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
or     %ecx,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x8(%rbp)
mov    %cl,(%rax)
mov    -0x10(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x10(%rbp)
jmp    112b <dehexify+0x1b>
mov    -0x20(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dehexify>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdi,%r14
test   %edx,%edx
je     1159 <dehexify+0x49>
mov    %rsi,%r12
mov    %edx,%r15d
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
movzbl (%r12,%rbx,2),%edi
call   1030 <hexDigitToNibble@plt>
mov    %eax,%ebp
shl    $0x4,%ebp
movzbl 0x1(%r12,%rbx,2),%edi
call   1030 <hexDigitToNibble@plt>
or     %ebp,%eax
mov    %al,(%r14,%rbx,1)
add    $0x1,%rbx
cmp    %ebx,%r15d
jne    1130 <dehexify+0x20>
mov    %r14,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i8* @dehexify(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%8 = load i8*, i8** %4
store i8* %8, i8** %7
br label %9
9: ; preds = %13, %3
%10 = load i32, i32* %6
%11 = add nsw i32 %10, -1
store i32 %11, i32* %6
%12 = icmp ne i32 %10, 0
br i1 %12, label %13, label %29
13: ; preds = %9
%14 = load i8*, i8** %5
%15 = getelementptr inbounds i8, i8* %14, i64 0
%16 = load i8, i8* %15
%17 = call i32 @hexDigitToNibble(i8 zeroext %16)
%18 = shl i32 %17, 4
%19 = load i8*, i8** %5
%20 = getelementptr inbounds i8, i8* %19, i64 1
%21 = load i8, i8* %20
%22 = call i32 @hexDigitToNibble(i8 zeroext %21)
%23 = or i32 %18, %22
%24 = trunc i32 %23 to i8
%25 = load i8*, i8** %4
%26 = getelementptr inbounds i8, i8* %25, i32 1
store i8* %26, i8** %4
store i8 %24, i8* %25
%27 = load i8*, i8** %5
%28 = getelementptr inbounds i8, i8* %27, i64 2
store i8* %28, i8** %5
br label %9
29: ; preds = %9
%30 = load i8*, i8** %7
ret i8* %30
}

LLVM IR (-O2):
define i8* @dehexify(i8* returned writeonly %0, i8* nocapture %1, i32 %2) {
%4 = icmp eq i32 %2, 0
br i1 %4, label %21, label %5
5: ; preds = %3, %5
%6 = phi i8* [ %18, %5 ], [ %0, %3 ]
%7 = phi i32 [ %9, %5 ], [ %2, %3 ]
%8 = phi i8* [ %19, %5 ], [ %1, %3 ]
%9 = add nsw i32 %7, -1
%10 = load i8, i8* %8
%11 = tail call i32 @hexDigitToNibble(i8 zeroext %10)
%12 = shl i32 %11, 4
%13 = getelementptr inbounds i8, i8* %8, i64 1
%14 = load i8, i8* %13
%15 = tail call i32 @hexDigitToNibble(i8 zeroext %14)
%16 = or i32 %15, %12
%17 = trunc i32 %16 to i8
%18 = getelementptr inbounds i8, i8* %6, i64 1
store i8 %17, i8* %6
%19 = getelementptr inbounds i8, i8* %8, i64 2
%20 = icmp eq i32 %9, 0
br i1 %20, label %21, label %5
21: ; preds = %5, %3
ret i8* %0
}