#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 */
char EOF;
char getchar();
scalar_t__ isnottab(int /*<<< orphan*/, char *);
int /*<<< orphan*/ putchar(char);
void detab(char *tabstop) {
  char c;
  int pos = 1;
  while ((c = getchar()) != EOF)
    if (c == '\t')
      do
        (void)putchar(' ');
      while (isnottab(pos++, tabstop));
    else {
      (void)putchar(c);
      if (c == '\n')
        pos = 1;
      else
        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    %al,-0x9(%rbp)
movsbl %al,%eax
mov    0x2e91(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     11d6 <detab+0xa6>
movsbl -0x9(%rbp),%eax
cmp    $0x9,%eax
jne    11a1 <detab+0x71>
jmp    1174 <detab+0x44>
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 <isnottab@plt>
cmp    $0x0,%rax
jne    1174 <detab+0x44>
jmp    11d1 <detab+0xa1>
movsbl -0x9(%rbp),%edi
call   1030 <putchar@plt>
movsbl -0x9(%rbp),%eax
cmp    $0xa,%eax
jne    11c3 <detab+0x93>
movl   $0x1,-0x10(%rbp)
jmp    11cc <detab+0x9c>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11d1 <detab+0xa1>
jmp    1143 <detab+0x13>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<detab>:
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),%al
jne    1160 <detab+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %eax,%r13d
mov    $0x1,%r12d
mov    $0x1,%ebx
jmp    1197 <detab+0x67>
movsbl %r13b,%edi
call   1030 <putchar@plt>
add    $0x1,%ebx
cmp    $0xa,%r13b
cmove  %r12d,%ebx
mov    %ebx,%ebp
xor    %eax,%eax
call   1040 <getchar@plt>
mov    %eax,%r13d
mov    %ebp,%ebx
cmp    (%r15),%al
je     1151 <detab+0x21>
cmp    $0x9,%r13b
jne    1170 <detab+0x40>
nopl   (%rax)
mov    $0x20,%edi
call   1030 <putchar@plt>
lea    0x1(%rbx),%ebp
mov    %ebx,%edi
mov    %r14,%rsi
call   1050 <isnottab@plt>
mov    %ebp,%ebx
test   %rax,%rax
jne    11a0 <detab+0x70>
jmp    1186 <detab+0x56>

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

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