#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 check_arg(char *);
int /*<<< orphan*/ detab(int, int);
int /*<<< orphan*/ entab(int, int);
int /*<<< orphan*/ printf(char *);
int main(int argc, char *argv[]) {
  int i;
  if (argc == 1) {
    printf("Usage: ./program.out -n +m\nDefault value has been setup\n");
    printf("Testing detab func\n");
    detab(8, 0);
    printf("\nTesting entab func\n");
    entab(8, 0);
  } else if ((argc > 1 && argc < 3) || (argc > 3))
    printf("Wrong input. Usage ./program.out -n +m\n");
  else {
    for (i = 1; argv[i] != NULL; i++) {
      detab(check_arg(argv[i]), check_arg(argv[i + 1]));
      ++i;
    }
    for (i = 1; argv[i] != NULL; i++) {
      entab(check_arg(argv[i]), check_arg(argv[i + 1]));
      ++i;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    11a1 <main+0x61>
lea    0xe99(%rip),%rdi
call   1040 <printf@plt>
lea    0xec6(%rip),%rdi
call   1040 <printf@plt>
mov    $0x8,%edi
xor    %esi,%esi
call   1030 <detab@plt>
lea    0xec2(%rip),%rdi
call   1040 <printf@plt>
mov    $0x8,%edi
xor    %esi,%esi
call   1060 <entab@plt>
jmp    12a4 <main+0x164>
cmpl   $0x1,-0x8(%rbp)
jle    11b5 <main+0x75>
cmpl   $0x3,-0x8(%rbp)
jl     11bf <main+0x7f>
cmpl   $0x3,-0x8(%rbp)
jle    11d0 <main+0x90>
lea    0xe9c(%rip),%rdi
call   1040 <printf@plt>
jmp    129f <main+0x15f>
movl   $0x1,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     1235 <main+0xf5>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1050 <check_arg@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
call   1050 <check_arg@plt>
mov    -0x18(%rbp),%edi
mov    %eax,%esi
call   1030 <detab@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11d7 <main+0x97>
movl   $0x1,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     129a <main+0x15a>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1050 <check_arg@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
call   1050 <check_arg@plt>
mov    -0x1c(%rbp),%edi
mov    %eax,%esi
call   1060 <entab@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    123c <main+0xfc>
jmp    129f <main+0x15f>
jmp    12a4 <main+0x164>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
cmp    $0x1,%edi
jne    118a <main+0x4a>
lea    0xed7(%rip),%rdi
call   1030 <puts@plt>
lea    0xf03(%rip),%rdi
call   1030 <puts@plt>
mov    $0x8,%edi
xor    %esi,%esi
call   1040 <detab@plt>
lea    0xefe(%rip),%rdi
call   1030 <puts@plt>
mov    $0x8,%edi
xor    %esi,%esi
call   1060 <entab@plt>
jmp    1223 <main+0xe3>
cmp    $0x2,%edi
je     1217 <main+0xd7>
cmp    $0x3,%edi
jg     1217 <main+0xd7>
mov    %rsi,%r14
mov    0x8(%rsi),%rdi
test   %rdi,%rdi
je     1223 <main+0xe3>
lea    0x18(%r14),%rbx
call   1050 <check_arg@plt>
mov    %eax,%ebp
mov    -0x8(%rbx),%rdi
call   1050 <check_arg@plt>
mov    %ebp,%edi
mov    %eax,%esi
call   1040 <detab@plt>
mov    (%rbx),%rdi
add    $0x10,%rbx
test   %rdi,%rdi
jne    11b0 <main+0x70>
mov    0x8(%r14),%rdi
test   %rdi,%rdi
je     1223 <main+0xe3>
add    $0x18,%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
call   1050 <check_arg@plt>
mov    %eax,%ebp
mov    -0x8(%r14),%rdi
call   1050 <check_arg@plt>
mov    %ebp,%edi
mov    %eax,%esi
call   1060 <entab@plt>
mov    (%r14),%rdi
add    $0x10,%r14
test   %rdi,%rdi
jne    11f0 <main+0xb0>
jmp    1223 <main+0xe3>
lea    0xde2(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [57 x i8] c"Usage: ./program.out -n +m\0ADefault value has been setup\0A\00"
@.str.1 = [20 x i8] c"Testing detab func\0A\00"
@.str.2 = [21 x i8] c"\0ATesting entab func\0A\00"
@.str.3 = [40 x i8] c"Wrong input. Usage ./program.out -n +m\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp eq i32 %7, 1
br i1 %8, label %9, label %15
9: ; preds = %2
%10 = call i32 @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%12 = call i32 @detab(i32 8, i32 0)
%13 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%14 = call i32 @entab(i32 8, i32 0)
br label %84
15: ; preds = %2
%16 = load i32, i32* %4
%17 = icmp sgt i32 %16, 1
br i1 %17, label %18, label %21
18: ; preds = %15
%19 = load i32, i32* %4
%20 = icmp slt i32 %19, 3
br i1 %20, label %24, label %21
21: ; preds = %18, %15
%22 = load i32, i32* %4
%23 = icmp sgt i32 %22, 3
br i1 %23, label %24, label %26
24: ; preds = %21, %18
%25 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0))
br label %83
26: ; preds = %21
store i32 1, i32* %6
br label %27
27: ; preds = %51, %26
%28 = load i8**, i8*** %5
%29 = load i32, i32* %6
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8*, i8** %28, i64 %30
%32 = load i8*, i8** %31
%33 = icmp ne i8* %32, null
br i1 %33, label %34, label %54
34: ; preds = %27
%35 = load i8**, i8*** %5
%36 = load i32, i32* %6
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8*, i8** %35, i64 %37
%39 = load i8*, i8** %38
%40 = call i32 @check_arg(i8* %39)
%41 = load i8**, i8*** %5
%42 = load i32, i32* %6
%43 = add nsw i32 %42, 1
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i8*, i8** %41, i64 %44
%46 = load i8*, i8** %45
%47 = call i32 @check_arg(i8* %46)
%48 = call i32 @detab(i32 %40, i32 %47)
%49 = load i32, i32* %6
%50 = add nsw i32 %49, 1
store i32 %50, i32* %6
br label %51
51: ; preds = %34
%52 = load i32, i32* %6
%53 = add nsw i32 %52, 1
store i32 %53, i32* %6
br label %27
54: ; preds = %27
store i32 1, i32* %6
br label %55
55: ; preds = %79, %54
%56 = load i8**, i8*** %5
%57 = load i32, i32* %6
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds i8*, i8** %56, i64 %58
%60 = load i8*, i8** %59
%61 = icmp ne i8* %60, null
br i1 %61, label %62, label %82
62: ; preds = %55
%63 = load i8**, i8*** %5
%64 = load i32, i32* %6
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds i8*, i8** %63, i64 %65
%67 = load i8*, i8** %66
%68 = call i32 @check_arg(i8* %67)
%69 = load i8**, i8*** %5
%70 = load i32, i32* %6
%71 = add nsw i32 %70, 1
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds i8*, i8** %69, i64 %72
%74 = load i8*, i8** %73
%75 = call i32 @check_arg(i8* %74)
%76 = call i32 @entab(i32 %68, i32 %75)
%77 = load i32, i32* %6
%78 = add nsw i32 %77, 1
store i32 %78, i32* %6
br label %79
79: ; preds = %62
%80 = load i32, i32* %6
%81 = add nsw i32 %80, 1
store i32 %81, i32* %6
br label %55
82: ; preds = %55
br label %83
83: ; preds = %82, %24
br label %84
84: ; preds = %83, %9
ret i32 0
}

LLVM IR (-O2):
@str = [39 x i8] c"Wrong input. Usage ./program.out -n +m\00"
@str.4 = [56 x i8] c"Usage: ./program.out -n +m\0ADefault value has been setup\00"
@str.5 = [19 x i8] c"Testing detab func\00"
@str.6 = [20 x i8] c"\0ATesting entab func\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 1
br i1 %3, label %4, label %10
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @str.4, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.5, i64 0, i64 0))
%7 = tail call i32 @detab(i32 8, i32 0)
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.6, i64 0, i64 0))
%9 = tail call i32 @entab(i32 8, i32 0)
br label %49
10: ; preds = %2
%11 = icmp eq i32 %0, 2
%12 = icmp sgt i32 %0, 3
%13 = or i1 %11, %12
br i1 %13, label %18, label %14
14: ; preds = %10
%15 = getelementptr inbounds i8*, i8** %1, i64 1
%16 = load i8*, i8** %15
%17 = icmp eq i8* %16, null
br i1 %17, label %49, label %23
18: ; preds = %10
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str, i64 0, i64 0))
br label %49
20: ; preds = %23
%21 = load i8*, i8** %15
%22 = icmp eq i8* %21, null
br i1 %22, label %49, label %36
23: ; preds = %14, %23
%24 = phi i64 [ %32, %23 ], [ 1, %14 ]
%25 = phi i8* [ %34, %23 ], [ %16, %14 ]
%26 = tail call i32 @check_arg(i8* %25)
%27 = add nuw nsw i64 %24, 1
%28 = getelementptr inbounds i8*, i8** %1, i64 %27
%29 = load i8*, i8** %28
%30 = tail call i32 @check_arg(i8* %29)
%31 = tail call i32 @detab(i32 %26, i32 %30)
%32 = add nuw i64 %24, 2
%33 = getelementptr inbounds i8*, i8** %1, i64 %32
%34 = load i8*, i8** %33
%35 = icmp eq i8* %34, null
br i1 %35, label %20, label %23
36: ; preds = %20, %36
%37 = phi i64 [ %45, %36 ], [ 1, %20 ]
%38 = phi i8* [ %47, %36 ], [ %21, %20 ]
%39 = tail call i32 @check_arg(i8* %38)
%40 = add nuw nsw i64 %37, 1
%41 = getelementptr inbounds i8*, i8** %1, i64 %40
%42 = load i8*, i8** %41
%43 = tail call i32 @check_arg(i8* %42)
%44 = tail call i32 @entab(i32 %39, i32 %43)
%45 = add nuw i64 %37, 2
%46 = getelementptr inbounds i8*, i8** %1, i64 %45
%47 = load i8*, i8** %46
%48 = icmp eq i8* %47, null
br i1 %48, label %49, label %36
49: ; preds = %36, %14, %20, %18, %4
ret i32 0
}