#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);
int /*<<< orphan*/ putchar(char);
void detab(char new[], char old[], int tab) {
  int i, j, n;
  int count;
  count = 0;
  i = j = n = 0;
  while ((new[i] = old[j]) != '\0') {
    if (new[i] == '\t') {
      for (n = 0; n < tab; ++n, ++i) {
        new[i] = ' ';
        count++;
        putchar(new[i]);
      }
      i++;
      j++;
    } else {
      putchar(new[i]);
      i++;
      j++;
    }
  }
  printf("\nNumber of blanks(corresponding to used tabs):%d\nLength of normal "
         "array:%d\nLength of Detabed array:%d\n",
         count, j, i);
}


x86 assembly (clang, -O0):
<detab>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    -0x8(%rbp),%rcx
movslq -0x18(%rbp),%rdx
mov    %al,(%rcx,%rdx,1)
movsbl %al,%eax
cmp    $0x0,%eax
je     1215 <detab+0xf5>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x9,%eax
jne    11ed <detab+0xcd>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11d6 <detab+0xb6>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movb   $0x20,(%rax,%rcx,1)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <putchar@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    118d <detab+0x6d>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1210 <detab+0xf0>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <putchar@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    114f <detab+0x2f>
mov    -0x24(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x18(%rbp),%ecx
lea    0xddb(%rip),%rdi
call   1040 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<detab>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r15
mov    %rdi,%r12
mov    %edx,0xc(%rsp)
mov    %edx,%r13d
xor    %ebx,%ebx
xor    %ebp,%ebp
movl   $0x0,0x8(%rsp)
mov    %rsi,0x10(%rsp)
jmp    1157 <detab+0x37>
xchg   %ax,%ax
add    $0x1,%rbx
add    $0x1,%ebp
mov    (%r15,%rbx,1),%al
movslq %ebp,%r14
mov    %al,(%r12,%r14,1)
cmp    $0x9,%al
je     1180 <detab+0x60>
test   %al,%al
je     11be <detab+0x9e>
movsbl %al,%edi
call   1030 <putchar@plt>
jmp    1150 <detab+0x30>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cmpl   $0x0,0xc(%rsp)
jle    1150 <detab+0x30>
add    %r12,%r14
xor    %r15d,%r15d
nopl   (%rax)
movb   $0x20,(%r14,%r15,1)
mov    $0x20,%edi
call   1030 <putchar@plt>
add    $0x1,%r15
cmp    %r15d,%r13d
jne    1190 <detab+0x70>
mov    0x8(%rsp),%eax
add    0xc(%rsp),%eax
mov    %eax,0x8(%rsp)
add    %r15d,%ebp
mov    0x10(%rsp),%r15
jmp    1150 <detab+0x30>
lea    0xe3b(%rip),%rdi
mov    0x8(%rsp),%esi
mov    %ebx,%edx
mov    %ebp,%ecx
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <printf@plt>

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

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