#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 */
scalar_t__ isdigit(char);
scalar_t__ isupper(char);
int oneHexCharToHex(char h) {
  int x = 0;
  if (isdigit(h)) {
    x = h - '0';
  } else if (isupper(h)) {
    x = h - 'A' + 10;
  } else {
    x = h - 'a' + 10;
  }
  return x;
}


x86 assembly (clang, -O0):
<oneHexCharToHex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
movl   $0x0,-0x8(%rbp)
movsbl -0x1(%rbp),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     1157 <oneHexCharToHex+0x37>
movsbl -0x1(%rbp),%eax
sub    $0x30,%eax
mov    %eax,-0x8(%rbp)
jmp    118e <oneHexCharToHex+0x6e>
movsbl -0x1(%rbp),%edi
call   1040 <isupper@plt>
cmp    $0x0,%rax
je     117c <oneHexCharToHex+0x5c>
movsbl -0x1(%rbp),%eax
sub    $0x41,%eax
add    $0xa,%eax
mov    %eax,-0x8(%rbp)
jmp    1189 <oneHexCharToHex+0x69>
movsbl -0x1(%rbp),%eax
sub    $0x61,%eax
add    $0xa,%eax
mov    %eax,-0x8(%rbp)
jmp    118e <oneHexCharToHex+0x6e>
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<oneHexCharToHex>:
push   %rbx
mov    %edi,%ebx
call   1030 <isdigit@plt>
movsbl %bl,%ebx
test   %rax,%rax
je     1135 <oneHexCharToHex+0x15>
add    $0xffffffd0,%ebx
jmp    1149 <oneHexCharToHex+0x29>
mov    %ebx,%edi
call   1040 <isupper@plt>
test   %rax,%rax
je     1146 <oneHexCharToHex+0x26>
add    $0xffffffc9,%ebx
jmp    1149 <oneHexCharToHex+0x29>
add    $0xffffffa9,%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @oneHexCharToHex(i8 signext %0) {
%2 = alloca i8
%3 = alloca i32
store i8 %0, i8* %2
store i32 0, i32* %3
%4 = load i8, i8* %2
%5 = call i64 @isdigit(i8 signext %4)
%6 = icmp ne i64 %5, 0
br i1 %6, label %7, label %11
7: ; preds = %1
%8 = load i8, i8* %2
%9 = sext i8 %8 to i32
%10 = sub nsw i32 %9, 48
store i32 %10, i32* %3
br label %26
11: ; preds = %1
%12 = load i8, i8* %2
%13 = call i64 @isupper(i8 signext %12)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %20
15: ; preds = %11
%16 = load i8, i8* %2
%17 = sext i8 %16 to i32
%18 = sub nsw i32 %17, 65
%19 = add nsw i32 %18, 10
store i32 %19, i32* %3
br label %25
20: ; preds = %11
%21 = load i8, i8* %2
%22 = sext i8 %21 to i32
%23 = sub nsw i32 %22, 97
%24 = add nsw i32 %23, 10
store i32 %24, i32* %3
br label %25
25: ; preds = %20, %15
br label %26
26: ; preds = %25, %7
%27 = load i32, i32* %3
ret i32 %27
}

LLVM IR (-O2):
define i32 @oneHexCharToHex(i8 signext %0) {
%2 = tail call i64 @isdigit(i8 signext %0)
%3 = icmp eq i64 %2, 0
br i1 %3, label %7, label %4
4: ; preds = %1
%5 = sext i8 %0 to i32
%6 = add nsw i32 %5, -48
br label %15
7: ; preds = %1
%8 = tail call i64 @isupper(i8 signext %0)
%9 = icmp eq i64 %8, 0
%10 = sext i8 %0 to i32
br i1 %9, label %13, label %11
11: ; preds = %7
%12 = add nsw i32 %10, -55
br label %15
13: ; preds = %7
%14 = add nsw i32 %10, -87
br label %15
15: ; preds = %11, %13, %4
%16 = phi i32 [ %6, %4 ], [ %12, %11 ], [ %14, %13 ]
ret i32 %16
}