#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 char uint8_t;
typedef char uint32_t;

/* Variables and functions */
int /*<<< orphan*/ bzero(char *, int);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
char strtoul(char *, char **, int);
int /*<<< orphan*/ uvarint_decode32(char *, int, char *);
uint32_t HexVar_To_Num_32(char theHEXstring[]) {
  uint8_t buffy[400] = {0};
  bzero(buffy, 400);
  char codo[800] = "\0";
  bzero(codo, 800);
  strcpy(codo, theHEXstring);
  char code[3] = "\0";
  bzero(code, 3);
  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;
    uint32_t lu = {0};
    lu = strtoul(code, &ck, 16);
    buffy[x] = lu;
    i++;
    x++;
  }
  static uint32_t decoded;
  uvarint_decode32(buffy, 10, &decoded);
  return decoded;
}


x86 assembly (clang, -O0):
<HexVar_To_Num_32>:
push   %rbp
mov    %rsp,%rbp
sub    $0x4e0,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x1a0(%rbp),%rdi
xor    %esi,%esi
mov    $0x190,%edx
call   1050 <memset@plt>
lea    -0x1a0(%rbp),%rdi
mov    $0x190,%esi
call   1070 <bzero@plt>
lea    -0x4c0(%rbp),%rdi
xor    %esi,%esi
mov    $0x320,%edx
call   1050 <memset@plt>
lea    -0x4c0(%rbp),%rdi
mov    $0x320,%esi
call   1070 <bzero@plt>
lea    -0x4c0(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1040 <strcpy@plt>
lea    -0x4c3(%rbp),%rdi
xor    %esi,%esi
mov    $0x3,%edx
call   1050 <memset@plt>
lea    -0x4c3(%rbp),%rdi
mov    $0x3,%esi
call   1070 <bzero@plt>
movb   $0x0,-0x4c0(%rbp)
movl   $0x0,-0x4c8(%rbp)
movl   $0x0,-0x4cc(%rbp)
cmpl   $0x18f,-0x4cc(%rbp)
jge    12d8 <HexVar_To_Num_32+0x178>
lea    -0x4c3(%rbp),%rdi
movslq -0x4cc(%rbp),%rax
lea    -0x4c0(%rbp),%rsi
add    %rax,%rsi
mov    $0x1,%edx
call   1030 <strncpy@plt>
lea    -0x4c3(%rbp),%rdi
add    $0x1,%rdi
mov    -0x4cc(%rbp),%eax
add    $0x1,%eax
cltq
lea    -0x4c0(%rbp),%rsi
add    %rax,%rsi
mov    $0x1,%edx
call   1030 <strncpy@plt>
movq   $0x0,-0x4d8(%rbp)
movb   $0x0,-0x4d9(%rbp)
lea    -0x4c3(%rbp),%rdi
lea    -0x4d8(%rbp),%rsi
mov    $0x10,%edx
call   1080 <strtoul@plt>
mov    %al,-0x4d9(%rbp)
mov    -0x4d9(%rbp),%cl
movslq -0x4c8(%rbp),%rax
mov    %cl,-0x1a0(%rbp,%rax,1)
mov    -0x4cc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4cc(%rbp)
mov    -0x4c8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c8(%rbp)
mov    -0x4cc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4cc(%rbp)
jmp    1206 <HexVar_To_Num_32+0xa6>
lea    -0x1a0(%rbp),%rdi
mov    $0xa,%esi
lea    0x2d66(%rip),%rdx
call   1060 <uvarint_decode32@plt>
movsbl 0x2d5a(%rip),%eax
add    $0x4e0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<HexVar_To_Num_32>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x4c0,%rsp
mov    %rdi,%r14
lea    0x10(%rsp),%rbx
xor    %r13d,%r13d
mov    $0x190,%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1050 <memset@plt>
mov    %rbx,%rdi
mov    $0x190,%esi
call   1070 <bzero@plt>
lea    0x1a0(%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    0x4(%rsp),%r14
mov    %r14,%rdi
mov    $0x3,%esi
call   1070 <bzero@plt>
movb   $0x0,0x7(%rsp)
lea    0x5(%rsp),%r15
lea    0x8(%rsp),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1030 <strncpy@plt>
lea    0x1(%rbx),%rsi
mov    %r15,%rdi
mov    $0x1,%edx
call   1030 <strncpy@plt>
movq   $0x0,0x8(%rsp)
mov    %r14,%rdi
mov    %r12,%rsi
mov    $0x10,%edx
call   1080 <strtoul@plt>
mov    %al,0x10(%rsp,%r13,1)
add    $0x1,%r13
add    $0x2,%rbx
cmp    $0xc8,%r13
jne    1200 <HexVar_To_Num_32+0xa0>
lea    0x2dfa(%rip),%rdx
lea    0x10(%rsp),%rdi
mov    $0xa,%esi
call   1060 <uvarint_decode32@plt>
mov    0x2de5(%rip),%al
add    $0x4c0,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

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