#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*/ putchar(int);
int main() {
  int c;
  int n;
  int s;
  n = 8;
  s = 0;
  while ((c = getchar()) != EOF) {
    if (c == ' ') {
      ++s;
      --n;
      if (n == 0) {
        putchar('\t');
        s = 0;
        n = 8;
      }
    } else {
      if (c != '\t' && s > 0)
        while (s > 0) {
          putchar(' ');
          --s;
        }
      s = 0;
      if (c == '\t' || c == '\n')
        n = 8;
      else {
        --n;
        if (n == 0)
          n = 8;
      }
      putchar(c);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x8,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x8(%rbp)
mov    0x2e9a(%rip),%rcx
cmp    (%rcx),%eax
je     122c <main+0x10c>
cmpl   $0x20,-0x8(%rbp)
jne    1199 <main+0x79>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    1194 <main+0x74>
mov    $0x9,%edi
call   1030 <putchar@plt>
movl   $0x0,-0x10(%rbp)
movl   $0x8,-0xc(%rbp)
jmp    1227 <main+0x107>
cmpl   $0x9,-0x8(%rbp)
je     11d9 <main+0xb9>
cmpl   $0x0,-0x10(%rbp)
jle    11d9 <main+0xb9>
jmp    11b2 <main+0x92>
cmpl   $0x0,-0x10(%rbp)
jle    11d4 <main+0xb4>
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
jmp    11b2 <main+0x92>
jmp    11d9 <main+0xb9>
movl   $0x0,-0x10(%rbp)
cmpl   $0x9,-0x8(%rbp)
je     11f4 <main+0xd4>
cmpl   $0xa,-0x8(%rbp)
jne    1200 <main+0xe0>
movl   $0x8,-0xc(%rbp)
jmp    121f <main+0xff>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    121a <main+0xfa>
movl   $0x8,-0xc(%rbp)
jmp    121f <main+0xff>
mov    -0x8(%rbp),%edi
call   1030 <putchar@plt>
jmp    113d <main+0x1d>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
xor    %eax,%eax
call   1040 <getchar@plt>
mov    0x2eb2(%rip),%r14
cmp    (%r14),%eax
jne    1146 <main+0x26>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %eax,%ebx
mov    $0x8,%r15d
xor    %ebp,%ebp
mov    $0x8,%r12d
jmp    1189 <main+0x69>
nopl   0x0(%rax,%rax,1)
add    $0xffffffff,%r12d
cmove  %r15d,%r12d
lea    -0x9(%rbx),%eax
cmp    $0x2,%eax
cmovb  %r15d,%r12d
mov    %ebx,%edi
call   1030 <putchar@plt>
xor    %ebp,%ebp
xor    %eax,%eax
call   1040 <getchar@plt>
mov    %eax,%ebx
cmp    (%r14),%eax
je     113b <main+0x1b>
cmp    $0x20,%ebx
jne    11a0 <main+0x80>
add    $0xffffffff,%r12d
je     11c4 <main+0xa4>
add    $0x1,%ebp
jmp    117b <main+0x5b>
nopl   0x0(%rax)
cmp    $0x9,%ebx
je     1160 <main+0x40>
test   %ebp,%ebp
jle    1160 <main+0x40>
add    $0x1,%ebp
nopl   0x0(%rax)
mov    $0x20,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
cmp    $0x1,%ebp
ja     11b0 <main+0x90>
jmp    1160 <main+0x40>
mov    $0x8,%r12d
mov    $0x9,%ebx
jmp    1172 <main+0x52>

LLVM IR (-O0):
@EOF = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 8, i32* %3
store i32 0, i32* %4
br label %5
5: ; preds = %54, %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 %55
9: ; preds = %5
%10 = load i32, i32* %2
%11 = icmp eq i32 %10, 32
br i1 %11, label %12, label %22
12: ; preds = %9
%13 = load i32, i32* %4
%14 = add nsw i32 %13, 1
store i32 %14, i32* %4
%15 = load i32, i32* %3
%16 = add nsw i32 %15, -1
store i32 %16, i32* %3
%17 = load i32, i32* %3
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %12
%20 = call i32 @putchar(i32 9)
store i32 0, i32* %4
store i32 8, i32* %3
br label %21
21: ; preds = %19, %12
br label %54
22: ; preds = %9
%23 = load i32, i32* %2
%24 = icmp ne i32 %23, 9
br i1 %24, label %25, label %37
25: ; preds = %22
%26 = load i32, i32* %4
%27 = icmp sgt i32 %26, 0
br i1 %27, label %28, label %37
28: ; preds = %25
br label %29
29: ; preds = %32, %28
%30 = load i32, i32* %4
%31 = icmp sgt i32 %30, 0
br i1 %31, label %32, label %36
32: ; preds = %29
%33 = call i32 @putchar(i32 32)
%34 = load i32, i32* %4
%35 = add nsw i32 %34, -1
store i32 %35, i32* %4
br label %29
36: ; preds = %29
br label %37
37: ; preds = %36, %25, %22
store i32 0, i32* %4
%38 = load i32, i32* %2
%39 = icmp eq i32 %38, 9
br i1 %39, label %43, label %40
40: ; preds = %37
%41 = load i32, i32* %2
%42 = icmp eq i32 %41, 10
br i1 %42, label %43, label %44
43: ; preds = %40, %37
store i32 8, i32* %3
br label %51
44: ; preds = %40
%45 = load i32, i32* %3
%46 = add nsw i32 %45, -1
store i32 %46, i32* %3
%47 = load i32, i32* %3
%48 = icmp eq i32 %47, 0
br i1 %48, label %49, label %50
49: ; preds = %44
store i32 8, i32* %3
br label %50
50: ; preds = %49, %44
br label %51
51: ; preds = %50, %43
%52 = load i32, i32* %2
%53 = call i32 @putchar(i32 %52)
br label %54
54: ; preds = %51, %21
br label %5
55: ; preds = %5
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 %39, label %4
4: ; preds = %0, %33
%5 = phi i32 [ %36, %33 ], [ %1, %0 ]
%6 = phi i32 [ %35, %33 ], [ 0, %0 ]
%7 = phi i32 [ %34, %33 ], [ 8, %0 ]
%8 = icmp eq i32 %5, 32
br i1 %8, label %9, label %13
9: ; preds = %4
%10 = add nsw i32 %6, 1
%11 = add nsw i32 %7, -1
%12 = icmp eq i32 %11, 0
br i1 %12, label %29, label %33
13: ; preds = %4
%14 = icmp ne i32 %5, 9
%15 = icmp sgt i32 %6, 0
%16 = select i1 %14, i1 %15, i1 false
br i1 %16, label %17, label %22
17: ; preds = %13, %17
%18 = phi i32 [ %20, %17 ], [ %6, %13 ]
%19 = tail call i32 @putchar(i32 32)
%20 = add nsw i32 %18, -1
%21 = icmp ugt i32 %18, 1
br i1 %21, label %17, label %22
22: ; preds = %17, %13
%23 = add i32 %5, -9
%24 = icmp ult i32 %23, 2
%25 = add nsw i32 %7, -1
%26 = icmp eq i32 %25, 0
%27 = select i1 %24, i1 true, i1 %26
%28 = select i1 %27, i32 8, i32 %25
br label %29
29: ; preds = %9, %22
%30 = phi i32 [ %5, %22 ], [ 9, %9 ]
%31 = phi i32 [ %28, %22 ], [ 8, %9 ]
%32 = tail call i32 @putchar(i32 %30)
br label %33
33: ; preds = %29, %9
%34 = phi i32 [ %11, %9 ], [ %31, %29 ]
%35 = phi i32 [ %10, %9 ], [ 0, %29 ]
%36 = tail call i32 (...) @getchar()
%37 = load i32, i32* @EOF
%38 = icmp eq i32 %36, %37
br i1 %38, label %39, label %4
39: ; preds = %33, %0
ret i32 0
}