#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;
typedef int uint64_t;

/* Variables and functions */
uint8_t hex2Bin(uint8_t *in, uint64_t inLen, uint8_t *out) {
  static uint8_t hexToNibble[256] = {
      0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0,
      0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0,
      0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0,
      0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0,
      0x0,  0x1,  0x2,  0x3,  0x4,  0x5,  0x6,  0x7,  0x8,  0x9,  0xf0, 0xf0,
      0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xa,  0xb,  0xc,  0xd,  0xe,  0xf,  0xf0,
      0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0,
      0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0,
      0xf0, 0xa,  0xb,  0xc,  0xd,  0xe,  0xf,  0xf0, 0xf0, 0xf0, 0xf0, 0xf0,
      0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0,
      0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0,
      0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0,
      0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0,
      0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0,
      0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0,
      0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0,
      0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0,
      0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0,
      0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0,
      0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0,
      0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0,
      0xf0, 0xf0, 0xf0, 0xf0};
  uint8_t isError = 0;
  for (int i = 0; i < (inLen); i += 2) {
    if (hexToNibble[in[i]] == 0xf0) {
      isError |= 1;
    }
    if (hexToNibble[in[i + 1]] == 0xf0) {
      isError |= 1;
    }
    out[i / 2] = (hexToNibble[in[i]] << 4) | (hexToNibble[in[i + 1]] & 0x0f);
  };
  return isError;
}


