#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 getchar();
int /*<<< orphan*/ putchar(int);
int main(int argc, char **argv) {
  int c;
  char newline = 0;
  char space = 0;
  while ((c = getchar()) > -1) {
    switch (c) {
    case '\n':
      if (newline) {
        continue;
      } else {
        newline = 1;
        space = 0;
        putchar(c);
      }
      break;
    case ' ':
      if (space)
        continue;
      else
        space = 1;
      break;
    default:
      if (space) {
        putchar(' ');
        space = 0;
      }
      putchar(c);
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movb   $0x0,-0x15(%rbp)
movb   $0x0,-0x16(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
jle    11d7 <main+0xb7>
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
sub    $0xa,%eax
je     1176 <main+0x56>
jmp    1165 <main+0x45>
mov    -0x1c(%rbp),%eax
sub    $0x20,%eax
je     119a <main+0x7a>
jmp    11b2 <main+0x92>
cmpb   $0x0,-0x15(%rbp)
je     1185 <main+0x65>
jmp    113e <main+0x1e>
movb   $0x1,-0x15(%rbp)
movb   $0x0,-0x16(%rbp)
mov    -0x14(%rbp),%edi
call   1030 <putchar@plt>
jmp    11d2 <main+0xb2>
cmpb   $0x0,-0x16(%rbp)
je     11a9 <main+0x89>
jmp    113e <main+0x1e>
movb   $0x1,-0x16(%rbp)
jmp    11d2 <main+0xb2>
cmpb   $0x0,-0x16(%rbp)
je     11ca <main+0xaa>
mov    $0x20,%edi
call   1030 <putchar@plt>
movb   $0x0,-0x16(%rbp)
mov    -0x14(%rbp),%edi
call   1030 <putchar@plt>
jmp    113e <main+0x1e>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
xor    %r14d,%r14d
xor    %ebp,%ebp
mov    %ebp,%eax
mov    %eax,%ebp
xor    %eax,%eax
call   1040 <getchar@plt>
test   %eax,%eax
js     1190 <main+0x70>
mov    %eax,%ebx
cmp    $0x20,%eax
jne    1150 <main+0x30>
mov    $0x1,%al
test   %bpl,%bpl
mov    $0x1,%bpl
jne    1130 <main+0x10>
jmp    112e <main+0xe>
xchg   %ax,%ax
cmp    $0xa,%ebx
jne    1170 <main+0x50>
mov    $0x1,%r15b
test   %r14b,%r14b
mov    $0x1,%r14b
jne    112c <main+0xc>
mov    $0xa,%ebx
jmp    1182 <main+0x62>
nopw   0x0(%rax,%rax,1)
test   %bpl,%bpl
je     117f <main+0x5f>
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    %r14d,%r15d
mov    %ebx,%edi
call   1030 <putchar@plt>
xor    %ebp,%ebp
mov    %r15d,%r14d
jmp    112c <main+0xc>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8
%8 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8 0, i8* %7
store i8 0, i8* %8
br label %9
9: ; preds = %36, %25, %17, %2
%10 = call i32 (...) @getchar()
store i32 %10, i32* %6
%11 = icmp sgt i32 %10, -1
br i1 %11, label %12, label %37
12: ; preds = %9
%13 = load i32, i32* %6
switch i32 %13, label %28 [
i32 10, label %14
i32 32, label %22
]
14: ; preds = %12
%15 = load i8, i8* %7
%16 = icmp ne i8 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %14
br label %9
18: ; preds = %14
store i8 1, i8* %7
store i8 0, i8* %8
%19 = load i32, i32* %6
%20 = call i32 @putchar(i32 %19)
br label %21
21: ; preds = %18
br label %36
22: ; preds = %12
%23 = load i8, i8* %8
%24 = icmp ne i8 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %22
br label %9
26: ; preds = %22
store i8 1, i8* %8
br label %27
27: ; preds = %26
br label %36
28: ; preds = %12
%29 = load i8, i8* %8
%30 = icmp ne i8 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %28
%32 = call i32 @putchar(i32 32)
store i8 0, i8* %8
br label %33
33: ; preds = %31, %28
%34 = load i32, i32* %6
%35 = call i32 @putchar(i32 %34)
br label %36
36: ; preds = %33, %27, %21
br label %9
37: ; preds = %9
%38 = load i32, i32* %3
ret i32 %38
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** nocapture readnone %1) {
br label %3
3: ; preds = %15, %2
%4 = phi i8 [ 0, %2 ], [ %16, %15 ]
%5 = phi i8 [ 0, %2 ], [ %17, %15 ]
br label %6
6: ; preds = %18, %3
%7 = phi i8 [ %5, %3 ], [ 1, %18 ]
br label %8
8: ; preds = %6, %18
%9 = phi i8 [ 1, %18 ], [ %7, %6 ]
%10 = tail call i32 (...) @getchar()
%11 = icmp sgt i32 %10, -1
br i1 %11, label %12, label %28
12: ; preds = %8
switch i32 %10, label %20 [
i32 10, label %13
i32 32, label %18
]
13: ; preds = %12
%14 = icmp eq i8 %4, 0
br i1 %14, label %24, label %15
15: ; preds = %13, %24
%16 = phi i8 [ %26, %24 ], [ 1, %13 ]
%17 = phi i8 [ 0, %24 ], [ %9, %13 ]
br label %3
18: ; preds = %12
%19 = icmp eq i8 %9, 0
br i1 %19, label %6, label %8
20: ; preds = %12
%21 = icmp eq i8 %9, 0
br i1 %21, label %24, label %22
22: ; preds = %20
%23 = tail call i32 @putchar(i32 32)
br label %24
24: ; preds = %20, %22, %13
%25 = phi i32 [ 10, %13 ], [ %10, %22 ], [ %10, %20 ]
%26 = phi i8 [ 1, %13 ], [ %4, %22 ], [ %4, %20 ]
%27 = tail call i32 @putchar(i32 %25)
br label %15
28: ; preds = %8
ret i32 0
}