#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 */
int getchar();
scalar_t__ isdigit(int);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ ungetc(int, int /*<<< orphan*/);
int number(int c) {
  int n = 0;
  while (isdigit(c)) {
    n = n * 10 + c - '0';
    c = getchar();
  }
  ungetc(c, stdin);
  if (n >= 100)
    return (-1);
  return (n);
}


x86 assembly (clang, -O0):
<number>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     1170 <number+0x40>
imul   $0xa,-0xc(%rbp),%eax
add    -0x8(%rbp),%eax
sub    $0x30,%eax
mov    %eax,-0xc(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x8(%rbp)
jmp    1142 <number+0x12>
mov    -0x8(%rbp),%edi
mov    0x2e6e(%rip),%rax
mov    (%rax),%esi
call   1050 <ungetc@plt>
cmpl   $0x64,-0xc(%rbp)
jl     1197 <number+0x67>
movl   $0xffffffff,-0x4(%rbp)
jmp    119d <number+0x6d>
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<number>:
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebx
call   1030 <isdigit@plt>
test   %rax,%rax
je     1190 <number+0x60>
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    (%r14,%r14,4),%eax
lea    (%rbx,%rax,2),%r14d
add    $0xffffffd0,%r14d
xor    %eax,%eax
call   1040 <getchar@plt>
mov    %eax,%ebx
mov    %eax,%edi
call   1030 <isdigit@plt>
test   %rax,%rax
jne    1150 <number+0x20>
mov    0x2e70(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
call   1050 <ungetc@plt>
cmp    $0x64,%r14d
mov    $0xffffffff,%eax
cmovl  %r14d,%eax
jmp    11a2 <number+0x72>
mov    0x2e51(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
call   1050 <ungetc@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@stdin = global i32 0
define i32 @number(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
store i32 0, i32* %4
br label %5
5: ; preds = %9, %1
%6 = load i32, i32* %3
%7 = call i64 @isdigit(i32 %6)
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %16
9: ; preds = %5
%10 = load i32, i32* %4
%11 = mul nsw i32 %10, 10
%12 = load i32, i32* %3
%13 = add nsw i32 %11, %12
%14 = sub nsw i32 %13, 48
store i32 %14, i32* %4
%15 = call i32 (...) @getchar()
store i32 %15, i32* %3
br label %5
16: ; preds = %5
%17 = load i32, i32* %3
%18 = load i32, i32* @stdin
%19 = call i32 @ungetc(i32 %17, i32 %18)
%20 = load i32, i32* %4
%21 = icmp sge i32 %20, 100
br i1 %21, label %22, label %23
22: ; preds = %16
store i32 -1, i32* %2
br label %25
23: ; preds = %16
%24 = load i32, i32* %4
store i32 %24, i32* %2
br label %25
25: ; preds = %23, %22
%26 = load i32, i32* %2
ret i32 %26
}

LLVM IR (-O2):
@stdin = global i32 0
define i32 @number(i32 %0) {
%2 = tail call i64 @isdigit(i32 %0)
%3 = icmp eq i64 %2, 0
br i1 %3, label %4, label %7
4: ; preds = %1
%5 = load i32, i32* @stdin
%6 = tail call i32 @ungetc(i32 %0, i32 %5)
br label %21
7: ; preds = %1, %7
%8 = phi i32 [ %12, %7 ], [ 0, %1 ]
%9 = phi i32 [ %13, %7 ], [ %0, %1 ]
%10 = mul nsw i32 %8, 10
%11 = add i32 %9, -48
%12 = add i32 %11, %10
%13 = tail call i32 (...) @getchar()
%14 = tail call i64 @isdigit(i32 %13)
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %7
16: ; preds = %7
%17 = load i32, i32* @stdin
%18 = tail call i32 @ungetc(i32 %13, i32 %17)
%19 = icmp sgt i32 %12, 99
%20 = select i1 %19, i32 -1, i32 %12
br label %21
21: ; preds = %16, %4
%22 = phi i32 [ 0, %4 ], [ %20, %16 ]
ret i32 %22
}