#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 */
unsigned char hex2uchar(char);
void hex2bin(char *client_hex, unsigned char uclient[]) {
  int i;
  unsigned char a, b;
  for (i = 0; i < 32; i += 2) {
    a = hex2uchar(client_hex[i]);
    b = hex2uchar(client_hex[i + 1]);
    uclient[i / 2] = (unsigned char)(a << 4 | b);
  }
}


x86 assembly (clang, -O0):
<hex2bin>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x20,-0x14(%rbp)
jge    119e <hex2bin+0x8e>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <hex2uchar@plt>
mov    %al,-0x15(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <hex2uchar@plt>
mov    %al,-0x16(%rbp)
movzbl -0x15(%rbp),%eax
shl    $0x4,%eax
movzbl -0x16(%rbp),%ecx
or     %ecx,%eax
mov    %al,-0x21(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    -0x21(%rbp),%dl
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x14(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x14(%rbp)
jmp    1127 <hex2bin+0x17>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hex2bin>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %rdi,%r14
mov    $0xfffffffffffffffe,%r12
cs nopw 0x0(%rax,%rax,1)
nop
movsbl 0x2(%r14,%r12,1),%edi
call   1030 <hex2uchar@plt>
mov    %eax,%ebx
movsbl 0x3(%r14,%r12,1),%edi
call   1030 <hex2uchar@plt>
shl    $0x4,%bl
or     %al,%bl
mov    %bl,(%r15)
add    $0x2,%r12
add    $0x1,%r15
cmp    $0x1e,%r12
jb     1130 <hex2bin+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @hex2bin(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8
%7 = alloca i8
store i8* %0, i8** %3
store i8* %1, i8** %4
store i32 0, i32* %5
br label %8
8: ; preds = %37, %2
%9 = load i32, i32* %5
%10 = icmp slt i32 %9, 32
br i1 %10, label %11, label %40
11: ; preds = %8
%12 = load i8*, i8** %3
%13 = load i32, i32* %5
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %12, i64 %14
%16 = load i8, i8* %15
%17 = call zeroext i8 @hex2uchar(i8 signext %16)
store i8 %17, i8* %6
%18 = load i8*, i8** %3
%19 = load i32, i32* %5
%20 = add nsw i32 %19, 1
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %18, i64 %21
%23 = load i8, i8* %22
%24 = call zeroext i8 @hex2uchar(i8 signext %23)
store i8 %24, i8* %7
%25 = load i8, i8* %6
%26 = zext i8 %25 to i32
%27 = shl i32 %26, 4
%28 = load i8, i8* %7
%29 = zext i8 %28 to i32
%30 = or i32 %27, %29
%31 = trunc i32 %30 to i8
%32 = load i8*, i8** %4
%33 = load i32, i32* %5
%34 = sdiv i32 %33, 2
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8, i8* %32, i64 %35
store i8 %31, i8* %36
br label %37
37: ; preds = %11
%38 = load i32, i32* %5
%39 = add nsw i32 %38, 2
store i32 %39, i32* %5
br label %8
40: ; preds = %8
ret void
}

LLVM IR (-O2):
define void @hex2bin(i8* nocapture %0, i8* nocapture writeonly %1) {
br label %3
3: ; preds = %2, %3
%4 = phi i64 [ 0, %2 ], [ %16, %3 ]
%5 = getelementptr inbounds i8, i8* %0, i64 %4
%6 = load i8, i8* %5
%7 = tail call zeroext i8 @hex2uchar(i8 signext %6)
%8 = or i64 %4, 1
%9 = getelementptr inbounds i8, i8* %0, i64 %8
%10 = load i8, i8* %9
%11 = tail call zeroext i8 @hex2uchar(i8 signext %10)
%12 = shl i8 %7, 4
%13 = or i8 %11, %12
%14 = lshr exact i64 %4, 1
%15 = getelementptr inbounds i8, i8* %1, i64 %14
store i8 %13, i8* %15
%16 = add nuw nsw i64 %4, 2
%17 = icmp ult i64 %4, 30
br i1 %17, label %3, label %18
18: ; preds = %3
ret void
}