#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 */
int /*<<< orphan*/ read(int /*<<< orphan*/, char *, int);
void scan_s(char *result_s, int *printed) {
  char *buf = result_s;
  read(0, buf, 1024);
  while (*buf != '\n' && *buf != 32 && *buf != '\0')
    buf++;
  *buf = '\0';
  (*printed)++;
}


x86 assembly (clang, -O0):
<scan_s>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
xor    %edi,%edi
mov    $0x400,%edx
call   1030 <read@plt>
mov    -0x18(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0x19(%rbp)
je     1172 <scan_s+0x62>
mov    -0x18(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x20,%ecx
mov    %al,-0x19(%rbp)
je     1172 <scan_s+0x62>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    1182 <scan_s+0x72>
jmp    1193 <scan_s+0x83>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1138 <scan_s+0x28>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<scan_s>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
xor    %edi,%edi
mov    %rbx,%rsi
mov    $0x400,%edx
call   1030 <read@plt>
movabs $0x100000401,%rax
jmp    1144 <scan_s+0x34>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%rbx
movzbl (%rbx),%ecx
cmp    $0x20,%rcx
ja     1140 <scan_s+0x30>
bt     %rcx,%rax
jae    1140 <scan_s+0x30>
movb   $0x0,(%rbx)
addl   $0x1,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @scan_s(i8* %0, i32* %1) {
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i8*
store i8* %0, i8** %3
store i32* %1, i32** %4
%6 = load i8*, i8** %3
store i8* %6, i8** %5
%7 = load i8*, i8** %5
%8 = call i32 @read(i32 0, i8* %7, i32 1024)
br label %9
9: ; preds = %26, %2
%10 = load i8*, i8** %5
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = icmp ne i32 %12, 10
br i1 %13, label %14, label %24
14: ; preds = %9
%15 = load i8*, i8** %5
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp ne i32 %17, 32
br i1 %18, label %19, label %24
19: ; preds = %14
%20 = load i8*, i8** %5
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp ne i32 %22, 0
br label %24
24: ; preds = %19, %14, %9
%25 = phi i1 [ false, %14 ], [ false, %9 ], [ %23, %19 ]
br i1 %25, label %26, label %29
26: ; preds = %24
%27 = load i8*, i8** %5
%28 = getelementptr inbounds i8, i8* %27, i32 1
store i8* %28, i8** %5
br label %9
29: ; preds = %24
%30 = load i8*, i8** %5
store i8 0, i8* %30
%31 = load i32*, i32** %4
%32 = load i32, i32* %31
%33 = add nsw i32 %32, 1
store i32 %33, i32* %31
ret void
}

LLVM IR (-O2):
define void @scan_s(i8* nocapture %0, i32* nocapture %1) {
%3 = tail call i32 @read(i32 0, i8* %0, i32 1024)
br label %4
4: ; preds = %7, %2
%5 = phi i8* [ %0, %2 ], [ %8, %7 ]
%6 = load i8, i8* %5
switch i8 %6, label %7 [
i8 10, label %9
i8 32, label %9
i8 0, label %9
]
7: ; preds = %4
%8 = getelementptr inbounds i8, i8* %5, i64 1
br label %4
9: ; preds = %4, %4, %4
store i8 0, i8* %5
%10 = load i32, i32* %1
%11 = add nsw i32 %10, 1
store i32 %11, i32* %1
ret void
}