#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 */
char EOF;
char getchar();
int /*<<< orphan*/ putchar(char);
int main(void) {
  char c;
  int spaces = 0;
  while ((c = getchar()) != EOF) {
    if (c == ' ') {
      if (spaces == 0) {
        putchar(c);
      }
      spaces++;
    } else {
      spaces = 0;
      putchar(c);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x5(%rbp)
movsbl %al,%eax
mov    0x2e9e(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     1198 <main+0x78>
movsbl -0x5(%rbp),%eax
cmp    $0x20,%eax
jne    1183 <main+0x63>
cmpl   $0x0,-0xc(%rbp)
jne    1175 <main+0x55>
movsbl -0x5(%rbp),%edi
call   1030 <putchar@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1193 <main+0x73>
movl   $0x0,-0xc(%rbp)
movsbl -0x5(%rbp),%edi
call   1030 <putchar@plt>
jmp    1136 <main+0x16>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
xor    %eax,%eax
call   1040 <getchar@plt>
mov    0x2eb7(%rip),%rbx
cmp    (%rbx),%al
jne    113e <main+0x1e>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
xor    %ebp,%ebp
jmp    1165 <main+0x45>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsbl %al,%edi
call   1030 <putchar@plt>
xor    %ebp,%ebp
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    (%rbx),%al
je     1135 <main+0x15>
cmp    $0x20,%al
jne    1150 <main+0x30>
test   %ebp,%ebp
jne    1177 <main+0x57>
mov    $0x20,%edi
call   1030 <putchar@plt>
add    $0x1,%ebp
jmp    115a <main+0x3a>

LLVM IR (-O0):
@EOF = global i8 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
br label %4
4: ; preds = %26, %0
%5 = call signext i8 (...) @getchar()
store i8 %5, i8* %2
%6 = sext i8 %5 to i32
%7 = load i8, i8* @EOF
%8 = sext i8 %7 to i32
%9 = icmp ne i32 %6, %8
br i1 %9, label %10, label %27
10: ; preds = %4
%11 = load i8, i8* %2
%12 = sext i8 %11 to i32
%13 = icmp eq i32 %12, 32
br i1 %13, label %14, label %23
14: ; preds = %10
%15 = load i32, i32* %3
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %14
%18 = load i8, i8* %2
%19 = call i32 @putchar(i8 signext %18)
br label %20
20: ; preds = %17, %14
%21 = load i32, i32* %3
%22 = add nsw i32 %21, 1
store i32 %22, i32* %3
br label %26
23: ; preds = %10
store i32 0, i32* %3
%24 = load i8, i8* %2
%25 = call i32 @putchar(i8 signext %24)
br label %26
26: ; preds = %23, %20
br label %4
27: ; preds = %4
ret i32 0
}

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