#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 atoi(char const *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
char getchar();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ putchar(char);
int /*<<< orphan*/ stderr;
int main(int argc, const char **argv) {
  if (argc < 2) {
    fprintf(stderr, "Usage: entab tabwidth1 tabwidth2 ... tabwidthn\n");
    return 1;
  }
  int arg = 1;
  int tabcount = 0;
  int count = 0;
  char c = 0;
  while (1) {
    tabcount = atoi(argv[arg]);
    tabcount = tabcount > 0 ? tabcount : 1;
    count = 0;
    printf(">>> ");
    while ((c = getchar()) != '\n') {
      if (c == ' ') {
        for (int i = 0; i < tabcount - count; ++i) {
          putchar(' ');
        }
      }
      putchar(c);
      count = (count + 1) % tabcount;
    }
    putchar('\n');
    arg = (arg + 1) % argc;
    arg = (arg == 0) ? 1 : arg;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    1190 <main+0x40>
mov    0x2e69(%rip),%rax
mov    (%rax),%edi
lea    0xe80(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%eax
add    $0x30,%rsp
pop    %rbp
ret
movl   $0x1,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movb   $0x0,-0x1d(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jle    11d2 <main+0x82>
mov    -0x18(%rbp),%eax
mov    %eax,-0x28(%rbp)
jmp    11df <main+0x8f>
mov    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11df <main+0x8f>
mov    -0x28(%rbp),%eax
mov    %eax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
lea    0xe3d(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %al,-0x1d(%rbp)
movsbl %al,%eax
cmp    $0xa,%eax
je     126b <main+0x11b>
movsbl -0x1d(%rbp),%eax
cmp    $0x20,%eax
jne    1250 <main+0x100>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    -0x18(%rbp),%ecx
sub    -0x1c(%rbp),%ecx
cmp    %ecx,%eax
jge    124b <main+0xfb>
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1222 <main+0xd2>
jmp    1250 <main+0x100>
movsbl -0x1d(%rbp),%edi
call   1030 <putchar@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
cltd
idivl  -0x18(%rbp)
mov    %edx,-0x1c(%rbp)
jmp    11f8 <main+0xa8>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
cltd
idivl  -0x8(%rbp)
mov    %edx,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    1299 <main+0x149>
mov    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    129f <main+0x14f>
mov    -0x14(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    11a9 <main+0x59>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,0x10(%rsp)
mov    %edi,0xc(%rsp)
cmp    $0x2,%edi
jge    1195 <main+0x45>
mov    0x2e6d(%rip),%rax
mov    (%rax),%edi
lea    0xe84(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x1,%r15d
mov    $0x1,%r13d
jmp    11cf <main+0x7f>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r13d
mov    %r13d,%eax
cltd
idivl  0xc(%rsp)
mov    %edx,%r13d
test   %edx,%edx
cmove  %r15d,%r13d
movslq %r13d,%rax
mov    0x10(%rsp),%rcx
mov    (%rcx,%rax,8),%rdi
call   1070 <atoi@plt>
mov    %eax,%r12d
test   %eax,%eax
cmovle %r15d,%r12d
lea    0xe40(%rip),%rdi
call   1040 <printf@plt>
xor    %ebx,%ebx
jmp    121a <main+0xca>
nopl   0x0(%rax)
cmp    $0xa,%r14b
je     11b0 <main+0x60>
movsbl %r14b,%edi
call   1030 <putchar@plt>
add    $0x1,%ebx
mov    %ebx,%eax
cltd
idiv   %r12d
mov    %edx,%ebx
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %eax,%r14d
cmp    $0x20,%al
jne    1200 <main+0xb0>
mov    %r12d,%ebp
sub    %ebx,%ebp
test   %ebp,%ebp
jle    1206 <main+0xb6>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    $0x20,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
jne    1240 <main+0xf0>
jmp    1206 <main+0xb6>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [48 x i8] c"Usage: entab tabwidth1 tabwidth2 ... tabwidthn\0A\00"
@.str.1 = [5 x i8] c">>> \00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = icmp slt i32 %11, 2
br i1 %12, label %13, label %16
13: ; preds = %2
%14 = load i32, i32* @stderr
%15 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0))
ret i32 1
16: ; preds = %2
store i32 1, i32* %6
store i32 0, i32* %7
store i32 0, i32* %8
store i8 0, i8* %9
br label %17
17: ; preds = %16, %71
%18 = load i8**, i8*** %5
%19 = load i32, i32* %6
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8*, i8** %18, i64 %20
%22 = load i8*, i8** %21
%23 = call i32 @atoi(i8* %22)
store i32 %23, i32* %7
%24 = load i32, i32* %7
%25 = icmp sgt i32 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %17
%27 = load i32, i32* %7
br label %29
28: ; preds = %17
br label %29
29: ; preds = %28, %26
%30 = phi i32 [ %27, %26 ], [ 1, %28 ]
store i32 %30, i32* %7
store i32 0, i32* %8
%31 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %32
32: ; preds = %53, %29
%33 = call signext i8 (...) @getchar()
store i8 %33, i8* %9
%34 = sext i8 %33 to i32
%35 = icmp ne i32 %34, 10
br i1 %35, label %36, label %60
36: ; preds = %32
%37 = load i8, i8* %9
%38 = sext i8 %37 to i32
%39 = icmp eq i32 %38, 32
br i1 %39, label %40, label %53
40: ; preds = %36
store i32 0, i32* %10
br label %41
41: ; preds = %49, %40
%42 = load i32, i32* %10
%43 = load i32, i32* %7
%44 = load i32, i32* %8
%45 = sub nsw i32 %43, %44
%46 = icmp slt i32 %42, %45
br i1 %46, label %47, label %52
47: ; preds = %41
%48 = call i32 @putchar(i8 signext 32)
br label %49
49: ; preds = %47
%50 = load i32, i32* %10
%51 = add nsw i32 %50, 1
store i32 %51, i32* %10
br label %41
52: ; preds = %41
br label %53
53: ; preds = %52, %36
%54 = load i8, i8* %9
%55 = call i32 @putchar(i8 signext %54)
%56 = load i32, i32* %8
%57 = add nsw i32 %56, 1
%58 = load i32, i32* %7
%59 = srem i32 %57, %58
store i32 %59, i32* %8
br label %32
60: ; preds = %32
%61 = call i32 @putchar(i8 signext 10)
%62 = load i32, i32* %6
%63 = add nsw i32 %62, 1
%64 = load i32, i32* %4
%65 = srem i32 %63, %64
store i32 %65, i32* %6
%66 = load i32, i32* %6
%67 = icmp eq i32 %66, 0
br i1 %67, label %68, label %69
68: ; preds = %60
br label %71
69: ; preds = %60
%70 = load i32, i32* %6
br label %71
71: ; preds = %69, %68
%72 = phi i32 [ 1, %68 ], [ %70, %69 ]
store i32 %72, i32* %6
br label %17
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [48 x i8] c"Usage: entab tabwidth1 tabwidth2 ... tabwidthn\0A\00"
@.str.1 = [5 x i8] c">>> \00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0))
ret i32 1
7: ; preds = %2, %31
%8 = phi i32 [ %36, %31 ], [ 1, %2 ]
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds i8*, i8** %1, i64 %9
%11 = load i8*, i8** %10
%12 = tail call i32 @atoi(i8* %11)
%13 = icmp sgt i32 %12, 1
%14 = select i1 %13, i32 %12, i32 1
%15 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %16
16: ; preds = %27, %7
%17 = phi i32 [ 0, %7 ], [ %30, %27 ]
%18 = tail call signext i8 (...) @getchar()
switch i8 %18, label %27 [
i8 10, label %31
i8 32, label %19
]
19: ; preds = %16
%20 = sub i32 %14, %17
%21 = icmp sgt i32 %20, 0
br i1 %21, label %22, label %27
22: ; preds = %19, %22
%23 = phi i32 [ %25, %22 ], [ 0, %19 ]
%24 = tail call i32 @putchar(i8 signext 32)
%25 = add nuw nsw i32 %23, 1
%26 = icmp eq i32 %25, %20
br i1 %26, label %27, label %22
27: ; preds = %22, %19, %16
%28 = tail call i32 @putchar(i8 signext %18)
%29 = add nsw i32 %17, 1
%30 = srem i32 %29, %14
br label %16
31: ; preds = %16
%32 = tail call i32 @putchar(i8 signext 10)
%33 = add nsw i32 %8, 1
%34 = srem i32 %33, %0
%35 = icmp eq i32 %34, 0
%36 = select i1 %35, i32 1, i32 %34
br label %7
}