#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 fgetc_unlocked(int /*<<< orphan*/);
int /*<<< orphan*/ stdin;
unsigned read_uint(void) {
  unsigned i = 0;
  register int c = fgetc_unlocked(stdin);
  while (c >= '0' && c <= '9') {
    i = i * 10 + (c - '0');
    c = fgetc_unlocked(stdin);
  }
  return i;
}


x86 assembly (clang, -O0):
<read_uint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2ec2(%rip),%rax
mov    (%rax),%edi
call   1030 <fgetc_unlocked@plt>
mov    %eax,-0x8(%rbp)
xor    %eax,%eax
cmpl   $0x30,-0x8(%rbp)
mov    %al,-0x9(%rbp)
jl     1149 <read_uint+0x39>
cmpl   $0x39,-0x8(%rbp)
setle  %al
mov    %al,-0x9(%rbp)
mov    -0x9(%rbp),%al
test   $0x1,%al
jne    1159 <read_uint+0x49>
jmp    117e <read_uint+0x6e>
imul   $0xa,-0x4(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x30,%ecx
add    %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    0x2e79(%rip),%rax
mov    (%rax),%edi
call   1030 <fgetc_unlocked@plt>
mov    %eax,-0x8(%rbp)
jmp    1130 <read_uint+0x20>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_uint>:
push   %r14
push   %rbx
push   %rax
mov    0x2ecd(%rip),%r14
mov    (%r14),%edi
call   1030 <fgetc_unlocked@plt>
add    $0xffffffd0,%eax
xor    %ebx,%ebx
cmp    $0x9,%eax
ja     1146 <read_uint+0x36>
xor    %ebx,%ebx
nop
lea    (%rbx,%rbx,4),%ecx
lea    (%rax,%rcx,2),%ebx
mov    (%r14),%edi
call   1030 <fgetc_unlocked@plt>
add    $0xffffffd0,%eax
cmp    $0xa,%eax
jb     1130 <read_uint+0x20>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@stdin = global i32 0
define i32 @read_uint() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = load i32, i32* @stdin
%4 = call i32 @fgetc_unlocked(i32 %3)
store i32 %4, i32* %2
br label %5
5: ; preds = %13, %0
%6 = load i32, i32* %2
%7 = icmp sge i32 %6, 48
br i1 %7, label %8, label %11
8: ; preds = %5
%9 = load i32, i32* %2
%10 = icmp sle i32 %9, 57
br label %11
11: ; preds = %8, %5
%12 = phi i1 [ false, %5 ], [ %10, %8 ]
br i1 %12, label %13, label %21
13: ; preds = %11
%14 = load i32, i32* %1
%15 = mul i32 %14, 10
%16 = load i32, i32* %2
%17 = sub nsw i32 %16, 48
%18 = add i32 %15, %17
store i32 %18, i32* %1
%19 = load i32, i32* @stdin
%20 = call i32 @fgetc_unlocked(i32 %19)
store i32 %20, i32* %2
br label %5
21: ; preds = %11
%22 = load i32, i32* %1
ret i32 %22
}

LLVM IR (-O2):
@stdin = global i32 0
define i32 @read_uint() {
%1 = load i32, i32* @stdin
%2 = tail call i32 @fgetc_unlocked(i32 %1)
%3 = add i32 %2, -48
%4 = icmp ult i32 %3, 10
br i1 %4, label %5, label %14
5: ; preds = %0, %5
%6 = phi i32 [ %12, %5 ], [ %3, %0 ]
%7 = phi i32 [ %9, %5 ], [ 0, %0 ]
%8 = mul i32 %7, 10
%9 = add i32 %6, %8
%10 = load i32, i32* @stdin
%11 = tail call i32 @fgetc_unlocked(i32 %10)
%12 = add i32 %11, -48
%13 = icmp ult i32 %12, 10
br i1 %13, label %5, label %14
14: ; preds = %5, %0
%15 = phi i32 [ 0, %0 ], [ %9, %5 ]
ret i32 %15
}