#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 space_count = 0, i;
  int ch;
  while ((ch = getchar()) != EOF) {
    if (ch == ' ') {
      space_count++;
    } else {
      if (space_count > 0) {
        for (i = 0; i < space_count / 4; i++) {
          putchar('\t');
        }
        for (i = 0; i < space_count % 4; i++) {
          putchar(' ');
        }
        space_count = 0;
      }
      putchar(ch);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x10(%rbp)
mov    0x2ea1(%rip),%rcx
cmp    (%rcx),%eax
je     11fd <main+0xdd>
cmpl   $0x20,-0x10(%rbp)
jne    1167 <main+0x47>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11f8 <main+0xd8>
cmpl   $0x0,-0x8(%rbp)
jle    11f0 <main+0xd0>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
cmp    %ecx,%eax
jge    11ae <main+0x8e>
mov    $0x9,%edi
call   1030 <putchar@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1178 <main+0x58>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    -0x18(%rbp),%eax
cmp    %edx,%eax
jge    11e9 <main+0xc9>
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11b5 <main+0x95>
movl   $0x0,-0x8(%rbp)
mov    -0x10(%rbp),%edi
call   1030 <putchar@plt>
jmp    1136 <main+0x16>
xor    %eax,%eax
add    $0x20,%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),%r14
cmp    (%r14),%eax
jne    1147 <main+0x27>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %eax,%ebx
xor    %r15d,%r15d
jmp    1162 <main+0x42>
xchg   %ax,%ax
add    $0x1,%r15d
xor    %eax,%eax
call   1040 <getchar@plt>
mov    %eax,%ebx
cmp    (%r14),%eax
je     113a <main+0x1a>
cmp    $0x20,%ebx
je     1150 <main+0x30>
test   %r15d,%r15d
jle    11bf <main+0x9f>
cmp    $0x4,%r15d
jb     118f <main+0x6f>
mov    %r15d,%ebp
shr    $0x2,%ebp
nopl   0x0(%rax,%rax,1)
mov    $0x9,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
jne    1180 <main+0x60>
lea    0x3(%r15),%eax
test   %r15d,%r15d
cmovns %r15d,%eax
and    $0xfffffffc,%eax
mov    %r15d,%ebp
sub    %eax,%ebp
xor    %r15d,%r15d
test   %ebp,%ebp
jle    11bf <main+0x9f>
nopl   0x0(%rax)
mov    $0x20,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
jne    11b0 <main+0x90>
mov    %ebx,%edi
call   1030 <putchar@plt>
jmp    1154 <main+0x34>

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 0, i32* %2
br label %5
5: ; preds = %44, %0
%6 = call i32 (...) @getchar()
store i32 %6, i32* %4
%7 = load i32, i32* @EOF
%8 = icmp ne i32 %6, %7
br i1 %8, label %9, label %45
9: ; preds = %5
%10 = load i32, i32* %4
%11 = icmp eq i32 %10, 32
br i1 %11, label %12, label %15
12: ; preds = %9
%13 = load i32, i32* %2
%14 = add nsw i32 %13, 1
store i32 %14, i32* %2
br label %44
15: ; preds = %9
%16 = load i32, i32* %2
%17 = icmp sgt i32 %16, 0
br i1 %17, label %18, label %41
18: ; preds = %15
store i32 0, i32* %3
br label %19
19: ; preds = %26, %18
%20 = load i32, i32* %3
%21 = load i32, i32* %2
%22 = sdiv i32 %21, 4
%23 = icmp slt i32 %20, %22
br i1 %23, label %24, label %29
24: ; preds = %19
%25 = call i32 @putchar(i32 9)
br label %26
26: ; preds = %24
%27 = load i32, i32* %3
%28 = add nsw i32 %27, 1
store i32 %28, i32* %3
br label %19
29: ; preds = %19
store i32 0, i32* %3
br label %30
30: ; preds = %37, %29
%31 = load i32, i32* %3
%32 = load i32, i32* %2
%33 = srem i32 %32, 4
%34 = icmp slt i32 %31, %33
br i1 %34, label %35, label %40
35: ; preds = %30
%36 = call i32 @putchar(i32 32)
br label %37
37: ; preds = %35
%38 = load i32, i32* %3
%39 = add nsw i32 %38, 1
store i32 %39, i32* %3
br label %30
40: ; preds = %30
store i32 0, i32* %2
br label %41
41: ; preds = %40, %15
%42 = load i32, i32* %4
%43 = call i32 @putchar(i32 %42)
br label %44
44: ; preds = %41, %12
br label %5
45: ; 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 %36, label %4
4: ; preds = %0, %31
%5 = phi i32 [ %33, %31 ], [ %1, %0 ]
%6 = phi i32 [ %32, %31 ], [ 0, %0 ]
%7 = icmp eq i32 %5, 32
br i1 %7, label %8, label %10
8: ; preds = %4
%9 = add nsw i32 %6, 1
br label %31
10: ; preds = %4
%11 = icmp sgt i32 %6, 0
br i1 %11, label %12, label %28
12: ; preds = %10
%13 = lshr i32 %6, 2
%14 = icmp ugt i32 %6, 3
br i1 %14, label %18, label %15
15: ; preds = %18, %12
%16 = srem i32 %6, 4
%17 = icmp sgt i32 %16, 0
br i1 %17, label %23, label %28
18: ; preds = %12, %18
%19 = phi i32 [ %21, %18 ], [ 0, %12 ]
%20 = tail call i32 @putchar(i32 9)
%21 = add nuw nsw i32 %19, 1
%22 = icmp eq i32 %21, %13
br i1 %22, label %15, label %18
23: ; preds = %15, %23
%24 = phi i32 [ %26, %23 ], [ 0, %15 ]
%25 = tail call i32 @putchar(i32 32)
%26 = add nuw nsw i32 %24, 1
%27 = icmp eq i32 %26, %16
br i1 %27, label %28, label %23
28: ; preds = %23, %15, %10
%29 = phi i32 [ %6, %10 ], [ 0, %15 ], [ 0, %23 ]
%30 = tail call i32 @putchar(i32 %5)
br label %31
31: ; preds = %28, %8
%32 = phi i32 [ %9, %8 ], [ %29, %28 ]
%33 = tail call i32 (...) @getchar()
%34 = load i32, i32* @EOF
%35 = icmp eq i32 %33, %34
br i1 %35, label %36, label %4
36: ; preds = %31, %0
ret i32 0
}