#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 input;
  while ((input = getchar()) != EOF) {
    if (input == ' ') {
      putchar(input);
      while ((input = getchar()) == ' ')
        ;
    }
    if (input != EOF) {
      putchar(input);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x8(%rbp)
mov    0x2ea8(%rip),%rcx
cmp    (%rcx),%eax
je     1196 <main+0x76>
cmpl   $0x20,-0x8(%rbp)
jne    1177 <main+0x57>
mov    -0x8(%rbp),%edi
call   1030 <putchar@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x20,%eax
jne    1172 <main+0x52>
jmp    115a <main+0x3a>
jmp    1177 <main+0x57>
mov    -0x8(%rbp),%eax
mov    0x2e67(%rip),%rcx
cmp    (%rcx),%eax
je     1191 <main+0x71>
mov    -0x8(%rbp),%edi
call   1030 <putchar@plt>
jmp    112f <main+0xf>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %eax,%eax
call   1040 <getchar@plt>
mov    0x2eb9(%rip),%rbx
jmp    1147 <main+0x27>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <getchar@plt>
mov    (%rbx),%ecx
cmp    %ecx,%eax
je     117b <main+0x5b>
cmp    $0x20,%eax
jne    116e <main+0x4e>
mov    $0x20,%edi
call   1030 <putchar@plt>
nopl   0x0(%rax)
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    $0x20,%eax
je     1160 <main+0x40>
mov    (%rbx),%ecx
cmp    %ecx,%eax
je     1140 <main+0x20>
mov    %eax,%edi
call   1030 <putchar@plt>
jmp    1140 <main+0x20>
xor    %eax,%eax
pop    %rbx
ret

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