#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, lastchar = EOF;
  while ((c = getchar()) != EOF) {
    if (c == ' ') {
      if (lastchar != ' ') {
        putchar(c);
      }
    }
    if (c != ' ') {
      putchar(c);
    }
    lastchar = 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     1192 <main+0x72>
cmpl   $0x20,-0x8(%rbp)
jne    1175 <main+0x55>
cmpl   $0x20,-0xc(%rbp)
je     1170 <main+0x50>
mov    -0x8(%rbp),%edi
call   1030 <putchar@plt>
jmp    1175 <main+0x55>
cmpl   $0x20,-0x8(%rbp)
je     1187 <main+0x67>
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    1149 <main+0x29>
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <getchar@plt>
mov    %ebx,%ebp
cmp    (%r14),%eax
je     1172 <main+0x52>
mov    %eax,%ebx
cmp    $0x20,%eax
jne    1164 <main+0x44>
cmp    $0x20,%ebp
je     1164 <main+0x44>
mov    $0x20,%edi
call   1030 <putchar@plt>
cmp    $0x20,%ebx
je     1140 <main+0x20>
mov    %ebx,%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 = %25, %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 %27
9: ; preds = %5
%10 = load i32, i32* %2
%11 = icmp eq i32 %10, 32
br i1 %11, label %12, label %19
12: ; preds = %9
%13 = load i32, i32* %3
%14 = icmp ne i32 %13, 32
br i1 %14, label %15, label %18
15: ; preds = %12
%16 = load i32, i32* %2
%17 = call i32 @putchar(i32 %16)
br label %18
18: ; preds = %15, %12
br label %19
19: ; preds = %18, %9
%20 = load i32, i32* %2
%21 = icmp ne i32 %20, 32
br i1 %21, label %22, label %25
22: ; preds = %19
%23 = load i32, i32* %2
%24 = call i32 @putchar(i32 %23)
br label %25
25: ; preds = %22, %19
%26 = load i32, i32* %2
store i32 %26, i32* %3
br label %5
27: ; preds = %5
%28 = load i32, i32* %1
ret i32 %28
}

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