#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 c;
  while ((c = getchar()) != EOF) {
    if (c == ' ') {
      putchar(c);
      while ((c = getchar()) == ' ') {
      }
      if (c == EOF)
        return 0;
      putchar(c);
    } else {
      putchar(c);
    }
  }
  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     11aa <main+0x8a>
cmpl   $0x20,-0x8(%rbp)
jne    119d <main+0x7d>
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>
mov    -0x8(%rbp),%eax
mov    0x2e6c(%rip),%rcx
cmp    (%rcx),%eax
jne    1190 <main+0x70>
movl   $0x0,-0x4(%rbp)
jmp    11b1 <main+0x91>
mov    -0x8(%rbp),%edi
call   1030 <putchar@plt>
jmp    11a5 <main+0x85>
mov    -0x8(%rbp),%edi
call   1030 <putchar@plt>
jmp    112f <main+0xf>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%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    114e <main+0x2e>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %eax,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    (%rbx),%eax
je     1180 <main+0x60>
cmp    $0x20,%eax
jne    1140 <main+0x20>
mov    $0x20,%edi
call   1030 <putchar@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    $0x20,%eax
je     1170 <main+0x50>
cmp    (%rbx),%eax
jne    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 = %28, %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 %29
7: ; preds = %3
%8 = load i32, i32* %2
%9 = icmp eq i32 %8, 32
br i1 %9, label %10, label %25
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
%18 = load i32, i32* %2
%19 = load i32, i32* @EOF
%20 = icmp eq i32 %18, %19
br i1 %20, label %21, label %22
21: ; preds = %17
store i32 0, i32* %1
br label %30
22: ; preds = %17
%23 = load i32, i32* %2
%24 = call i32 @putchar(i32 %23)
br label %28
25: ; preds = %7
%26 = load i32, i32* %2
%27 = call i32 @putchar(i32 %26)
br label %28
28: ; preds = %25, %22
br label %3
29: ; preds = %3
store i32 0, i32* %1
br label %30
30: ; preds = %29, %21
%31 = load i32, i32* %1
ret i32 %31
}

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 %21, label %4
4: ; preds = %0, %15
%5 = phi i32 [ %18, %15 ], [ %1, %0 ]
%6 = icmp eq i32 %5, 32
br i1 %6, label %7, label %15
7: ; preds = %4
%8 = tail call i32 @putchar(i32 32)
br label %9
9: ; preds = %9, %7
%10 = tail call i32 (...) @getchar()
%11 = icmp eq i32 %10, 32
br i1 %11, label %9, label %12
12: ; preds = %9
%13 = load i32, i32* @EOF
%14 = icmp eq i32 %10, %13
br i1 %14, label %21, label %15
15: ; preds = %4, %12
%16 = phi i32 [ %10, %12 ], [ %5, %4 ]
%17 = tail call i32 @putchar(i32 %16)
%18 = tail call i32 (...) @getchar()
%19 = load i32, i32* @EOF
%20 = icmp eq i32 %18, %19
br i1 %20, label %21, label %4
21: ; preds = %12, %15, %0
ret i32 0
}