#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 in() {
  char ch = getchar();
  int x = 0;
  while (ch < '0' || ch > '9')
    ch = getchar();
  while (ch >= '0' && ch <= '9')
    x = x * 10 + ch - '0', ch = getchar();
  return x;
}


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

x86 assembly (clang, -O2):
<in>:
push   %rbx
xor    %eax,%eax
call   1030 <getchar@plt>
mov    %eax,%ecx
add    $0xc6,%cl
cmp    $0xf5,%cl
ja     113f <in+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 <in+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 <in+0x40>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @in() {
%1 = alloca i8
%2 = alloca i32
%3 = call signext i8 (...) @getchar()
store i8 %3, i8* %1
store i32 0, i32* %2
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
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 %28, 10
%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 @in() {
%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
}