// File: /workspace/github_c_makefile_star2_O0/simh[P]simtools/converters/indent/indent.c
// Function: main
int main (int argc, char *argv[])
{
int i, j, fill, itc, incomm, in8tab, ip, op;
char *ppos, iline[256], oline[256], oname[256];
FILE *ifile, *ofile;

if ((argc < 2) || (argv[0] == NULL)) {
	printf ("Usage is: asc file [file...]\n");
	exit (0);  }

for (i = 1; i < argc; i++) {
	strcpy (oname, argv[i]);
        if (ppos = strrchr (oname, '.')) strcpy (ppos, ".new");
            else strcat (oname, ".new");
	ifile = fopen (argv[i], "ra");
	if (ifile == NULL) {
	    printf ("Error opening file: %s\n", argv[i]);
	    exit (0);  }
	ofile = fopen (oname, "wa");
	if (ofile == NULL) {
	    printf ("Error opening file: %s\n", oname);
	    exit (0);  }

	printf ("Processing file %s\n", argv[i]);
	for (incomm = in8tab = 0;;) {
	    for (j = 0; j < 256; j++) iline[j] = oline[j] = 0;
	    if (fgets (iline, 256, ifile) == NULL) break;
	    ip = 0;
	    if (!incomm) {
		    if (strncmp (iline, "    ", 4) == 0) in8tab = 1;
		    else if (!isspace (iline[0]) && (iline[0] != '#') && strncmp (iline, "/*", 2)) in8tab = 0;
		    if ((strncmp (iline, "else {\t", 7) == 0) &&
		        !isspace (iline[7])) {
		        fputs ("else {\n", ofile);
		        ip = 6;
		        }
		    else if ((strncmp (iline, "do {\t", 5) == 0) &&
		        !isspace (iline[5])) {
		        fputs ("do {\n", ofile);
		        ip = 4;
		        }
		    }
	    for (itc = op = 0; iline[ip]; ip++) {
		    if (!incomm && (op == 0)) {
		        if (iline[ip] == '\t') {
			        itc++;
			        continue;
			        }
		        else if (itc) {
			        fill = (itc * 8) - (in8tab? 0: 4);
			        while (fill--) oline[op++] = ' ';
			        }
		        }
		    switch (iline[ip]) {
		    case '/':
		        if (!incomm && (iline[ip + 1] == '*')) {
			    incomm = 1;
			    if (ip != 0) {
			        while (op < COMM_POS) oline[op++] = ' ';
			        }
			    }
		        oline[op++] = iline[ip];
		        break;
		    case '*':
		        if (incomm && (iline[ip + 1] == '/')) incomm = 0;
		        oline[op++] = iline[ip];
		        break;
		    case '\t':
		        fill = 8 - (op % 8);
		        while (fill--) oline[op++] = ' ';
		        break;
		    case '\r':
		        break;
		    default:
		        oline[op++] = iline[ip];
		        break;
		        }
		    }
	    if (op) fputs (oline, ofile);
	    }
	fclose (ifile);
	fclose (ofile);
	}
return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x360, %rsp            # imm = 0x360
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpl $0x2, -0x8(%rbp)
jl 0x1209
movq -0x10(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x121e
leaq 0xe90(%rip), %rdi       # 0x20a0
movb $0x0, %al
callq 0x1060
xorl %edi, %edi
callq 0x10c0
movl $0x1, -0x14(%rbp)
movl -0x14(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0x1704
leaq -0x340(%rbp), %rdi
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
callq 0x1040
leaq -0x340(%rbp), %rdi
movl $0x2e, %esi
callq 0x1070
movq %rax, -0x38(%rbp)
cmpq $0x0, %rax
je 0x1276
movq -0x38(%rbp), %rdi
leaq 0xe4f(%rip), %rsi       # 0x20be
callq 0x1040
jmp 0x1289
leaq -0x340(%rbp), %rdi
leaq 0xe3a(%rip), %rsi       # 0x20be
callq 0x10b0
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0xe27(%rip), %rsi       # 0x20c3
callq 0x10a0
movq %rax, -0x348(%rbp)
cmpq $0x0, -0x348(%rbp)
jne 0x12d3
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
leaq 0xe01(%rip), %rdi       # 0x20c6
movb $0x0, %al
callq 0x1060
xorl %edi, %edi
callq 0x10c0
leaq -0x340(%rbp), %rdi
leaq 0xdfd(%rip), %rsi       # 0x20de
callq 0x10a0
movq %rax, -0x350(%rbp)
cmpq $0x0, -0x350(%rbp)
jne 0x1313
leaq -0x340(%rbp), %rsi
leaq 0xdc1(%rip), %rdi       # 0x20c6
movb $0x0, %al
callq 0x1060
xorl %edi, %edi
callq 0x10c0
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
leaq 0xdbb(%rip), %rdi       # 0x20e1
movb $0x0, %al
callq 0x1060
movl $0x0, -0x28(%rbp)
movl $0x0, -0x24(%rbp)
movl $0x0, -0x18(%rbp)
cmpl $0x100, -0x18(%rbp)     # imm = 0x100
jge 0x136e
movslq -0x18(%rbp), %rax
movb $0x0, -0x240(%rbp,%rax)
movslq -0x18(%rbp), %rax
movb $0x0, -0x140(%rbp,%rax)
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x1342
leaq -0x140(%rbp), %rdi
movq -0x348(%rbp), %rdx
movl $0x100, %esi            # imm = 0x100
callq 0x1090
cmpq $0x0, %rax
jne 0x1391
jmp 0x16de
movl $0x0, -0x2c(%rbp)
cmpl $0x0, -0x24(%rbp)
jne 0x14ce
leaq -0x140(%rbp), %rdi
leaq 0xd45(%rip), %rsi       # 0x20f5
movl $0x4, %edx
callq 0x1030
cmpl $0x0, %eax
jne 0x13c8
movl $0x1, -0x28(%rbp)
jmp 0x141a
callq 0x10d0
movq (%rax), %rax
movsbl -0x140(%rbp), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x2000, %eax           # imm = 0x2000
cmpl $0x0, %eax
jne 0x1418
movsbl -0x140(%rbp), %eax
cmpl $0x23, %eax
je 0x1418
leaq -0x140(%rbp), %rdi
leaq 0xcf8(%rip), %rsi       # 0x20fa
movl $0x2, %edx
callq 0x1030
cmpl $0x0, %eax
je 0x1418
movl $0x0, -0x28(%rbp)
jmp 0x141a
leaq -0x140(%rbp), %rdi
leaq 0xcd5(%rip), %rsi       # 0x20fd
movl $0x7, %edx
callq 0x1030
cmpl $0x0, %eax
jne 0x1473
callq 0x10d0
movq (%rax), %rax
movsbl -0x139(%rbp), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x2000, %eax           # imm = 0x2000
cmpl $0x0, %eax
jne 0x1473
movq -0x350(%rbp), %rsi
leaq 0xca0(%rip), %rdi       # 0x2105
callq 0x1080
movl $0x6, -0x2c(%rbp)
jmp 0x14cc
leaq -0x140(%rbp), %rdi
leaq 0xc8c(%rip), %rsi       # 0x210d
movl $0x5, %edx
callq 0x1030
cmpl $0x0, %eax
jne 0x14ca
callq 0x10d0
movq (%rax), %rax
movsbl -0x13b(%rbp), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x2000, %eax           # imm = 0x2000
cmpl $0x0, %eax
jne 0x14ca
movq -0x350(%rbp), %rsi
leaq 0xc55(%rip), %rdi       # 0x2113
callq 0x1080
movl $0x4, -0x2c(%rbp)
jmp 0x14cc
jmp 0x14ce
movl $0x0, -0x30(%rbp)
movl $0x0, -0x20(%rbp)
movslq -0x2c(%rbp), %rax
cmpb $0x0, -0x140(%rbp,%rax)
je 0x16c0
cmpl $0x0, -0x24(%rbp)
jne 0x1567
cmpl $0x0, -0x30(%rbp)
jne 0x1567
movslq -0x2c(%rbp), %rax
movsbl -0x140(%rbp,%rax), %eax
cmpl $0x9, %eax
jne 0x1519
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x16b2
cmpl $0x0, -0x20(%rbp)
je 0x1563
movl -0x20(%rbp), %eax
shll $0x3, %eax
movl -0x28(%rbp), %esi
movl $0x4, %ecx
xorl %edx, %edx
cmpl $0x0, %esi
cmovnel %edx, %ecx
subl %ecx, %eax
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
movl %eax, %ecx
addl $-0x1, %ecx
movl %ecx, -0x1c(%rbp)
cmpl $0x0, %eax
je 0x1561
movl -0x30(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x30(%rbp)
cltq
movb $0x20, -0x240(%rbp,%rax)
jmp 0x153a
jmp 0x1563
jmp 0x1565
jmp 0x1567
movslq -0x2c(%rbp), %rax
movsbl -0x140(%rbp,%rax), %eax
addl $-0x9, %eax
movl %eax, %ecx
movq %rcx, -0x358(%rbp)
subl $0x26, %eax
ja 0x1691
movq -0x358(%rbp), %rax
leaq 0xa6e(%rip), %rcx       # 0x2004
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
cmpl $0x0, -0x24(%rbp)
jne 0x15ea
movl -0x2c(%rbp), %eax
addl $0x1, %eax
cltq
movsbl -0x140(%rbp,%rax), %eax
cmpl $0x2a, %eax
jne 0x15ea
movl $0x1, -0x24(%rbp)
cmpl $0x0, -0x2c(%rbp)
je 0x15e8
jmp 0x15c9
cmpl $0x38, -0x30(%rbp)
jge 0x15e6
movl -0x30(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x30(%rbp)
cltq
movb $0x20, -0x240(%rbp,%rax)
jmp 0x15c9
jmp 0x15e8
jmp 0x15ea
movslq -0x2c(%rbp), %rax
movb -0x140(%rbp,%rax), %cl
movl -0x30(%rbp), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, -0x30(%rbp)
cltq
movb %cl, -0x240(%rbp,%rax)
jmp 0x16b0
cmpl $0x0, -0x24(%rbp)
je 0x1630
movl -0x2c(%rbp), %eax
addl $0x1, %eax
cltq
movsbl -0x140(%rbp,%rax), %eax
cmpl $0x2f, %eax
jne 0x1630
movl $0x0, -0x24(%rbp)
movslq -0x2c(%rbp), %rax
movb -0x140(%rbp,%rax), %cl
movl -0x30(%rbp), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, -0x30(%rbp)
cltq
movb %cl, -0x240(%rbp,%rax)
jmp 0x16b0
movl -0x30(%rbp), %eax
movl $0x8, %ecx
cltd
idivl %ecx
movl $0x8, %eax
subl %edx, %eax
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
movl %eax, %ecx
addl $-0x1, %ecx
movl %ecx, -0x1c(%rbp)
cmpl $0x0, %eax
je 0x168d
movl -0x30(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x30(%rbp)
cltq
movb $0x20, -0x240(%rbp,%rax)
jmp 0x1666
jmp 0x16b0
jmp 0x16b0
movslq -0x2c(%rbp), %rax
movb -0x140(%rbp,%rax), %cl
movl -0x30(%rbp), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, -0x30(%rbp)
cltq
movb %cl, -0x240(%rbp,%rax)
jmp 0x16b2
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x14dc
cmpl $0x0, -0x30(%rbp)
je 0x16d9
leaq -0x240(%rbp), %rdi
movq -0x350(%rbp), %rsi
callq 0x1080
jmp 0x133b
movq -0x348(%rbp), %rdi
callq 0x1050
movq -0x350(%rbp), %rdi
callq 0x1050
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x1225
xorl %eax, %eax
addq $0x360, %rsp            # imm = 0x360
popq %rbp
retq