#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(char);
scalar_t__ tabpos(int, int *);
void entab(int *tab) {
  int c;
  int pos = 0;
  int space = 0;
  while ((c = getchar()) != EOF) {
    pos++;
    if (c == ' ') {
      space++;
    } else {
      if (c == '\t') {
        space = 0;
        while (!tabpos(pos, tab)) {
          pos++;
        }
        putchar('\\');
        putchar('t');
      } else if (c == '\n') {
        space = 0;
        pos = 0;
        putchar(c);
      } else {
        while (space > 0) {
          putchar('-');
          space--;
        }
        putchar(c);
      }
    }
    if (tabpos(pos, tab) && space > 0) {
      space = 0;
      putchar('\\');
      putchar('t');
    }
  }
}


x86 assembly (clang, -O0):
<entab>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0xc(%rbp)
mov    0x2e8d(%rip),%rcx
cmp    (%rcx),%eax
je     1282 <entab+0x152>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x20,-0xc(%rbp)
jne    1184 <entab+0x54>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1242 <entab+0x112>
cmpl   $0x9,-0xc(%rbp)
jne    11de <entab+0xae>
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%edi
mov    -0x8(%rbp),%rsi
call   1050 <tabpos@plt>
cmp    $0x0,%rax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11b7 <entab+0x87>
jmp    11c5 <entab+0x95>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1195 <entab+0x65>
mov    $0x5c,%edi
call   1030 <putchar@plt>
mov    $0x74,%edi
call   1030 <putchar@plt>
jmp    123d <entab+0x10d>
cmpl   $0xa,-0xc(%rbp)
jne    1206 <entab+0xd6>
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0xc(%rbp),%eax
movsbl %al,%edi
call   1030 <putchar@plt>
jmp    1238 <entab+0x108>
jmp    120b <entab+0xdb>
cmpl   $0x0,-0x14(%rbp)
jle    122d <entab+0xfd>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    120b <entab+0xdb>
mov    -0xc(%rbp),%eax
movsbl %al,%edi
call   1030 <putchar@plt>
jmp    123d <entab+0x10d>
jmp    1242 <entab+0x112>
mov    -0x10(%rbp),%edi
mov    -0x8(%rbp),%rsi
call   1050 <tabpos@plt>
cmp    $0x0,%rax
je     127d <entab+0x14d>
cmpl   $0x0,-0x14(%rbp)
jle    127d <entab+0x14d>
movl   $0x0,-0x14(%rbp)
mov    $0x5c,%edi
call   1030 <putchar@plt>
mov    $0x74,%edi
call   1030 <putchar@plt>
jmp    114a <entab+0x1a>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<entab>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
xor    %eax,%eax
call   1040 <getchar@plt>
mov    0x2e9c(%rip),%r15
cmp    (%r15),%eax
jne    1160 <entab+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %eax,%r12d
xor    %ebp,%ebp
xor    %ebx,%ebx
jmp    117f <entab+0x4f>
nopl   0x0(%rax)
xor    %eax,%eax
call   1040 <getchar@plt>
mov    %eax,%r12d
cmp    (%r15),%eax
je     1151 <entab+0x21>
lea    0x1(%rbx),%r13d
cmp    $0x20,%r12d
je     11e0 <entab+0xb0>
cmp    $0xa,%r12d
je     11d0 <entab+0xa0>
cmp    $0x9,%r12d
jne    11f0 <entab+0xc0>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%ebx
mov    %ebx,%edi
mov    %r14,%rsi
call   1050 <tabpos@plt>
test   %rax,%rax
je     11a0 <entab+0x70>
mov    $0x5c,%edi
call   1030 <putchar@plt>
mov    $0x74,%edi
call   1030 <putchar@plt>
jmp    11dc <entab+0xac>
nopl   0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %ebx,%ebx
xor    %ebp,%ebp
jmp    1220 <entab+0xf0>
add    $0x1,%ebp
jmp    121d <entab+0xed>
cs nopw 0x0(%rax,%rax,1)
nop
test   %ebp,%ebp
jle    1214 <entab+0xe4>
add    $0x1,%ebp
nopw   0x0(%rax,%rax,1)
mov    $0x2d,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
cmp    $0x1,%ebp
ja     1200 <entab+0xd0>
xor    %ebp,%ebp
movsbl %r12b,%edi
call   1030 <putchar@plt>
mov    %r13d,%ebx
mov    %ebx,%edi
mov    %r14,%rsi
call   1050 <tabpos@plt>
test   %rax,%rax
je     1170 <entab+0x40>
test   %ebp,%ebp
jle    1170 <entab+0x40>
mov    $0x5c,%edi
call   1030 <putchar@plt>
mov    $0x74,%edi
call   1030 <putchar@plt>
xor    %ebp,%ebp
jmp    1170 <entab+0x40>

