// File: /workspace/github_c_makefile_star2_O3/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 $0x338, %rsp            # imm = 0x338
cmpl $0x2, %edi
jl 0x163a
movq %rsi, %rbx
cmpq $0x0, (%rsi)
je 0x163a
movl %edi, %eax
movq %rax, 0x18(%rsp)
movl $0x1, %r15d
leaq 0x230(%rsp), %r12
movq %rbx, 0x20(%rsp)
movq (%rbx,%r15,8), %r14
movq %r12, %rdi
movq %r14, %rsi
callq 0x1030
movq %r12, %rdi
movl $0x2e, %esi
callq 0x1080
testq %rax, %rax
je 0x125e
movb $0x0, 0x4(%rax)
movl $0x77656e2e, (%rax)     # imm = 0x77656E2E
movq (%rbx,%r15,8), %r14
jmp 0x1279
movq %r12, %rdi
callq 0x1060
movl $0x77656e2e, 0x230(%rsp,%rax) # imm = 0x77656E2E
movb $0x0, 0x234(%rsp,%rax)
movq %r14, %rdi
leaq 0xd86(%rip), %rsi       # 0x2009
callq 0x10c0
movq %rax, 0x10(%rsp)
testq %rax, %rax
je 0x1610
movq %r12, %rdi
leaq 0xd84(%rip), %rsi       # 0x2024
callq 0x10c0
movq %rax, 0x8(%rsp)
testq %rax, %rax
je 0x161d
movq %r15, 0x28(%rsp)
movq (%rbx,%r15,8), %rsi
leaq 0xd64(%rip), %rdi       # 0x2027
xorl %eax, %eax
callq 0x1070
movl $0x100, %edx            # imm = 0x100
leaq 0x130(%rsp), %rdi
xorl %esi, %esi
callq 0x10a0
movl $0x100, %edx            # imm = 0x100
leaq 0x30(%rsp), %rbx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x10a0
movq %rbx, %rdi
movl $0x100, %esi            # imm = 0x100
movq 0x10(%rsp), %rdx
callq 0x10b0
testq %rax, %rax
je 0x15c8
movl $0x0, 0x4(%rsp)
xorl %r13d, %r13d
testl %r13d, %r13d
jne 0x13ee
movl 0x30(%rsp), %r14d
movl $0x1, %ebx
cmpl $0x20202020, %r14d      # imm = 0x20202020
je 0x1365
callq 0x10e0
movq (%rax), %rax
movsbq %r14b, %rcx
movzwl %r14w, %edx
cmpl $0x2a2f, %edx           # imm = 0x2A2F
movl $0x0, %ebx
movl 0x4(%rsp), %edx
cmovel %edx, %ebx
testb $0x20, 0x1(%rax,%rcx,2)
cmovnel %edx, %ebx
cmpb $0x23, %r14b
cmovel %edx, %ebx
movl 0x30(%rsp), %eax
movl $0x65736c65, %ecx       # imm = 0x65736C65
xorl %ecx, %eax
movl 0x33(%rsp), %ecx
movl $0x97b2065, %edx        # imm = 0x97B2065
xorl %edx, %ecx
orl %eax, %ecx
jne 0x13a1
callq 0x10e0
movq (%rax), %rax
movsbq 0x37(%rsp), %rcx
movl $0x6, %r15d
testb $0x20, 0x1(%rax,%rcx,2)
leaq 0xca4(%rip), %rdi       # 0x2043
je 0x13da
movl 0x30(%rsp), %eax
movl $0x7b206f64, %ecx       # imm = 0x7B206F64
xorl %ecx, %eax
movzbl 0x34(%rsp), %ecx
xorl $0x9, %ecx
orl %eax, %ecx
jne 0x13ea
callq 0x10e0
movq (%rax), %rax
movsbq 0x35(%rsp), %rcx
movl $0x4, %r15d
testb $0x20, 0x1(%rax,%rcx,2)
leaq 0xc79(%rip), %rdi       # 0x2051
jne 0x13ea
movq 0x8(%rsp), %rsi
callq 0x1090
movl %ebx, 0x4(%rsp)
jmp 0x13f1
movl %ebx, 0x4(%rsp)
xorl %r15d, %r15d
movb 0x30(%rsp,%r15), %bpl
testb %bpl, %bpl
je 0x1585
xorl %r12d, %r12d
cmpl $0x0, 0x4(%rsp)
setne %r12b
shll $0x2, %r12d
orl $-0x8, %r12d
xorl %ebx, %ebx
leal (%r12,%rbx,8), %r14d
addq $0x4, %r14
incq %r15
xorl %eax, %eax
movl %r13d, %ecx
orl %eax, %ecx
jne 0x1453
cmpb $0x9, %bpl
je 0x155a
testl %ebx, %ebx
je 0x1451
leaq 0x130(%rsp), %rdi
movl $0x20, %esi
movq %r14, %rdx
callq 0x10a0
movl %r14d, %eax
jmp 0x1453
xorl %eax, %eax
movzbl %bpl, %ecx
cmpl $0x29, %ecx
jg 0x146c
cmpl $0x9, %ecx
je 0x14df
cmpl $0xd, %ecx
je 0x1547
jmp 0x14d0
cmpl $0x2a, %ecx
je 0x150f
cmpl $0x2f, %ecx
jne 0x14d0
movl $0x1, %ebp
testl %r13d, %r13d
jne 0x1537
cmpb $0x2a, 0x30(%rsp,%r15)
jne 0x1535
cmpq $0x1, %r15
je 0x1537
cmpl $0x37, %eax
jg 0x1537
movslq %eax, %rcx
leaq (%rsp,%rcx), %rdi
addq $0x130, %rdi            # imm = 0x130
movl $0x37, %edx
subl %eax, %edx
incq %rdx
movl $0x20, %esi
callq 0x10a0
movl $0x38, %eax
jmp 0x1537
movslq %eax, %rcx
incl %eax
movb %bpl, 0x130(%rsp,%rcx)
jmp 0x1547
leal 0x7(%rax), %ebp
testl %eax, %eax
cmovnsl %eax, %ebp
andl $-0x8, %ebp
movl %ebp, %edx
subl %eax, %edx
addl $0x8, %edx
cltq
leaq (%rsp,%rax), %rdi
addq $0x130, %rdi            # imm = 0x130
movl $0x20, %esi
callq 0x10a0
addl $0x8, %ebp
movl %ebp, %eax
jmp 0x1547
testl %r13d, %r13d
je 0x1523
xorl %r13d, %r13d
cmpb $0x2f, 0x30(%rsp,%r15)
setne %r13b
jmp 0x1526
xorl %r13d, %r13d
movslq %eax, %rcx
incl %eax
movb $0x2a, 0x130(%rsp,%rcx)
jmp 0x1547
xorl %ebp, %ebp
movslq %eax, %rcx
incl %eax
movb $0x2f, 0x130(%rsp,%rcx)
movl %ebp, %r13d
movb 0x30(%rsp,%r15), %bpl
incq %r15
testb %bpl, %bpl
jne 0x1422
jmp 0x156f
incl %ebx
movb 0x30(%rsp,%r15), %bpl
xorl %r13d, %r13d
testb %bpl, %bpl
jne 0x1415
jmp 0x1585
testl %eax, %eax
je 0x1585
leaq 0x130(%rsp), %rdi
movq 0x8(%rsp), %rsi
callq 0x1090
movl $0x100, %edx            # imm = 0x100
leaq 0x130(%rsp), %rdi
xorl %esi, %esi
callq 0x10a0
movl $0x100, %edx            # imm = 0x100
leaq 0x30(%rsp), %rbx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x10a0
movq %rbx, %rdi
movl $0x100, %esi            # imm = 0x100
movq 0x10(%rsp), %rdx
callq 0x10b0
testq %rax, %rax
jne 0x1318
movq 0x10(%rsp), %rdi
callq 0x1050
movq 0x8(%rsp), %rdi
callq 0x1050
movq 0x28(%rsp), %r15
incq %r15
cmpq 0x18(%rsp), %r15
movq 0x20(%rsp), %rbx
leaq 0x230(%rsp), %r12
jne 0x122d
xorl %eax, %eax
addq $0x338, %rsp            # imm = 0x338
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq (%rbx,%r15,8), %rsi
leaq 0x9f1(%rip), %rdi       # 0x200c
jmp 0x162c
leaq 0x9e8(%rip), %rdi       # 0x200c
leaq 0x230(%rsp), %rsi
xorl %eax, %eax
callq 0x1070
xorl %edi, %edi
callq 0x10d0
leaq 0xa16(%rip), %rdi       # 0x2057
callq 0x1040
jmp 0x1633