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


x86 assembly (clang, -O0):
<scan>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0xc(%rbp)
movsbl -0x5(%rbp),%eax
sub    $0x30,%eax
mov    %eax,-0xc(%rbp)
mov    $0x0,%al
call   1030 <getchar@plt>
mov    %al,-0x5(%rbp)
movsbl -0x5(%rbp),%ecx
mov    $0x1,%al
cmp    $0x30,%ecx
mov    %al,-0xd(%rbp)
jl     1152 <scan+0x42>
movsbl -0x5(%rbp),%eax
cmp    $0x39,%eax
setg   %al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
test   $0x1,%al
jne    1162 <scan+0x52>
jmp    1180 <scan+0x70>
movsbl -0x5(%rbp),%eax
cmp    $0xa,%eax
jne    117b <scan+0x6b>
movl   $0xffffffff,-0x4(%rbp)
jmp    11d9 <scan+0xc9>
jmp    1129 <scan+0x19>
jmp    1185 <scan+0x75>
mov    $0x0,%al
call   1030 <getchar@plt>
mov    %al,-0x5(%rbp)
movsbl -0x5(%rbp),%ecx
xor    %eax,%eax
cmp    $0x30,%ecx
mov    %al,-0xe(%rbp)
jl     11ae <scan+0x9e>
movsbl -0x5(%rbp),%eax
cmp    $0x39,%eax
setle  %al
mov    %al,-0xe(%rbp)
mov    -0xe(%rbp),%al
test   $0x1,%al
jne    11be <scan+0xae>
jmp    11d3 <scan+0xc3>
imul   $0xa,-0xc(%rbp),%eax
movsbl -0x5(%rbp),%ecx
add    %ecx,%eax
sub    $0x30,%eax
mov    %eax,-0xc(%rbp)
jmp    1185 <scan+0x75>
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<scan>:
push   %rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1030 <getchar@plt>
lea    -0x3a(%rax),%ecx
cmp    $0xf6,%cl
jae    113a <scan+0x2a>
cmp    $0xa,%al
jne    1120 <scan+0x10>
mov    $0xffffffff,%ebx
jmp    117d <scan+0x6d>
xor    %eax,%eax
call   1030 <getchar@plt>
lea    -0x30(%rax),%ecx
mov    $0xffffffd0,%ebx
cmp    $0x9,%cl
ja     117d <scan+0x6d>
mov    $0xffffffd0,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
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 <scan+0x50>
mov    %ebx,%eax
pop    %rbx
ret

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

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