#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 EOF;
int getchar();
int /*<<< orphan*/ putchar(int);
int main() {
  int rw;
  short nosym = 1, prevSpace = 0;
  while ((rw = getchar()) != EOF)
    switch (rw) {
    case '\n':
      if (prevSpace)
        prevSpace = 0;
      putchar('\n');
      nosym = 1;
      break;
    case ' ':
      if (nosym) {
        if (!prevSpace) {
          putchar(' ');
          prevSpace = 1;
        }
      } else
        putchar(' ');
      break;
    default:
      nosym = 0;
      putchar(rw);
    }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movw   $0x1,-0xa(%rbp)
movw   $0x0,-0xc(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x8(%rbp)
mov    0x2e9c(%rip),%rcx
cmp    (%rcx),%eax
je     11ec <main+0xcc>
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
sub    $0xa,%eax
je     1179 <main+0x59>
jmp    1168 <main+0x48>
mov    -0x10(%rbp),%eax
sub    $0x20,%eax
je     119f <main+0x7f>
jmp    11d9 <main+0xb9>
cmpw   $0x0,-0xc(%rbp)
je     118a <main+0x6a>
movw   $0x0,-0xc(%rbp)
mov    $0xa,%edi
call   1030 <putchar@plt>
movw   $0x1,-0xa(%rbp)
jmp    11e7 <main+0xc7>
cmpw   $0x0,-0xa(%rbp)
je     11ca <main+0xaa>
cmpw   $0x0,-0xc(%rbp)
jne    11c5 <main+0xa5>
mov    $0x20,%edi
call   1030 <putchar@plt>
movw   $0x1,-0xc(%rbp)
jmp    11d4 <main+0xb4>
mov    $0x20,%edi
call   1030 <putchar@plt>
jmp    11e7 <main+0xc7>
movw   $0x0,-0xa(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <putchar@plt>
jmp    113b <main+0x1b>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
xor    %eax,%eax
call   1040 <getchar@plt>
mov    0x2eb6(%rip),%r14
cmp    (%r14),%eax
jne    113e <main+0x1e>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    $0x1,%bx
xor    %ebp,%ebp
jmp    1165 <main+0x45>
cs nopw 0x0(%rax,%rax,1)
xor    %ebx,%ebx
mov    %eax,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    (%r14),%eax
je     1137 <main+0x17>
cmp    $0xa,%eax
je     1190 <main+0x70>
cmp    $0x20,%eax
jne    1150 <main+0x30>
mov    $0x20,%eax
test   %bx,%bx
je     1150 <main+0x30>
mov    $0x1,%bx
test   %bp,%bp
mov    $0x1,%bp
jne    1159 <main+0x39>
jmp    1152 <main+0x32>
nopl   0x0(%rax,%rax,1)
xor    %ebp,%ebp
mov    $0x1,%bx
jmp    1152 <main+0x32>

LLVM IR (-O0):
@EOF = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i16
%4 = alloca i16
store i32 0, i32* %1
store i16 1, i16* %3
store i16 0, i16* %4
br label %5
5: ; preds = %32, %0
%6 = call i32 (...) @getchar()
store i32 %6, i32* %2
%7 = load i32, i32* @EOF
%8 = icmp ne i32 %6, %7
br i1 %8, label %9, label %33
9: ; preds = %5
%10 = load i32, i32* %2
switch i32 %10, label %29 [
i32 10, label %11
i32 32, label %17
]
11: ; preds = %9
%12 = load i16, i16* %4
%13 = icmp ne i16 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %11
store i16 0, i16* %4
br label %15
15: ; preds = %14, %11
%16 = call i32 @putchar(i32 10)
store i16 1, i16* %3
br label %32
17: ; preds = %9
%18 = load i16, i16* %3
%19 = icmp ne i16 %18, 0
br i1 %19, label %20, label %26
20: ; preds = %17
%21 = load i16, i16* %4
%22 = icmp ne i16 %21, 0
br i1 %22, label %25, label %23
23: ; preds = %20
%24 = call i32 @putchar(i32 32)
store i16 1, i16* %4
br label %25
25: ; preds = %23, %20
br label %28
26: ; preds = %17
%27 = call i32 @putchar(i32 32)
br label %28
28: ; preds = %26, %25
br label %32
29: ; preds = %9
store i16 0, i16* %3
%30 = load i32, i32* %2
%31 = call i32 @putchar(i32 %30)
br label %32
32: ; preds = %29, %28, %15
br label %5
33: ; preds = %5
ret i32 0
}

LLVM IR (-O2):
@EOF = global i32 0
define i32 @main() {
%1 = tail call i32 (...) @getchar()
%2 = load i32, i32* @EOF
%3 = icmp eq i32 %1, %2
br i1 %3, label %24, label %4
4: ; preds = %0, %18
%5 = phi i32 [ %21, %18 ], [ %1, %0 ]
%6 = phi i16 [ %20, %18 ], [ 0, %0 ]
%7 = phi i16 [ %19, %18 ], [ 1, %0 ]
switch i32 %5, label %12 [
i32 10, label %13
i32 32, label %8
]
8: ; preds = %4
%9 = icmp eq i16 %7, 0
br i1 %9, label %13, label %10
10: ; preds = %8
%11 = icmp eq i16 %6, 0
br i1 %11, label %13, label %18
12: ; preds = %4
br label %13
13: ; preds = %8, %10, %4, %12
%14 = phi i32 [ %5, %12 ], [ %5, %4 ], [ 32, %10 ], [ 32, %8 ]
%15 = phi i16 [ 0, %12 ], [ 1, %4 ], [ 1, %10 ], [ 0, %8 ]
%16 = phi i16 [ %6, %12 ], [ 0, %4 ], [ 1, %10 ], [ %6, %8 ]
%17 = tail call i32 @putchar(i32 %14)
br label %18
18: ; preds = %13, %10
%19 = phi i16 [ 1, %10 ], [ %15, %13 ]
%20 = phi i16 [ 1, %10 ], [ %16, %13 ]
%21 = tail call i32 (...) @getchar()
%22 = load i32, i32* @EOF
%23 = icmp eq i32 %21, %22
br i1 %23, label %24, label %4
24: ; preds = %18, %0
ret i32 0
}