#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;
char getchar();
char readUntilSpace(char *string) {
  char c;
  int i = 0;
  while (1) {
    c = getchar();
    if (c == ' ' || c == '\n' || c == EOF) {
      string[i] = '\0';
      return c;
    }
    string[i] = c;
    i++;
  }
}


x86 assembly (clang, -O0):
<readUntilSpace>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x10(%rbp)
mov    $0x0,%al
call   1030 <getchar@plt>
mov    %al,-0x9(%rbp)
movsbl -0x9(%rbp),%eax
cmp    $0x20,%eax
je     115d <readUntilSpace+0x4d>
movsbl -0x9(%rbp),%eax
cmp    $0xa,%eax
je     115d <readUntilSpace+0x4d>
movsbl -0x9(%rbp),%eax
mov    0x2e96(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
jne    1173 <readUntilSpace+0x63>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
movsbl -0x9(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret
mov    -0x9(%rbp),%dl
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1123 <readUntilSpace+0x13>

x86 assembly (clang, -O2):
<readUntilSpace>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
mov    0x2ec9(%rip),%r15
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1030 <getchar@plt>
cmp    $0xa,%al
je     114e <readUntilSpace+0x3e>
cmp    $0x20,%al
je     114e <readUntilSpace+0x3e>
cmp    (%r15),%al
je     114e <readUntilSpace+0x3e>
mov    %al,(%r14,%rbx,1)
add    $0x1,%rbx
jmp    1130 <readUntilSpace+0x20>
mov    %ebx,%ecx
movb   $0x0,(%r14,%rcx,1)
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@EOF = global i8 0
define signext i8 @readUntilSpace(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 = %1, %26
%6 = call signext i8 (...) @getchar()
store i8 %6, i8* %3
%7 = load i8, i8* %3
%8 = sext i8 %7 to i32
%9 = icmp eq i32 %8, 32
br i1 %9, label %20, label %10
10: ; preds = %5
%11 = load i8, i8* %3
%12 = sext i8 %11 to i32
%13 = icmp eq i32 %12, 10
br i1 %13, label %20, label %14
14: ; preds = %10
%15 = load i8, i8* %3
%16 = sext i8 %15 to i32
%17 = load i8, i8* @EOF
%18 = sext i8 %17 to i32
%19 = icmp eq i32 %16, %18
br i1 %19, label %20, label %26
20: ; preds = %14, %10, %5
%21 = load i8*, i8** %2
%22 = load i32, i32* %4
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %21, i64 %23
store i8 0, i8* %24
%25 = load i8, i8* %3
ret i8 %25
26: ; preds = %14
%27 = load i8, i8* %3
%28 = load i8*, i8** %2
%29 = load i32, i32* %4
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %28, i64 %30
store i8 %27, i8* %31
%32 = load i32, i32* %4
%33 = add nsw i32 %32, 1
store i32 %33, i32* %4
br label %5
}

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