#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 */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ printf(char *, char);
void CHexSymbol(char *symbol, int *target) {
  if (*symbol) {
    if ('1' <= *symbol && *symbol <= '9') {
      *target = *symbol - '1' + 1;
    } else if ('A' <= *symbol && *symbol <= 'F') {
      *target = *symbol - (int)'A' + 10;
    } else {
      printf("Error at CHexSymbol!! %c is not allowed!!", *symbol);
      exit(1);
    }
    CHexSymbol(++symbol, ++target);
  }
}


x86 assembly (clang, -O0):
<CHexSymbol>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     1204 <CHexSymbol+0xd4>
mov    -0x8(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x31,%eax
cmp    %ecx,%eax
jg     1189 <CHexSymbol+0x59>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x39,%eax
jg     1189 <CHexSymbol+0x59>
mov    -0x8(%rbp),%rax
movsbl (%rax),%ecx
sub    $0x31,%ecx
add    $0x1,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
jmp    11e7 <CHexSymbol+0xb7>
mov    -0x8(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x41,%eax
cmp    %ecx,%eax
jg     11c5 <CHexSymbol+0x95>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x46,%eax
jg     11c5 <CHexSymbol+0x95>
mov    -0x8(%rbp),%rax
movsbl (%rax),%ecx
sub    $0x41,%ecx
add    $0xa,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
jmp    11e2 <CHexSymbol+0xb2>
mov    -0x8(%rbp),%rax
lea    0xe30(%rip),%rdi
movsbl (%rax),%esi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
jmp    11e7 <CHexSymbol+0xb7>
mov    -0x8(%rbp),%rdi
add    $0x1,%rdi
mov    %rdi,-0x8(%rbp)
mov    -0x10(%rbp),%rsi
add    $0x4,%rsi
mov    %rsi,-0x10(%rbp)
call   1040 <CHexSymbol@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CHexSymbol>:
push   %rax
mov    (%rdi),%dl
test   %dl,%dl
je     117c <CHexSymbol+0x5c>
xor    %ecx,%ecx
jmp    1143 <CHexSymbol+0x23>
nopl   0x0(%rax,%rax,1)
add    %r8d,%eax
mov    %eax,(%rsi,%rcx,4)
movzbl 0x1(%rdi,%rcx,1),%edx
add    $0x1,%rcx
test   %dl,%dl
je     117c <CHexSymbol+0x5c>
movsbl %dl,%r8d
lea    -0x31(%r8),%r9d
mov    $0xffffffd0,%eax
cmp    $0x9,%r9b
jb     1130 <CHexSymbol+0x10>
add    $0xbf,%dl
mov    $0xffffffc9,%eax
cmp    $0x6,%dl
jb     1130 <CHexSymbol+0x10>
lea    0xe96(%rip),%rdi
mov    %r8d,%esi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>
pop    %rax
ret

LLVM IR (-O0):
@.str = [42 x i8] c"Error at CHexSymbol!! %c is not allowed!!\00"
define void @CHexSymbol(i8* %0, i32* %1) {
%3 = alloca i8*
%4 = alloca i32*
store i8* %0, i8** %3
store i32* %1, i32** %4
%5 = load i8*, i8** %3
%6 = load i8, i8* %5
%7 = icmp ne i8 %6, 0
br i1 %7, label %8, label %53
8: ; preds = %2
%9 = load i8*, i8** %3
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = icmp sle i32 49, %11
br i1 %12, label %13, label %25
13: ; preds = %8
%14 = load i8*, i8** %3
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp sle i32 %16, 57
br i1 %17, label %18, label %25
18: ; preds = %13
%19 = load i8*, i8** %3
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = sub nsw i32 %21, 49
%23 = add nsw i32 %22, 1
%24 = load i32*, i32** %4
store i32 %23, i32* %24
br label %48
25: ; preds = %13, %8
%26 = load i8*, i8** %3
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp sle i32 65, %28
br i1 %29, label %30, label %42
30: ; preds = %25
%31 = load i8*, i8** %3
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = icmp sle i32 %33, 70
br i1 %34, label %35, label %42
35: ; preds = %30
%36 = load i8*, i8** %3
%37 = load i8, i8* %36
%38 = sext i8 %37 to i32
%39 = sub nsw i32 %38, 65
%40 = add nsw i32 %39, 10
%41 = load i32*, i32** %4
store i32 %40, i32* %41
br label %47
42: ; preds = %30, %25
%43 = load i8*, i8** %3
%44 = load i8, i8* %43
%45 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i8 signext %44)
%46 = call i32 @exit(i32 1)
unreachable
47: ; preds = %35
br label %48
48: ; preds = %47, %18
%49 = load i8*, i8** %3
%50 = getelementptr inbounds i8, i8* %49, i32 1
store i8* %50, i8** %3
%51 = load i32*, i32** %4
%52 = getelementptr inbounds i32, i32* %51, i32 1
store i32* %52, i32** %4
br label %53
53: ; preds = %48, %2
ret void
}

LLVM IR (-O2):
@.str = [42 x i8] c"Error at CHexSymbol!! %c is not allowed!!\00"
define void @CHexSymbol(i8* nocapture %0, i32* nocapture writeonly %1) {
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, 0
br i1 %4, label %25, label %5
5: ; preds = %2, %18
%6 = phi i8 [ %23, %18 ], [ %3, %2 ]
%7 = phi i32* [ %22, %18 ], [ %1, %2 ]
%8 = phi i8* [ %21, %18 ], [ %0, %2 ]
%9 = sext i8 %6 to i32
%10 = add i8 %6, -49
%11 = icmp ult i8 %10, 9
br i1 %11, label %18, label %12
12: ; preds = %5
%13 = add i8 %6, -65
%14 = icmp ult i8 %13, 6
br i1 %14, label %18, label %15
15: ; preds = %12
%16 = tail call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i8 signext %6)
%17 = tail call i32 @exit(i32 1)
unreachable
18: ; preds = %12, %5
%19 = phi i32 [ -48, %5 ], [ -55, %12 ]
%20 = add nsw i32 %19, %9
store i32 %20, i32* %7
%21 = getelementptr inbounds i8, i8* %8, i64 1
%22 = getelementptr inbounds i32, i32* %7, i64 1
%23 = load i8, i8* %21
%24 = icmp eq i8 %23, 0
br i1 %24, label %25, label %5
25: ; preds = %18, %2
ret void
}