#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*/ printf(char *);
int /*<<< orphan*/ putchar(int);
int main() {
  int c, i, j;
  int num_spaces, num_tabs, remaining_spaces;
  const int TAB_WIDTH = 3;
  num_spaces = num_tabs = remaining_spaces = 0;
  while ((c = getchar()) != EOF) {
    if (c == ' ') {
      num_spaces++;
    } else {
      num_tabs = num_spaces / TAB_WIDTH;
      remaining_spaces = num_spaces % TAB_WIDTH;
      for (i = 0; i < num_tabs; i++) {
        printf("\t");
      }
      for (j = 0; j < remaining_spaces; j++) {
        putchar(' ');
      }
      putchar(c);
      num_spaces = num_tabs = remaining_spaces = 0;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x3,-0x20(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x14(%rbp)
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %eax,-0x8(%rbp)
mov    0x2e7c(%rip),%rcx
cmp    (%rcx),%eax
je     1222 <main+0xf2>
cmpl   $0x20,-0x8(%rbp)
jne    118c <main+0x5c>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    121d <main+0xed>
mov    -0x14(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    %edx,-0x1c(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11d5 <main+0xa5>
lea    0xe3e(%rip),%rdi
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11af <main+0x7f>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1200 <main+0xd0>
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11dc <main+0xac>
mov    -0x8(%rbp),%edi
call   1030 <putchar@plt>
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x14(%rbp)
jmp    115b <main+0x2b>
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,%r15d
xor    %ebx,%ebx
jmp    1162 <main+0x42>
xchg   %ax,%ax
add    $0x1,%ebx
xor    %eax,%eax
call   1040 <getchar@plt>
mov    %eax,%r15d
cmp    (%r14),%eax
je     113a <main+0x1a>
cmp    $0x20,%r15d
je     1150 <main+0x30>
movslq %ebx,%rax
imul   $0x55555556,%rax,%rbx
mov    %rbx,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rbx
add    %ecx,%ebx
lea    (%rbx,%rbx,2),%ecx
mov    %eax,%ebp
sub    %ecx,%ebp
cmp    $0x3,%eax
jl     119f <main+0x7f>
nopl   0x0(%rax,%rax,1)
mov    $0x9,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebx
jne    1190 <main+0x70>
test   %ebp,%ebp
jle    11bf <main+0x9f>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    $0x20,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
jne    11b0 <main+0x90>
mov    %r15d,%edi
call   1030 <putchar@plt>
xor    %ebx,%ebx
jmp    1153 <main+0x33>

LLVM IR (-O0):
@EOF = global i32 0
@.str = [2 x i8] c"\09\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %1
store i32 3, i32* %8
store i32 0, i32* %7
store i32 0, i32* %6
store i32 0, i32* %5
br label %9
9: ; preds = %46, %0
%10 = call i32 (...) @getchar()
store i32 %10, i32* %2
%11 = load i32, i32* @EOF
%12 = icmp ne i32 %10, %11
br i1 %12, label %13, label %47
13: ; preds = %9
%14 = load i32, i32* %2
%15 = icmp eq i32 %14, 32
br i1 %15, label %16, label %19
16: ; preds = %13
%17 = load i32, i32* %5
%18 = add nsw i32 %17, 1
store i32 %18, i32* %5
br label %46
19: ; preds = %13
%20 = load i32, i32* %5
%21 = sdiv i32 %20, 3
store i32 %21, i32* %6
%22 = load i32, i32* %5
%23 = srem i32 %22, 3
store i32 %23, i32* %7
store i32 0, i32* %3
br label %24
24: ; preds = %30, %19
%25 = load i32, i32* %3
%26 = load i32, i32* %6
%27 = icmp slt i32 %25, %26
br i1 %27, label %28, label %33
28: ; preds = %24
%29 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %30
30: ; preds = %28
%31 = load i32, i32* %3
%32 = add nsw i32 %31, 1
store i32 %32, i32* %3
br label %24
33: ; preds = %24
store i32 0, i32* %4
br label %34
34: ; preds = %40, %33
%35 = load i32, i32* %4
%36 = load i32, i32* %7
%37 = icmp slt i32 %35, %36
br i1 %37, label %38, label %43
38: ; preds = %34
%39 = call i32 @putchar(i32 32)
br label %40
40: ; preds = %38
%41 = load i32, i32* %4
%42 = add nsw i32 %41, 1
store i32 %42, i32* %4
br label %34
43: ; preds = %34
%44 = load i32, i32* %2
%45 = call i32 @putchar(i32 %44)
store i32 0, i32* %7
store i32 0, i32* %6
store i32 0, i32* %5
br label %46
46: ; preds = %43, %16
br label %9
47: ; preds = %9
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 %33, label %4
4: ; preds = %0, %28
%5 = phi i32 [ %30, %28 ], [ %1, %0 ]
%6 = phi i32 [ %29, %28 ], [ 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 %28
10: ; preds = %4
%11 = sdiv i32 %6, 3
%12 = srem i32 %6, 3
%13 = icmp sgt i32 %6, 2
br i1 %13, label %16, label %14
14: ; preds = %16, %10
%15 = icmp sgt i32 %12, 0
br i1 %15, label %21, label %26
16: ; preds = %10, %16
%17 = phi i32 [ %19, %16 ], [ 0, %10 ]
%18 = tail call i32 @putchar(i32 9)
%19 = add nuw nsw i32 %17, 1
%20 = icmp eq i32 %19, %11
br i1 %20, label %14, label %16
21: ; preds = %14, %21
%22 = phi i32 [ %24, %21 ], [ 0, %14 ]
%23 = tail call i32 @putchar(i32 32)
%24 = add nuw nsw i32 %22, 1
%25 = icmp eq i32 %24, %12
br i1 %25, label %26, label %21
26: ; preds = %21, %14
%27 = tail call i32 @putchar(i32 %5)
br label %28
28: ; preds = %26, %8
%29 = phi i32 [ %9, %8 ], [ 0, %26 ]
%30 = tail call i32 (...) @getchar()
%31 = load i32, i32* @EOF
%32 = icmp eq i32 %30, %31
br i1 %32, label %33, label %4
33: ; preds = %28, %0
ret i32 0
}