#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, n;
  while ((c = getchar()) != EOF) {
    if (c == ' ') {
      putchar(c);
      while ((n = getchar()) == ' ') {
        ;
      }
      c = n;
    }
    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     1185 <main+0x65>
cmpl   $0x20,-0x8(%rbp)
jne    1178 <main+0x58>
mov    -0x8(%rbp),%edi
call   1030 <putchar@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0xc(%rbp)
cmp    $0x20,%eax
jne    1172 <main+0x52>
jmp    115a <main+0x3a>
mov    -0xc(%rbp),%eax
mov    %eax,-0x8(%rbp)
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    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     117e <main+0x5e>
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>
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
%3 = alloca i32
store i32 0, i32* %1
br label %4
4: ; preds = %20, %0
%5 = call i32 (...) @getchar()
store i32 %5, i32* %2
%6 = load i32, i32* @EOF
%7 = icmp ne i32 %5, %6
br i1 %7, label %8, label %23
8: ; preds = %4
%9 = load i32, i32* %2
%10 = icmp eq i32 %9, 32
br i1 %10, label %11, label %20
11: ; preds = %8
%12 = load i32, i32* %2
%13 = call i32 @putchar(i32 %12)
br label %14
14: ; preds = %17, %11
%15 = call i32 (...) @getchar()
store i32 %15, i32* %3
%16 = icmp eq i32 %15, 32
br i1 %16, label %17, label %18
17: ; preds = %14
br label %14
18: ; preds = %14
%19 = load i32, i32* %3
store i32 %19, i32* %2
br label %20
20: ; preds = %18, %8
%21 = load i32, i32* %2
%22 = call i32 @putchar(i32 %21)
br label %4
23: ; preds = %4
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 %18, label %4
4: ; preds = %0, %12
%5 = phi i32 [ %15, %12 ], [ %1, %0 ]
%6 = icmp eq i32 %5, 32
br i1 %6, label %7, label %12
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, %4
%13 = phi i32 [ %5, %4 ], [ %10, %9 ]
%14 = tail call i32 @putchar(i32 %13)
%15 = tail call i32 (...) @getchar()
%16 = load i32, i32* @EOF
%17 = icmp eq i32 %15, %16
br i1 %17, label %18, label %4
18: ; preds = %12, %0
ret i32 0
}