#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*/ assert(int);
int hexToInt(int h) {
  if (h >= '0' && h <= '9') {
    return h - '0';
  } else if (h >= 'a' && h <= 'f') {
    return h - 'a' + 10;
  } else {
    assert(h >= 'A' && h <= 'F');
    return h - 'A' + 10;
  }
}


x86 assembly (clang, -O0):
<hexToInt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
cmpl   $0x30,-0x8(%rbp)
jl     113d <hexToInt+0x2d>
cmpl   $0x39,-0x8(%rbp)
jg     113d <hexToInt+0x2d>
mov    -0x8(%rbp),%eax
sub    $0x30,%eax
mov    %eax,-0x4(%rbp)
jmp    1194 <hexToInt+0x84>
cmpl   $0x61,-0x8(%rbp)
jl     1162 <hexToInt+0x52>
cmpl   $0x66,-0x8(%rbp)
jg     1162 <hexToInt+0x52>
mov    -0x8(%rbp),%eax
sub    $0x61,%eax
add    $0xa,%eax
mov    %eax,-0x4(%rbp)
jmp    1194 <hexToInt+0x84>
xor    %eax,%eax
cmpl   $0x41,-0x8(%rbp)
mov    %al,-0x9(%rbp)
jl     117b <hexToInt+0x6b>
cmpl   $0x46,-0x8(%rbp)
setle  %al
mov    %al,-0x9(%rbp)
mov    -0x9(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x8(%rbp),%eax
sub    $0x41,%eax
add    $0xa,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hexToInt>:
push   %rbx
mov    %edi,%ebx
lea    -0x30(%rbx),%eax
cmp    $0xa,%eax
jb     113e <hexToInt+0x2e>
lea    -0x61(%rbx),%eax
cmp    $0x5,%eax
ja     1128 <hexToInt+0x18>
add    $0xffffffa9,%ebx
jmp    113c <hexToInt+0x2c>
lea    -0x41(%rbx),%eax
xor    %edi,%edi
cmp    $0x6,%eax
setb   %dil
call   1030 <assert@plt>
add    $0xffffffc9,%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @hexToInt(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = icmp sge i32 %4, 48
br i1 %5, label %6, label %12
6: ; preds = %1
%7 = load i32, i32* %3
%8 = icmp sle i32 %7, 57
br i1 %8, label %9, label %12
9: ; preds = %6
%10 = load i32, i32* %3
%11 = sub nsw i32 %10, 48
store i32 %11, i32* %2
br label %35
12: ; preds = %6, %1
%13 = load i32, i32* %3
%14 = icmp sge i32 %13, 97
br i1 %14, label %15, label %22
15: ; preds = %12
%16 = load i32, i32* %3
%17 = icmp sle i32 %16, 102
br i1 %17, label %18, label %22
18: ; preds = %15
%19 = load i32, i32* %3
%20 = sub nsw i32 %19, 97
%21 = add nsw i32 %20, 10
store i32 %21, i32* %2
br label %35
22: ; preds = %15, %12
%23 = load i32, i32* %3
%24 = icmp sge i32 %23, 65
br i1 %24, label %25, label %28
25: ; preds = %22
%26 = load i32, i32* %3
%27 = icmp sle i32 %26, 70
br label %28
28: ; preds = %25, %22
%29 = phi i1 [ false, %22 ], [ %27, %25 ]
%30 = zext i1 %29 to i32
%31 = call i32 @assert(i32 %30)
%32 = load i32, i32* %3
%33 = sub nsw i32 %32, 65
%34 = add nsw i32 %33, 10
store i32 %34, i32* %2
br label %35
35: ; preds = %28, %18, %9
%36 = load i32, i32* %2
ret i32 %36
}

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