#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 setExceptionCode(int);
int HexCharToNibble(unsigned char HexChar) {
  if (HexChar >= 'a' && HexChar <= 'f') {
    return HexChar - 'a' + 10;
  }
  if (HexChar >= 'A' && HexChar <= 'F') {
    return HexChar - 'A' + 10;
  }
  if (HexChar >= '0' && HexChar <= '9') {
    return HexChar - '0';
  }
  return (setExceptionCode(2), (-1));
}


x86 assembly (clang, -O0):
<HexCharToNibble>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x5(%rbp)
movzbl -0x5(%rbp),%eax
cmp    $0x61,%eax
jl     114a <HexCharToNibble+0x3a>
movzbl -0x5(%rbp),%eax
cmp    $0x66,%eax
jg     114a <HexCharToNibble+0x3a>
movzbl -0x5(%rbp),%eax
sub    $0x61,%eax
add    $0xa,%eax
mov    %eax,-0x4(%rbp)
jmp    11b0 <HexCharToNibble+0xa0>
movzbl -0x5(%rbp),%eax
cmp    $0x41,%eax
jl     1176 <HexCharToNibble+0x66>
movzbl -0x5(%rbp),%eax
cmp    $0x46,%eax
jg     1176 <HexCharToNibble+0x66>
movzbl -0x5(%rbp),%eax
sub    $0x41,%eax
add    $0xa,%eax
mov    %eax,-0x4(%rbp)
jmp    11b0 <HexCharToNibble+0xa0>
movzbl -0x5(%rbp),%eax
cmp    $0x30,%eax
jl     119f <HexCharToNibble+0x8f>
movzbl -0x5(%rbp),%eax
cmp    $0x39,%eax
jg     119f <HexCharToNibble+0x8f>
movzbl -0x5(%rbp),%eax
sub    $0x30,%eax
mov    %eax,-0x4(%rbp)
jmp    11b0 <HexCharToNibble+0xa0>
mov    $0x2,%edi
call   1030 <setExceptionCode@plt>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<HexCharToNibble>:
mov    %edi,%eax
lea    -0x61(%rax),%ecx
cmp    $0x5,%cl
ja     111e <HexCharToNibble+0xe>
add    $0xffffffa9,%eax
ret
lea    -0x41(%rax),%ecx
cmp    $0x5,%cl
ja     112a <HexCharToNibble+0x1a>
add    $0xffffffc9,%eax
ret
lea    -0x30(%rax),%ecx
cmp    $0x9,%cl
ja     1136 <HexCharToNibble+0x26>
add    $0xffffffd0,%eax
ret
push   %rax
mov    $0x2,%edi
call   1030 <setExceptionCode@plt>
mov    $0xffffffff,%eax
add    $0x8,%rsp
ret

LLVM IR (-O0):
define i32 @HexCharToNibble(i8 zeroext %0) {
%2 = alloca i32
%3 = alloca i8
store i8 %0, i8* %3
%4 = load i8, i8* %3
%5 = zext i8 %4 to i32
%6 = icmp sge i32 %5, 97
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, 102
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, 97
%15 = add nsw i32 %14, 10
store i32 %15, i32* %2
br label %43
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 %29
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 %29
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
store i32 %28, i32* %2
br label %43
29: ; preds = %20, %16
%30 = load i8, i8* %3
%31 = zext i8 %30 to i32
%32 = icmp sge i32 %31, 48
br i1 %32, label %33, label %41
33: ; preds = %29
%34 = load i8, i8* %3
%35 = zext i8 %34 to i32
%36 = icmp sle i32 %35, 57
br i1 %36, label %37, label %41
37: ; preds = %33
%38 = load i8, i8* %3
%39 = zext i8 %38 to i32
%40 = sub nsw i32 %39, 48
store i32 %40, i32* %2
br label %43
41: ; preds = %33, %29
%42 = call i32 @setExceptionCode(i32 2)
store i32 -1, i32* %2
br label %43
43: ; preds = %41, %37, %24, %11
%44 = load i32, i32* %2
ret i32 %44
}

LLVM IR (-O2):
define i32 @HexCharToNibble(i8 zeroext %0) {
%2 = zext i8 %0 to i32
%3 = add i8 %0, -97
%4 = icmp ult i8 %3, 6
br i1 %4, label %5, label %7
5: ; preds = %1
%6 = add nsw i32 %2, -87
br label %19
7: ; preds = %1
%8 = add i8 %0, -65
%9 = icmp ult i8 %8, 6
br i1 %9, label %10, label %12
10: ; preds = %7
%11 = add nsw i32 %2, -55
br label %19
12: ; preds = %7
%13 = add i8 %0, -48
%14 = icmp ult i8 %13, 10
br i1 %14, label %15, label %17
15: ; preds = %12
%16 = add nsw i32 %2, -48
br label %19
17: ; preds = %12
%18 = tail call i32 @setExceptionCode(i32 2)
br label %19
19: ; preds = %17, %15, %10, %5
%20 = phi i32 [ %6, %5 ], [ %11, %10 ], [ %16, %15 ], [ -1, %17 ]
ret i32 %20
}