#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;
  char state = 0;
  while ((c = getchar()) != EOF) {
    if (c == ' ') {
      if (state == 1) {
        putchar(' ');
        state = 0;
      }
    } else {
      putchar(c);
      state = 1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movb   $0x0,-0x6(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x5(%rbp)
movsbl %al,%eax
mov    0x2ea1(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     1191 <main+0x71>
movsbl -0x5(%rbp),%eax
cmp    $0x20,%eax
jne    117f <main+0x5f>
movsbl -0x6(%rbp),%eax
cmp    $0x1,%eax
jne    117a <main+0x5a>
mov    $0x20,%edi
call   1030 <putchar@plt>
movb   $0x0,-0x6(%rbp)
jmp    118c <main+0x6c>
movsbl -0x5(%rbp),%edi
call   1030 <putchar@plt>
movb   $0x1,-0x6(%rbp)
jmp    1133 <main+0x13>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
xor    %eax,%eax
call   1040 <getchar@plt>
mov    0x2eb6(%rip),%r14
cmp    (%r14),%al
jne    113e <main+0x1e>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
xor    %ebx,%ebx
jmp    1166 <main+0x46>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsbl %al,%edi
call   1030 <putchar@plt>
mov    %ebp,%ebx
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    (%r14),%al
je     1137 <main+0x17>
mov    $0x1,%bpl
cmp    $0x20,%al
jne    1150 <main+0x30>
cmp    $0x1,%bl
jne    115a <main+0x3a>
mov    $0x20,%al
xor    %ebp,%ebp
jmp    1150 <main+0x30>

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