#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();
int readn(int *n) {
  int c = 0;
  *n = 0;
  for (; !((c >= '0') && (c <= '9')); c = getchar())
    ;
  for (; ((c >= '0') && (c <= '9')); c = getchar())
    *n = (*n) * 10 + c - '0';
  return (*n);
}


x86 assembly (clang, -O0):
<readn>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movl   $0x0,(%rax)
xor    %eax,%eax
cmpl   $0x30,-0xc(%rbp)
mov    %al,-0xd(%rbp)
jl     1146 <readn+0x36>
cmpl   $0x39,-0xc(%rbp)
setle  %al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
xor    $0xff,%al
test   $0x1,%al
jne    1158 <readn+0x48>
jmp    116c <readn+0x5c>
jmp    115d <readn+0x4d>
mov    $0x0,%al
call   1030 <getchar@plt>
mov    %eax,-0xc(%rbp)
jmp    112d <readn+0x1d>
jmp    1171 <readn+0x61>
xor    %eax,%eax
cmpl   $0x30,-0xc(%rbp)
mov    %al,-0xe(%rbp)
jl     118a <readn+0x7a>
cmpl   $0x39,-0xc(%rbp)
setle  %al
mov    %al,-0xe(%rbp)
mov    -0xe(%rbp),%al
test   $0x1,%al
jne    119a <readn+0x8a>
jmp    11bc <readn+0xac>
mov    -0x8(%rbp),%rax
imul   $0xa,(%rax),%ecx
add    -0xc(%rbp),%ecx
sub    $0x30,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
mov    $0x0,%al
call   1030 <getchar@plt>
mov    %eax,-0xc(%rbp)
jmp    1171 <readn+0x61>
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readn>:
push   %rbx
mov    %rdi,%rbx
movl   $0x0,(%rdi)
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1030 <getchar@plt>
lea    -0x3a(%rax),%ecx
cmp    $0xfffffff6,%ecx
jb     1120 <readn+0x10>
nop
mov    (%rbx),%ecx
lea    (%rcx,%rcx,4),%ecx
lea    (%rax,%rcx,2),%eax
add    $0xffffffd0,%eax
mov    %eax,(%rbx)
xor    %eax,%eax
call   1030 <getchar@plt>
mov    %eax,%ecx
add    $0xffffffd0,%ecx
cmp    $0xa,%ecx
jb     1130 <readn+0x20>
mov    (%rbx),%eax
pop    %rbx
ret

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

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