#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 */
char EOF;
char getchar();
int getInput(void) {
  char ch;
  int ret = -1;
  ch = getchar();
  if (ch >= '0' && ch <= '9') {
    ret = ch - '0';
  } else if (ch >= 'a' && ch <= 'c') {
    ret = ch - 'a' + 10;
  }
  while ((ch = getchar()) != '\n' && ch != EOF)
    ;
  return ret;
}


x86 assembly (clang, -O0):
<getInput>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0xffffffff,-0x8(%rbp)
mov    $0x0,%al
call   1030 <getchar@plt>
mov    %al,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
cmp    $0x30,%eax
jl     1152 <getInput+0x42>
movsbl -0x1(%rbp),%eax
cmp    $0x39,%eax
jg     1152 <getInput+0x42>
movsbl -0x1(%rbp),%eax
sub    $0x30,%eax
mov    %eax,-0x8(%rbp)
jmp    117e <getInput+0x6e>
movsbl -0x1(%rbp),%eax
cmp    $0x61,%eax
jl     1179 <getInput+0x69>
movsbl -0x1(%rbp),%eax
cmp    $0x63,%eax
jg     1179 <getInput+0x69>
movsbl -0x1(%rbp),%eax
sub    $0x61,%eax
add    $0xa,%eax
mov    %eax,-0x8(%rbp)
jmp    117e <getInput+0x6e>
jmp    1183 <getInput+0x73>
mov    $0x0,%al
call   1030 <getchar@plt>
mov    %al,-0x1(%rbp)
movsbl %al,%ecx
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0x9(%rbp)
je     11b4 <getInput+0xa4>
movsbl -0x1(%rbp),%eax
mov    0x2e3f(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
setne  %al
mov    %al,-0x9(%rbp)
mov    -0x9(%rbp),%al
test   $0x1,%al
jne    11c4 <getInput+0xb4>
jmp    11c9 <getInput+0xb9>
jmp    1183 <getInput+0x73>
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getInput>:
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1030 <getchar@plt>
movsbl %al,%r14d
lea    -0x30(%r14),%eax
cmp    $0x9,%al
ja     112d <getInput+0x1d>
add    $0xffffffd0,%r14d
jmp    1143 <getInput+0x33>
lea    -0x61(%r14),%eax
add    $0xffffffa9,%r14d
cmp    $0x3,%al
mov    $0xffffffff,%eax
cmovb  %r14d,%eax
mov    %eax,%r14d
mov    0x2e9e(%rip),%rbx
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1030 <getchar@plt>
cmp    $0xa,%al
je     115f <getInput+0x4f>
cmp    (%rbx),%al
jne    1150 <getInput+0x40>
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@EOF = global i8 0
define i32 @getInput() {
%1 = alloca i8
%2 = alloca i32
store i32 -1, i32* %2
%3 = call signext i8 (...) @getchar()
store i8 %3, i8* %1
%4 = load i8, i8* %1
%5 = sext i8 %4 to i32
%6 = icmp sge i32 %5, 48
br i1 %6, label %7, label %15
7: ; preds = %0
%8 = load i8, i8* %1
%9 = sext i8 %8 to i32
%10 = icmp sle i32 %9, 57
br i1 %10, label %11, label %15
11: ; preds = %7
%12 = load i8, i8* %1
%13 = sext i8 %12 to i32
%14 = sub nsw i32 %13, 48
store i32 %14, i32* %2
br label %29
15: ; preds = %7, %0
%16 = load i8, i8* %1
%17 = sext i8 %16 to i32
%18 = icmp sge i32 %17, 97
br i1 %18, label %19, label %28
19: ; preds = %15
%20 = load i8, i8* %1
%21 = sext i8 %20 to i32
%22 = icmp sle i32 %21, 99
br i1 %22, label %23, label %28
23: ; preds = %19
%24 = load i8, i8* %1
%25 = sext i8 %24 to i32
%26 = sub nsw i32 %25, 97
%27 = add nsw i32 %26, 10
store i32 %27, i32* %2
br label %28
28: ; preds = %23, %19, %15
br label %29
29: ; preds = %28, %11
br label %30
30: ; preds = %42, %29
%31 = call signext i8 (...) @getchar()
store i8 %31, i8* %1
%32 = sext i8 %31 to i32
%33 = icmp ne i32 %32, 10
br i1 %33, label %34, label %40
34: ; preds = %30
%35 = load i8, i8* %1
%36 = sext i8 %35 to i32
%37 = load i8, i8* @EOF
%38 = sext i8 %37 to i32
%39 = icmp ne i32 %36, %38
br label %40
40: ; preds = %34, %30
%41 = phi i1 [ false, %30 ], [ %39, %34 ]
br i1 %41, label %42, label %43
42: ; preds = %40
br label %30
43: ; preds = %40
%44 = load i32, i32* %2
ret i32 %44
}

LLVM IR (-O2):
@EOF = global i8 0
define i32 @getInput() {
%1 = tail call signext i8 (...) @getchar()
%2 = sext i8 %1 to i32
%3 = add i8 %1, -48
%4 = icmp ult i8 %3, 10
br i1 %4, label %5, label %7
5: ; preds = %0
%6 = add nsw i32 %2, -48
br label %12
7: ; preds = %0
%8 = add i8 %1, -97
%9 = icmp ult i8 %8, 3
%10 = add nsw i32 %2, -87
%11 = select i1 %9, i32 %10, i32 -1
br label %12
12: ; preds = %7, %5
%13 = phi i32 [ %6, %5 ], [ %11, %7 ]
br label %14
14: ; preds = %14, %12
%15 = tail call signext i8 (...) @getchar()
%16 = icmp ne i8 %15, 10
%17 = load i8, i8* @EOF
%18 = icmp ne i8 %15, %17
%19 = select i1 %16, i1 %18, i1 false
br i1 %19, label %14, label %20
20: ; preds = %14
ret i32 %13
}