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


x86 assembly (clang, -O0):
<read_int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1030 <getchar_unlocked@plt>
mov    %al,-0x5(%rbp)
movsbl -0x5(%rbp),%ecx
mov    $0x1,%al
cmp    $0x30,%ecx
mov    %al,-0x6(%rbp)
jl     1148 <read_int+0x38>
movsbl -0x5(%rbp),%eax
cmp    $0x39,%eax
setg   %al
mov    %al,-0x6(%rbp)
mov    -0x6(%rbp),%al
test   $0x1,%al
jne    1158 <read_int+0x48>
jmp    1167 <read_int+0x57>
mov    $0x0,%al
call   1030 <getchar_unlocked@plt>
mov    %al,-0x5(%rbp)
jmp    1129 <read_int+0x19>
jmp    116c <read_int+0x5c>
movsbl -0x5(%rbp),%ecx
xor    %eax,%eax
cmp    $0x30,%ecx
mov    %al,-0x7(%rbp)
jl     118b <read_int+0x7b>
movsbl -0x5(%rbp),%eax
cmp    $0x39,%eax
setle  %al
mov    %al,-0x7(%rbp)
mov    -0x7(%rbp),%al
test   $0x1,%al
jne    119b <read_int+0x8b>
jmp    11ba <read_int+0xaa>
imul   $0xa,-0x4(%rbp),%eax
movsbl -0x5(%rbp),%ecx
add    %ecx,%eax
sub    $0x30,%eax
mov    %eax,-0x4(%rbp)
mov    $0x0,%al
call   1030 <getchar_unlocked@plt>
mov    %al,-0x5(%rbp)
jmp    116c <read_int+0x5c>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_int>:
push   %rbx
xor    %eax,%eax
call   1030 <getchar_unlocked@plt>
mov    %eax,%ecx
add    $0xc6,%cl
cmp    $0xf5,%cl
ja     113f <read_int+0x2f>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %eax,%eax
call   1030 <getchar_unlocked@plt>
lea    -0x3a(%rax),%ecx
cmp    $0xf6,%cl
jb     1130 <read_int+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_unlocked@plt>
mov    %eax,%ecx
add    $0xd0,%cl
cmp    $0xa,%cl
jb     1150 <read_int+0x40>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @read_int() {
%1 = alloca i32
%2 = alloca i8
store i32 0, i32* %1
%3 = call signext i8 (...) @getchar_unlocked()
store i8 %3, i8* %2
br label %4
4: ; preds = %14, %0
%5 = load i8, i8* %2
%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* %2
%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_unlocked()
store i8 %15, i8* %2
br label %4
16: ; preds = %12
br label %17
17: ; preds = %27, %16
%18 = load i8, i8* %2
%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* %2
%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* %1
%29 = mul nsw i32 10, %28
%30 = load i8, i8* %2
%31 = sext i8 %30 to i32
%32 = add nsw i32 %29, %31
%33 = sub nsw i32 %32, 48
store i32 %33, i32* %1
%34 = call signext i8 (...) @getchar_unlocked()
store i8 %34, i8* %2
br label %17
35: ; preds = %25
%36 = load i32, i32* %1
ret i32 %36
}

LLVM IR (-O2):
define i32 @read_int() {
%1 = tail call signext i8 (...) @getchar_unlocked()
%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_unlocked()
%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 i8 [ %17, %10 ], [ %9, %8 ]
%12 = phi i32 [ %16, %10 ], [ 0, %8 ]
%13 = zext i8 %11 to i32
%14 = mul nsw i32 %12, 10
%15 = add i32 %14, -48
%16 = add i32 %15, %13
%17 = tail call signext i8 (...) @getchar_unlocked()
%18 = add i8 %17, -48
%19 = icmp ult i8 %18, 10
br i1 %19, label %10, label %20
20: ; preds = %10
ret i32 %16
}