#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 *basename(char *);
int /*<<< orphan*/ detab(int, int);
int /*<<< orphan*/ entab(int, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ read_arg(char *, int *, int *);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
int main(int argc, char **argv) {
  char *prog_name = basename(argv[0]);
  int m = 0;
  int n = 8;
  for (int i = 1; i < argc; i++)
    read_arg(argv[i], &m, &n);
  printf("m = %d, n = %d\n", m, n);
  if (strcmp(prog_name, "entab") == 0) {
    printf("ENTAB\n");
    entab(m, n);
  } else if (strcmp(prog_name, "detab") == 0) {
    printf("DETAB\n");
    detab(m, n);
  } else {
    fprintf(stderr, "Unrekognized program name: '%s'\n", prog_name);
  }
}


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)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1070 <basename@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x8,-0x20(%rbp)
movl   $0x1,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11de <main+0x6e>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    -0x1c(%rbp),%rsi
lea    -0x20(%rbp),%rdx
call   1080 <read_arg@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11ab <main+0x3b>
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
lea    0xe15(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
lea    0xe13(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    122a <main+0xba>
lea    0xe03(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x1c(%rbp),%edi
mov    -0x20(%rbp),%esi
call   1090 <entab@plt>
jmp    1280 <main+0x110>
mov    -0x18(%rbp),%rdi
lea    0xde8(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1262 <main+0xf2>
lea    0xdd8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x1c(%rbp),%edi
mov    -0x20(%rbp),%esi
call   1030 <detab@plt>
jmp    127b <main+0x10b>
mov    0x2d77(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xdb4(%rip),%rsi
call   1060 <fprintf@plt>
jmp    1280 <main+0x110>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r13
mov    %edi,%ebp
mov    (%rsi),%rdi
call   1080 <basename@plt>
mov    %rax,%r14
movl   $0x0,0x4(%rsp)
movl   $0x8,(%rsp)
cmp    $0x2,%ebp
jl     11e2 <main+0x62>
mov    %ebp,%ebp
mov    $0x1,%ebx
lea    0x4(%rsp),%r15
mov    %rsp,%r12
xchg   %ax,%ax
mov    0x0(%r13,%rbx,8),%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1090 <read_arg@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    11c0 <main+0x40>
mov    0x4(%rsp),%esi
mov    (%rsp),%edx
jmp    11e9 <main+0x69>
xor    %esi,%esi
mov    $0x8,%edx
lea    0xe10(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe12(%rip),%rsi
mov    %r14,%rdi
call   1060 <strcmp@plt>
test   %rax,%rax
je     1239 <main+0xb9>
lea    0xe04(%rip),%rsi
mov    %r14,%rdi
call   1060 <strcmp@plt>
test   %rax,%rax
je     1253 <main+0xd3>
mov    0x2dba(%rip),%rax
mov    (%rax),%edi
lea    0xded(%rip),%rsi
mov    %r14,%rdx
call   1070 <fprintf@plt>
jmp    126b <main+0xeb>
lea    0xe03(%rip),%rdi
call   1030 <puts@plt>
mov    0x4(%rsp),%edi
mov    (%rsp),%esi
call   10a0 <entab@plt>
jmp    126b <main+0xeb>
lea    0xde3(%rip),%rdi
call   1030 <puts@plt>
mov    0x4(%rsp),%edi
mov    (%rsp),%esi
call   1040 <detab@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [16 x i8] c"m = %d, n = %d\0A\00"
@.str.1 = [6 x i8] c"entab\00"
@.str.2 = [7 x i8] c"ENTAB\0A\00"
@.str.3 = [6 x i8] c"detab\00"
@.str.4 = [7 x i8] c"DETAB\0A\00"
@stderr = global i32 0
@.str.5 = [33 x i8] c"Unrekognized program name: '%s'\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 0
%12 = load i8*, i8** %11
%13 = call i8* @basename(i8* %12)
store i8* %13, i8** %6
store i32 0, i32* %7
store i32 8, i32* %8
store i32 1, i32* %9
br label %14
14: ; preds = %25, %2
%15 = load i32, i32* %9
%16 = load i32, i32* %4
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %28
18: ; preds = %14
%19 = load i8**, i8*** %5
%20 = load i32, i32* %9
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8*, i8** %19, i64 %21
%23 = load i8*, i8** %22
%24 = call i32 @read_arg(i8* %23, i32* %7, i32* %8)
br label %25
25: ; preds = %18
%26 = load i32, i32* %9
%27 = add nsw i32 %26, 1
store i32 %27, i32* %9
br label %14
28: ; preds = %14
%29 = load i32, i32* %7
%30 = load i32, i32* %8
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %29, i32 %30)
%32 = load i8*, i8** %6
%33 = call i64 @strcmp(i8* %32, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%34 = icmp eq i64 %33, 0
br i1 %34, label %35, label %40
35: ; preds = %28
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%37 = load i32, i32* %7
%38 = load i32, i32* %8
%39 = call i32 @entab(i32 %37, i32 %38)
br label %54
40: ; preds = %28
%41 = load i8*, i8** %6
%42 = call i64 @strcmp(i8* %41, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%43 = icmp eq i64 %42, 0
br i1 %43, label %44, label %49
44: ; preds = %40
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%46 = load i32, i32* %7
%47 = load i32, i32* %8
%48 = call i32 @detab(i32 %46, i32 %47)
br label %53
49: ; preds = %40
%50 = load i32, i32* @stderr
%51 = load i8*, i8** %6
%52 = call i32 @fprintf(i32 %50, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0), i8* %51)
br label %53
53: ; preds = %49, %44
br label %54
54: ; preds = %53, %35
%55 = load i32, i32* %3
ret i32 %55
}

LLVM IR (-O2):
@.str = [16 x i8] c"m = %d, n = %d\0A\00"
@.str.1 = [6 x i8] c"entab\00"
@.str.3 = [6 x i8] c"detab\00"
@stderr = global i32 0
@.str.5 = [33 x i8] c"Unrekognized program name: '%s'\0A\00"
@str = [6 x i8] c"DETAB\00"
@str.6 = [6 x i8] c"ENTAB\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i32
%5 = load i8*, i8** %1
%6 = tail call i8* @basename(i8* %5)
%7 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%8 = bitcast i32* %4 to i8*
store i32 8, i32* %4
%9 = icmp sgt i32 %0, 1
br i1 %9, label %10, label %15
10: ; preds = %2
%11 = zext i32 %0 to i64
br label %21
12: ; preds = %21
%13 = load i32, i32* %3
%14 = load i32, i32* %4
br label %15
15: ; preds = %12, %2
%16 = phi i32 [ %14, %12 ], [ 8, %2 ]
%17 = phi i32 [ %13, %12 ], [ 0, %2 ]
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %17, i32 %16)
%19 = call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
br i1 %20, label %28, label %33
21: ; preds = %10, %21
%22 = phi i64 [ 1, %10 ], [ %26, %21 ]
%23 = getelementptr inbounds i8*, i8** %1, i64 %22
%24 = load i8*, i8** %23
%25 = call i32 @read_arg(i8* %24, i32* %3, i32* %4)
%26 = add nuw nsw i64 %22, 1
%27 = icmp eq i64 %26, %11
br i1 %27, label %12, label %21
28: ; preds = %15
%29 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.6, i64 0, i64 0))
%30 = load i32, i32* %3
%31 = load i32, i32* %4
%32 = call i32 @entab(i32 %30, i32 %31)
br label %44
33: ; preds = %15
%34 = call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%35 = icmp eq i64 %34, 0
br i1 %35, label %36, label %41
36: ; preds = %33
%37 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str, i64 0, i64 0))
%38 = load i32, i32* %3
%39 = load i32, i32* %4
%40 = call i32 @detab(i32 %38, i32 %39)
br label %44
41: ; preds = %33
%42 = load i32, i32* @stderr
%43 = call i32 @fprintf(i32 %42, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0), i8* %6)
br label %44
44: ; preds = %36, %41, %28
ret i32 0
}