#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();
scalar_t__ isblank(char);
scalar_t__ isdigit(char);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ ungetc(char, int /*<<< orphan*/);
int ReadInt(void) {
  int value = 0;
  int sign = 1;
  char c = 0;
  do {
    c = getchar();
  } while (isblank(c));
  if (c == '-' || c == '+') {
    if (c == '-') {
      sign = -1;
    }
    c = getchar();
  }
  while (isblank(c)) {
    c = getchar();
  }
  while (isdigit(c)) {
    value = value * 10 + (c - '0');
    c = getchar();
  }
  ungetc(c, stdin);
  return value * sign;
}


x86 assembly (clang, -O0):
<ReadInt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
movb   $0x0,-0x9(%rbp)
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %al,-0x9(%rbp)
movsbl -0x9(%rbp),%edi
call   1040 <isblank@plt>
cmp    $0x0,%rax
jne    115a <ReadInt+0x1a>
movsbl -0x9(%rbp),%eax
cmp    $0x2d,%eax
je     1191 <ReadInt+0x51>
movsbl -0x9(%rbp),%eax
cmp    $0x2b,%eax
jne    11af <ReadInt+0x6f>
movsbl -0x9(%rbp),%eax
cmp    $0x2d,%eax
jne    11a5 <ReadInt+0x65>
movl   $0xffffffff,-0x8(%rbp)
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %al,-0x9(%rbp)
jmp    11b4 <ReadInt+0x74>
movsbl -0x9(%rbp),%edi
call   1040 <isblank@plt>
cmp    $0x0,%rax
je     11d6 <ReadInt+0x96>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %al,-0x9(%rbp)
jmp    11b4 <ReadInt+0x74>
jmp    11db <ReadInt+0x9b>
movsbl -0x9(%rbp),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     120d <ReadInt+0xcd>
imul   $0xa,-0x4(%rbp),%eax
movsbl -0x9(%rbp),%ecx
sub    $0x30,%ecx
add    %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %al,-0x9(%rbp)
jmp    11db <ReadInt+0x9b>
mov    -0x9(%rbp),%al
mov    0x2dd1(%rip),%rcx
mov    (%rcx),%esi
movsbl %al,%edi
call   1060 <ungetc@plt>
mov    -0x4(%rbp),%eax
imul   -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ReadInt>:
push   %rbp
push   %r14
push   %rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %eax,%ebx
movsbl %al,%edi
call   1040 <isblank@plt>
test   %rax,%rax
jne    1150 <ReadInt+0x10>
mov    $0x1,%ebp
cmp    $0x2b,%bl
je     117a <ReadInt+0x3a>
cmp    $0x2d,%bl
jne    1183 <ReadInt+0x43>
mov    $0xffffffff,%ebp
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %eax,%ebx
movsbl %bl,%edi
cs nopw 0x0(%rax,%rax,1)
call   1040 <isblank@plt>
test   %rax,%rax
je     11a8 <ReadInt+0x68>
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %eax,%ebx
movsbl %al,%edi
jmp    1190 <ReadInt+0x50>
movsbl %bl,%edi
call   1030 <isdigit@plt>
xor    %r14d,%r14d
test   %rax,%rax
je     11e5 <ReadInt+0xa5>
nopl   0x0(%rax,%rax,1)
lea    (%r14,%r14,4),%eax
movsbl %bl,%ecx
lea    (%rcx,%rax,2),%r14d
add    $0xffffffd0,%r14d
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %eax,%ebx
movsbl %al,%edi
call   1030 <isdigit@plt>
test   %rax,%rax
jne    11c0 <ReadInt+0x80>
imul   %ebp,%r14d
mov    0x2df8(%rip),%rax
mov    (%rax),%esi
movsbl %bl,%edi
call   1060 <ungetc@plt>
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@stdin = global i32 0
define i32 @ReadInt() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8
store i32 0, i32* %1
store i32 1, i32* %2
store i8 0, i8* %3
br label %4
4: ; preds = %6, %0
%5 = call signext i8 (...) @getchar()
store i8 %5, i8* %3
br label %6
6: ; preds = %4
%7 = load i8, i8* %3
%8 = call i64 @isblank(i8 signext %7)
%9 = icmp ne i64 %8, 0
br i1 %9, label %4, label %10
10: ; preds = %6
%11 = load i8, i8* %3
%12 = sext i8 %11 to i32
%13 = icmp eq i32 %12, 45
br i1 %13, label %18, label %14
14: ; preds = %10
%15 = load i8, i8* %3
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 43
br i1 %17, label %18, label %25
18: ; preds = %14, %10
%19 = load i8, i8* %3
%20 = sext i8 %19 to i32
%21 = icmp eq i32 %20, 45
br i1 %21, label %22, label %23
22: ; preds = %18
store i32 -1, i32* %2
br label %23
23: ; preds = %22, %18
%24 = call signext i8 (...) @getchar()
store i8 %24, i8* %3
br label %25
25: ; preds = %23, %14
br label %26
26: ; preds = %30, %25
%27 = load i8, i8* %3
%28 = call i64 @isblank(i8 signext %27)
%29 = icmp ne i64 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %26
%31 = call signext i8 (...) @getchar()
store i8 %31, i8* %3
br label %26
32: ; preds = %26
br label %33
33: ; preds = %37, %32
%34 = load i8, i8* %3
%35 = call i64 @isdigit(i8 signext %34)
%36 = icmp ne i64 %35, 0
br i1 %36, label %37, label %45
37: ; preds = %33
%38 = load i32, i32* %1
%39 = mul nsw i32 %38, 10
%40 = load i8, i8* %3
%41 = sext i8 %40 to i32
%42 = sub nsw i32 %41, 48
%43 = add nsw i32 %39, %42
store i32 %43, i32* %1
%44 = call signext i8 (...) @getchar()
store i8 %44, i8* %3
br label %33
45: ; preds = %33
%46 = load i8, i8* %3
%47 = load i32, i32* @stdin
%48 = call i32 @ungetc(i8 signext %46, i32 %47)
%49 = load i32, i32* %1
%50 = load i32, i32* %2
%51 = mul nsw i32 %49, %50
ret i32 %51
}

