#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*/ printSpaces(int);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  int c, cspace, state;
  state = cspace = 0;
  while ((c = getchar()) != EOF) {
    if (c == ' ') {
      state = 1;
      cspace++;
    } else {
      if (state == 1)
        printSpaces(cspace);
      state = 0;
      cspace = 0;
      printf("%c", c);
    }
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x8(%rbp)
mov    0x2e8a(%rip),%rcx
cmp    (%rcx),%eax
je     11bb <main+0x8b>
cmpl   $0x20,-0x8(%rbp)
jne    1185 <main+0x55>
movl   $0x1,-0x10(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11b6 <main+0x86>
cmpl   $0x1,-0x10(%rbp)
jne    1197 <main+0x67>
mov    -0xc(%rbp),%edi
call   1050 <printSpaces@plt>
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%esi
lea    0xe51(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    114d <main+0x1d>
lea    0xe41(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
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    0x2ea3(%rip),%r14
cmp    (%r14),%eax
jne    1161 <main+0x31>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %eax,%ebp
xor    %r15d,%r15d
xor    %ebx,%ebx
jmp    118a <main+0x5a>
nopw   0x0(%rax,%rax,1)
mov    %ebp,%edi
call   1030 <putchar@plt>
xor    %ebx,%ebx
xor    %r15d,%r15d
xor    %eax,%eax
call   1040 <getchar@plt>
mov    %eax,%ebp
cmp    (%r14),%eax
je     114a <main+0x1a>
cmp    $0x20,%ebp
jne    11a0 <main+0x70>
add    $0x1,%ebx
mov    $0x1,%r15d
jmp    117c <main+0x4c>
nopw   0x0(%rax,%rax,1)
cmp    $0x1,%r15d
jne    1170 <main+0x40>
mov    %ebx,%edi
call   1050 <printSpaces@plt>
jmp    1170 <main+0x40>

LLVM IR (-O0):
@EOF = global i32 0
@.str = [3 x i8] c"%c\00"
@.str.1 = [2 x i8] c"\0A\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
store i32 0, i32* %4
br label %5
5: ; preds = %24, %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 %25
9: ; preds = %5
%10 = load i32, i32* %2
%11 = icmp eq i32 %10, 32
br i1 %11, label %12, label %15
12: ; preds = %9
store i32 1, i32* %4
%13 = load i32, i32* %3
%14 = add nsw i32 %13, 1
store i32 %14, i32* %3
br label %24
15: ; preds = %9
%16 = load i32, i32* %4
%17 = icmp eq i32 %16, 1
br i1 %17, label %18, label %21
18: ; preds = %15
%19 = load i32, i32* %3
%20 = call i32 @printSpaces(i32 %19)
br label %21
21: ; preds = %18, %15
store i32 0, i32* %4
store i32 0, i32* %3
%22 = load i32, i32* %2
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %22)
br label %24
24: ; preds = %21, %12
br label %5
25: ; preds = %5
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@EOF = global i32 0
define i32 @main() {
%1 = tail call i32 (...) @getchar()
%2 = load i32, i32* @EOF
%3 = icmp eq i32 %1, %2
br i1 %3, label %23, label %4
4: ; preds = %0, %17
%5 = phi i32 [ %20, %17 ], [ %1, %0 ]
%6 = phi i32 [ %19, %17 ], [ 0, %0 ]
%7 = phi i32 [ %18, %17 ], [ 0, %0 ]
%8 = icmp eq i32 %5, 32
br i1 %8, label %9, label %11
9: ; preds = %4
%10 = add nsw i32 %7, 1
br label %17
11: ; preds = %4
%12 = icmp eq i32 %6, 1
br i1 %12, label %13, label %15
13: ; preds = %11
%14 = tail call i32 @printSpaces(i32 %7)
br label %15
15: ; preds = %13, %11
%16 = tail call i32 @putchar(i32 %5)
br label %17
17: ; preds = %15, %9
%18 = phi i32 [ %10, %9 ], [ 0, %15 ]
%19 = phi i32 [ 1, %9 ], [ 0, %15 ]
%20 = tail call i32 (...) @getchar()
%21 = load i32, i32* @EOF
%22 = icmp eq i32 %20, %21
br i1 %22, label %23, label %4
23: ; preds = %17, %0
%24 = tail call i32 @putchar(i32 10)
ret i32 0
}