#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*/ G_STATIC_ASSERT_EXPR(int);
int nm_utils_hexchar_to_int(char ch) {
  G_STATIC_ASSERT_EXPR('0' < 'A');
  G_STATIC_ASSERT_EXPR('A' < 'a');
  if (ch >= '0') {
    if (ch <= '9')
      return ch - '0';
    if (ch >= 'A') {
      if (ch <= 'F')
        return ((int)ch) + (10 - (int)'A');
      if (ch >= 'a' && ch <= 'f')
        return ((int)ch) + (10 - (int)'a');
    }
  }
  return -1;
}


x86 assembly (clang, -O0):
<nm_utils_hexchar_to_int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x5(%rbp)
mov    $0x1,%edi
call   1030 <G_STATIC_ASSERT_EXPR@plt>
mov    $0x1,%edi
call   1030 <G_STATIC_ASSERT_EXPR@plt>
movsbl -0x5(%rbp),%eax
cmp    $0x30,%eax
jl     11b7 <nm_utils_hexchar_to_int+0xa7>
movsbl -0x5(%rbp),%eax
cmp    $0x39,%eax
jg     115b <nm_utils_hexchar_to_int+0x4b>
movsbl -0x5(%rbp),%eax
sub    $0x30,%eax
mov    %eax,-0x4(%rbp)
jmp    11be <nm_utils_hexchar_to_int+0xae>
movsbl -0x5(%rbp),%eax
cmp    $0x41,%eax
jl     11b2 <nm_utils_hexchar_to_int+0xa2>
movsbl -0x5(%rbp),%eax
cmp    $0x46,%eax
jg     1184 <nm_utils_hexchar_to_int+0x74>
movsbl -0x5(%rbp),%eax
add    $0xffffffc9,%eax
mov    %eax,-0x4(%rbp)
jmp    11be <nm_utils_hexchar_to_int+0xae>
movsbl -0x5(%rbp),%eax
cmp    $0x61,%eax
jl     11ad <nm_utils_hexchar_to_int+0x9d>
movsbl -0x5(%rbp),%eax
cmp    $0x66,%eax
jg     11ad <nm_utils_hexchar_to_int+0x9d>
movsbl -0x5(%rbp),%eax
add    $0xffffffa9,%eax
mov    %eax,-0x4(%rbp)
jmp    11be <nm_utils_hexchar_to_int+0xae>
jmp    11b2 <nm_utils_hexchar_to_int+0xa2>
jmp    11b7 <nm_utils_hexchar_to_int+0xa7>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nm_utils_hexchar_to_int>:
push   %rbx
mov    %edi,%ebx
mov    $0x1,%edi
call   1030 <G_STATIC_ASSERT_EXPR@plt>
mov    $0x1,%edi
call   1030 <G_STATIC_ASSERT_EXPR@plt>
mov    $0xffffffff,%eax
cmp    $0x30,%bl
jl     115c <nm_utils_hexchar_to_int+0x4c>
cmp    $0x39,%bl
ja     113b <nm_utils_hexchar_to_int+0x2b>
add    $0xffffffd0,%ebx
jmp    1148 <nm_utils_hexchar_to_int+0x38>
cmp    $0x41,%bl
jb     115c <nm_utils_hexchar_to_int+0x4c>
cmp    $0x46,%bl
ja     114c <nm_utils_hexchar_to_int+0x3c>
add    $0xffffffc9,%ebx
mov    %ebx,%eax
pop    %rbx
ret
lea    -0x61(%rbx),%eax
add    $0xffffffa9,%ebx
cmp    $0x6,%al
mov    $0xffffffff,%eax
cmovb  %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @nm_utils_hexchar_to_int(i8 signext %0) {
%2 = alloca i32
%3 = alloca i8
store i8 %0, i8* %3
%4 = call i32 @G_STATIC_ASSERT_EXPR(i32 1)
%5 = call i32 @G_STATIC_ASSERT_EXPR(i32 1)
%6 = load i8, i8* %3
%7 = sext i8 %6 to i32
%8 = icmp sge i32 %7, 48
br i1 %8, label %9, label %43
9: ; preds = %1
%10 = load i8, i8* %3
%11 = sext i8 %10 to i32
%12 = icmp sle i32 %11, 57
br i1 %12, label %13, label %17
13: ; preds = %9
%14 = load i8, i8* %3
%15 = sext i8 %14 to i32
%16 = sub nsw i32 %15, 48
store i32 %16, i32* %2
br label %44
17: ; preds = %9
%18 = load i8, i8* %3
%19 = sext i8 %18 to i32
%20 = icmp sge i32 %19, 65
br i1 %20, label %21, label %42
21: ; preds = %17
%22 = load i8, i8* %3
%23 = sext i8 %22 to i32
%24 = icmp sle i32 %23, 70
br i1 %24, label %25, label %29
25: ; preds = %21
%26 = load i8, i8* %3
%27 = sext i8 %26 to i32
%28 = add nsw i32 %27, -55
store i32 %28, i32* %2
br label %44
29: ; preds = %21
%30 = load i8, i8* %3
%31 = sext i8 %30 to i32
%32 = icmp sge i32 %31, 97
br i1 %32, label %33, label %41
33: ; preds = %29
%34 = load i8, i8* %3
%35 = sext i8 %34 to i32
%36 = icmp sle i32 %35, 102
br i1 %36, label %37, label %41
37: ; preds = %33
%38 = load i8, i8* %3
%39 = sext i8 %38 to i32
%40 = add nsw i32 %39, -87
store i32 %40, i32* %2
br label %44
41: ; preds = %33, %29
br label %42
42: ; preds = %41, %17
br label %43
43: ; preds = %42, %1
store i32 -1, i32* %2
br label %44
44: ; preds = %43, %37, %25, %13
%45 = load i32, i32* %2
ret i32 %45
}

LLVM IR (-O2):
define i32 @nm_utils_hexchar_to_int(i8 signext %0) {
%2 = tail call i32 @G_STATIC_ASSERT_EXPR(i32 1)
%3 = tail call i32 @G_STATIC_ASSERT_EXPR(i32 1)
%4 = sext i8 %0 to i32
%5 = icmp sgt i8 %0, 47
br i1 %5, label %6, label %21
6: ; preds = %1
%7 = icmp ult i8 %0, 58
br i1 %7, label %8, label %10
8: ; preds = %6
%9 = add nsw i32 %4, -48
br label %21
10: ; preds = %6
%11 = icmp ugt i8 %0, 64
br i1 %11, label %12, label %21
12: ; preds = %10
%13 = icmp ult i8 %0, 71
br i1 %13, label %14, label %16
14: ; preds = %12
%15 = add nsw i32 %4, -55
br label %21
16: ; preds = %12
%17 = add nsw i8 %0, -97
%18 = icmp ult i8 %17, 6
%19 = add nsw i32 %4, -87
%20 = select i1 %18, i32 %19, i32 -1
br label %21
21: ; preds = %16, %1, %10, %14, %8
%22 = phi i32 [ %9, %8 ], [ %15, %14 ], [ -1, %10 ], [ -1, %1 ], [ %20, %16 ]
ret i32 %22
}