#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() {
  int prev_was_space = 0;
  char curr;
  while ((curr = getchar()) != EOF) {
    if (prev_was_space && curr == ' ') {
      continue;
    }
    putchar(curr);
    prev_was_space = (curr == ' ');
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x9(%rbp)
movsbl %al,%eax
mov    0x2e9e(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     1191 <main+0x71>
cmpl   $0x0,-0x8(%rbp)
je     1171 <main+0x51>
movsbl -0x9(%rbp),%eax
cmp    $0x20,%eax
jne    1171 <main+0x51>
jmp    1136 <main+0x16>
movsbl -0x9(%rbp),%edi
call   1030 <putchar@plt>
movsbl -0x9(%rbp),%eax
cmp    $0x20,%eax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x8(%rbp)
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    116b <main+0x4b>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %ebp,%ebp
cmp    $0x20,%al
sete   %bpl
movsbl %al,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    (%rbx),%al
je     1135 <main+0x15>
test   %ebp,%ebp
je     1150 <main+0x30>
mov    $0x1,%ebp
cmp    $0x20,%al
je     1160 <main+0x40>
jmp    1150 <main+0x30>

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