#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*/ print_spaces(int);
int /*<<< orphan*/ putchar(int);
void entab(int character, int start_column, int tab_stop) {
  static int column_count, space_count;
  if ((column_count += (character == '\t') ? tab_stop : 1) >= start_column) {
    if (character == ' ') {
      if (++space_count >= tab_stop) {
        putchar('\t');
        space_count = 0;
      }
    } else {
      print_spaces(space_count);
      space_count = 0;
      putchar(character);
    }
  } else
    putchar(character);
  if (character == '\n')
    column_count = space_count = 0;
}


x86 assembly (clang, -O0):
<entab>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
cmpl   $0x9,-0x4(%rbp)
jne    1146 <entab+0x26>
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    1153 <entab+0x33>
mov    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1153 <entab+0x33>
mov    -0x10(%rbp),%eax
add    0x2ed8(%rip),%eax
mov    %eax,0x2ed2(%rip)
cmp    -0x8(%rbp),%eax
jl     11c8 <entab+0xa8>
cmpl   $0x20,-0x4(%rbp)
jne    11a6 <entab+0x86>
mov    0x2ebd(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2eb4(%rip)
cmp    -0xc(%rbp),%eax
jl     11a1 <entab+0x81>
mov    $0x9,%edi
call   1030 <putchar@plt>
movl   $0x0,0x2e97(%rip)
jmp    11c3 <entab+0xa3>
mov    0x2e8c(%rip),%edi
call   1040 <print_spaces@plt>
movl   $0x0,0x2e7d(%rip)
mov    -0x4(%rbp),%edi
call   1030 <putchar@plt>
jmp    11d0 <entab+0xb0>
mov    -0x4(%rbp),%edi
call   1030 <putchar@plt>
cmpl   $0xa,-0x4(%rbp)
jne    11ee <entab+0xce>
movl   $0x0,0x2e54(%rip)
movl   $0x0,0x2e46(%rip)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<entab>:
push   %rbx
mov    %edi,%ebx
cmp    $0x9,%edi
mov    $0x1,%eax
cmove  %edx,%eax
add    0x2f00(%rip),%eax
mov    %eax,0x2efa(%rip)
cmp    %esi,%eax
jl     1178 <entab+0x58>
mov    0x2ef4(%rip),%edi
cmp    $0x20,%ebx
jne    1169 <entab+0x49>
add    $0x1,%edi
mov    %edi,0x2ee6(%rip)
cmp    %edx,%edi
jl     119b <entab+0x7b>
mov    $0x9,%edi
call   1030 <putchar@plt>
lea    0x2ed1(%rip),%rax
jmp    1195 <entab+0x75>
call   1040 <print_spaces@plt>
movl   $0x0,0x2ec0(%rip)
mov    %ebx,%edi
call   1030 <putchar@plt>
cmp    $0xa,%ebx
jne    119b <entab+0x7b>
movl   $0x0,0x2eaa(%rip)
lea    0x2e9f(%rip),%rax
movl   $0x0,(%rax)
pop    %rbx
ret

LLVM IR (-O0):
@entab.column_count = internal global i32 0
@entab.space_count = internal global i32 0
define void @entab(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%7 = load i32, i32* %4
%8 = icmp eq i32 %7, 9
br i1 %8, label %9, label %11
9: ; preds = %3
%10 = load i32, i32* %6
br label %12
11: ; preds = %3
br label %12
12: ; preds = %11, %9
%13 = phi i32 [ %10, %9 ], [ 1, %11 ]
%14 = load i32, i32* @entab.column_count
%15 = add nsw i32 %14, %13
store i32 %15, i32* @entab.column_count
%16 = load i32, i32* %5
%17 = icmp sge i32 %15, %16
br i1 %17, label %18, label %35
18: ; preds = %12
%19 = load i32, i32* %4
%20 = icmp eq i32 %19, 32
br i1 %20, label %21, label %29
21: ; preds = %18
%22 = load i32, i32* @entab.space_count
%23 = add nsw i32 %22, 1
store i32 %23, i32* @entab.space_count
%24 = load i32, i32* %6
%25 = icmp sge i32 %23, %24
br i1 %25, label %26, label %28
26: ; preds = %21
%27 = call i32 @putchar(i32 9)
store i32 0, i32* @entab.space_count
br label %28
28: ; preds = %26, %21
br label %34
29: ; preds = %18
%30 = load i32, i32* @entab.space_count
%31 = call i32 @print_spaces(i32 %30)
store i32 0, i32* @entab.space_count
%32 = load i32, i32* %4
%33 = call i32 @putchar(i32 %32)
br label %34
34: ; preds = %29, %28
br label %38
35: ; preds = %12
%36 = load i32, i32* %4
%37 = call i32 @putchar(i32 %36)
br label %38
38: ; preds = %35, %34
%39 = load i32, i32* %4
%40 = icmp eq i32 %39, 10
br i1 %40, label %41, label %42
41: ; preds = %38
store i32 0, i32* @entab.space_count
store i32 0, i32* @entab.column_count
br label %42
42: ; preds = %41, %38
ret void
}

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