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


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    -0x8(%rbp),%eax
mov    0x2ea5(%rip),%rcx
cmp    (%rcx),%eax
je     11a1 <main+0x81>
jmp    1150 <main+0x30>
cmpl   $0x20,-0x8(%rbp)
jne    118a <main+0x6a>
mov    -0x8(%rbp),%edi
call   1030 <putchar@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x20,-0x8(%rbp)
jne    1185 <main+0x65>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x8(%rbp)
jmp    116c <main+0x4c>
jmp    1150 <main+0x30>
mov    -0x8(%rbp),%edi
call   1030 <putchar@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x8(%rbp)
jmp    1139 <main+0x19>
mov    $0x0,%al
call   1040 <getchar@plt>
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     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
call   1040 <getchar@plt>
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
%3 = call i32 (...) @getchar()
store i32 %3, i32* %2
br label %4
4: ; preds = %22, %0
%5 = load i32, i32* %2
%6 = load i32, i32* @EOF
%7 = icmp ne i32 %5, %6
br i1 %7, label %8, label %26
8: ; preds = %4
br label %9
9: ; preds = %21, %8
%10 = load i32, i32* %2
%11 = icmp eq i32 %10, 32
br i1 %11, label %12, label %22
12: ; preds = %9
%13 = load i32, i32* %2
%14 = call i32 @putchar(i32 %13)
%15 = call i32 (...) @getchar()
store i32 %15, i32* %2
br label %16
16: ; preds = %19, %12
%17 = load i32, i32* %2
%18 = icmp eq i32 %17, 32
br i1 %18, label %19, label %21
19: ; preds = %16
%20 = call i32 (...) @getchar()
store i32 %20, i32* %2
br label %16
21: ; preds = %16
br label %9
22: ; preds = %9
%23 = load i32, i32* %2
%24 = call i32 @putchar(i32 %23)
%25 = call i32 (...) @getchar()
store i32 %25, i32* %2
br label %4
26: ; preds = %4
%27 = call i32 (...) @getchar()
%28 = load i32, i32* %1
ret i32 %28
}

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