#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 EOF;
int /*<<< orphan*/ exit(int);
char getchar_unlocked();
int fastscan_string_w(char *str, int buffer_size) {
  char c;
  int size_of_str = 0;
  c = getchar_unlocked();
  for (; c != ' ' && c != '\n' && c != '\0' && c != EOF;
       c = getchar_unlocked(), ++size_of_str) {
    if (size_of_str > buffer_size)
      exit(-1);
    str[size_of_str] = c;
  }
  return size_of_str;
}


x86 assembly (clang, -O0):
<fastscan_string_w>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x14(%rbp)
mov    $0x0,%al
call   1030 <getchar_unlocked@plt>
mov    %al,-0xd(%rbp)
movsbl -0xd(%rbp),%ecx
xor    %eax,%eax
cmp    $0x20,%ecx
mov    %al,-0x15(%rbp)
je     118c <fastscan_string_w+0x6c>
movsbl -0xd(%rbp),%ecx
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0x15(%rbp)
je     118c <fastscan_string_w+0x6c>
movsbl -0xd(%rbp),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x15(%rbp)
je     118c <fastscan_string_w+0x6c>
movsbl -0xd(%rbp),%eax
mov    0x2e67(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
setne  %al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
test   $0x1,%al
jne    119c <fastscan_string_w+0x7c>
jmp    11d8 <fastscan_string_w+0xb8>
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jle    11b2 <fastscan_string_w+0x92>
mov    $0xffffffff,%edi
call   1040 <exit@plt>
mov    -0xd(%rbp),%dl
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    $0x0,%al
call   1030 <getchar_unlocked@plt>
mov    %al,-0xd(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1140 <fastscan_string_w+0x20>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fastscan_string_w>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %esi,%ebx
mov    %rdi,%r14
xor    %eax,%eax
call   1030 <getchar_unlocked@plt>
test   %ebx,%ebx
mov    $0xffffffff,%r15d
cmovns %ebx,%r15d
add    $0x1,%r15d
mov    0x2e9c(%rip),%r12
movabs $0x100000401,%r13
xor    %ebx,%ebx
cmp    $0x20,%al
ja     1169 <fastscan_string_w+0x49>
nopl   0x0(%rax)
movzbl %al,%ecx
bt     %rcx,%r13
jb     1189 <fastscan_string_w+0x69>
cmp    (%r12),%al
je     1189 <fastscan_string_w+0x69>
cmp    %rbx,%r15
je     1195 <fastscan_string_w+0x75>
mov    %al,(%r14,%rbx,1)
xor    %eax,%eax
call   1030 <getchar_unlocked@plt>
add    $0x1,%rbx
cmp    $0x20,%al
jbe    1160 <fastscan_string_w+0x40>
jmp    1169 <fastscan_string_w+0x49>
mov    %ebx,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
mov    $0xffffffff,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@EOF = global i8 0
define i32 @fastscan_string_w(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8
%6 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
store i32 0, i32* %6
%7 = call signext i8 (...) @getchar_unlocked()
store i8 %7, i8* %5
br label %8
8: ; preds = %40, %2
%9 = load i8, i8* %5
%10 = sext i8 %9 to i32
%11 = icmp ne i32 %10, 32
br i1 %11, label %12, label %26
12: ; preds = %8
%13 = load i8, i8* %5
%14 = sext i8 %13 to i32
%15 = icmp ne i32 %14, 10
br i1 %15, label %16, label %26
16: ; preds = %12
%17 = load i8, i8* %5
%18 = sext i8 %17 to i32
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %26
20: ; preds = %16
%21 = load i8, i8* %5
%22 = sext i8 %21 to i32
%23 = load i8, i8* @EOF
%24 = sext i8 %23 to i32
%25 = icmp ne i32 %22, %24
br label %26
26: ; preds = %20, %16, %12, %8
%27 = phi i1 [ false, %16 ], [ false, %12 ], [ false, %8 ], [ %25, %20 ]
br i1 %27, label %28, label %44
28: ; preds = %26
%29 = load i32, i32* %6
%30 = load i32, i32* %4
%31 = icmp sgt i32 %29, %30
br i1 %31, label %32, label %34
32: ; preds = %28
%33 = call i32 @exit(i32 -1)
unreachable
34: ; preds = %28
%35 = load i8, i8* %5
%36 = load i8*, i8** %3
%37 = load i32, i32* %6
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8, i8* %36, i64 %38
store i8 %35, i8* %39
br label %40
40: ; preds = %34
%41 = call signext i8 (...) @getchar_unlocked()
store i8 %41, i8* %5
%42 = load i32, i32* %6
%43 = add nsw i32 %42, 1
store i32 %43, i32* %6
br label %8
44: ; preds = %26
%45 = load i32, i32* %6
ret i32 %45
}

LLVM IR (-O2):
@EOF = global i8 0
define i32 @fastscan_string_w(i8* nocapture writeonly %0, i32 %1) {
%3 = tail call signext i8 (...) @getchar_unlocked()
%4 = call i32 @llvm.smax.i32(i32 %1, i32 -1)
%5 = add i32 %4, 1
%6 = zext i32 %5 to i64
br label %7
7: ; preds = %17, %2
%8 = phi i64 [ %20, %17 ], [ 0, %2 ]
%9 = phi i8 [ %19, %17 ], [ %3, %2 ]
switch i8 %9, label %10 [
i8 32, label %21
i8 10, label %21
i8 0, label %21
]
10: ; preds = %7
%11 = load i8, i8* @EOF
%12 = icmp eq i8 %9, %11
br i1 %12, label %21, label %13
13: ; preds = %10
%14 = icmp eq i64 %8, %6
br i1 %14, label %15, label %17
15: ; preds = %13
%16 = tail call i32 @exit(i32 -1)
unreachable
17: ; preds = %13
%18 = getelementptr inbounds i8, i8* %0, i64 %8
store i8 %9, i8* %18
%19 = tail call signext i8 (...) @getchar_unlocked()
%20 = add nuw nsw i64 %8, 1
br label %7
21: ; preds = %7, %7, %7, %10
%22 = trunc i64 %8 to i32
ret i32 %22
}