#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
char fgetc(int /*<<< orphan*/ *);
char getc(int /*<<< orphan*/ *);
long numbread(FILE *fily) {
  char ch;
  long b;
  ch = ' ';
  while ((ch < '0') || (ch > '9')) {
    ch = fgetc(fily);
  }
  b = 0;
  while ((ch >= '0') && (ch <= '9')) {
    b = b * 10 + (long)(ch - '0');
    ch = getc(fily);
  }
  return (b);
}


x86 assembly (clang, -O0):
<numbread>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movb   $0x20,-0x9(%rbp)
movsbl -0x9(%rbp),%ecx
mov    $0x1,%al
cmp    $0x30,%ecx
mov    %al,-0x19(%rbp)
jl     114f <numbread+0x2f>
movsbl -0x9(%rbp),%eax
cmp    $0x39,%eax
setg   %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    115f <numbread+0x3f>
jmp    1170 <numbread+0x50>
mov    -0x8(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %al,-0x9(%rbp)
jmp    1130 <numbread+0x10>
movq   $0x0,-0x18(%rbp)
movsbl -0x9(%rbp),%ecx
xor    %eax,%eax
cmp    $0x30,%ecx
mov    %al,-0x1a(%rbp)
jl     1197 <numbread+0x77>
movsbl -0x9(%rbp),%eax
cmp    $0x39,%eax
setle  %al
mov    %al,-0x1a(%rbp)
mov    -0x1a(%rbp),%al
test   $0x1,%al
jne    11a7 <numbread+0x87>
jmp    11ce <numbread+0xae>
imul   $0xa,-0x18(%rbp),%rax
movsbl -0x9(%rbp),%ecx
sub    $0x30,%ecx
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <getc@plt>
mov    %al,-0x9(%rbp)
jmp    1178 <numbread+0x58>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<numbread>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1030 <fgetc@plt>
lea    -0x3a(%rax),%ecx
cmp    $0xf6,%cl
jb     1130 <numbread+0x10>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    (%rbx,%rbx,4),%rcx
movzbl %al,%eax
add    $0xffffffd0,%eax
lea    (%rax,%rcx,2),%rbx
mov    %r14,%rdi
call   1040 <getc@plt>
mov    %eax,%ecx
add    $0xd0,%cl
cmp    $0xa,%cl
jb     1150 <numbread+0x30>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i64 @numbread(i32* %0) {
%2 = alloca i32*
%3 = alloca i8
%4 = alloca i64
store i32* %0, i32** %2
store i8 32, i8* %3
br label %5
5: ; preds = %15, %1
%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 %18
15: ; preds = %13
%16 = load i32*, i32** %2
%17 = call signext i8 @fgetc(i32* %16)
store i8 %17, i8* %3
br label %5
18: ; preds = %13
store i64 0, i64* %4
br label %19
19: ; preds = %29, %18
%20 = load i8, i8* %3
%21 = sext i8 %20 to i32
%22 = icmp sge i32 %21, 48
br i1 %22, label %23, label %27
23: ; preds = %19
%24 = load i8, i8* %3
%25 = sext i8 %24 to i32
%26 = icmp sle i32 %25, 57
br label %27
27: ; preds = %23, %19
%28 = phi i1 [ false, %19 ], [ %26, %23 ]
br i1 %28, label %29, label %39
29: ; preds = %27
%30 = load i64, i64* %4
%31 = mul nsw i64 %30, 10
%32 = load i8, i8* %3
%33 = sext i8 %32 to i32
%34 = sub nsw i32 %33, 48
%35 = sext i32 %34 to i64
%36 = add nsw i64 %31, %35
store i64 %36, i64* %4
%37 = load i32*, i32** %2
%38 = call signext i8 @getc(i32* %37)
store i8 %38, i8* %3
br label %19
39: ; preds = %27
%40 = load i64, i64* %4
ret i64 %40
}

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