#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 */
size_t fread(char *, int, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdin;
int main(int argc, char *argv[]) {
  (void)argc;
  (void)argv;
  char buffer[1024 + 1];
  buffer[1024] = '\0';
  size_t bytes;
  do {
    bytes = fread(buffer, 1, 1024, stdin);
    buffer[bytes] = '\0';
    for (size_t i = 0; i < 1024 && buffer[i + 1] != '\0'; ++i) {
      if (buffer[i] == ' ') {
        buffer[i] = '\n';
      }
    }
    printf("%s", buffer);
  } while (bytes != 0);
  printf("\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x440,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movb   $0x0,-0x20(%rbp)
lea    -0x420(%rbp),%rdi
mov    0x2e9d(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%esi
mov    $0x400,%edx
call   1030 <fread@plt>
mov    %rax,-0x428(%rbp)
mov    -0x428(%rbp),%rax
movb   $0x0,-0x420(%rbp,%rax,1)
movq   $0x0,-0x430(%rbp)
xor    %eax,%eax
cmpq   $0x400,-0x430(%rbp)
mov    %al,-0x431(%rbp)
jae    11b1 <main+0x91>
mov    -0x430(%rbp),%rax
movsbl -0x41f(%rbp,%rax,1),%eax
ff
cmp    $0x0,%eax
setne  %al
mov    %al,-0x431(%rbp)
mov    -0x431(%rbp),%al
test   $0x1,%al
jne    11c4 <main+0xa4>
jmp    1207 <main+0xe7>
mov    -0x430(%rbp),%rax
movsbl -0x420(%rbp,%rax,1),%eax
ff
cmp    $0x20,%eax
jne    11eb <main+0xcb>
mov    -0x430(%rbp),%rax
movb   $0xa,-0x420(%rbp,%rax,1)
0a
jmp    11f0 <main+0xd0>
mov    -0x430(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x430(%rbp)
jmp    117d <main+0x5d>
lea    -0x420(%rbp),%rsi
lea    0xdeb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpq   $0x0,-0x428(%rbp)
jne    113d <main+0x1d>
lea    0xdd2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x440,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x408,%rsp
movb   $0x0,0x400(%rsp)
mov    0x2e9b(%rip),%r12
mov    %rsp,%r15
lea    0xea9(%rip),%r14
jmp    1172 <main+0x42>
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
test   %rbx,%rbx
je     11d6 <main+0xa6>
mov    (%r12),%ecx
mov    %r15,%rdi
mov    $0x1,%esi
mov    $0x400,%edx
call   1040 <fread@plt>
mov    %rax,%rbx
movb   $0x0,(%rsp,%rax,1)
xor    %eax,%eax
jmp    11ac <main+0x7c>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rcx,%rax
cmp    $0x400,%rcx
je     1160 <main+0x30>
cmpb   $0x0,0x1(%rsp,%rax,1)
je     1160 <main+0x30>
cmpb   $0x20,(%rsp,%rax,1)
jne    11bd <main+0x8d>
movb   $0xa,(%rsp,%rax,1)
cmpb   $0x0,0x2(%rsp,%rax,1)
je     1160 <main+0x30>
lea    0x2(%rax),%rcx
cmpb   $0x20,0x1(%rsp,%rax,1)
jne    11a0 <main+0x70>
movb   $0xa,0x1(%rsp,%rax,1)
jmp    11a0 <main+0x70>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x408,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stdin = global i32 0
@.str = [3 x i8] c"%s\00"
@.str.1 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [1025 x i8]
%7 = alloca i64
%8 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds [1025 x i8], [1025 x i8]* %6, i64 0, i64 1024
store i8 0, i8* %11
br label %12
12: ; preds = %46, %2
%13 = getelementptr inbounds [1025 x i8], [1025 x i8]* %6, i64 0, i64 0
%14 = load i32, i32* @stdin
%15 = call i64 @fread(i8* %13, i32 1, i32 1024, i32 %14)
store i64 %15, i64* %7
%16 = load i64, i64* %7
%17 = getelementptr inbounds [1025 x i8], [1025 x i8]* %6, i64 0, i64 %16
store i8 0, i8* %17
store i64 0, i64* %8
br label %18
18: ; preds = %40, %12
%19 = load i64, i64* %8
%20 = icmp ult i64 %19, 1024
br i1 %20, label %21, label %28
21: ; preds = %18
%22 = load i64, i64* %8
%23 = add i64 %22, 1
%24 = getelementptr inbounds [1025 x i8], [1025 x i8]* %6, i64 0, i64 %23
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp ne i32 %26, 0
br label %28
28: ; preds = %21, %18
%29 = phi i1 [ false, %18 ], [ %27, %21 ]
br i1 %29, label %30, label %43
30: ; preds = %28
%31 = load i64, i64* %8
%32 = getelementptr inbounds [1025 x i8], [1025 x i8]* %6, i64 0, i64 %31
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
%35 = icmp eq i32 %34, 32
br i1 %35, label %36, label %39
36: ; preds = %30
%37 = load i64, i64* %8
%38 = getelementptr inbounds [1025 x i8], [1025 x i8]* %6, i64 0, i64 %37
store i8 10, i8* %38
br label %39
39: ; preds = %36, %30
br label %40
40: ; preds = %39
%41 = load i64, i64* %8
%42 = add i64 %41, 1
store i64 %42, i64* %8
br label %18
43: ; preds = %28
%44 = getelementptr inbounds [1025 x i8], [1025 x i8]* %6, i64 0, i64 0
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %44)
br label %46
46: ; preds = %43
%47 = load i64, i64* %7
%48 = icmp ne i64 %47, 0
br i1 %48, label %12, label %49
49: ; preds = %46
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%51 = load i32, i32* %3
ret i32 %51
}

LLVM IR (-O2):
@stdin = global i32 0
@.str = [3 x i8] c"%s\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [1025 x i8]
%4 = getelementptr inbounds [1025 x i8], [1025 x i8]* %3, i64 0, i64 0
%5 = getelementptr inbounds [1025 x i8], [1025 x i8]* %3, i64 0, i64 1024
store i8 0, i8* %5
br label %6
6: ; preds = %16, %2
%7 = load i32, i32* @stdin
%8 = call i64 @fread(i8* %4, i32 1, i32 1024, i32 %7)
%9 = getelementptr inbounds [1025 x i8], [1025 x i8]* %3, i64 0, i64 %8
store i8 0, i8* %9
br label %10
10: ; preds = %34, %6
%11 = phi i64 [ 0, %6 ], [ %25, %34 ]
%12 = or i64 %11, 1
%13 = getelementptr inbounds [1025 x i8], [1025 x i8]* %3, i64 0, i64 %12
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %34, %24, %10
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %4)
%18 = icmp eq i64 %8, 0
br i1 %18, label %36, label %6
19: ; preds = %10
%20 = getelementptr inbounds [1025 x i8], [1025 x i8]* %3, i64 0, i64 %11
%21 = load i8, i8* %20
%22 = icmp eq i8 %21, 32
br i1 %22, label %23, label %24
23: ; preds = %19
store i8 10, i8* %20
br label %24
24: ; preds = %19, %23
%25 = add nuw nsw i64 %11, 2
%26 = getelementptr inbounds [1025 x i8], [1025 x i8]* %3, i64 0, i64 %25
%27 = load i8, i8* %26
%28 = icmp eq i8 %27, 0
br i1 %28, label %16, label %29
29: ; preds = %24
%30 = getelementptr inbounds [1025 x i8], [1025 x i8]* %3, i64 0, i64 %12
%31 = load i8, i8* %30
%32 = icmp eq i8 %31, 32
br i1 %32, label %33, label %34
33: ; preds = %29
store i8 10, i8* %30
br label %34
34: ; preds = %33, %29
%35 = icmp eq i64 %25, 1024
br i1 %35, label %16, label %10
36: ; preds = %16
%37 = call i32 @putchar(i32 10)
ret i32 0
}