#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);
int main() {
  int c, state;
  state = 0;
  c = getchar();
  while (c != EOF) {
    if (c == ' ' && state == 1) {
      state = 1;
    } else if (c == ' ' && state == 0) {
      putchar(' ');
      state = 1;
    } else {
      state = 0;
      putchar(c);
    }
    c = getchar();
  }
  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    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    0x2e9e(%rip),%rcx
cmp    (%rcx),%eax
je     11bf <main+0x9f>
cmpl   $0x20,-0x8(%rbp)
jne    1172 <main+0x52>
cmpl   $0x1,-0xc(%rbp)
jne    1172 <main+0x52>
movl   $0x1,-0xc(%rbp)
jmp    11b0 <main+0x90>
cmpl   $0x20,-0x8(%rbp)
jne    119c <main+0x7c>
cmpl   $0x0,-0xc(%rbp)
jne    119c <main+0x7c>
mov    $0x20,%edi
call   1030 <putchar@plt>
movl   $0x1,-0xc(%rbp)
jmp    11ab <main+0x8b>
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <putchar@plt>
jmp    11b0 <main+0x90>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x8(%rbp)
jmp    1140 <main+0x20>
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),%rbx
cmp    (%rbx),%eax
jne    113d <main+0x1d>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    $0x20,%r14d
xor    %ecx,%ecx
jmp    1175 <main+0x55>
nopw   0x0(%rax,%rax,1)
mov    %eax,%edx
xor    $0x20,%edx
xor    %ebp,%ebp
or     %ecx,%edx
sete   %bpl
cmove  %r14d,%eax
mov    %eax,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
mov    %ebp,%ecx
cmp    (%rbx),%eax
je     1136 <main+0x16>
cmp    $0x20,%eax
jne    1150 <main+0x30>
mov    $0x1,%ebp
cmp    $0x1,%ecx
je     1168 <main+0x48>
jmp    1150 <main+0x30>

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

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