#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);
main() {
  int c, prev;
  prev = EOF;
  while ((c = getchar()) != EOF) {
    if (c == ' ') {
      prev = c;
      continue;
    }
    if (prev == ' ')
      putchar(' ');
    putchar(c);
    prev = c;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2eb2(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x8(%rbp)
mov    0x2e9c(%rip),%rcx
cmp    (%rcx),%eax
je     1190 <main+0x70>
cmpl   $0x20,-0x8(%rbp)
jne    1169 <main+0x49>
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    113b <main+0x1b>
cmpl   $0x20,-0xc(%rbp)
jne    117d <main+0x5d>
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    -0x8(%rbp),%edi
call   1030 <putchar@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    113b <main+0x1b>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    0x2ebd(%rip),%r14
mov    (%r14),%ebp
xor    %eax,%eax
call   1040 <getchar@plt>
jmp    1150 <main+0x30>
nopw   0x0(%rax,%rax,1)
mov    %ebx,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
mov    %ebx,%ebp
cmp    (%r14),%eax
je     116d <main+0x4d>
mov    %eax,%ebx
cmp    $0x20,%eax
je     1147 <main+0x27>
cmp    $0x20,%ebp
jne    1140 <main+0x20>
mov    $0x20,%edi
call   1030 <putchar@plt>
jmp    1140 <main+0x20>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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