#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 InputReadChar();
scalar_t__ IsDigit(char);
int InputReadTextInt(void) {
  char c;
  while (!IsDigit(c = InputReadChar()))
    ;
  int iResult = 0;
  do {
    iResult *= 10;
    iResult += (c - '0');
    c = InputReadChar();
  } while (IsDigit(c));
  return iResult;
}


x86 assembly (clang, -O0):
<InputReadTextInt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1030 <InputReadChar@plt>
mov    %al,-0x1(%rbp)
movsbl %al,%edi
call   1040 <IsDigit@plt>
cmp    $0x0,%rax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1150 <InputReadTextInt+0x30>
jmp    1155 <InputReadTextInt+0x35>
jmp    1128 <InputReadTextInt+0x8>
movl   $0x0,-0x8(%rbp)
imul   $0xa,-0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
movsbl -0x1(%rbp),%eax
sub    $0x30,%eax
add    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    $0x0,%al
call   1030 <InputReadChar@plt>
mov    %al,-0x1(%rbp)
movsbl -0x1(%rbp),%edi
call   1040 <IsDigit@plt>
cmp    $0x0,%rax
jne    115c <InputReadTextInt+0x3c>
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<InputReadTextInt>:
push   %r14
push   %rbx
push   %rax
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %eax,%eax
call   1030 <InputReadChar@plt>
mov    %eax,%ebx
movsbl %al,%edi
call   1040 <IsDigit@plt>
test   %rax,%rax
je     1130 <InputReadTextInt+0x10>
xor    %r14d,%r14d
nopl   0x0(%rax)
lea    (%r14,%r14,4),%eax
movsbl %bl,%ecx
lea    (%rcx,%rax,2),%r14d
add    $0xffffffd0,%r14d
xor    %eax,%eax
call   1030 <InputReadChar@plt>
mov    %eax,%ebx
movsbl %al,%edi
call   1040 <IsDigit@plt>
test   %rax,%rax
jne    1150 <InputReadTextInt+0x30>
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @InputReadTextInt() {
%1 = alloca i8
%2 = alloca i32
br label %3
3: ; preds = %8, %0
%4 = call signext i8 (...) @InputReadChar()
store i8 %4, i8* %1
%5 = call i64 @IsDigit(i8 signext %4)
%6 = icmp ne i64 %5, 0
%7 = xor i1 %6, true
br i1 %7, label %8, label %9
8: ; preds = %3
br label %3
9: ; preds = %3
store i32 0, i32* %2
br label %10
10: ; preds = %19, %9
%11 = load i32, i32* %2
%12 = mul nsw i32 %11, 10
store i32 %12, i32* %2
%13 = load i8, i8* %1
%14 = sext i8 %13 to i32
%15 = sub nsw i32 %14, 48
%16 = load i32, i32* %2
%17 = add nsw i32 %16, %15
store i32 %17, i32* %2
%18 = call signext i8 (...) @InputReadChar()
store i8 %18, i8* %1
br label %19
19: ; preds = %10
%20 = load i8, i8* %1
%21 = call i64 @IsDigit(i8 signext %20)
%22 = icmp ne i64 %21, 0
br i1 %22, label %10, label %23
23: ; preds = %19
%24 = load i32, i32* %2
ret i32 %24
}

LLVM IR (-O2):
define i32 @InputReadTextInt() {
br label %1
1: ; preds = %1, %0
%2 = tail call signext i8 (...) @InputReadChar()
%3 = tail call i64 @IsDigit(i8 signext %2)
%4 = icmp eq i64 %3, 0
br i1 %4, label %1, label %5
5: ; preds = %1, %5
%6 = phi i8 [ %12, %5 ], [ %2, %1 ]
%7 = phi i32 [ %11, %5 ], [ 0, %1 ]
%8 = mul nsw i32 %7, 10
%9 = sext i8 %6 to i32
%10 = add nsw i32 %9, -48
%11 = add nsw i32 %10, %8
%12 = tail call signext i8 (...) @InputReadChar()
%13 = tail call i64 @IsDigit(i8 signext %12)
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %5
15: ; preds = %5
ret i32 %11
}