#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();
char *getstr(char *array) {
  char c;
  int i = 0;
  while ((c = getchar()) != ' ' && (c != '\t') && (c != '\n'))
    array[i++] = c;
  array[i] = '\0';
  while (c != '\n')
    c = getchar();
  return array;
}


x86 assembly (clang, -O0):
<getstr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x10(%rbp)
mov    $0x0,%al
call   1030 <getchar@plt>
mov    %al,-0x9(%rbp)
movsbl %al,%ecx
xor    %eax,%eax
cmp    $0x20,%ecx
mov    %al,-0x11(%rbp)
je     115d <getstr+0x4d>
movsbl -0x9(%rbp),%ecx
xor    %eax,%eax
cmp    $0x9,%ecx
mov    %al,-0x11(%rbp)
je     115d <getstr+0x4d>
movsbl -0x9(%rbp),%eax
cmp    $0xa,%eax
setne  %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    116d <getstr+0x5d>
jmp    118a <getstr+0x7a>
mov    -0x9(%rbp),%dl
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x10(%rbp)
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
jmp    1123 <getstr+0x13>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
movsbl -0x9(%rbp),%eax
cmp    $0xa,%eax
je     11b2 <getstr+0xa2>
mov    $0x0,%al
call   1030 <getchar@plt>
mov    %al,-0x9(%rbp)
jmp    1196 <getstr+0x86>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getstr>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
movabs $0x100000600,%r15
xor    %ebx,%ebx
jmp    1138 <getstr+0x28>
cs nopw 0x0(%rax,%rax,1)
mov    %al,(%r14,%rbx,1)
add    $0x1,%rbx
xor    %eax,%eax
call   1030 <getchar@plt>
cmp    $0x20,%al
ja     1130 <getstr+0x20>
movzbl %al,%ecx
bt     %rcx,%r15
jae    1130 <getstr+0x20>
mov    %ebx,%ecx
movb   $0x0,(%r14,%rcx,1)
cmp    $0xa,%al
je     116b <getstr+0x5b>
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1030 <getchar@plt>
cmp    $0xa,%al
jne    1160 <getstr+0x50>
mov    %r14,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define i8* @getstr(i8* returned writeonly %0) {
br label %2
2: ; preds = %5, %1
%3 = phi i64 [ %6, %5 ], [ 0, %1 ]
%4 = tail call signext i8 (...) @getchar()
switch i8 %4, label %5 [
i8 32, label %8
i8 10, label %8
i8 9, label %8
]
5: ; preds = %2
%6 = add nuw i64 %3, 1
%7 = getelementptr inbounds i8, i8* %0, i64 %3
store i8 %4, i8* %7
br label %2
8: ; preds = %2, %2, %2
%9 = and i64 %3, 4294967295
%10 = getelementptr inbounds i8, i8* %0, i64 %9
store i8 0, i8* %10
%11 = icmp eq i8 %4, 10
br i1 %11, label %15, label %12
12: ; preds = %8, %12
%13 = tail call signext i8 (...) @getchar()
%14 = icmp eq i8 %13, 10
br i1 %14, label %15, label %12
15: ; preds = %12, %8
ret i8* %0
}