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


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

x86 assembly (clang, -O2):
<b36toi>:
push   %rbx
mov    %edi,%ebx
movzbl %bl,%edi
call   1030 <isdigit@plt>
movsbl %bl,%ebx
test   %rax,%rax
je     1148 <b36toi+0x18>
add    $0xffffffd0,%ebx
jmp    116f <b36toi+0x3f>
mov    %ebx,%edi
call   1040 <islower@plt>
test   %rax,%rax
je     1159 <b36toi+0x29>
add    $0xffffffa9,%ebx
jmp    116f <b36toi+0x3f>
mov    %ebx,%edi
call   1050 <isupper@plt>
test   %rax,%rax
je     116a <b36toi+0x3a>
add    $0xffffffc9,%ebx
jmp    116f <b36toi+0x3f>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @b36toi(i8 signext %0) {
%2 = alloca i32
%3 = alloca i8
store i8 %0, i8* %3
%4 = load i8, i8* %3
%5 = call i64 @isdigit(i8 zeroext %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 %30
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 %30
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 %30
29: ; preds = %20
store i32 -1, i32* %2
br label %30
30: ; preds = %29, %24, %15, %7
%31 = load i32, i32* %2
ret i32 %31
}

LLVM IR (-O2):
define i32 @b36toi(i8 signext %0) {
%2 = tail call i64 @isdigit(i8 zeroext %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
}