#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();
void scan(int *pn) {
  int sign = 1;
  int n = 0;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-')
      sign = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9')
    n = (n << 3) + (n << 1) + c - '0', c = getchar();
  n = n * sign;
  *pn = n;
}


x86 assembly (clang, -O0):
<scan>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    $0x0,%al
call   1030 <getchar@plt>
mov    %al,-0x11(%rbp)
movsbl -0x11(%rbp),%ecx
mov    $0x1,%al
cmp    $0x30,%ecx
mov    %al,-0x12(%rbp)
jl     1153 <scan+0x43>
movsbl -0x11(%rbp),%eax
cmp    $0x39,%eax
setg   %al
mov    %al,-0x12(%rbp)
mov    -0x12(%rbp),%al
test   $0x1,%al
jne    1163 <scan+0x53>
jmp    1186 <scan+0x76>
movsbl -0x11(%rbp),%eax
cmp    $0x2d,%eax
jne    1177 <scan+0x67>
movl   $0xffffffff,-0xc(%rbp)
mov    $0x0,%al
call   1030 <getchar@plt>
mov    %al,-0x11(%rbp)
jmp    1134 <scan+0x24>
jmp    118b <scan+0x7b>
movsbl -0x11(%rbp),%ecx
xor    %eax,%eax
cmp    $0x30,%ecx
mov    %al,-0x13(%rbp)
jl     11aa <scan+0x9a>
movsbl -0x11(%rbp),%eax
cmp    $0x39,%eax
setle  %al
mov    %al,-0x13(%rbp)
mov    -0x13(%rbp),%al
test   $0x1,%al
jne    11ba <scan+0xaa>
jmp    11e3 <scan+0xd3>
mov    -0x10(%rbp),%eax
shl    $0x3,%eax
mov    -0x10(%rbp),%ecx
shl    $0x1,%ecx
add    %ecx,%eax
movsbl -0x11(%rbp),%ecx
add    %ecx,%eax
sub    $0x30,%eax
mov    %eax,-0x10(%rbp)
mov    $0x0,%al
call   1030 <getchar@plt>
mov    %al,-0x11(%rbp)
jmp    118b <scan+0x7b>
mov    -0x10(%rbp),%eax
imul   -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<scan>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%r14
xor    %eax,%eax
call   1030 <getchar@plt>
mov    %eax,%ecx
add    $0xc6,%cl
mov    $0x1,%ebp
cmp    $0xf5,%cl
ja     1156 <scan+0x46>
mov    $0x1,%ebp
mov    $0xffffffff,%ebx
nopw   0x0(%rax,%rax,1)
cmp    $0x2d,%al
cmove  %ebx,%ebp
xor    %eax,%eax
call   1030 <getchar@plt>
mov    %eax,%ecx
add    $0xc6,%cl
cmp    $0xf6,%cl
jb     1140 <scan+0x30>
xor    %ebx,%ebx
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     1160 <scan+0x50>
imul   %ebp,%ebx
mov    %ebx,(%r14)
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
define void @scan(i32* nocapture writeonly %0) {
%2 = tail call signext i8 (...) @getchar()
%3 = add i8 %2, -58
%4 = icmp ult i8 %3, -10
br i1 %4, label %8, label %5
5: ; preds = %8, %1
%6 = phi i32 [ 1, %1 ], [ %12, %8 ]
%7 = phi i8 [ %2, %1 ], [ %13, %8 ]
br label %16
8: ; preds = %1, %8
%9 = phi i8 [ %13, %8 ], [ %2, %1 ]
%10 = phi i32 [ %12, %8 ], [ 1, %1 ]
%11 = icmp eq i8 %9, 45
%12 = select i1 %11, i32 -1, i32 %10
%13 = tail call signext i8 (...) @getchar()
%14 = add i8 %13, -58
%15 = icmp ult i8 %14, -10
br i1 %15, label %8, label %5
16: ; preds = %5, %16
%17 = phi i8 [ %23, %16 ], [ %7, %5 ]
%18 = phi i32 [ %22, %16 ], [ 0, %5 ]
%19 = zext i8 %17 to i32
%20 = mul i32 %18, 10
%21 = add i32 %20, -48
%22 = add i32 %21, %19
%23 = tail call signext i8 (...) @getchar()
%24 = add i8 %23, -48
%25 = icmp ult i8 %24, 10
br i1 %25, label %16, label %26
26: ; preds = %16
%27 = mul nsw i32 %22, %6
store i32 %27, i32* %0
ret void
}