#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();
int rin() {
  char c = getchar();
  while (c < '0' || c > '9')
    c = getchar();
  int ret = 0;
  while (c >= '0' && c <= '9') {
    ret = 10 * ret + c - 48;
    c = getchar();
  }
  return ret;
}


x86 assembly (clang, -O0):
<rin>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1030 <getchar@plt>
mov    %al,-0x1(%rbp)
movsbl -0x1(%rbp),%ecx
mov    $0x1,%al
cmp    $0x30,%ecx
mov    %al,-0x9(%rbp)
jl     1141 <rin+0x31>
movsbl -0x1(%rbp),%eax
cmp    $0x39,%eax
setg   %al
mov    %al,-0x9(%rbp)
mov    -0x9(%rbp),%al
test   $0x1,%al
jne    1151 <rin+0x41>
jmp    1160 <rin+0x50>
mov    $0x0,%al
call   1030 <getchar@plt>
mov    %al,-0x1(%rbp)
jmp    1122 <rin+0x12>
movl   $0x0,-0x8(%rbp)
movsbl -0x1(%rbp),%ecx
xor    %eax,%eax
cmp    $0x30,%ecx
mov    %al,-0xa(%rbp)
jl     1186 <rin+0x76>
movsbl -0x1(%rbp),%eax
cmp    $0x39,%eax
setle  %al
mov    %al,-0xa(%rbp)
mov    -0xa(%rbp),%al
test   $0x1,%al
jne    1196 <rin+0x86>
jmp    11b5 <rin+0xa5>
imul   $0xa,-0x8(%rbp),%eax
movsbl -0x1(%rbp),%ecx
add    %ecx,%eax
sub    $0x30,%eax
mov    %eax,-0x8(%rbp)
mov    $0x0,%al
call   1030 <getchar@plt>
mov    %al,-0x1(%rbp)
jmp    1167 <rin+0x57>
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rin>:
push   %rbx
xor    %eax,%eax
call   1030 <getchar@plt>
mov    %eax,%ecx
add    $0xc6,%cl
cmp    $0xf5,%cl
ja     113f <rin+0x2f>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %eax,%eax
call   1030 <getchar@plt>
lea    -0x3a(%rax),%ecx
cmp    $0xf6,%cl
jb     1130 <rin+0x20>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movzbl %al,%eax
lea    (%rbx,%rbx,4),%ecx
lea    (%rax,%rcx,2),%ebx
add    $0xffffffd0,%ebx
xor    %eax,%eax
call   1030 <getchar@plt>
mov    %eax,%ecx
add    $0xd0,%cl
cmp    $0xa,%cl
jb     1150 <rin+0x40>
mov    %ebx,%eax
pop    %rbx
ret

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

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