#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*/ tabpos(int /*<<< orphan*/, int *);
void detab(int *tab) {
  int c;
  int p = 1;
  while ((c = getchar()) != EOF) {
    if (c == '\t') {
      do {
        putchar('-');
      } while (!tabpos(p++, tab));
    } else if (c == '\n') {
      putchar(c);
      p = 1;
    } else {
      putchar(c);
      p++;
    }
  }
}


x86 assembly (clang, -O0):
<detab>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x1,-0x10(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0xc(%rbp)
mov    0x2e94(%rip),%rcx
cmp    (%rcx),%eax
je     11d7 <detab+0xa7>
cmpl   $0x9,-0xc(%rbp)
jne    119e <detab+0x6e>
jmp    116b <detab+0x3b>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    -0x10(%rbp),%edi
mov    %edi,%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rsi
call   1050 <tabpos@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    116b <detab+0x3b>
jmp    11d2 <detab+0xa2>
cmpl   $0xa,-0xc(%rbp)
jne    11bc <detab+0x8c>
mov    -0xc(%rbp),%edi
call   1030 <putchar@plt>
movl   $0x1,-0x10(%rbp)
jmp    11cd <detab+0x9d>
mov    -0xc(%rbp),%edi
call   1030 <putchar@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11d2 <detab+0xa2>
jmp    1143 <detab+0x13>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<detab>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
xor    %eax,%eax
call   1040 <getchar@plt>
mov    0x2ea0(%rip),%r15
cmp    (%r15),%eax
jne    1158 <detab+0x28>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x1,%ebx
jmp    117a <detab+0x4a>
nop
mov    %eax,%edi
call   1030 <putchar@plt>
add    $0x1,%ebx
mov    %ebx,%ebp
xor    %eax,%eax
call   1040 <getchar@plt>
mov    %ebp,%ebx
cmp    (%r15),%eax
je     114d <detab+0x1d>
cmp    $0xa,%eax
je     11b0 <detab+0x80>
cmp    $0x9,%eax
jne    1160 <detab+0x30>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0x2d,%edi
call   1030 <putchar@plt>
lea    0x1(%rbx),%ebp
mov    %ebx,%edi
mov    %r14,%rsi
call   1050 <tabpos@plt>
mov    %ebp,%ebx
test   %eax,%eax
je     1190 <detab+0x60>
jmp    116c <detab+0x3c>
nop
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    $0x1,%ebp
jmp    116c <detab+0x3c>

LLVM IR (-O0):
@EOF = global i32 0
define void @detab(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
store i32* %0, i32** %2
store i32 1, i32* %4
br label %5
5: ; preds = %35, %1
%6 = call i32 (...) @getchar()
store i32 %6, i32* %3
%7 = load i32, i32* @EOF
%8 = icmp ne i32 %6, %7
br i1 %8, label %9, label %36
9: ; preds = %5
%10 = load i32, i32* %3
%11 = icmp eq i32 %10, 9
br i1 %11, label %12, label %23
12: ; preds = %9
br label %13
13: ; preds = %15, %12
%14 = call i32 @putchar(i32 45)
br label %15
15: ; preds = %13
%16 = load i32, i32* %4
%17 = add nsw i32 %16, 1
store i32 %17, i32* %4
%18 = load i32*, i32** %2
%19 = call i32 @tabpos(i32 %16, i32* %18)
%20 = icmp ne i32 %19, 0
%21 = xor i1 %20, true
br i1 %21, label %13, label %22
22: ; preds = %15
br label %35
23: ; preds = %9
%24 = load i32, i32* %3
%25 = icmp eq i32 %24, 10
br i1 %25, label %26, label %29
26: ; preds = %23
%27 = load i32, i32* %3
%28 = call i32 @putchar(i32 %27)
store i32 1, i32* %4
br label %34
29: ; preds = %23
%30 = load i32, i32* %3
%31 = call i32 @putchar(i32 %30)
%32 = load i32, i32* %4
%33 = add nsw i32 %32, 1
store i32 %33, i32* %4
br label %34
34: ; preds = %29, %26
br label %35
35: ; preds = %34, %22
br label %5
36: ; preds = %5
ret void
}

LLVM IR (-O2):
@EOF = global i32 0
define void @detab(i32* %0) {
%2 = tail call i32 (...) @getchar()
%3 = load i32, i32* @EOF
%4 = icmp eq i32 %2, %3
br i1 %4, label %24, label %5
5: ; preds = %1, %19
%6 = phi i32 [ %21, %19 ], [ %2, %1 ]
%7 = phi i32 [ %20, %19 ], [ 1, %1 ]
switch i32 %6, label %16 [
i32 9, label %8
i32 10, label %14
]
8: ; preds = %5, %8
%9 = phi i32 [ %11, %8 ], [ %7, %5 ]
%10 = tail call i32 @putchar(i32 45)
%11 = add nsw i32 %9, 1
%12 = tail call i32 @tabpos(i32 %9, i32* %0)
%13 = icmp eq i32 %12, 0
br i1 %13, label %8, label %19
14: ; preds = %5
%15 = tail call i32 @putchar(i32 10)
br label %19
16: ; preds = %5
%17 = tail call i32 @putchar(i32 %6)
%18 = add nsw i32 %7, 1
br label %19
19: ; preds = %8, %14, %16
%20 = phi i32 [ 1, %14 ], [ %18, %16 ], [ %11, %8 ]
%21 = tail call i32 (...) @getchar()
%22 = load i32, i32* @EOF
%23 = icmp eq i32 %21, %22
br i1 %23, label %24, label %5
24: ; preds = %19, %1
ret void
}