#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*/ DebugPrintf(int, char *, unsigned char, unsigned char);
int /*<<< orphan*/ exit(int);
unsigned char Ascii2Hex(unsigned char c) {
  if (c >= '0' && c <= '9') {
    return (unsigned char)(c - '0');
  }
  if (c >= 'A' && c <= 'F') {
    return (unsigned char)(c - 'A' + 10);
  }
  if (c >= 'a' && c <= 'f') {
    return (unsigned char)(c - 'a' + 10);
  }
  DebugPrintf(1, "Wrong Hex-Nibble %c (%02X)\n", c, c);
  exit(1);
  return 0;
}


x86 assembly (clang, -O0):
<Ascii2Hex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x2(%rbp)
movzbl -0x2(%rbp),%eax
cmp    $0x30,%eax
jl     1157 <Ascii2Hex+0x37>
movzbl -0x2(%rbp),%eax
cmp    $0x39,%eax
jg     1157 <Ascii2Hex+0x37>
movzbl -0x2(%rbp),%eax
sub    $0x30,%eax
mov    %al,-0x1(%rbp)
jmp    11d4 <Ascii2Hex+0xb4>
movzbl -0x2(%rbp),%eax
cmp    $0x41,%eax
jl     1183 <Ascii2Hex+0x63>
movzbl -0x2(%rbp),%eax
cmp    $0x46,%eax
jg     1183 <Ascii2Hex+0x63>
movzbl -0x2(%rbp),%eax
sub    $0x41,%eax
add    $0xa,%eax
mov    %al,-0x1(%rbp)
jmp    11d4 <Ascii2Hex+0xb4>
movzbl -0x2(%rbp),%eax
cmp    $0x61,%eax
jl     11af <Ascii2Hex+0x8f>
movzbl -0x2(%rbp),%eax
cmp    $0x66,%eax
jg     11af <Ascii2Hex+0x8f>
movzbl -0x2(%rbp),%eax
sub    $0x61,%eax
add    $0xa,%eax
mov    %al,-0x1(%rbp)
jmp    11d4 <Ascii2Hex+0xb4>
mov    -0x2(%rbp),%al
mov    $0x1,%edi
lea    0xe42(%rip),%rsi
movzbl %al,%edx
movzbl -0x2(%rbp),%ecx
call   1030 <DebugPrintf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>
movzbl -0x1(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Ascii2Hex>:
lea    -0x30(%rdi),%eax
cmp    $0xa,%al
jb     1141 <Ascii2Hex+0x21>
lea    -0x41(%rdi),%eax
cmp    $0x5,%al
ja     1134 <Ascii2Hex+0x14>
add    $0xc9,%dil
jmp    113f <Ascii2Hex+0x1f>
lea    -0x61(%rdi),%eax
cmp    $0x5,%al
ja     1142 <Ascii2Hex+0x22>
add    $0xa9,%dil
mov    %edi,%eax
ret
push   %rax
movzbl %dil,%ecx
lea    0xeb2(%rip),%rsi
mov    $0x1,%edi
mov    %ecx,%edx
call   1030 <DebugPrintf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@.str = [28 x i8] c"Wrong Hex-Nibble %c (%02X)\0A\00"
define zeroext i8 @Ascii2Hex(i8 zeroext %0) {
%2 = alloca i8
%3 = alloca i8
store i8 %0, i8* %3
%4 = load i8, i8* %3
%5 = zext i8 %4 to i32
%6 = icmp sge i32 %5, 48
br i1 %6, label %7, label %16
7: ; preds = %1
%8 = load i8, i8* %3
%9 = zext i8 %8 to i32
%10 = icmp sle i32 %9, 57
br i1 %10, label %11, label %16
11: ; preds = %7
%12 = load i8, i8* %3
%13 = zext i8 %12 to i32
%14 = sub nsw i32 %13, 48
%15 = trunc i32 %14 to i8
store i8 %15, i8* %2
br label %49
16: ; preds = %7, %1
%17 = load i8, i8* %3
%18 = zext i8 %17 to i32
%19 = icmp sge i32 %18, 65
br i1 %19, label %20, label %30
20: ; preds = %16
%21 = load i8, i8* %3
%22 = zext i8 %21 to i32
%23 = icmp sle i32 %22, 70
br i1 %23, label %24, label %30
24: ; preds = %20
%25 = load i8, i8* %3
%26 = zext i8 %25 to i32
%27 = sub nsw i32 %26, 65
%28 = add nsw i32 %27, 10
%29 = trunc i32 %28 to i8
store i8 %29, i8* %2
br label %49
30: ; preds = %20, %16
%31 = load i8, i8* %3
%32 = zext i8 %31 to i32
%33 = icmp sge i32 %32, 97
br i1 %33, label %34, label %44
34: ; preds = %30
%35 = load i8, i8* %3
%36 = zext i8 %35 to i32
%37 = icmp sle i32 %36, 102
br i1 %37, label %38, label %44
38: ; preds = %34
%39 = load i8, i8* %3
%40 = zext i8 %39 to i32
%41 = sub nsw i32 %40, 97
%42 = add nsw i32 %41, 10
%43 = trunc i32 %42 to i8
store i8 %43, i8* %2
br label %49
44: ; preds = %34, %30
%45 = load i8, i8* %3
%46 = load i8, i8* %3
%47 = call i32 @DebugPrintf(i32 1, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8 zeroext %45, i8 zeroext %46)
%48 = call i32 @exit(i32 1)
unreachable
49: ; preds = %38, %24, %11
%50 = load i8, i8* %2
ret i8 %50
}

LLVM IR (-O2):
@.str = [28 x i8] c"Wrong Hex-Nibble %c (%02X)\0A\00"
define zeroext i8 @Ascii2Hex(i8 zeroext %0) {
%2 = add i8 %0, -48
%3 = icmp ult i8 %2, 10
br i1 %3, label %17, label %4
4: ; preds = %1
%5 = add i8 %0, -65
%6 = icmp ult i8 %5, 6
br i1 %6, label %7, label %9
7: ; preds = %4
%8 = add nsw i8 %0, -55
br label %17
9: ; preds = %4
%10 = add i8 %0, -97
%11 = icmp ult i8 %10, 6
br i1 %11, label %12, label %14
12: ; preds = %9
%13 = add nsw i8 %0, -87
br label %17
14: ; preds = %9
%15 = tail call i32 @DebugPrintf(i32 1, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8 zeroext %0, i8 zeroext %0)
%16 = tail call i32 @exit(i32 1)
unreachable
17: ; preds = %1, %12, %7
%18 = phi i8 [ %8, %7 ], [ %13, %12 ], [ %2, %1 ]
ret i8 %18
}