#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);
void main() {
  int c;
  int space = 0;
  printf("please press the word\n");
  while ((c = getchar()) != EOF) {
    if (c != ' ') {
      putchar(c);
      space = 0;
      continue;
    } else
      space++;
    if (space == 1)
      putchar(c);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x8(%rbp)
lea    0xeba(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %eax,-0x4(%rbp)
mov    0x2e8c(%rip),%rcx
cmp    (%rcx),%eax
je     11a2 <main+0x72>
cmpl   $0x20,-0x4(%rbp)
je     1182 <main+0x52>
mov    -0x4(%rbp),%edi
call   1030 <putchar@plt>
movl   $0x0,-0x8(%rbp)
jmp    114b <main+0x1b>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    119d <main+0x6d>
mov    -0x4(%rbp),%edi
call   1030 <putchar@plt>
jmp    114b <main+0x1b>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
lea    0xec5(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
mov    0x2e9a(%rip),%r14
cmp    (%r14),%eax
jne    1158 <main+0x28>
pop    %rbx
pop    %r14
pop    %rbp
ret
xor    %ebx,%ebx
jmp    117b <main+0x4b>
mov    $0x1,%ebp
mov    $0x20,%eax
mov    %eax,%edi
call   1030 <putchar@plt>
mov    %ebp,%ebx
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    (%r14),%eax
je     1153 <main+0x23>
xor    %ebp,%ebp
cmp    $0x20,%eax
jne    1166 <main+0x36>
test   %ebx,%ebx
je     115c <main+0x2c>
add    $0x1,%ebx
jmp    116f <main+0x3f>

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

LLVM IR (-O2):
@EOF = global i32 0
@str = [22 x i8] c"please press the word\00"
define void @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 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 %21, label %5
5: ; preds = %0, %13
%6 = phi i32 [ %15, %13 ], [ %2, %0 ]
%7 = phi i32 [ %14, %13 ], [ 0, %0 ]
%8 = icmp eq i32 %6, 32
br i1 %8, label %18, label %9
9: ; preds = %5, %18
%10 = phi i32 [ 32, %18 ], [ %6, %5 ]
%11 = phi i32 [ 1, %18 ], [ 0, %5 ]
%12 = tail call i32 @putchar(i32 %10)
br label %13
13: ; preds = %9, %18
%14 = phi i32 [ %19, %18 ], [ %11, %9 ]
%15 = tail call i32 (...) @getchar()
%16 = load i32, i32* @EOF
%17 = icmp eq i32 %15, %16
br i1 %17, label %21, label %5
18: ; preds = %5
%19 = add nsw i32 %7, 1
%20 = icmp eq i32 %7, 0
br i1 %20, label %9, label %13
21: ; preds = %13, %0
ret void
}