#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 */
typedef size_t uint32_t;

/* Variables and functions */
size_t SIZE_MAX;
scalar_t__ isdigit(size_t);
scalar_t__ islower(size_t);
scalar_t__ isupper(size_t);
size_t decode_digit(uint32_t v) {
  if (isdigit(v)) {
    return 22 + (v - '0');
  }
  if (islower(v)) {
    return v - 'a';
  }
  if (isupper(v)) {
    return v - 'A';
  }
  return SIZE_MAX;
}


x86 assembly (clang, -O0):
<decode_digit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     1164 <decode_digit+0x34>
mov    -0x10(%rbp),%rax
sub    $0x30,%rax
add    $0x16,%rax
mov    %rax,-0x8(%rbp)
jmp    11ba <decode_digit+0x8a>
mov    -0x10(%rbp),%rdi
call   1040 <islower@plt>
cmp    $0x0,%rax
je     1188 <decode_digit+0x58>
mov    -0x10(%rbp),%rax
sub    $0x61,%rax
mov    %rax,-0x8(%rbp)
jmp    11ba <decode_digit+0x8a>
mov    -0x10(%rbp),%rdi
call   1050 <isupper@plt>
cmp    $0x0,%rax
je     11ac <decode_digit+0x7c>
mov    -0x10(%rbp),%rax
sub    $0x41,%rax
mov    %rax,-0x8(%rbp)
jmp    11ba <decode_digit+0x8a>
mov    0x2e25(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<decode_digit>:
push   %rbx
mov    %rdi,%rbx
call   1030 <isdigit@plt>
test   %rax,%rax
je     1144 <decode_digit+0x14>
add    $0xffffffffffffffe6,%rbx
jmp    1174 <decode_digit+0x44>
mov    %rbx,%rdi
call   1040 <islower@plt>
test   %rax,%rax
je     1157 <decode_digit+0x27>
add    $0xffffffffffffff9f,%rbx
jmp    1174 <decode_digit+0x44>
mov    %rbx,%rdi
call   1050 <isupper@plt>
test   %rax,%rax
je     116a <decode_digit+0x3a>
add    $0xffffffffffffffbf,%rbx
jmp    1174 <decode_digit+0x44>
mov    0x2e67(%rip),%rax
mov    (%rax),%rbx
mov    %rbx,%rax
pop    %rbx
ret

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

LLVM IR (-O2):
@SIZE_MAX = global i64 0
define i64 @decode_digit(i64 %0) {
%2 = tail call i64 @isdigit(i64 %0)
%3 = icmp eq i64 %2, 0
br i1 %3, label %6, label %4
4: ; preds = %1
%5 = add i64 %0, -26
br label %18
6: ; preds = %1
%7 = tail call i64 @islower(i64 %0)
%8 = icmp eq i64 %7, 0
br i1 %8, label %11, label %9
9: ; preds = %6
%10 = add i64 %0, -97
br label %18
11: ; preds = %6
%12 = tail call i64 @isupper(i64 %0)
%13 = icmp eq i64 %12, 0
br i1 %13, label %16, label %14
14: ; preds = %11
%15 = add i64 %0, -65
br label %18
16: ; preds = %11
%17 = load i64, i64* @SIZE_MAX
br label %18
18: ; preds = %16, %14, %9, %4
%19 = phi i64 [ %5, %4 ], [ %10, %9 ], [ %15, %14 ], [ %17, %16 ]
ret i64 %19
}