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


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     11d0 <detab+0xa0>
cmpl   $0x9,-0xc(%rbp)
jne    1197 <detab+0x67>
jmp    116b <detab+0x3b>
mov    $0x20,%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    $0x1,%eax
jne    116b <detab+0x3b>
jmp    11cb <detab+0x9b>
cmpl   $0xa,-0xc(%rbp)
jne    11b5 <detab+0x85>
mov    -0xc(%rbp),%edi
call   1030 <putchar@plt>
movl   $0x1,-0x10(%rbp)
jmp    11c6 <detab+0x96>
mov    -0xc(%rbp),%edi
call   1030 <putchar@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11cb <detab+0x9b>
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    $0x20,%edi
call   1030 <putchar@plt>
lea    0x1(%rbx),%ebp
mov    %ebx,%edi
mov    %r14,%rsi
call   1050 <tabpos@plt>
mov    %ebp,%ebx
cmp    $0x1,%eax
jne    1190 <detab+0x60>
jmp    116c <detab+0x3c>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    $0x1,%ebp
jmp    116c <detab+0x3c>

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

LLVM IR (-O2):
@EOF = global i32 0
define void @detab(i8* %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 32)
%11 = add nsw i32 %9, 1
%12 = tail call i32 @tabpos(i32 %9, i8* %0)
%13 = icmp eq i32 %12, 1
br i1 %13, label %19, label %8
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
}