#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__ util_hexToint(char *, int);
int util_hexToBuf(char *hexString, int hexStringLength, char *output) {
  int i, x = hexStringLength / 2;
  for (i = 0; i < x; i++) {
    output[i] = (char)util_hexToint(hexString + (i * 2), 2);
  }
  return i;
}


x86 assembly (clang, -O0):
<util_hexToBuf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x20(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    1178 <util_hexToBuf+0x68>
mov    -0x8(%rbp),%rdi
mov    -0x1c(%rbp),%eax
shl    $0x1,%eax
cltq
add    %rax,%rdi
mov    $0x2,%esi
call   1030 <util_hexToint@plt>
mov    %al,%dl
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1138 <util_hexToBuf+0x28>
mov    -0x1c(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<util_hexToBuf>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
xor    %r14d,%r14d
cmp    $0x2,%esi
jl     115e <util_hexToBuf+0x4e>
mov    %rdx,%r15
mov    %rdi,%rbp
mov    %esi,%r14d
shr    $0x1f,%r14d
add    %esi,%r14d
sar    %r14d
mov    %r14d,%r12d
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    %rbp,%rdi
mov    $0x2,%esi
call   1030 <util_hexToint@plt>
mov    %al,(%r15,%rbx,1)
add    $0x1,%rbx
add    $0x2,%rbp
cmp    %rbx,%r12
jne    1140 <util_hexToBuf+0x30>
mov    %r14d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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