#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;
  int stat = 0;
  while ((c = getchar()) != EOF) {
    if (c == ' ') {
      if (++stat == 1) {
        printf("%c", c);
      }
    } else {
      stat = 0;
      printf("%c", c);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x5(%rbp)
movsbl %al,%eax
mov    0x2e9e(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     11a5 <main+0x85>
movsbl -0x5(%rbp),%eax
cmp    $0x20,%eax
jne    1189 <main+0x69>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
cmp    $0x1,%eax
jne    1184 <main+0x64>
lea    0xe85(%rip),%rdi
movsbl -0x5(%rbp),%esi
call   1030 <printf@plt>
jmp    11a0 <main+0x80>
movl   $0x0,-0xc(%rbp)
lea    0xe69(%rip),%rdi
movsbl -0x5(%rbp),%esi
call   1030 <printf@plt>
jmp    1136 <main+0x16>
xor    %eax,%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),%r15
cmp    (%r15),%al
jne    1147 <main+0x27>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xeb2(%rip),%r14
xor    %ebx,%ebx
jmp    1172 <main+0x52>
mov    $0x1,%ebp
mov    $0x20,%al
movsbl %al,%esi
mov    %r14,%rdi
call   1030 <printf@plt>
mov    %ebp,%ebx
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    (%r15),%al
je     113a <main+0x1a>
xor    %ebp,%ebp
cmp    $0x20,%al
jne    1159 <main+0x39>
test   %ebx,%ebx
je     1152 <main+0x32>
add    $0x1,%ebx
jmp    1166 <main+0x46>

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 i32
store i32 0, i32* %1
store i32 0, i32* %3
br label %4
4: ; preds = %25, %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 %26
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 %22
14: ; preds = %10
%15 = load i32, i32* %3
%16 = add nsw i32 %15, 1
store i32 %16, i32* %3
%17 = icmp eq i32 %16, 1
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 %21
21: ; preds = %18, %14
br label %25
22: ; preds = %10
store i32 0, i32* %3
%23 = load i8, i8* %2
%24 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %23)
br label %25
25: ; preds = %22, %21
br label %4
26: ; preds = %4
ret i32 0
}

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 %20, label %4
4: ; preds = %0, %15
%5 = phi i8 [ %17, %15 ], [ %1, %0 ]
%6 = phi i32 [ %16, %15 ], [ 0, %0 ]
%7 = icmp eq i8 %5, 32
br i1 %7, label %8, label %11
8: ; preds = %4
%9 = add nsw i32 %6, 1
%10 = icmp eq i32 %6, 0
br i1 %10, label %11, label %15
11: ; preds = %4, %8
%12 = phi i8 [ 32, %8 ], [ %5, %4 ]
%13 = phi i32 [ 1, %8 ], [ 0, %4 ]
%14 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %12)
br label %15
15: ; preds = %11, %8
%16 = phi i32 [ %9, %8 ], [ %13, %11 ]
%17 = tail call signext i8 (...) @getchar()
%18 = load i8, i8* @EOF
%19 = icmp eq i8 %17, %18
br i1 %19, label %20, label %4
20: ; preds = %15, %0
ret i32 0
}