#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__ isspace(char);
int char_to_int(char c) {
  switch (c) {
  case '0':
    return 0;
  case '1':
    return 1;
  case '2':
    return 2;
  case '3':
    return 3;
  case '4':
    return 4;
  case '5':
    return 5;
  case '6':
    return 6;
  case '7':
    return 7;
  case '8':
    return 8;
  case '/':
    return -1;
  }
  if (isspace(c))
    return -2;
  return -3;
}


x86 assembly (clang, -O0):
<char_to_int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x5(%rbp)
movsbl -0x5(%rbp),%eax
add    $0xffffffd1,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x9,%eax
ja     11c0 <char_to_int+0xb0>
mov    -0x10(%rbp),%rax
lea    0xec1(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x0,-0x4(%rbp)
jmp    11e6 <char_to_int+0xd6>
movl   $0x1,-0x4(%rbp)
jmp    11e6 <char_to_int+0xd6>
movl   $0x2,-0x4(%rbp)
jmp    11e6 <char_to_int+0xd6>
movl   $0x3,-0x4(%rbp)
jmp    11e6 <char_to_int+0xd6>
movl   $0x4,-0x4(%rbp)
jmp    11e6 <char_to_int+0xd6>
movl   $0x5,-0x4(%rbp)
jmp    11e6 <char_to_int+0xd6>
movl   $0x6,-0x4(%rbp)
jmp    11e6 <char_to_int+0xd6>
movl   $0x7,-0x4(%rbp)
jmp    11e6 <char_to_int+0xd6>
movl   $0x8,-0x4(%rbp)
jmp    11e6 <char_to_int+0xd6>
movl   $0xffffffff,-0x4(%rbp)
jmp    11e6 <char_to_int+0xd6>
movsbl -0x5(%rbp),%edi
call   1030 <isspace@plt>
cmp    $0x0,%rax
je     11df <char_to_int+0xcf>
movl   $0xfffffffe,-0x4(%rbp)
jmp    11e6 <char_to_int+0xd6>
movl   $0xfffffffd,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<char_to_int>:
mov    %edi,%eax
lea    -0x2f(%rax),%ecx
cmp    $0xa,%ecx
jae    111e <char_to_int+0xe>
add    $0xffffffd0,%eax
ret
push   %rax
movsbl %al,%edi
call   1030 <isspace@plt>
cmp    $0x1,%rax
mov    $0xfffffffe,%eax
sbb    $0x0,%eax
add    $0x8,%rsp
ret

LLVM IR (-O0):
define i32 @char_to_int(i8 signext %0) {
%2 = alloca i32
%3 = alloca i8
store i8 %0, i8* %3
%4 = load i8, i8* %3
%5 = sext i8 %4 to i32
switch i32 %5, label %16 [
i32 48, label %6
i32 49, label %7
i32 50, label %8
i32 51, label %9
i32 52, label %10
i32 53, label %11
i32 54, label %12
i32 55, label %13
i32 56, label %14
i32 47, label %15
]
6: ; preds = %1
store i32 0, i32* %2
br label %22
7: ; preds = %1
store i32 1, i32* %2
br label %22
8: ; preds = %1
store i32 2, i32* %2
br label %22
9: ; preds = %1
store i32 3, i32* %2
br label %22
10: ; preds = %1
store i32 4, i32* %2
br label %22
11: ; preds = %1
store i32 5, i32* %2
br label %22
12: ; preds = %1
store i32 6, i32* %2
br label %22
13: ; preds = %1
store i32 7, i32* %2
br label %22
14: ; preds = %1
store i32 8, i32* %2
br label %22
15: ; preds = %1
store i32 -1, i32* %2
br label %22
16: ; preds = %1
%17 = load i8, i8* %3
%18 = call i64 @isspace(i8 signext %17)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %16
store i32 -2, i32* %2
br label %22
21: ; preds = %16
store i32 -3, i32* %2
br label %22
22: ; preds = %21, %20, %15, %14, %13, %12, %11, %10, %9, %8, %7, %6
%23 = load i32, i32* %2
ret i32 %23
}

LLVM IR (-O2):
define i32 @char_to_int(i8 signext %0) {
%2 = sext i8 %0 to i32
%3 = add nsw i32 %2, -47
%4 = icmp ult i32 %3, 10
br i1 %4, label %9, label %5
5: ; preds = %1
%6 = tail call i64 @isspace(i8 signext %0)
%7 = icmp eq i64 %6, 0
%8 = select i1 %7, i32 -3, i32 -2
br label %11
9: ; preds = %1
%10 = add nsw i32 %2, -48
br label %11
11: ; preds = %9, %5
%12 = phi i32 [ %8, %5 ], [ %10, %9 ]
ret i32 %12
}