#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 EINVAL;
int unbase32hexchar(char c) {
  unsigned offset;
  if (c >= '0' && c <= '9')
    return c - '0';
  offset = '9' - '0' + 1;
  if (c >= 'A' && c <= 'V')
    return c - 'A' + offset;
  return -EINVAL;
}


x86 assembly (clang, -O0):
<unbase32hexchar>:
push   %rbp
mov    %rsp,%rbp
mov    %dil,%al
mov    %al,-0x5(%rbp)
movsbl -0x5(%rbp),%eax
cmp    $0x30,%eax
jl     1133 <unbase32hexchar+0x33>
movsbl -0x5(%rbp),%eax
cmp    $0x39,%eax
jg     1133 <unbase32hexchar+0x33>
movsbl -0x5(%rbp),%eax
sub    $0x30,%eax
mov    %eax,-0x4(%rbp)
jmp    1174 <unbase32hexchar+0x74>
movl   $0xa,-0xc(%rbp)
movsbl -0x5(%rbp),%eax
cmp    $0x41,%eax
jl     1166 <unbase32hexchar+0x66>
movsbl -0x5(%rbp),%eax
cmp    $0x56,%eax
jg     1166 <unbase32hexchar+0x66>
movsbl -0x5(%rbp),%eax
sub    $0x41,%eax
add    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1174 <unbase32hexchar+0x74>
xor    %eax,%eax
mov    0x2e71(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<unbase32hexchar>:
mov    %edi,%eax
lea    -0x30(%rax),%ecx
cmp    $0x9,%cl
ja     110e <unbase32hexchar+0xe>
add    $0xffffffd0,%eax
ret
lea    -0x41(%rax),%ecx
cmp    $0x15,%cl
ja     111a <unbase32hexchar+0x1a>
add    $0xffffffc9,%eax
ret
mov    0x2ebf(%rip),%rcx
xor    %eax,%eax
sub    (%rcx),%eax
ret

LLVM IR (-O0):
@EINVAL = global i32 0
define i32 @unbase32hexchar(i8 signext %0) {
%2 = alloca i32
%3 = alloca i8
%4 = alloca i32
store i8 %0, i8* %3
%5 = load i8, i8* %3
%6 = sext i8 %5 to i32
%7 = icmp sge i32 %6, 48
br i1 %7, label %8, label %16
8: ; preds = %1
%9 = load i8, i8* %3
%10 = sext i8 %9 to i32
%11 = icmp sle i32 %10, 57
br i1 %11, label %12, label %16
12: ; preds = %8
%13 = load i8, i8* %3
%14 = sext i8 %13 to i32
%15 = sub nsw i32 %14, 48
store i32 %15, i32* %2
br label %33
16: ; preds = %8, %1
store i32 10, i32* %4
%17 = load i8, i8* %3
%18 = sext 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 = sext i8 %21 to i32
%23 = icmp sle i32 %22, 86
br i1 %23, label %24, label %30
24: ; preds = %20
%25 = load i8, i8* %3
%26 = sext i8 %25 to i32
%27 = sub nsw i32 %26, 65
%28 = load i32, i32* %4
%29 = add i32 %27, %28
store i32 %29, i32* %2
br label %33
30: ; preds = %20, %16
%31 = load i32, i32* @EINVAL
%32 = sub nsw i32 0, %31
store i32 %32, i32* %2
br label %33
33: ; preds = %30, %24, %12
%34 = load i32, i32* %2
ret i32 %34
}

LLVM IR (-O2):
@EINVAL = global i32 0
define i32 @unbase32hexchar(i8 signext %0) {
%2 = sext i8 %0 to i32
%3 = add i8 %0, -48
%4 = icmp ult i8 %3, 10
br i1 %4, label %5, label %7
5: ; preds = %1
%6 = add nsw i32 %2, -48
br label %15
7: ; preds = %1
%8 = add i8 %0, -65
%9 = icmp ult i8 %8, 22
br i1 %9, label %10, label %12
10: ; preds = %7
%11 = add nsw i32 %2, -55
br label %15
12: ; preds = %7
%13 = load i32, i32* @EINVAL
%14 = sub nsw i32 0, %13
br label %15
15: ; preds = %12, %10, %5
%16 = phi i32 [ %6, %5 ], [ %11, %10 ], [ %14, %12 ]
ret i32 %16
}