#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();
long numbread() {
  char ch;
  long b;
  ch = ' ';
  while ((ch < '0') || (ch > '9')) {
    ch = getchar();
  }
  b = 0;
  while ((ch >= '0') && (ch <= '9')) {
    b = b * 10 + (long)(ch - '0');
    ch = getchar();
  }
  return (b);
}


x86 assembly (clang, -O0):
<numbread>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movb   $0x20,-0x1(%rbp)
movsbl -0x1(%rbp),%ecx
mov    $0x1,%al
cmp    $0x30,%ecx
mov    %al,-0x11(%rbp)
jl     113b <numbread+0x2b>
movsbl -0x1(%rbp),%eax
cmp    $0x39,%eax
setg   %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    114b <numbread+0x3b>
jmp    115a <numbread+0x4a>
mov    $0x0,%al
call   1030 <getchar@plt>
mov    %al,-0x1(%rbp)
jmp    111c <numbread+0xc>
movq   $0x0,-0x10(%rbp)
movsbl -0x1(%rbp),%ecx
xor    %eax,%eax
cmp    $0x30,%ecx
mov    %al,-0x12(%rbp)
jl     1181 <numbread+0x71>
movsbl -0x1(%rbp),%eax
cmp    $0x39,%eax
setle  %al
mov    %al,-0x12(%rbp)
mov    -0x12(%rbp),%al
test   $0x1,%al
jne    1191 <numbread+0x81>
jmp    11b6 <numbread+0xa6>
imul   $0xa,-0x10(%rbp),%rax
movsbl -0x1(%rbp),%ecx
sub    $0x30,%ecx
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    $0x0,%al
call   1030 <getchar@plt>
mov    %al,-0x1(%rbp)
jmp    1162 <numbread+0x52>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<numbread>:
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
jb     1120 <numbread+0x10>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    (%rbx,%rbx,4),%rcx
movzbl %al,%eax
add    $0xffffffd0,%eax
lea    (%rax,%rcx,2),%rbx
xor    %eax,%eax
call   1030 <getchar@plt>
mov    %eax,%ecx
add    $0xd0,%cl
cmp    $0xa,%cl
jb     1140 <numbread+0x30>
mov    %rbx,%rax
pop    %rbx
ret

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

LLVM IR (-O2):
define i64 @numbread() {
br label %1
1: ; preds = %0, %1
%2 = tail call signext i8 (...) @getchar()
%3 = add i8 %2, -58
%4 = icmp ult i8 %3, -10
br i1 %4, label %1, label %5
5: ; preds = %1, %5
%6 = phi i64 [ %12, %5 ], [ 0, %1 ]
%7 = phi i8 [ %13, %5 ], [ %2, %1 ]
%8 = zext i8 %7 to i64
%9 = mul nsw i64 %6, 10
%10 = add nuw nsw i64 %8, 4294967248
%11 = and i64 %10, 4294967295
%12 = add nsw i64 %11, %9
%13 = tail call signext i8 (...) @getchar()
%14 = add i8 %13, -48
%15 = icmp ult i8 %14, 10
br i1 %15, label %5, label %16
16: ; preds = %5
ret i64 %12
}