#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 /*<<< orphan*/ printf(char *, int, int);
int /*<<< orphan*/ putchar(char);
void entab(char new[], char old[]) {
  int i, j;
  int space;
  space = 0;
  i = j = 0;
  while ((new[i] = old[j]) != '\0') {
    if (new[i] == ' ') {
      space++;
      if (space == 4) {
        i = i - 3;
        new[i] = '\t';
        putchar(new[i]);
        space = 0;
      }
    } else {
      space = 0;
      putchar(new[i]);
    }
    i++;
    j++;
  }
  printf("\nLength of normal array:%d\nLength of Entabed array:%d\n", j, i);
}


x86 assembly (clang, -O0):
<entab>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    -0x8(%rbp),%rcx
movslq -0x14(%rbp),%rdx
mov    %al,(%rcx,%rdx,1)
movsbl %al,%eax
cmp    $0x0,%eax
je     11f0 <entab+0xd0>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
jne    11c1 <entab+0xa1>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x4,-0x1c(%rbp)
jne    11bc <entab+0x9c>
mov    -0x14(%rbp),%eax
sub    $0x3,%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movb   $0x9,(%rax,%rcx,1)
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <putchar@plt>
movl   $0x0,-0x1c(%rbp)
jmp    11d9 <entab+0xb9>
movl   $0x0,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <putchar@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1145 <entab+0x25>
mov    -0x18(%rbp),%esi
mov    -0x14(%rbp),%edx
lea    0xe03(%rip),%rdi
call   1040 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<entab>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
xor    %ebx,%ebx
xor    %ebp,%ebp
xor    %eax,%eax
jmp    1155 <entab+0x35>
cs nopw 0x0(%rax,%rax,1)
nop
test   %dl,%dl
je     117e <entab+0x5e>
movsbl %dl,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x1,%ebp
add    $0x1,%rbx
movzbl (%r14,%rbx,1),%edx
movslq %ebp,%rcx
mov    %dl,(%r15,%rcx,1)
cmp    $0x20,%dl
jne    1140 <entab+0x20>
add    $0x1,%eax
cmp    $0x4,%eax
jne    114e <entab+0x2e>
movb   $0x9,-0x3(%r15,%rcx,1)
add    $0xfffffffffffffffd,%rcx
mov    $0x9,%dl
mov    %ecx,%ebp
jmp    1144 <entab+0x24>
lea    0xe7b(%rip),%rdi
mov    %ebx,%esi
mov    %ebp,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [55 x i8] c"\0ALength of normal array:%d\0ALength of Entabed array:%d\0A\00"
define void @entab(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
store i32 0, i32* %7
store i32 0, i32* %6
store i32 0, i32* %5
br label %8
8: ; preds = %54, %2
%9 = load i8*, i8** %4
%10 = load i32, i32* %6
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds i8, i8* %9, i64 %11
%13 = load i8, i8* %12
%14 = load i8*, i8** %3
%15 = load i32, i32* %5
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %14, i64 %16
store i8 %13, i8* %17
%18 = sext i8 %13 to i32
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %59
20: ; preds = %8
%21 = load i8*, i8** %3
%22 = load i32, i32* %5
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %21, i64 %23
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp eq i32 %26, 32
br i1 %27, label %28, label %47
28: ; preds = %20
%29 = load i32, i32* %7
%30 = add nsw i32 %29, 1
store i32 %30, i32* %7
%31 = load i32, i32* %7
%32 = icmp eq i32 %31, 4
br i1 %32, label %33, label %46
33: ; preds = %28
%34 = load i32, i32* %5
%35 = sub nsw i32 %34, 3
store i32 %35, i32* %5
%36 = load i8*, i8** %3
%37 = load i32, i32* %5
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8, i8* %36, i64 %38
store i8 9, i8* %39
%40 = load i8*, i8** %3
%41 = load i32, i32* %5
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i8, i8* %40, i64 %42
%44 = load i8, i8* %43
%45 = call i32 @putchar(i8 signext %44)
store i32 0, i32* %7
br label %46
46: ; preds = %33, %28
br label %54
47: ; preds = %20
store i32 0, i32* %7
%48 = load i8*, i8** %3
%49 = load i32, i32* %5
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i8, i8* %48, i64 %50
%52 = load i8, i8* %51
%53 = call i32 @putchar(i8 signext %52)
br label %54
54: ; preds = %47, %46
%55 = load i32, i32* %5
%56 = add nsw i32 %55, 1
store i32 %56, i32* %5
%57 = load i32, i32* %6
%58 = add nsw i32 %57, 1
store i32 %58, i32* %6
br label %8
59: ; preds = %8
%60 = load i32, i32* %6
%61 = load i32, i32* %5
%62 = call i32 @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str, i64 0, i64 0), i32 %60, i32 %61)
ret void
}

LLVM IR (-O2):
@.str = [55 x i8] c"\0ALength of normal array:%d\0ALength of Entabed array:%d\0A\00"
define void @entab(i8* nocapture writeonly %0, i8* nocapture %1) {
br label %3
3: ; preds = %22, %2
%4 = phi i64 [ %26, %22 ], [ 0, %2 ]
%5 = phi i32 [ %25, %22 ], [ 0, %2 ]
%6 = phi i32 [ %24, %22 ], [ 0, %2 ]
%7 = getelementptr inbounds i8, i8* %1, i64 %4
%8 = load i8, i8* %7
%9 = sext i32 %5 to i64
%10 = getelementptr inbounds i8, i8* %0, i64 %9
store i8 %8, i8* %10
switch i8 %8, label %18 [
i8 0, label %27
i8 32, label %11
]
11: ; preds = %3
%12 = add nsw i32 %6, 1
%13 = icmp eq i32 %12, 4
br i1 %13, label %14, label %22
14: ; preds = %11
%15 = add nsw i32 %5, -3
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %0, i64 %16
store i8 9, i8* %17
br label %18
18: ; preds = %3, %14
%19 = phi i8 [ 9, %14 ], [ %8, %3 ]
%20 = phi i32 [ %15, %14 ], [ %5, %3 ]
%21 = tail call i32 @putchar(i8 signext %19)
br label %22
22: ; preds = %18, %11
%23 = phi i32 [ %5, %11 ], [ %20, %18 ]
%24 = phi i32 [ %12, %11 ], [ 0, %18 ]
%25 = add nsw i32 %23, 1
%26 = add nuw i64 %4, 1
br label %3
27: ; preds = %3
%28 = trunc i64 %4 to i32
%29 = tail call i32 @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str, i64 0, i64 0), i32 %28, i32 %5)
ret void
}