#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 /*<<< orphan*/ uint8_t;
typedef int /*<<< orphan*/ uint64_t;

/* Variables and functions */
int /*<<< orphan*/ bzero(char *, int);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
int /*<<< orphan*/ strtoul(char *, char **, int);
int /*<<< orphan*/ uvarint_decode64(int /*<<< orphan*/ *, int,
                                    int /*<<< orphan*/ *);
uint64_t HexVar_To_Num_64(char *theHEXstring) {
  uint8_t buffy[400] = {0};
  char codo[800] = "\0";
  bzero(codo, 800);
  strcpy(codo, theHEXstring);
  char code[3] = "\0";
  int x = 0;
  for (int i = 0; i < 399; i++) {
    strncpy(&code[0], &codo[i], 1);
    strncpy(&code[1], &codo[i + 1], 1);
    char *ck = NULL;
    uint64_t lu = 0;
    lu = strtoul(code, &ck, 16);
    buffy[x] = lu;
    i++;
    x++;
  }
  static uint64_t decoded;
  uvarint_decode64(buffy, 400, &decoded);
  return decoded;
}


x86 assembly (clang, -O0):
<HexVar_To_Num_64>:
push   %rbp
mov    %rsp,%rbp
sub    $0x990,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x650(%rbp),%rdi
xor    %esi,%esi
mov    $0x640,%edx
call   1050 <memset@plt>
lea    -0x970(%rbp),%rdi
xor    %esi,%esi
mov    $0x320,%edx
call   1050 <memset@plt>
lea    -0x970(%rbp),%rdi
mov    $0x320,%esi
call   1070 <bzero@plt>
lea    -0x970(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1040 <strcpy@plt>
lea    -0x973(%rbp),%rdi
xor    %esi,%esi
mov    $0x3,%edx
call   1050 <memset@plt>
movl   $0x0,-0x978(%rbp)
movl   $0x0,-0x97c(%rbp)
cmpl   $0x18f,-0x97c(%rbp)
jge    12b2 <HexVar_To_Num_64+0x152>
lea    -0x973(%rbp),%rdi
movslq -0x97c(%rbp),%rax
lea    -0x970(%rbp),%rsi
add    %rax,%rsi
mov    $0x1,%edx
call   1030 <strncpy@plt>
lea    -0x973(%rbp),%rdi
add    $0x1,%rdi
mov    -0x97c(%rbp),%eax
add    $0x1,%eax
cltq
lea    -0x970(%rbp),%rsi
add    %rax,%rsi
mov    $0x1,%edx
call   1030 <strncpy@plt>
movq   $0x0,-0x988(%rbp)
movl   $0x0,-0x98c(%rbp)
lea    -0x973(%rbp),%rdi
lea    -0x988(%rbp),%rsi
mov    $0x10,%edx
call   1080 <strtoul@plt>
mov    %eax,-0x98c(%rbp)
mov    -0x98c(%rbp),%ecx
movslq -0x978(%rbp),%rax
mov    %ecx,-0x650(%rbp,%rax,4)
mov    -0x97c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x97c(%rbp)
mov    -0x978(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x978(%rbp)
mov    -0x97c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x97c(%rbp)
jmp    11dd <HexVar_To_Num_64+0x7d>
lea    -0x650(%rbp),%rdi
mov    $0x190,%esi
lea    0x2d8f(%rip),%rdx
call   1060 <uvarint_decode64@plt>
mov    0x2d84(%rip),%eax
add    $0x990,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<HexVar_To_Num_64>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x970,%rsp
mov    %rdi,%r14
lea    0x10(%rsp),%rdi
xor    %r13d,%r13d
mov    $0x640,%edx
xor    %esi,%esi
call   1050 <memset@plt>
lea    0x650(%rsp),%rbx
mov    $0x320,%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1050 <memset@plt>
mov    %rbx,%rdi
mov    $0x320,%esi
call   1070 <bzero@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <strcpy@plt>
movb   $0x0,0x6(%rsp)
movw   $0x0,0x4(%rsp)
lea    0x5(%rsp),%r14
lea    0x4(%rsp),%r15
lea    0x8(%rsp),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1030 <strncpy@plt>
lea    0x1(%rbx),%rsi
mov    %r14,%rdi
mov    $0x1,%edx
call   1030 <strncpy@plt>
movq   $0x0,0x8(%rsp)
mov    %r15,%rdi
mov    %r12,%rsi
mov    $0x10,%edx
call   1080 <strtoul@plt>
mov    %eax,0x10(%rsp,%r13,4)
add    $0x1,%r13
add    $0x2,%rbx
cmp    $0xc8,%r13
jne    11e0 <HexVar_To_Num_64+0x80>
lea    0x2e1d(%rip),%rdx
lea    0x10(%rsp),%rdi
mov    $0x190,%esi
call   1060 <uvarint_decode64@plt>
mov    0x2e08(%rip),%eax
add    $0x970,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@HexVar_To_Num_64.decoded = internal global i32 0
define i32 @HexVar_To_Num_64(i8* %0) {
%2 = alloca i8*
%3 = alloca [400 x i32]
%4 = alloca [800 x i8]
%5 = alloca [3 x i8]
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
store i8* %0, i8** %2
%10 = bitcast [400 x i32]* %3 to i8*
%11 = bitcast [800 x i8]* %4 to i8*
%12 = getelementptr inbounds [800 x i8], [800 x i8]* %4, i64 0, i64 0
%13 = call i32 @bzero(i8* %12, i32 800)
%14 = getelementptr inbounds [800 x i8], [800 x i8]* %4, i64 0, i64 0
%15 = load i8*, i8** %2
%16 = call i32 @strcpy(i8* %14, i8* %15)
%17 = bitcast [3 x i8]* %5 to i8*
store i32 0, i32* %6
store i32 0, i32* %7
br label %18
18: ; preds = %43, %1
%19 = load i32, i32* %7
%20 = icmp slt i32 %19, 399
br i1 %20, label %21, label %46
21: ; preds = %18
%22 = getelementptr inbounds [3 x i8], [3 x i8]* %5, i64 0, i64 0
%23 = load i32, i32* %7
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [800 x i8], [800 x i8]* %4, i64 0, i64 %24
%26 = call i32 @strncpy(i8* %22, i8* %25, i32 1)
%27 = getelementptr inbounds [3 x i8], [3 x i8]* %5, i64 0, i64 1
%28 = load i32, i32* %7
%29 = add nsw i32 %28, 1
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [800 x i8], [800 x i8]* %4, i64 0, i64 %30
%32 = call i32 @strncpy(i8* %27, i8* %31, i32 1)
store i8* null, i8** %8
store i32 0, i32* %9
%33 = getelementptr inbounds [3 x i8], [3 x i8]* %5, i64 0, i64 0
%34 = call i32 @strtoul(i8* %33, i8** %8, i32 16)
store i32 %34, i32* %9
%35 = load i32, i32* %9
%36 = load i32, i32* %6
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [400 x i32], [400 x i32]* %3, i64 0, i64 %37
store i32 %35, i32* %38
%39 = load i32, i32* %7
%40 = add nsw i32 %39, 1
store i32 %40, i32* %7
%41 = load i32, i32* %6
%42 = add nsw i32 %41, 1
store i32 %42, i32* %6
br label %43
43: ; preds = %21
%44 = load i32, i32* %7
%45 = add nsw i32 %44, 1
store i32 %45, i32* %7
br label %18
46: ; preds = %18
%47 = getelementptr inbounds [400 x i32], [400 x i32]* %3, i64 0, i64 0
%48 = call i32 @uvarint_decode64(i32* %47, i32 400, i32* @HexVar_To_Num_64.decoded)
%49 = load i32, i32* @HexVar_To_Num_64.decoded
ret i32 %49
}

LLVM IR (-O2):
@HexVar_To_Num_64.decoded = internal global i32 0
define i32 @HexVar_To_Num_64(i8* %0) {
%2 = alloca [400 x i32]
%3 = alloca [800 x i8]
%4 = alloca [3 x i8]
%5 = alloca i8*
%6 = bitcast [400 x i32]* %2 to i8*
%7 = getelementptr inbounds [800 x i8], [800 x i8]* %3, i64 0, i64 0
%8 = call i32 @bzero(i8* %7, i32 800)
%9 = call i32 @strcpy(i8* %7, i8* %0)
%10 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 0
%11 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 1
%12 = bitcast i8** %5 to i8*
br label %17
13: ; preds = %17
%14 = getelementptr inbounds [400 x i32], [400 x i32]* %2, i64 0, i64 0
%15 = call i32 @uvarint_decode64(i32* %14, i32 400, i32* @HexVar_To_Num_64.decoded)
%16 = load i32, i32* @HexVar_To_Num_64.decoded
ret i32 %16
17: ; preds = %1, %17
%18 = phi i64 [ 0, %1 ], [ %28, %17 ]
%19 = phi i64 [ 0, %1 ], [ %27, %17 ]
%20 = getelementptr inbounds [800 x i8], [800 x i8]* %3, i64 0, i64 %18
%21 = call i32 @strncpy(i8* %10, i8* %20, i32 1)
%22 = or i64 %18, 1
%23 = getelementptr inbounds [800 x i8], [800 x i8]* %3, i64 0, i64 %22
%24 = call i32 @strncpy(i8* %11, i8* %23, i32 1)
store i8* null, i8** %5
%25 = call i32 @strtoul(i8* %10, i8** %5, i32 16)
%26 = getelementptr inbounds [400 x i32], [400 x i32]* %2, i64 0, i64 %19
store i32 %25, i32* %26
%27 = add nuw nsw i64 %19, 1
%28 = add nuw nsw i64 %18, 2
%29 = icmp eq i64 %27, 200
br i1 %29, label %13, label %17
}