#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 getchar();
int getint() {
  int ret = 0, fix = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-')
      fix = -1;
    ch = getchar();
  }
  while ('0' <= ch && ch <= '9') {
    ret = ret * 10 + ch - '0';
    ch = getchar();
  }
  return ret * fix;
}


x86 assembly (clang, -O0):
<getint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
mov    $0x0,%al
call   1030 <getchar@plt>
mov    %al,-0x9(%rbp)
movsbl -0x9(%rbp),%ecx
mov    $0x1,%al
cmp    $0x30,%ecx
mov    %al,-0xa(%rbp)
jl     114f <getint+0x3f>
movsbl -0x9(%rbp),%eax
cmp    $0x39,%eax
setg   %al
mov    %al,-0xa(%rbp)
mov    -0xa(%rbp),%al
test   $0x1,%al
jne    115f <getint+0x4f>
jmp    1182 <getint+0x72>
movsbl -0x9(%rbp),%eax
cmp    $0x2d,%eax
jne    1173 <getint+0x63>
movl   $0xffffffff,-0x8(%rbp)
mov    $0x0,%al
call   1030 <getchar@plt>
mov    %al,-0x9(%rbp)
jmp    1130 <getint+0x20>
jmp    1187 <getint+0x77>
movsbl -0x9(%rbp),%edx
xor    %eax,%eax
mov    $0x30,%ecx
cmp    %edx,%ecx
mov    %al,-0xb(%rbp)
jg     11aa <getint+0x9a>
movsbl -0x9(%rbp),%eax
cmp    $0x39,%eax
setle  %al
mov    %al,-0xb(%rbp)
mov    -0xb(%rbp),%al
test   $0x1,%al
jne    11ba <getint+0xaa>
jmp    11d9 <getint+0xc9>
imul   $0xa,-0x4(%rbp),%eax
movsbl -0x9(%rbp),%ecx
add    %ecx,%eax
sub    $0x30,%eax
mov    %eax,-0x4(%rbp)
mov    $0x0,%al
call   1030 <getchar@plt>
mov    %al,-0x9(%rbp)
jmp    1187 <getint+0x77>
mov    -0x4(%rbp),%eax
imul   -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getint>:
push   %rbp
push   %rbx
push   %rax
xor    %eax,%eax
call   1030 <getchar@plt>
mov    %eax,%ecx
add    $0xc6,%cl
mov    $0x1,%ebp
cmp    $0xf5,%cl
ja     1156 <getint+0x46>
mov    $0x1,%ebp
mov    $0xffffffff,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
cmp    $0x2d,%al
cmove  %ebx,%ebp
xor    %eax,%eax
call   1030 <getchar@plt>
mov    %eax,%ecx
add    $0xc6,%cl
cmp    $0xf6,%cl
jb     1140 <getint+0x30>
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
movzbl %al,%eax
lea    (%rbx,%rbx,4),%ecx
lea    (%rax,%rcx,2),%ebx
add    $0xffffffd0,%ebx
xor    %eax,%eax
call   1030 <getchar@plt>
mov    %eax,%ecx
add    $0xd0,%cl
cmp    $0xa,%cl
jb     1160 <getint+0x50>
imul   %ebp,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @getint() {
%1 = tail call signext i8 (...) @getchar()
%2 = add i8 %1, -58
%3 = icmp ult i8 %2, -10
br i1 %3, label %7, label %4
4: ; preds = %7, %0
%5 = phi i32 [ 1, %0 ], [ %11, %7 ]
%6 = phi i8 [ %1, %0 ], [ %12, %7 ]
br label %15
7: ; preds = %0, %7
%8 = phi i8 [ %12, %7 ], [ %1, %0 ]
%9 = phi i32 [ %11, %7 ], [ 1, %0 ]
%10 = icmp eq i8 %8, 45
%11 = select i1 %10, i32 -1, i32 %9
%12 = tail call signext i8 (...) @getchar()
%13 = add i8 %12, -58
%14 = icmp ult i8 %13, -10
br i1 %14, label %7, label %4
15: ; preds = %4, %15
%16 = phi i8 [ %22, %15 ], [ %6, %4 ]
%17 = phi i32 [ %21, %15 ], [ 0, %4 ]
%18 = zext i8 %16 to i32
%19 = mul nsw i32 %17, 10
%20 = add i32 %19, -48
%21 = add i32 %20, %18
%22 = tail call signext i8 (...) @getchar()
%23 = add i8 %22, -48
%24 = icmp ult i8 %23, 10
br i1 %24, label %15, label %25
25: ; preds = %15
%26 = mul nsw i32 %21, %5
ret i32 %26
}