#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*/ printf(char *, char);
int main(void) {
  char c;
  char stat = '?';
  while ((c = getchar()) != EOF) {
    if (c == ' ' && stat != ' ') {
      printf("%c", c);
    } else if (c != ' ') {
      printf("%c", c);
    }
    stat = c;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movb   $0x3f,-0x6(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x5(%rbp)
movsbl %al,%eax
mov    0x2ea1(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     11ae <main+0x8e>
movsbl -0x5(%rbp),%eax
cmp    $0x20,%eax
jne    1181 <main+0x61>
movsbl -0x6(%rbp),%eax
cmp    $0x20,%eax
je     1181 <main+0x61>
lea    0xe8d(%rip),%rdi
movsbl -0x5(%rbp),%esi
call   1030 <printf@plt>
jmp    11a3 <main+0x83>
movsbl -0x5(%rbp),%eax
cmp    $0x20,%eax
je     119e <main+0x7e>
lea    0xe6b(%rip),%rdi
movsbl -0x5(%rbp),%esi
call   1030 <printf@plt>
jmp    11a3 <main+0x83>
mov    -0x5(%rbp),%al
mov    %al,-0x6(%rbp)
jmp    1133 <main+0x13>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1040 <getchar@plt>
mov    0x2eb3(%rip),%rbp
cmp    0x0(%rbp),%al
jne    1147 <main+0x27>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x3f,%cl
mov    $0x20,%r15d
lea    0xeaa(%rip),%r14
jmp    118b <main+0x6b>
nopl   0x0(%rax,%rax,1)
cmp    $0x20,%bl
movzbl %bl,%eax
mov    %eax,%edx
cmove  %r15d,%edx
cmp    $0x20,%cl
cmove  %eax,%edx
movsbl %dl,%esi
mov    %r14,%rdi
call   1030 <printf@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
mov    %ebx,%ecx
cmp    0x0(%rbp),%al
je     113a <main+0x1a>
mov    %eax,%ebx
cmp    $0x20,%cl
jne    1160 <main+0x40>
cmp    $0x20,%bl
je     117d <main+0x5d>
jmp    1160 <main+0x40>

LLVM IR (-O0):
@EOF = global i8 0
@.str = [3 x i8] c"%c\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca i8
store i32 0, i32* %1
store i8 63, i8* %3
br label %4
4: ; preds = %29, %0
%5 = call signext i8 (...) @getchar()
store i8 %5, i8* %2
%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 %31
10: ; preds = %4
%11 = load i8, i8* %2
%12 = sext i8 %11 to i32
%13 = icmp eq i32 %12, 32
br i1 %13, label %14, label %21
14: ; preds = %10
%15 = load i8, i8* %3
%16 = sext i8 %15 to i32
%17 = icmp ne i32 %16, 32
br i1 %17, label %18, label %21
18: ; preds = %14
%19 = load i8, i8* %2
%20 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %19)
br label %29
21: ; preds = %14, %10
%22 = load i8, i8* %2
%23 = sext i8 %22 to i32
%24 = icmp ne i32 %23, 32
br i1 %24, label %25, label %28
25: ; preds = %21
%26 = load i8, i8* %2
%27 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %26)
br label %28
28: ; preds = %25, %21
br label %29
29: ; preds = %28, %18
%30 = load i8, i8* %2
store i8 %30, i8* %3
br label %4
31: ; preds = %4
%32 = load i32, i32* %1
ret i32 %32
}

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