#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 */
scalar_t__ strtoul(char *, char **, int);
void Hex2Byte(const char *hexString, unsigned char *byteArray,
              size_t byteArraySize) {
  if (NULL == hexString || NULL == byteArray || 0 == byteArraySize) {
    return;
  }
  char temp[3];
  char *end;
  for (size_t i = 0; i < byteArraySize; i++) {
    temp[0] = hexString[i * 2];
    temp[1] = hexString[i * 2 + 1];
    temp[2] = 0;
    byteArray[i] = (unsigned char)strtoul(temp, &end, 16);
  }
}


x86 assembly (clang, -O0):
<Hex2Byte>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
xor    %eax,%eax
cmp    -0x8(%rbp),%rax
je     1148 <Hex2Byte+0x38>
xor    %eax,%eax
cmp    -0x10(%rbp),%rax
je     1148 <Hex2Byte+0x38>
xor    %eax,%eax
cmp    -0x18(%rbp),%rax
jne    114d <Hex2Byte+0x3d>
jmp    11bc <Hex2Byte+0xac>
movq   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    11bc <Hex2Byte+0xac>
mov    -0x8(%rbp),%rax
mov    -0x30(%rbp),%rcx
shl    $0x1,%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x1b(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x30(%rbp),%rcx
shl    $0x1,%rcx
mov    0x1(%rax,%rcx,1),%al
mov    %al,-0x1a(%rbp)
movb   $0x0,-0x19(%rbp)
lea    -0x1b(%rbp),%rdi
lea    -0x28(%rbp),%rsi
mov    $0x10,%edx
call   1030 <strtoul@plt>
mov    %al,%dl
mov    -0x10(%rbp),%rax
mov    -0x30(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    1155 <Hex2Byte+0x45>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Hex2Byte>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
test   %rdi,%rdi
je     1183 <Hex2Byte+0x73>
mov    %rsi,%r15
test   %rsi,%rsi
je     1183 <Hex2Byte+0x73>
mov    %rdx,%r14
test   %rdx,%rdx
je     1183 <Hex2Byte+0x73>
mov    %rdi,%rbx
xor    %ebp,%ebp
lea    0xd(%rsp),%r12
lea    0x10(%rsp),%r13
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movzbl (%rbx,%rbp,2),%eax
mov    %al,0xd(%rsp)
movzbl 0x1(%rbx,%rbp,2),%eax
mov    %al,0xe(%rsp)
movb   $0x0,0xf(%rsp)
mov    %r12,%rdi
mov    %r13,%rsi
mov    $0x10,%edx
call   1030 <strtoul@plt>
mov    %al,(%r15,%rbp,1)
add    $0x1,%rbp
cmp    %rbp,%r14
jne    1150 <Hex2Byte+0x40>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @Hex2Byte(i8* %0, i8* %1, i64 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca [3 x i8]
%8 = alloca i8*
%9 = alloca i64
store i8* %0, i8** %4
store i8* %1, i8** %5
store i64 %2, i64* %6
%10 = load i8*, i8** %4
%11 = icmp eq i8* null, %10
br i1 %11, label %18, label %12
12: ; preds = %3
%13 = load i8*, i8** %5
%14 = icmp eq i8* null, %13
br i1 %14, label %18, label %15
15: ; preds = %12
%16 = load i64, i64* %6
%17 = icmp eq i64 0, %16
br i1 %17, label %18, label %19
18: ; preds = %15, %12, %3
br label %48
19: ; preds = %15
store i64 0, i64* %9
br label %20
20: ; preds = %45, %19
%21 = load i64, i64* %9
%22 = load i64, i64* %6
%23 = icmp ult i64 %21, %22
br i1 %23, label %24, label %48
24: ; preds = %20
%25 = load i8*, i8** %4
%26 = load i64, i64* %9
%27 = mul i64 %26, 2
%28 = getelementptr inbounds i8, i8* %25, i64 %27
%29 = load i8, i8* %28
%30 = getelementptr inbounds [3 x i8], [3 x i8]* %7, i64 0, i64 0
store i8 %29, i8* %30
%31 = load i8*, i8** %4
%32 = load i64, i64* %9
%33 = mul i64 %32, 2
%34 = add i64 %33, 1
%35 = getelementptr inbounds i8, i8* %31, i64 %34
%36 = load i8, i8* %35
%37 = getelementptr inbounds [3 x i8], [3 x i8]* %7, i64 0, i64 1
store i8 %36, i8* %37
%38 = getelementptr inbounds [3 x i8], [3 x i8]* %7, i64 0, i64 2
store i8 0, i8* %38
%39 = getelementptr inbounds [3 x i8], [3 x i8]* %7, i64 0, i64 0
%40 = call i64 @strtoul(i8* %39, i8** %8, i32 16)
%41 = trunc i64 %40 to i8
%42 = load i8*, i8** %5
%43 = load i64, i64* %9
%44 = getelementptr inbounds i8, i8* %42, i64 %43
store i8 %41, i8* %44
br label %45
45: ; preds = %24
%46 = load i64, i64* %9
%47 = add i64 %46, 1
store i64 %47, i64* %9
br label %20
48: ; preds = %18, %20
ret void
}

LLVM IR (-O2):
define void @Hex2Byte(i8* %0, i8* writeonly %1, i64 %2) {
%4 = alloca [3 x i8]
%5 = alloca i8*
%6 = icmp eq i8* %0, null
%7 = icmp eq i8* %1, null
%8 = or i1 %6, %7
%9 = icmp eq i64 %2, 0
%10 = or i1 %8, %9
br i1 %10, label %30, label %11
11: ; preds = %3
%12 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 0
%13 = bitcast i8** %5 to i8*
%14 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 1
%15 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 2
br label %17
16: ; preds = %17
br label %30
17: ; preds = %11, %17
%18 = phi i64 [ 0, %11 ], [ %28, %17 ]
%19 = shl i64 %18, 1
%20 = getelementptr inbounds i8, i8* %0, i64 %19
%21 = load i8, i8* %20
store i8 %21, i8* %12
%22 = or i64 %19, 1
%23 = getelementptr inbounds i8, i8* %0, i64 %22
%24 = load i8, i8* %23
store i8 %24, i8* %14
store i8 0, i8* %15
%25 = call i64 @strtoul(i8* %12, i8** %5, i32 16)
%26 = trunc i64 %25 to i8
%27 = getelementptr inbounds i8, i8* %1, i64 %18
store i8 %26, i8* %27
%28 = add nuw i64 %18, 1
%29 = icmp eq i64 %28, %2
br i1 %29, label %16, label %17
30: ; preds = %3, %16
ret void
}