LLVM IR (-O0):
@EOF = global i32 0
define void @entab(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32* %0, i32** %2
store i32 0, i32* %4
store i32 0, i32* %5
br label %6
6: ; preds = %66, %1
%7 = call i32 (...) @getchar()
store i32 %7, i32* %3
%8 = load i32, i32* @EOF
%9 = icmp ne i32 %7, %8
br i1 %9, label %10, label %67
10: ; preds = %6
%11 = load i32, i32* %4
%12 = add nsw i32 %11, 1
store i32 %12, i32* %4
%13 = load i32, i32* %3
%14 = icmp eq i32 %13, 32
br i1 %14, label %15, label %18
15: ; preds = %10
%16 = load i32, i32* %5
%17 = add nsw i32 %16, 1
store i32 %17, i32* %5
br label %55
18: ; preds = %10
%19 = load i32, i32* %3
%20 = icmp eq i32 %19, 9
br i1 %20, label %21, label %34
21: ; preds = %18
store i32 0, i32* %5
br label %22
22: ; preds = %28, %21
%23 = load i32, i32* %4
%24 = load i32*, i32** %2
%25 = call i64 @tabpos(i32 %23, i32* %24)
%26 = icmp ne i64 %25, 0
%27 = xor i1 %26, true
br i1 %27, label %28, label %31
28: ; preds = %22
%29 = load i32, i32* %4
%30 = add nsw i32 %29, 1
store i32 %30, i32* %4
br label %22
31: ; preds = %22
%32 = call i32 @putchar(i8 signext 92)
%33 = call i32 @putchar(i8 signext 116)
br label %54
34: ; preds = %18
%35 = load i32, i32* %3
%36 = icmp eq i32 %35, 10
br i1 %36, label %37, label %41
37: ; preds = %34
store i32 0, i32* %5
store i32 0, i32* %4
%38 = load i32, i32* %3
%39 = trunc i32 %38 to i8
%40 = call i32 @putchar(i8 signext %39)
br label %53
41: ; preds = %34
br label %42
42: ; preds = %45, %41
%43 = load i32, i32* %5
%44 = icmp sgt i32 %43, 0
br i1 %44, label %45, label %49
45: ; preds = %42
%46 = call i32 @putchar(i8 signext 45)
%47 = load i32, i32* %5
%48 = add nsw i32 %47, -1
store i32 %48, i32* %5
br label %42
49: ; preds = %42
%50 = load i32, i32* %3
%51 = trunc i32 %50 to i8
%52 = call i32 @putchar(i8 signext %51)
br label %53
53: ; preds = %49, %37
br label %54
54: ; preds = %53, %31
br label %55
55: ; preds = %54, %15
%56 = load i32, i32* %4
%57 = load i32*, i32** %2
%58 = call i64 @tabpos(i32 %56, i32* %57)
%59 = icmp ne i64 %58, 0
br i1 %59, label %60, label %66
60: ; preds = %55
%61 = load i32, i32* %5
%62 = icmp sgt i32 %61, 0
br i1 %62, label %63, label %66
63: ; preds = %60
store i32 0, i32* %5
%64 = call i32 @putchar(i8 signext 92)
%65 = call i32 @putchar(i8 signext 116)
br label %66
66: ; preds = %63, %60, %55
br label %6
67: ; preds = %6
ret void
}

LLVM IR (-O2):
@EOF = global i32 0
define void @entab(i32* %0) {
%2 = tail call i32 (...) @getchar()
%3 = load i32, i32* @EOF
%4 = icmp eq i32 %2, %3
br i1 %4, label %48, label %5
5: ; preds = %1, %43
%6 = phi i32 [ %45, %43 ], [ %2, %1 ]
%7 = phi i32 [ %44, %43 ], [ 0, %1 ]
%8 = phi i32 [ %34, %43 ], [ 0, %1 ]
%9 = add nsw i32 %8, 1
switch i32 %6, label %10 [
i32 32, label %12
i32 9, label %14
i32 10, label %22
]
10: ; preds = %5
%11 = icmp sgt i32 %7, 0
br i1 %11, label %24, label %29
12: ; preds = %5
%13 = add nsw i32 %7, 1
br label %33
14: ; preds = %5, %14
%15 = phi i32 [ %18, %14 ], [ %9, %5 ]
%16 = tail call i64 @tabpos(i32 %15, i32* %0)
%17 = icmp eq i64 %16, 0
%18 = add nsw i32 %15, 1
br i1 %17, label %14, label %19
19: ; preds = %14
%20 = tail call i32 @putchar(i8 signext 92)
%21 = tail call i32 @putchar(i8 signext 116)
br label %33
22: ; preds = %5
%23 = tail call i32 @putchar(i8 signext 10)
br label %33
24: ; preds = %10, %24
%25 = phi i32 [ %27, %24 ], [ %7, %10 ]
%26 = tail call i32 @putchar(i8 signext 45)
%27 = add nsw i32 %25, -1
%28 = icmp ugt i32 %25, 1
br i1 %28, label %24, label %29
29: ; preds = %24, %10
%30 = phi i32 [ %7, %10 ], [ 0, %24 ]
%31 = trunc i32 %6 to i8
%32 = tail call i32 @putchar(i8 signext %31)
br label %33
33: ; preds = %19, %29, %22, %12
%34 = phi i32 [ %9, %12 ], [ %15, %19 ], [ 0, %22 ], [ %9, %29 ]
%35 = phi i32 [ %13, %12 ], [ 0, %19 ], [ 0, %22 ], [ %30, %29 ]
%36 = tail call i64 @tabpos(i32 %34, i32* %0)
%37 = icmp ne i64 %36, 0
%38 = icmp sgt i32 %35, 0
%39 = select i1 %37, i1 %38, i1 false
br i1 %39, label %40, label %43
40: ; preds = %33
%41 = tail call i32 @putchar(i8 signext 92)
%42 = tail call i32 @putchar(i8 signext 116)
br label %43
43: ; preds = %40, %33
%44 = phi i32 [ 0, %40 ], [ %35, %33 ]
%45 = tail call i32 (...) @getchar()
%46 = load i32, i32* @EOF
%47 = icmp eq i32 %45, %46
br i1 %47, label %48, label %5
48: ; preds = %43, %1
ret void
}