#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;

/* Variables and functions */
int hex_to_bin(int /*<<< orphan*/);
void hex2bin(uint8_t *dst, const char *src, size_t count) {
  while (count--) {
    *dst = hex_to_bin(*src++) << 4;
    *dst += hex_to_bin(*src++);
    dst++;
  }
}


x86 assembly (clang, -O0):
<hex2bin>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x18(%rbp)
cmp    $0x0,%rax
je     1191 <hex2bin+0x81>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movsbl (%rax),%edi
call   1030 <hex_to_bin@plt>
mov    %eax,%ecx
shl    $0x4,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movsbl (%rax),%edi
call   1030 <hex_to_bin@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
add    (%rax),%ecx
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x8(%rbp)
jmp    1124 <hex2bin+0x14>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hex2bin>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %rdx,%rdx
je     1159 <hex2bin+0x49>
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r12
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
movsbl (%r15,%rbx,2),%edi
call   1030 <hex_to_bin@plt>
shl    $0x4,%eax
mov    %eax,(%r12,%rbx,4)
movsbl 0x1(%r15,%rbx,2),%edi
call   1030 <hex_to_bin@plt>
add    %eax,(%r12,%rbx,4)
add    $0x1,%rbx
cmp    %rbx,%r14
jne    1130 <hex2bin+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

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