#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 /*<<< orphan*/ uint8_t;
typedef int uint16_t;

/* Variables and functions */
int s_h2b4(int /*<<< orphan*/);
void pdu_hex2bytes(uint8_t *h, uint16_t len, uint8_t *b) {
  if (len == 0)
    return;
  len >>= 1;
  while (len--) {
    *b++ = (s_h2b4(*h) << 4) | s_h2b4(*(h + 1));
    h += 2;
  }
}


x86 assembly (clang, -O0):
<pdu_hex2bytes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    1132 <pdu_hex2bytes+0x22>
jmp    1193 <pdu_hex2bytes+0x83>
mov    -0xc(%rbp),%eax
sar    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0xc(%rbp)
cmp    $0x0,%eax
je     1193 <pdu_hex2bytes+0x83>
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
call   1030 <s_h2b4@plt>
shl    $0x4,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%edi
call   1030 <s_h2b4@plt>
mov    -0x1c(%rbp),%ecx
or     %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x4,%rdx
mov    %rdx,-0x18(%rbp)
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x8(%rbp)
jmp    113b <pdu_hex2bytes+0x2b>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pdu_hex2bytes>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
cmp    $0x2,%esi
jb     1157 <pdu_hex2bytes+0x47>
mov    %rdx,%r14
mov    %esi,%r15d
mov    %rdi,%r12
sar    %r15d
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    (%r12,%rbx,8),%edi
call   1030 <s_h2b4@plt>
mov    %eax,%ebp
shl    $0x4,%ebp
mov    0x4(%r12,%rbx,8),%edi
call   1030 <s_h2b4@plt>
or     %ebp,%eax
mov    %eax,(%r14,%rbx,4)
add    $0x1,%rbx
cmp    %ebx,%r15d
jne    1130 <pdu_hex2bytes+0x20>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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