#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 /*<<< orphan*/ space_to_tab(char *, int);
int main() {
  int c;
  char charters[4];
  int len_char;
  len_char = 0;
  while ((c = getchar()) != EOF) {
    if (c == '\n') {
      space_to_tab(charters, len_char);
      len_char = 0;
      putchar(c);
    } else if (len_char >= 4) {
      space_to_tab(charters, len_char);
      len_char = 0;
      charters[len_char] = c;
      ++len_char;
    } else {
      charters[len_char] = c;
      ++len_char;
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %eax,-0x8(%rbp)
mov    0x2e91(%rip),%rcx
cmp    (%rcx),%eax
je     11e1 <main+0xb1>
cmpl   $0xa,-0x8(%rbp)
jne    1189 <main+0x59>
lea    -0xc(%rbp),%rdi
mov    -0x10(%rbp),%esi
call   1040 <space_to_tab@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <putchar@plt>
jmp    11dc <main+0xac>
cmpl   $0x4,-0x10(%rbp)
jl     11c1 <main+0x91>
lea    -0xc(%rbp),%rdi
mov    -0x10(%rbp),%esi
call   1040 <space_to_tab@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    %al,%cl
movslq -0x10(%rbp),%rax
mov    %cl,-0xc(%rbp,%rax,1)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11d7 <main+0xa7>
mov    -0x8(%rbp),%eax
mov    %al,%cl
movslq -0x10(%rbp),%rax
mov    %cl,-0xc(%rbp,%rax,1)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11dc <main+0xac>
jmp    1146 <main+0x16>
mov    -0x4(%rbp),%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   1050 <getchar@plt>
mov    0x2ea3(%rip),%r15
cmp    (%r15),%eax
jne    1157 <main+0x27>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %eax,%ebx
lea    0x4(%rsp),%r14
xor    %ebp,%ebp
jmp    1194 <main+0x64>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %ebp,%esi
call   1040 <space_to_tab@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %ebp,%ebp
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %eax,%ebx
cmp    (%r15),%eax
je     114a <main+0x1a>
cmp    $0xa,%ebx
je     1170 <main+0x40>
cmp    $0x4,%ebp
jge    11aa <main+0x7a>
movslq %ebp,%rax
mov    %bl,0x4(%rsp,%rax,1)
add    $0x1,%ebp
jmp    1186 <main+0x56>
mov    %r14,%rdi
mov    %ebp,%esi
call   1040 <space_to_tab@plt>
mov    %bl,0x4(%rsp)
mov    $0x1,%ebp
jmp    1186 <main+0x56>

LLVM IR (-O0):
@EOF = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [4 x i8]
%4 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %4
br label %5
5: ; preds = %41, %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 %42
9: ; preds = %5
%10 = load i32, i32* %2
%11 = icmp eq i32 %10, 10
br i1 %11, label %12, label %18
12: ; preds = %9
%13 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
%14 = load i32, i32* %4
%15 = call i32 @space_to_tab(i8* %13, i32 %14)
store i32 0, i32* %4
%16 = load i32, i32* %2
%17 = call i32 @putchar(i32 %16)
br label %41
18: ; preds = %9
%19 = load i32, i32* %4
%20 = icmp sge i32 %19, 4
br i1 %20, label %21, label %32
21: ; preds = %18
%22 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
%23 = load i32, i32* %4
%24 = call i32 @space_to_tab(i8* %22, i32 %23)
store i32 0, i32* %4
%25 = load i32, i32* %2
%26 = trunc i32 %25 to i8
%27 = load i32, i32* %4
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 %28
store i8 %26, i8* %29
%30 = load i32, i32* %4
%31 = add nsw i32 %30, 1
store i32 %31, i32* %4
br label %40
32: ; preds = %18
%33 = load i32, i32* %2
%34 = trunc i32 %33 to i8
%35 = load i32, i32* %4
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 %36
store i8 %34, i8* %37
%38 = load i32, i32* %4
%39 = add nsw i32 %38, 1
store i32 %39, i32* %4
br label %40
40: ; preds = %32, %21
br label %41
41: ; preds = %40, %12
br label %5
42: ; preds = %5
%43 = load i32, i32* %1
ret i32 %43
}

LLVM IR (-O2):
@EOF = global i32 0
define i32 @main() {
%1 = alloca [4 x i8]
%2 = getelementptr inbounds [4 x i8], [4 x i8]* %1, i64 0, i64 0
%3 = call i32 (...) @getchar()
%4 = load i32, i32* @EOF
%5 = icmp eq i32 %3, %4
br i1 %5, label %28, label %6
6: ; preds = %0, %23
%7 = phi i32 [ %25, %23 ], [ %3, %0 ]
%8 = phi i32 [ %24, %23 ], [ 0, %0 ]
%9 = icmp eq i32 %7, 10
br i1 %9, label %10, label %13
10: ; preds = %6
%11 = call i32 @space_to_tab(i8* %2, i32 %8)
%12 = call i32 @putchar(i32 10)
br label %23
13: ; preds = %6
%14 = icmp sgt i32 %8, 3
br i1 %14, label %15, label %18
15: ; preds = %13
%16 = call i32 @space_to_tab(i8* %2, i32 %8)
%17 = trunc i32 %7 to i8
store i8 %17, i8* %2
br label %23
18: ; preds = %13
%19 = trunc i32 %7 to i8
%20 = sext i32 %8 to i64
%21 = getelementptr inbounds [4 x i8], [4 x i8]* %1, i64 0, i64 %20
store i8 %19, i8* %21
%22 = add nsw i32 %8, 1
br label %23
23: ; preds = %15, %18, %10
%24 = phi i32 [ 0, %10 ], [ 1, %15 ], [ %22, %18 ]
%25 = call i32 (...) @getchar()
%26 = load i32, i32* @EOF
%27 = icmp eq i32 %25, %26
br i1 %27, label %28, label %6
28: ; preds = %23, %0
ret i32 0
}