LLVM IR (-O2):
@stdin = global i32 0
define i32 @ReadInt() {
br label %1
1: ; preds = %1, %0
%2 = tail call signext i8 (...) @getchar()
%3 = tail call i64 @isblank(i8 signext %2)
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %1
5: ; preds = %1
switch i8 %2, label %10 [
i8 45, label %6
i8 43, label %7
]
6: ; preds = %5
br label %7
7: ; preds = %5, %6
%8 = phi i32 [ -1, %6 ], [ 1, %5 ]
%9 = tail call signext i8 (...) @getchar()
br label %10
10: ; preds = %5, %7
%11 = phi i32 [ %8, %7 ], [ 1, %5 ]
%12 = phi i8 [ %9, %7 ], [ %2, %5 ]
%13 = tail call i64 @isblank(i8 signext %12)
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %19
15: ; preds = %19, %10
%16 = phi i8 [ %12, %10 ], [ %20, %19 ]
%17 = tail call i64 @isdigit(i8 signext %16)
%18 = icmp eq i64 %17, 0
br i1 %18, label %33, label %23
19: ; preds = %10, %19
%20 = tail call signext i8 (...) @getchar()
%21 = tail call i64 @isblank(i8 signext %20)
%22 = icmp eq i64 %21, 0
br i1 %22, label %15, label %19
23: ; preds = %15, %23
%24 = phi i8 [ %30, %23 ], [ %16, %15 ]
%25 = phi i32 [ %29, %23 ], [ 0, %15 ]
%26 = mul nsw i32 %25, 10
%27 = sext i8 %24 to i32
%28 = add i32 %26, -48
%29 = add i32 %28, %27
%30 = tail call signext i8 (...) @getchar()
%31 = tail call i64 @isdigit(i8 signext %30)
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %23
33: ; preds = %23, %15
%34 = phi i32 [ 0, %15 ], [ %29, %23 ]
%35 = phi i8 [ %16, %15 ], [ %30, %23 ]
%36 = load i32, i32* @stdin
%37 = tail call i32 @ungetc(i8 signext %35, i32 %36)
%38 = mul nsw i32 %34, %11
ret i32 %38
}