// File: /workspace/github_c_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x348, %rsp            # imm = 0x348
cmpl $0x2, %edi
jl 0x162d
movq %rsi, %rbx
cmpq $0x0, (%rsi)
je 0x162d
movl %edi, %eax
movq %rax, 0x20(%rsp)
movl $0x1, %r14d
leaq 0x240(%rsp), %r15
movq %rbx, 0x28(%rsp)
movq (%rbx,%r14,8), %rsi
movq %r15, %rdi
callq 0x1030
movq %r15, %rdi
movl $0x2e, %esi
callq 0x1080
testq %rax, %rax
je 0x1257
movb $0x0, 0x4(%rax)
movl $0x77656e2e, (%rax)     # imm = 0x77656E2E
jmp 0x1272
movq %r15, %rdi
callq 0x1060
movl $0x77656e2e, 0x240(%rsp,%rax) # imm = 0x77656E2E
movb $0x0, 0x244(%rsp,%rax)
movq (%rbx,%r14,8), %rdi
leaq 0xd8c(%rip), %rsi       # 0x2009
callq 0x10c0
movq %rax, 0x18(%rsp)
testq %rax, %rax
je 0x1603
leaq 0x240(%rsp), %rdi
leaq 0xd85(%rip), %rsi       # 0x2024
callq 0x10c0
movq %rax, 0x10(%rsp)
testq %rax, %rax
je 0x1610
movq %r14, 0x30(%rsp)
movq (%rbx,%r14,8), %rsi
leaq 0xd65(%rip), %rdi       # 0x2027
xorl %eax, %eax
callq 0x1070
movl $0x100, %edx            # imm = 0x100
leaq 0x140(%rsp), %rdi
xorl %esi, %esi
callq 0x10a0
movl $0x100, %edx            # imm = 0x100
leaq 0x40(%rsp), %rbx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x10a0
movq %rbx, %rdi
movl $0x100, %esi            # imm = 0x100
movq 0x18(%rsp), %rdx
callq 0x10b0
testq %rax, %rax
je 0x15bb
movl $0x0, 0xc(%rsp)
xorl %r14d, %r14d
testl %r14d, %r14d
jne 0x13eb
movl $0x1, %ebx
cmpl $0x20202020, 0x40(%rsp) # imm = 0x20202020
je 0x1362
callq 0x10e0
movq (%rax), %rax
movsbq 0x40(%rsp), %rcx
testb $0x20, 0x1(%rax,%rcx,2)
movl $0x0, %ebx
movl 0xc(%rsp), %edx
cmovnel %edx, %ebx
movzwl 0x40(%rsp), %eax
cmpl $0x2a2f, %eax           # imm = 0x2A2F
cmovel %edx, %ebx
cmpq $0x23, %rcx
cmovel %edx, %ebx
movl 0x40(%rsp), %eax
movl $0x65736c65, %ecx       # imm = 0x65736C65
xorl %ecx, %eax
movl 0x43(%rsp), %ecx
movl $0x97b2065, %edx        # imm = 0x97B2065
xorl %edx, %ecx
orl %eax, %ecx
jne 0x139e
callq 0x10e0
movq (%rax), %rax
movsbq 0x47(%rsp), %rcx
movl $0x6, %r13d
testb $0x20, 0x1(%rax,%rcx,2)
leaq 0xca7(%rip), %rdi       # 0x2043
je 0x13d7
movl 0x40(%rsp), %eax
movl $0x7b206f64, %ecx       # imm = 0x7B206F64
xorl %ecx, %eax
movzbl 0x44(%rsp), %ecx
xorl $0x9, %ecx
orl %eax, %ecx
jne 0x13e7
callq 0x10e0
movq (%rax), %rax
movsbq 0x45(%rsp), %rcx
movl $0x4, %r13d
testb $0x20, 0x1(%rax,%rcx,2)
leaq 0xc7c(%rip), %rdi       # 0x2051
jne 0x13e7
movq 0x10(%rsp), %rsi
callq 0x1090
movl %ebx, 0xc(%rsp)
jmp 0x13ee
movl %ebx, 0xc(%rsp)
xorl %r13d, %r13d
movb 0x40(%rsp,%r13), %bl
testb %bl, %bl
je 0x1560
xorl %eax, %eax
cmpl $0x0, 0xc(%rsp)
setne %al
leal -0x4(,%rax,4), %ecx
movq %rcx, 0x38(%rsp)
leal -0x8(,%rax,4), %r12d
xorl %eax, %eax
xorl %ebp, %ebp
movl %r14d, %ecx
orl %eax, %ecx
jne 0x145f
cmpb $0x9, %bl
jne 0x1435
incl %ebp
xorl %r14d, %r14d
xorl %eax, %eax
jmp 0x1549
testl %ebp, %ebp
je 0x145d
leal (%r12,%rbp,8), %edx
addq $0x4, %rdx
leaq 0x140(%rsp), %rdi
movl $0x20, %esi
callq 0x10a0
movq 0x38(%rsp), %rax
leal (%rax,%rbp,8), %eax
jmp 0x145f
xorl %eax, %eax
movzbl %bl, %ecx
cmpl $0x29, %ecx
jg 0x147a
cmpl $0x9, %ecx
je 0x14e2
cmpl $0xd, %ecx
je 0x1549
jmp 0x1529
cmpl $0x2a, %ecx
je 0x1512
cmpl $0x2f, %ecx
jne 0x1529
movl $0x1, %r15d
testl %r14d, %r14d
jne 0x153a
cmpb $0x2a, 0x41(%rsp,%r13)
jne 0x1537
testq %r13, %r13
je 0x153a
cmpl $0x37, %eax
jg 0x153a
movslq %eax, %rcx
leaq (%rsp,%rcx), %rdi
addq $0x140, %rdi            # imm = 0x140
movl $0x37, %edx
subl %eax, %edx
incq %rdx
movl $0x20, %esi
callq 0x10a0
movl $0x38, %eax
jmp 0x153a
leal 0x7(%rax), %ebx
testl %eax, %eax
cmovnsl %eax, %ebx
andl $-0x8, %ebx
movl %ebx, %edx
subl %eax, %edx
addl $0x8, %edx
cltq
leaq (%rsp,%rax), %rdi
addq $0x140, %rdi            # imm = 0x140
movl $0x20, %esi
callq 0x10a0
addl $0x8, %ebx
movl %ebx, %eax
jmp 0x1549
testl %r14d, %r14d
je 0x1526
xorl %r14d, %r14d
cmpb $0x2f, 0x41(%rsp,%r13)
setne %r14b
jmp 0x1529
xorl %r14d, %r14d
movslq %eax, %rcx
incl %eax
movb %bl, 0x140(%rsp,%rcx)
jmp 0x1549
xorl %r15d, %r15d
movslq %eax, %rcx
incl %eax
movb %bl, 0x140(%rsp,%rcx)
movl %r15d, %r14d
movb 0x41(%rsp,%r13), %bl
incq %r13
testb %bl, %bl
jne 0x141d
testl %eax, %eax
sete %al
jmp 0x1562
movb $0x1, %al
testb %al, %al
jne 0x1578
leaq 0x140(%rsp), %rdi
movq 0x10(%rsp), %rsi
callq 0x1090
movl $0x100, %edx            # imm = 0x100
leaq 0x140(%rsp), %rdi
xorl %esi, %esi
callq 0x10a0
movl $0x100, %edx            # imm = 0x100
leaq 0x40(%rsp), %rbx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x10a0
movq %rbx, %rdi
movl $0x100, %esi            # imm = 0x100
movq 0x18(%rsp), %rdx
callq 0x10b0
testq %rax, %rax
jne 0x1317
movq 0x18(%rsp), %rdi
callq 0x1050
movq 0x10(%rsp), %rdi
callq 0x1050
movq 0x30(%rsp), %r14
incq %r14
cmpq 0x20(%rsp), %r14
movq 0x28(%rsp), %rbx
leaq 0x240(%rsp), %r15
jne 0x122d
xorl %eax, %eax
addq $0x348, %rsp            # imm = 0x348
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq (%rbx,%r14,8), %rsi
leaq 0x9fe(%rip), %rdi       # 0x200c
jmp 0x161f
leaq 0x9f5(%rip), %rdi       # 0x200c
leaq 0x240(%rsp), %rsi
xorl %eax, %eax
callq 0x1070
xorl %edi, %edi
callq 0x10d0
leaq 0xa23(%rip), %rdi       # 0x2057
callq 0x1040
jmp 0x1626