// File: /workspace/github_c_makefile_star2_O1/simh[P]simtools/extracters/mmdir/mmdir.c
// Function: main
int main (int argc, char *argv[])
{
int obj, i, k, fc, rc, tpos, sa, ea, fr, fq;
unsigned char b[53];
unsigned char bca[4];
unsigned int bc;
int preveof;
FILE *ifile;
#define MAXRLNT 65536

if ((argc < 2) || (argv[0] == NULL)) {
	printf ("Usage is: verb file [file...]\n");
	exit (0);  }

for (i = 1; i < argc; i++) {
	ifile = fopen (argv[i], "rb");
	if (ifile == NULL) {
	    printf ("Error opening file: %s\n", argv[i]);
	    return 0;  }
	printf ("Processing input file %s\n", argv[i]);
	tpos = 0; rc = 1; fc = 0; preveof = 0;
	for (;;) {
	    fseek (ifile, tpos, SEEK_SET);
	    k = fread (bca, 1, 4, ifile);
	    bc = (((unsigned int) bca[3]) << 24) | (((unsigned int) bca[2]) << 16) |
		(((unsigned int) bca[1]) << 8) | ((unsigned int) bca[0]);
	    if ((k == 0) || (bc == 0xFFFFFFFF)) {
		printf ("End of physical tape\n");
		break;  }
	    if (bc & 0x80000000) {
		printf ("Error marker at record %d\n", rc);
		bc = bc & ~0x80000000;  }
	    if (bc == 0) {
		if (preveof) {
		    printf ("End of logical tape\n");
		    break;  }
		preveof = 1;
		fc++; obj++;
		rc = 1;
		tpos = tpos + 4;  }
	    else if (bc > MAXRLNT) {
		printf ("Invalid record length %d, terminating\n", bc);
		break;  }
	    else {
		tpos = tpos + 8 + ((bc + 1) & ~1);
		preveof = 0;
		if (fc && (rc == 1)) {
		    if (bc != 52) {
			printf ("Invalid record length %d, terminating\n", bc);
			break;  }
		    fread (b, 1, 52, ifile);
		    sa = (((unsigned int) b[18]) << 16) |
			(((unsigned int) b[19]) << 8) | ((unsigned int) b[20]);
		    ea = (((unsigned int) b[21]) << 16) |
			(((unsigned int) b[22]) << 8) | ((unsigned int) b[23]);
		    fr = b[27] >> 4;
		    fq = b[27] & 0xF;
		    printf ("%3d %c%c%c 06-%c%c%c", fc,
			b[0], b[1], b[2], b[3], b[4], b[5]);
		    if (fr) printf ("F0%X", fr);
		    else printf ("   ");
		    printf ("R%c%c%c%c %c%c  ",
			b[6], b[7], b[25], b[26], b[28], b[29]);
		    b[18] = b[51] = b[52] = 0;
		    printf ("%s%s  %06X %06X %X\n",
			&b[8], &b[30], sa, ea, fq);
		    }
		rc++;  }
	    }
	fclose (ifile);
	}
return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
cmpl $0x2, %edi
jl 0x14c2
movq %rsi, %rbx
cmpq $0x0, (%rsi)
je 0x14c2
movl %edi, %eax
movq %rax, 0x60(%rsp)
movl $0x1, %eax
leaq 0xc(%rsp), %r15
movq %rbx, 0x68(%rsp)
movq (%rbx,%rax,8), %rdi
movq %rax, %r14
leaq 0xe1d(%rip), %rsi       # 0x2004
callq 0x1080
movq %r14, 0x70(%rsp)
movq (%rbx,%r14,8), %rsi
testq %rax, %rax
je 0x14a0
movq %rax, %r12
xorl %r14d, %r14d
leaq 0xe14(%rip), %rdi       # 0x201f
xorl %eax, %eax
callq 0x1060
movb $0x1, %bpl
movl $0x0, 0x10(%rsp)
movq %r12, 0x78(%rsp)
movl $0x1, %r13d
movslq %r14d, %rsi
movq %r12, %rdi
xorl %edx, %edx
callq 0x1070
movl $0x1, %esi
movl $0x4, %edx
movq %r15, %rdi
movq %r12, %rcx
callq 0x1040
testl %eax, %eax
je 0x1469
movzbl 0xf(%rsp), %eax
shll $0x18, %eax
movzbl 0xe(%rsp), %ecx
shll $0x10, %ecx
movzbl 0xd(%rsp), %edx
shll $0x8, %edx
movzbl 0xc(%rsp), %ebx
orl %ecx, %ebx
orl %edx, %ebx
orl %eax, %ebx
cmpl $-0x1, %ebx
je 0x1469
testl %eax, %eax
jns 0x1299
leaq 0xdb0(%rip), %rdi       # 0x2039
movl %r13d, %esi
xorl %eax, %eax
callq 0x1060
andl $0x7fffffff, %ebx       # imm = 0x7FFFFFFF
testl %ebx, %ebx
je 0x1442
cmpl $0x10001, %ebx          # imm = 0x10001
jae 0x1457
cmpl $0x0, 0x10(%rsp)
setne %al
cmpl $0x1, %r13d
sete %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x1428
cmpl $0x34, %ebx
jne 0x1457
movl %r13d, 0x1c(%rsp)
movq %r14, 0x80(%rsp)
movl $0x1, %esi
movl $0x34, %edx
leaq 0x20(%rsp), %rdi
movq %r12, %rcx
callq 0x1040
movzbl 0x32(%rsp), %r12d
movzbl 0x33(%rsp), %r14d
movzbl 0x34(%rsp), %eax
movl %eax, 0x14(%rsp)
movzbl 0x35(%rsp), %r15d
movzbl 0x36(%rsp), %ebp
movzbl 0x37(%rsp), %eax
movl %eax, 0x18(%rsp)
movzbl 0x3b(%rsp), %r13d
movzbl 0x20(%rsp), %edx
movzbl 0x21(%rsp), %ecx
movzbl 0x22(%rsp), %r8d
movzbl 0x23(%rsp), %r9d
movzbl 0x24(%rsp), %r10d
movzbl 0x25(%rsp), %r11d
leaq 0xd2f(%rip), %rdi       # 0x207b
movl 0x10(%rsp), %esi
xorl %eax, %eax
pushq %r11
pushq %r10
callq 0x1060
addq $0x10, %rsp
cmpl $0x10, %r13d
jae 0x1375
leaq 0xd29(%rip), %rdi       # 0x2095
xorl %eax, %eax
callq 0x1060
jmp 0x1389
movl %r13d, %esi
shrl $0x4, %esi
leaq 0xd0e(%rip), %rdi       # 0x2090
xorl %eax, %eax
callq 0x1060
shll $0x10, %r12d
shll $0x8, %r14d
orl %r12d, %r14d
addl 0x14(%rsp), %r14d
shll $0x10, %r15d
shll $0x8, %ebp
orl %r15d, %ebp
addl 0x18(%rsp), %ebp
andl $0xf, %r13d
movzbl 0x26(%rsp), %esi
movzbl 0x27(%rsp), %edx
movzbl 0x39(%rsp), %ecx
movzbl 0x3a(%rsp), %r8d
movzbl 0x3c(%rsp), %r9d
movzbl 0x3d(%rsp), %r10d
subq $0x8, %rsp
leaq 0xcc2(%rip), %rdi       # 0x2099
xorl %eax, %eax
pushq %r10
callq 0x1060
addq $0x10, %rsp
movw $0x0, 0x53(%rsp)
movb $0x0, 0x32(%rsp)
leaq 0xcb3(%rip), %rdi       # 0x20aa
leaq 0x28(%rsp), %rsi
leaq 0x3e(%rsp), %rdx
movl %r14d, %ecx
movl %ebp, %r8d
movl %r13d, %r9d
xorl %eax, %eax
callq 0x1060
leaq 0xc(%rsp), %r15
movq 0x78(%rsp), %r12
movq 0x80(%rsp), %r14
movl 0x1c(%rsp), %r13d
incl %ebx
andl $0x3fffe, %ebx          # imm = 0x3FFFE
addl %ebx, %r14d
addl $0x8, %r14d
incl %r13d
movb $0x1, %bpl
jmp 0x1228
testb $0x1, %bpl
je 0x1497
incl 0x10(%rsp)
addl $0x4, %r14d
xorl %ebp, %ebp
jmp 0x1222
leaq 0xbf6(%rip), %rdi       # 0x2054
movl %ebx, %esi
xorl %eax, %eax
callq 0x1060
jmp 0x1475
leaq 0xc62(%rip), %rdi       # 0x20d2
callq 0x1030
movq %r12, %rdi
callq 0x1050
movq 0x70(%rsp), %rax
incq %rax
cmpq 0x60(%rsp), %rax
movq 0x68(%rsp), %rbx
jne 0x11d9
jmp 0x14ae
leaq 0xc20(%rip), %rdi       # 0x20be
jmp 0x1470
leaq 0xb60(%rip), %rdi       # 0x2007
xorl %eax, %eax
callq 0x1060
xorl %eax, %eax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xc1e(%rip), %rdi       # 0x20e7
callq 0x1030
xorl %edi, %edi
callq 0x1090