#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__ islower(char);
scalar_t__ isupper(char);
int Char2Int(char character) {
  if (isdigit(character)) {
    return (character - '0');
  } else if (islower(character)) {
    return (character - 'a' + 10);
  } else if (isupper(character)) {
    return (character - 'A' + 10);
  }
  return (-1);
}


x86 assembly (clang, -O0):
<Char2Int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x5(%rbp)
movsbl -0x5(%rbp),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     1160 <Char2Int+0x30>
movsbl -0x5(%rbp),%eax
sub    $0x30,%eax
mov    %eax,-0x4(%rbp)
jmp    11bb <Char2Int+0x8b>
movsbl -0x5(%rbp),%edi
call   1040 <islower@plt>
cmp    $0x0,%rax
je     1185 <Char2Int+0x55>
movsbl -0x5(%rbp),%eax
sub    $0x61,%eax
add    $0xa,%eax
mov    %eax,-0x4(%rbp)
jmp    11bb <Char2Int+0x8b>
movsbl -0x5(%rbp),%edi
call   1050 <isupper@plt>
cmp    $0x0,%rax
je     11aa <Char2Int+0x7a>
movsbl -0x5(%rbp),%eax
sub    $0x41,%eax
add    $0xa,%eax
mov    %eax,-0x4(%rbp)
jmp    11bb <Char2Int+0x8b>
jmp    11af <Char2Int+0x7f>
jmp    11b4 <Char2Int+0x84>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Char2Int>:
push   %rbx
mov    %edi,%ebx
call   1030 <isdigit@plt>
movsbl %bl,%ebx
test   %rax,%rax
je     1145 <Char2Int+0x15>
add    $0xffffffd0,%ebx
jmp    116c <Char2Int+0x3c>
mov    %ebx,%edi
call   1040 <islower@plt>
test   %rax,%rax
je     1156 <Char2Int+0x26>
add    $0xffffffa9,%ebx
jmp    116c <Char2Int+0x3c>
mov    %ebx,%edi
call   1050 <isupper@plt>
test   %rax,%rax
je     1167 <Char2Int+0x37>
add    $0xffffffc9,%ebx
jmp    116c <Char2Int+0x3c>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
pop    %rbx
ret

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

LLVM IR (-O2):
define i32 @Char2Int(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 %19
7: ; preds = %1
%8 = tail call i64 @islower(i8 signext %0)
%9 = icmp eq i64 %8, 0
br i1 %9, label %13, label %10
10: ; preds = %7
%11 = sext i8 %0 to i32
%12 = add nsw i32 %11, -87
br label %19
13: ; preds = %7
%14 = tail call i64 @isupper(i8 signext %0)
%15 = icmp eq i64 %14, 0
br i1 %15, label %19, label %16
16: ; preds = %13
%17 = sext i8 %0 to i32
%18 = add nsw i32 %17, -55
br label %19
19: ; preds = %13, %16, %10, %4
%20 = phi i32 [ %6, %4 ], [ %12, %10 ], [ %18, %16 ], [ -1, %13 ]
ret i32 %20
}