#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*/ printf(char *);
int /*<<< orphan*/ putchar(int);
int main(void) {
  int c;
  int blank_count = 0;
  printf("enter some words with double spaces between:\n");
  while ((c = getchar()) != EOF) {
    if (c == ' ') {
      if (blank_count == 0) {
        blank_count = 1;
        putchar(c);
      }
    } else {
      blank_count = 0;
      putchar(c);
    }
  }
  return 0;
}


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,-0x8(%rbp)
mov    0x2e85(%rip),%rcx
cmp    (%rcx),%eax
je     11a7 <main+0x77>
cmpl   $0x20,-0x8(%rbp)
jne    1193 <main+0x63>
cmpl   $0x0,-0xc(%rbp)
jne    118e <main+0x5e>
movl   $0x1,-0xc(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <putchar@plt>
jmp    11a2 <main+0x72>
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <putchar@plt>
jmp    1152 <main+0x22>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
lea    0xec6(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
mov    0x2e9b(%rip),%rbx
cmp    (%rbx),%eax
jne    115a <main+0x2a>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
xor    %ecx,%ecx
jmp    1174 <main+0x44>
xchg   %ax,%ax
mov    %eax,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %ebp,%ecx
cmp    (%rbx),%eax
je     1151 <main+0x21>
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 = [46 x i8] c"enter some words with double spaces between:\0A\00"
@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 @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0))
br label %5
5: ; preds = %22, %0
%6 = call i32 (...) @getchar()
store i32 %6, i32* %2
%7 = load i32, i32* @EOF
%8 = icmp ne i32 %6, %7
br i1 %8, label %9, label %23
9: ; preds = %5
%10 = load i32, i32* %2
%11 = icmp eq i32 %10, 32
br i1 %11, label %12, label %19
12: ; preds = %9
%13 = load i32, i32* %3
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %12
store i32 1, i32* %3
%16 = load i32, i32* %2
%17 = call i32 @putchar(i32 %16)
br label %18
18: ; preds = %15, %12
br label %22
19: ; preds = %9
store i32 0, i32* %3
%20 = load i32, i32* %2
%21 = call i32 @putchar(i32 %20)
br label %22
22: ; preds = %19, %18
br label %5
23: ; preds = %5
ret i32 0
}

LLVM IR (-O2):
@EOF = global i32 0
@str = [45 x i8] c"enter some words with double spaces between:\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 (...) @getchar()
%3 = load i32, i32* @EOF
%4 = icmp eq i32 %2, %3
br i1 %4, label %20, label %5
5: ; preds = %0, %15
%6 = phi i32 [ %17, %15 ], [ %2, %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 = %5, %9
%12 = phi i32 [ 32, %9 ], [ %6, %5 ]
%13 = phi i32 [ 1, %9 ], [ 0, %5 ]
%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 = load i32, i32* @EOF
%19 = icmp eq i32 %17, %18
br i1 %19, label %20, label %5
20: ; preds = %15, %0
ret i32 0
}