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


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     11af <main+0x8f>
cmpl   $0x20,-0x8(%rbp)
jne    11aa <main+0x8a>
jmp    1157 <main+0x37>
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,%ecx
mov    -0xc(%rbp),%eax
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%eax
cmp    $0x20,%eax
jne    11a2 <main+0x82>
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    -0x8(%rbp),%eax
mov    0x2e58(%rip),%rcx
cmp    (%rcx),%eax
jne    119d <main+0x7d>
jmp    11a2 <main+0x82>
jmp    1157 <main+0x37>
mov    -0x8(%rbp),%edi
call   1030 <putchar@plt>
jmp    112f <main+0xf>
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    1147 <main+0x27>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    (%rbx),%eax
je     1163 <main+0x43>
cmp    $0x20,%eax
jne    1140 <main+0x20>
xor    %eax,%eax
call   1040 <getchar@plt>
mov    $0x20,%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 = %27, %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 %28
7: ; preds = %3
%8 = load i32, i32* %2
%9 = icmp eq i32 %8, 32
br i1 %9, label %10, label %27
10: ; preds = %7
br label %11
11: ; preds = %23, %10
%12 = load i32, i32* %2
%13 = call i32 (...) @getchar()
%14 = icmp eq i32 %12, %13
%15 = zext i1 %14 to i32
%16 = icmp eq i32 %15, 32
br i1 %16, label %17, label %24
17: ; preds = %11
%18 = call i32 @putchar(i32 32)
%19 = load i32, i32* %2
%20 = load i32, i32* @EOF
%21 = icmp eq i32 %19, %20
br i1 %21, label %22, label %23
22: ; preds = %17
br label %24
23: ; preds = %17
br label %11
24: ; preds = %22, %11
%25 = load i32, i32* %2
%26 = call i32 @putchar(i32 %25)
br label %27
27: ; preds = %24, %7
br label %3
28: ; preds = %3
%29 = load i32, i32* %1
ret i32 %29
}

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