x86 assembly (clang, -O0):
<hex2Bin>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11ec <hex2Bin+0xec>
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
movslq (%rax,%rcx,4),%rcx
lea    0x2ef4(%rip),%rax
cmpl   $0xf0,(%rax,%rcx,4)
jne    1152 <hex2Bin+0x52>
mov    -0x1c(%rbp),%eax
or     $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movslq (%rax,%rcx,4),%rcx
lea    0x2ec6(%rip),%rax
cmpl   $0xf0,(%rax,%rcx,4)
jne    1180 <hex2Bin+0x80>
mov    -0x1c(%rbp),%eax
or     $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
movslq (%rax,%rcx,4),%rcx
lea    0x2e9d(%rip),%rax
mov    (%rax,%rcx,4),%eax
shl    $0x4,%eax
mov    -0x8(%rbp),%rcx
mov    -0x20(%rbp),%edx
add    $0x1,%edx
movslq %edx,%rdx
movslq (%rcx,%rdx,4),%rdx
lea    0x2e7f(%rip),%rcx
mov    (%rcx,%rdx,4),%ecx
and    $0xf,%ecx
or     %ecx,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    -0x2c(%rbp),%edx
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x20(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x20(%rbp)
jmp    111d <hex2Bin+0x1d>
mov    -0x1c(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<hex2Bin>:
push   %rbx
test   %esi,%esi
jle    1165 <hex2Bin+0x65>
mov    %esi,%r8d
xor    %esi,%esi
lea    0xeef(%rip),%r9
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movslq (%rdi,%rsi,4),%rcx
mov    (%r9,%rcx,4),%r11d
cmp    $0xf0,%r11d
sete   %r10b
movslq 0x4(%rdi,%rsi,4),%rcx
mov    (%r9,%rcx,4),%ecx
cmp    $0xf0,%ecx
sete   %bl
or     %r10b,%bl
movzbl %bl,%ebx
or     %ebx,%eax
shl    $0x4,%r11d
and    $0xf,%ecx
or     %r11d,%ecx
mov    %ecx,(%rdx,%rsi,2)
add    $0x2,%rsi
cmp    %r8,%rsi
jb     1120 <hex2Bin+0x20>
pop    %rbx
ret
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@hex2Bin.hexToNibble = internal global [256 x i32] [i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240]
define i32 @hex2Bin(i32* %0, i32 %1, i32* %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
store i32* %2, i32** %6
store i32 0, i32* %7
store i32 0, i32* %8
br label %9
9: ; preds = %66, %3
%10 = load i32, i32* %8
%11 = load i32, i32* %5
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %69
13: ; preds = %9
%14 = load i32*, i32** %4
%15 = load i32, i32* %8
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i32, i32* %14, i64 %16
%18 = load i32, i32* %17
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [256 x i32], [256 x i32]* @hex2Bin.hexToNibble, i64 0, i64 %19
%21 = load i32, i32* %20
%22 = icmp eq i32 %21, 240
br i1 %22, label %23, label %26
23: ; preds = %13
%24 = load i32, i32* %7
%25 = or i32 %24, 1
store i32 %25, i32* %7
br label %26
26: ; preds = %23, %13
%27 = load i32*, i32** %4
%28 = load i32, i32* %8
%29 = add nsw i32 %28, 1
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i32, i32* %27, i64 %30
%32 = load i32, i32* %31
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [256 x i32], [256 x i32]* @hex2Bin.hexToNibble, i64 0, i64 %33
%35 = load i32, i32* %34
%36 = icmp eq i32 %35, 240
br i1 %36, label %37, label %40
37: ; preds = %26
%38 = load i32, i32* %7
%39 = or i32 %38, 1
store i32 %39, i32* %7
br label %40
40: ; preds = %37, %26
%41 = load i32*, i32** %4
%42 = load i32, i32* %8
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i32, i32* %41, i64 %43
%45 = load i32, i32* %44
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds [256 x i32], [256 x i32]* @hex2Bin.hexToNibble, i64 0, i64 %46
%48 = load i32, i32* %47
%49 = shl i32 %48, 4
%50 = load i32*, i32** %4
%51 = load i32, i32* %8
%52 = add nsw i32 %51, 1
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds i32, i32* %50, i64 %53
%55 = load i32, i32* %54
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds [256 x i32], [256 x i32]* @hex2Bin.hexToNibble, i64 0, i64 %56
%58 = load i32, i32* %57
%59 = and i32 %58, 15
%60 = or i32 %49, %59
%61 = load i32*, i32** %6
%62 = load i32, i32* %8
%63 = sdiv i32 %62, 2
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds i32, i32* %61, i64 %64
store i32 %60, i32* %65
br label %66
66: ; preds = %40
%67 = load i32, i32* %8
%68 = add nsw i32 %67, 2
store i32 %68, i32* %8
br label %9
69: ; preds = %9
%70 = load i32, i32* %7
ret i32 %70
}

LLVM IR (-O2):
@hex2Bin.hexToNibble = internal unnamed_addr constant [256 x i32] [i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240, i32 240]
define i32 @hex2Bin(i32* nocapture %0, i32 %1, i32* nocapture writeonly %2) {
%4 = icmp sgt i32 %1, 0
br i1 %4, label %5, label %7
5: ; preds = %3
%6 = zext i32 %1 to i64
br label %9
7: ; preds = %9, %3
%8 = phi i32 [ 0, %3 ], [ %27, %9 ]
ret i32 %8
9: ; preds = %5, %9
%10 = phi i64 [ 0, %5 ], [ %33, %9 ]
%11 = phi i32 [ 0, %5 ], [ %27, %9 ]
%12 = getelementptr inbounds i32, i32* %0, i64 %10
%13 = load i32, i32* %12
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [256 x i32], [256 x i32]* @hex2Bin.hexToNibble, i64 0, i64 %14
%16 = load i32, i32* %15
%17 = icmp eq i32 %16, 240
%18 = or i64 %10, 1
%19 = getelementptr inbounds i32, i32* %0, i64 %18
%20 = load i32, i32* %19
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [256 x i32], [256 x i32]* @hex2Bin.hexToNibble, i64 0, i64 %21
%23 = load i32, i32* %22
%24 = icmp eq i32 %23, 240
%25 = select i1 %24, i1 true, i1 %17
%26 = zext i1 %25 to i32
%27 = or i32 %11, %26
%28 = shl i32 %16, 4
%29 = and i32 %23, 15
%30 = or i32 %29, %28
%31 = lshr exact i64 %10, 1
%32 = getelementptr inbounds i32, i32* %2, i64 %31
store i32 %30, i32* %32
%33 = add nuw nsw i64 %10, 2
%34 = icmp ult i64 %33, %6
br i1 %34, label %9, label %7
}