int convertchar(int ascii) {
  if (ascii >= 0x41 && ascii < 0x5B) {
    return ascii - 0x37;
  } else if (ascii >= 0x61 && ascii < 0x7B) {
    return ascii - 0x57;
  } else if (ascii >= 0x30 && ascii < 0x3A) {
    return ascii - 0x30;
  } else {
    switch (ascii) {
    case 0x20:
      return -1;
      break;
    case 0x21:
      return 0x24;
      break;
    case 0x23:
      return 0x25;
      break;
    case 0x3F:
      return 0x26;
      break;
    case 0x26:
      return 0x27;
      break;
    case 0x25:
      return 0x28;
      break;
    case 0x2A:
      return 0x32;
      break;
    case 0x2B:
      return 0x33;
      break;
    case 0x2C:
      return 0x34;
      break;
    case 0x2D:
      return 0x35;
      break;
    case 0x2E:
      return 0x36;
      break;
    case 0x2F:
      return 0x37;
      break;
    }
  }
  return -1;
}


x86 assembly (clang, -O0):
<convertchar>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
cmpl   $0x41,-0x8(%rbp)
jl     1129 <convertchar+0x29>
cmpl   $0x5b,-0x8(%rbp)
jge    1129 <convertchar+0x29>
mov    -0x8(%rbp),%eax
sub    $0x37,%eax
mov    %eax,-0x4(%rbp)
jmp    123c <convertchar+0x13c>
cmpl   $0x61,-0x8(%rbp)
jl     114b <convertchar+0x4b>
cmpl   $0x7b,-0x8(%rbp)
jge    114b <convertchar+0x4b>
mov    -0x8(%rbp),%eax
sub    $0x57,%eax
mov    %eax,-0x4(%rbp)
jmp    123c <convertchar+0x13c>
cmpl   $0x30,-0x8(%rbp)
jl     116d <convertchar+0x6d>
cmpl   $0x3a,-0x8(%rbp)
jge    116d <convertchar+0x6d>
mov    -0x8(%rbp),%eax
sub    $0x30,%eax
mov    %eax,-0x4(%rbp)
jmp    123c <convertchar+0x13c>
mov    -0x8(%rbp),%eax
add    $0xffffffe0,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x1f,%eax
ja     1226 <convertchar+0x126>
mov    -0x10(%rbp),%rax
lea    0xe73(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0xffffffff,-0x4(%rbp)
jmp    123c <convertchar+0x13c>
movl   $0x24,-0x4(%rbp)
jmp    123c <convertchar+0x13c>
movl   $0x25,-0x4(%rbp)
jmp    123c <convertchar+0x13c>
movl   $0x26,-0x4(%rbp)
jmp    123c <convertchar+0x13c>
movl   $0x27,-0x4(%rbp)
jmp    123c <convertchar+0x13c>
movl   $0x28,-0x4(%rbp)
jmp    123c <convertchar+0x13c>
movl   $0x32,-0x4(%rbp)
jmp    123c <convertchar+0x13c>
movl   $0x33,-0x4(%rbp)
jmp    123c <convertchar+0x13c>
movl   $0x34,-0x4(%rbp)
jmp    123c <convertchar+0x13c>
movl   $0x35,-0x4(%rbp)
jmp    123c <convertchar+0x13c>
movl   $0x36,-0x4(%rbp)
jmp    123c <convertchar+0x13c>
movl   $0x37,-0x4(%rbp)
jmp    123c <convertchar+0x13c>
jmp    122b <convertchar+0x12b>
jmp    1230 <convertchar+0x130>
jmp    1235 <convertchar+0x135>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<convertchar>:
lea    -0x41(%rdi),%eax
cmp    $0x19,%eax
ja     110e <convertchar+0xe>
add    $0xffffffc9,%edi
mov    %edi,%eax
ret
lea    -0x61(%rdi),%eax
cmp    $0x19,%eax
ja     111c <convertchar+0x1c>
add    $0xffffffa9,%edi
mov    %edi,%eax
ret
lea    -0x30(%rdi),%eax
cmp    $0xa,%eax
jae    1125 <convertchar+0x25>
ret
mov    $0xffffffff,%eax
add    $0xffffffdf,%edi
cmp    $0x1e,%edi
ja     1124 <convertchar+0x24>
lea    0xec7(%rip),%rcx
movslq (%rcx,%rdi,4),%rdx
add    %rcx,%rdx
jmp    *%rdx
mov    $0x24,%eax
ret
mov    $0x25,%eax
ret
mov    $0x28,%eax
ret
mov    $0x27,%eax
ret
mov    $0x32,%eax
ret
mov    $0x33,%eax
ret
mov    $0x34,%eax
ret
mov    $0x35,%eax
ret
mov    $0x36,%eax
ret
mov    $0x37,%eax
ret
mov    $0x26,%eax
ret

LLVM IR (-O0):
define i32 @convertchar(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = icmp sge i32 %4, 65
br i1 %5, label %6, label %12
6: ; preds = %1
%7 = load i32, i32* %3
%8 = icmp slt i32 %7, 91
br i1 %8, label %9, label %12
9: ; preds = %6
%10 = load i32, i32* %3
%11 = sub nsw i32 %10, 55
store i32 %11, i32* %2
br label %48
12: ; preds = %6, %1
%13 = load i32, i32* %3
%14 = icmp sge i32 %13, 97
br i1 %14, label %15, label %21
15: ; preds = %12
%16 = load i32, i32* %3
%17 = icmp slt i32 %16, 123
br i1 %17, label %18, label %21
18: ; preds = %15
%19 = load i32, i32* %3
%20 = sub nsw i32 %19, 87
store i32 %20, i32* %2
br label %48
21: ; preds = %15, %12
%22 = load i32, i32* %3
%23 = icmp sge i32 %22, 48
br i1 %23, label %24, label %30
24: ; preds = %21
%25 = load i32, i32* %3
%26 = icmp slt i32 %25, 58
br i1 %26, label %27, label %30
27: ; preds = %24
%28 = load i32, i32* %3
%29 = sub nsw i32 %28, 48
store i32 %29, i32* %2
br label %48
30: ; preds = %24, %21
%31 = load i32, i32* %3
switch i32 %31, label %44 [
i32 32, label %32
i32 33, label %33
i32 35, label %34
i32 63, label %35
i32 38, label %36
i32 37, label %37
i32 42, label %38
i32 43, label %39
i32 44, label %40
i32 45, label %41
i32 46, label %42
i32 47, label %43
]
32: ; preds = %30
store i32 -1, i32* %2
br label %48
33: ; preds = %30
store i32 36, i32* %2
br label %48
34: ; preds = %30
store i32 37, i32* %2
br label %48
35: ; preds = %30
store i32 38, i32* %2
br label %48
36: ; preds = %30
store i32 39, i32* %2
br label %48
37: ; preds = %30
store i32 40, i32* %2
br label %48
38: ; preds = %30
store i32 50, i32* %2
br label %48
39: ; preds = %30
store i32 51, i32* %2
br label %48
40: ; preds = %30
store i32 52, i32* %2
br label %48
41: ; preds = %30
store i32 53, i32* %2
br label %48
42: ; preds = %30
store i32 54, i32* %2
br label %48
43: ; preds = %30
store i32 55, i32* %2
br label %48
44: ; preds = %30
br label %45
45: ; preds = %44
br label %46
46: ; preds = %45
br label %47
47: ; preds = %46
store i32 -1, i32* %2
br label %48
48: ; preds = %47, %43, %42, %41, %40, %39, %38, %37, %36, %35, %34, %33, %32, %27, %18, %9
%49 = load i32, i32* %2
ret i32 %49
}

LLVM IR (-O2):
define i32 @convertchar(i32 %0) {
%2 = add i32 %0, -65
%3 = icmp ult i32 %2, 26
br i1 %3, label %4, label %6
4: ; preds = %1
%5 = add nsw i32 %0, -55
br label %26
6: ; preds = %1
%7 = add i32 %0, -97
%8 = icmp ult i32 %7, 26
br i1 %8, label %9, label %11
9: ; preds = %6
%10 = add nsw i32 %0, -87
br label %26
11: ; preds = %6
%12 = add i32 %0, -48
%13 = icmp ult i32 %12, 10
br i1 %13, label %26, label %14
14: ; preds = %11
switch i32 %0, label %26 [
i32 47, label %25
i32 33, label %15
i32 35, label %16
i32 63, label %17
i32 38, label %18
i32 37, label %19
i32 42, label %20
i32 43, label %21
i32 44, label %22
i32 45, label %23
i32 46, label %24
]
15: ; preds = %14
br label %26
16: ; preds = %14
br label %26
17: ; preds = %14
br label %26
18: ; preds = %14
br label %26
19: ; preds = %14
br label %26
20: ; preds = %14
br label %26
21: ; preds = %14
br label %26
22: ; preds = %14
br label %26
23: ; preds = %14
br label %26
24: ; preds = %14
br label %26
25: ; preds = %14
br label %26
26: ; preds = %11, %14, %25, %24, %23, %22, %21, %20, %19, %18, %17, %16, %15, %9, %4
%27 = phi i32 [ %5, %4 ], [ %10, %9 ], [ 55, %25 ], [ 54, %24 ], [ 53, %23 ], [ 52, %22 ], [ 51, %21 ], [ 50, %20 ], [ 40, %19 ], [ 39, %18 ], [ 38, %17 ], [ 37, %16 ], [ 36, %15 ], [ -1, %14 ], [ %12, %11 ]
ret i32 %27
}