#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*/ printf(char *);
int /*<<< orphan*/ putchar(int);
main() {
  int code;
  int secondSpace = 0;
  int end;
  printf("Enter END symbol: ");
  end = getchar();
  while ((code = getchar()) != end) {
    if (code != ' ') {
      putchar(code);
      secondSpace = 0;
    }
    if (code == ' ') {
      if (secondSpace == 0) {
        putchar(code);
      }
      secondSpace = 1;
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xeb3(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %eax,-0x10(%rbp)
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %eax,-0x8(%rbp)
cmp    -0x10(%rbp),%eax
je     11b0 <main+0x80>
cmpl   $0x20,-0x8(%rbp)
je     1188 <main+0x58>
mov    -0x8(%rbp),%edi
call   1030 <putchar@plt>
movl   $0x0,-0xc(%rbp)
cmpl   $0x20,-0x8(%rbp)
jne    11ab <main+0x7b>
cmpl   $0x0,-0xc(%rbp)
jne    11a4 <main+0x74>
mov    -0x8(%rbp),%edi
call   1030 <putchar@plt>
movl   $0x1,-0xc(%rbp)
jmp    115c <main+0x2c>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
lea    0xec6(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    %ebx,%eax
jne    115c <main+0x2c>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
xor    %ecx,%ecx
jmp    1174 <main+0x44>
mov    %eax,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %ebp,%ecx
cmp    %ebx,%eax
je     1153 <main+0x23>
xor    %ebp,%ebp
cmp    $0x20,%eax
jne    1160 <main+0x30>
mov    $0x1,%ebp
test   %ecx,%ecx
jne    1167 <main+0x37>
mov    $0x20,%eax
jmp    1160 <main+0x30>

LLVM IR (-O0):
@.str = [19 x i8] c"Enter END symbol: \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
%5 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%6 = call i32 (...) @getchar()
store i32 %6, i32* %4
br label %7
7: ; preds = %27, %0
%8 = call i32 (...) @getchar()
store i32 %8, i32* %2
%9 = load i32, i32* %4
%10 = icmp ne i32 %8, %9
br i1 %10, label %11, label %28
11: ; preds = %7
%12 = load i32, i32* %2
%13 = icmp ne i32 %12, 32
br i1 %13, label %14, label %17
14: ; preds = %11
%15 = load i32, i32* %2
%16 = call i32 @putchar(i32 %15)
store i32 0, i32* %3
br label %17
17: ; preds = %14, %11
%18 = load i32, i32* %2
%19 = icmp eq i32 %18, 32
br i1 %19, label %20, label %27
20: ; preds = %17
%21 = load i32, i32* %3
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %20
%24 = load i32, i32* %2
%25 = call i32 @putchar(i32 %24)
br label %26
26: ; preds = %23, %20
store i32 1, i32* %3
br label %27
27: ; preds = %26, %17
br label %7
28: ; preds = %7
%29 = load i32, i32* %1
ret i32 %29
}

LLVM IR (-O2):
@.str = [19 x i8] c"Enter END symbol: \00"
define i32 @main() {
%1 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 (...) @getchar()
%3 = tail call i32 (...) @getchar()
%4 = icmp eq i32 %3, %2
br i1 %4, label %19, label %5
5: ; preds = %0, %15
%6 = phi i32 [ %17, %15 ], [ %3, %0 ]
%7 = phi i32 [ %16, %15 ], [ 0, %0 ]
%8 = icmp eq i32 %6, 32
br i1 %8, label %9, label %11
9: ; preds = %5
%10 = icmp eq i32 %7, 0
br i1 %10, label %11, label %15
11: ; preds = %9, %5
%12 = phi i32 [ %6, %5 ], [ 32, %9 ]
%13 = phi i32 [ 0, %5 ], [ 1, %9 ]
%14 = tail call i32 @putchar(i32 %12)
br label %15
15: ; preds = %11, %9
%16 = phi i32 [ 1, %9 ], [ %13, %11 ]
%17 = tail call i32 (...) @getchar()
%18 = icmp eq i32 %17, %2
br i1 %18, label %19, label %5
19: ; preds = %15, %0
ret i32 0
}