#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 */
char EOF;
int countspaces(char *, int);
char getchar();
int /*<<< orphan*/ printf(char *, char *);
int main() {
  char input[1000];
  char c;
  int i, j;
  for (i = 0; (c = getchar()) != EOF && i < 1000 - 1; i++) {
    input[i] = c;
    if (c == ' ' && countspaces(input, i) == 4) {
      input[i - (3)] = '\t';
      i -= (3);
    }
  }
  printf("%s", input);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x400,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x3f8(%rbp)
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %al,-0x3f1(%rbp)
movsbl %al,%ecx
mov    0x2e85(%rip),%rax
movsbl (%rax),%edx
xor    %eax,%eax
cmp    %edx,%ecx
mov    %al,-0x3fd(%rbp)
je     1189 <main+0x59>
cmpl   $0x3e7,-0x3f8(%rbp)
setl   %al
mov    %al,-0x3fd(%rbp)
mov    -0x3fd(%rbp),%al
test   $0x1,%al
jne    119c <main+0x6c>
jmp    1216 <main+0xe6>
mov    -0x3f1(%rbp),%cl
movslq -0x3f8(%rbp),%rax
mov    %cl,-0x3f0(%rbp,%rax,1)
movsbl -0x3f1(%rbp),%eax
cmp    $0x20,%eax
jne    11fd <main+0xcd>
lea    -0x3f0(%rbp),%rdi
mov    -0x3f8(%rbp),%esi
call   1040 <countspaces@plt>
cmp    $0x4,%eax
jne    11fd <main+0xcd>
mov    -0x3f8(%rbp),%eax
sub    $0x3,%eax
cltq
movb   $0x9,-0x3f0(%rbp,%rax,1)
09
mov    -0x3f8(%rbp),%eax
sub    $0x3,%eax
mov    %eax,-0x3f8(%rbp)
jmp    1202 <main+0xd2>
mov    -0x3f8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3f8(%rbp)
jmp    114c <main+0x1c>
lea    -0x3f0(%rbp),%rsi
lea    0xddc(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x400,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x3e8,%rsp
xor    %eax,%eax
call   1050 <getchar@plt>
mov    0x2e9c(%rip),%r15
cmp    (%r15),%al
je     11a0 <main+0x70>
mov    %rsp,%r14
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
movslq %ebx,%r12
mov    %al,(%rsp,%r12,1)
cmp    $0x20,%al
jne    1187 <main+0x57>
mov    %r14,%rdi
mov    %ebx,%esi
call   1040 <countspaces@plt>
cmp    $0x4,%eax
jne    1187 <main+0x57>
movb   $0x9,-0x3(%rsp,%r12,1)
add    $0xfffffffffffffffd,%r12
mov    %r12d,%ebx
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    (%r15),%al
je     11a0 <main+0x70>
lea    0x1(%rbx),%ecx
cmp    $0x3e6,%ebx
mov    %ecx,%ebx
jl     1160 <main+0x30>
lea    0xe59(%rip),%rdi
mov    %rsp,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x3e8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@EOF = global i8 0
@.str = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [1000 x i8]
%3 = alloca i8
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %4
br label %6
6: ; preds = %38, %0
%7 = call signext i8 (...) @getchar()
store i8 %7, i8* %3
%8 = sext i8 %7 to i32
%9 = load i8, i8* @EOF
%10 = sext i8 %9 to i32
%11 = icmp ne i32 %8, %10
br i1 %11, label %12, label %15
12: ; preds = %6
%13 = load i32, i32* %4
%14 = icmp slt i32 %13, 999
br label %15
15: ; preds = %12, %6
%16 = phi i1 [ false, %6 ], [ %14, %12 ]
br i1 %16, label %17, label %41
17: ; preds = %15
%18 = load i8, i8* %3
%19 = load i32, i32* %4
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 %20
store i8 %18, i8* %21
%22 = load i8, i8* %3
%23 = sext i8 %22 to i32
%24 = icmp eq i32 %23, 32
br i1 %24, label %25, label %37
25: ; preds = %17
%26 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 0
%27 = load i32, i32* %4
%28 = call i32 @countspaces(i8* %26, i32 %27)
%29 = icmp eq i32 %28, 4
br i1 %29, label %30, label %37
30: ; preds = %25
%31 = load i32, i32* %4
%32 = sub nsw i32 %31, 3
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 %33
store i8 9, i8* %34
%35 = load i32, i32* %4
%36 = sub nsw i32 %35, 3
store i32 %36, i32* %4
br label %37
37: ; preds = %30, %25, %17
br label %38
38: ; preds = %37
%39 = load i32, i32* %4
%40 = add nsw i32 %39, 1
store i32 %40, i32* %4
br label %6
41: ; preds = %15
%42 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 0
%43 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %42)
ret i32 0
}

LLVM IR (-O2):
@EOF = global i8 0
@.str = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca [1000 x i8]
%2 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%3 = call signext i8 (...) @getchar()
%4 = load i8, i8* @EOF
%5 = icmp eq i8 %3, %4
br i1 %5, label %27, label %6
6: ; preds = %0, %19
%7 = phi i8 [ %22, %19 ], [ %3, %0 ]
%8 = phi i32 [ %21, %19 ], [ 0, %0 ]
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 %9
store i8 %7, i8* %10
%11 = icmp eq i8 %7, 32
br i1 %11, label %12, label %19
12: ; preds = %6
%13 = call i32 @countspaces(i8* %2, i32 %8)
%14 = icmp eq i32 %13, 4
br i1 %14, label %15, label %19
15: ; preds = %12
%16 = add nsw i32 %8, -3
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 %17
store i8 9, i8* %18
br label %19
19: ; preds = %6, %12, %15
%20 = phi i32 [ %16, %15 ], [ %8, %12 ], [ %8, %6 ]
%21 = add nsw i32 %20, 1
%22 = call signext i8 (...) @getchar()
%23 = load i8, i8* @EOF
%24 = icmp ne i8 %22, %23
%25 = icmp slt i32 %20, 998
%26 = select i1 %24, i1 %25, i1 false
br i1 %26, label %6, label %27
27: ; preds = %19, %0
%28 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %2)
ret i32 0
}