// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0xa0, %rsp
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpl $0x2, -0x8(%rbp)
jl 0x11b9
movq -0x10(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x11ce
leaq 0xe44(%rip), %rdi       # 0x2004
movb $0x0, %al
callq 0x1050
xorl %edi, %edi
callq 0x1080
movl $0x1, -0x18(%rbp)
movl -0x18(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0x14fb
movq -0x10(%rbp), %rax
movslq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0xe2f(%rip), %rsi       # 0x2023
callq 0x1070
movq %rax, -0x88(%rbp)
cmpq $0x0, -0x88(%rbp)
jne 0x1230
movq -0x10(%rbp), %rax
movslq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
leaq 0xe09(%rip), %rdi       # 0x2026
movb $0x0, %al
callq 0x1050
movl $0x0, -0x4(%rbp)
jmp 0x1502
movq -0x10(%rbp), %rax
movslq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
leaq 0xdfb(%rip), %rdi       # 0x203e
movb $0x0, %al
callq 0x1050
movl $0x0, -0x28(%rbp)
movl $0x1, -0x24(%rbp)
movl $0x0, -0x20(%rbp)
movl $0x0, -0x7c(%rbp)
movq -0x88(%rbp), %rdi
movslq -0x28(%rbp), %rsi
xorl %edx, %edx
callq 0x1060
leaq -0x74(%rbp), %rdi
movq -0x88(%rbp), %rcx
movl $0x1, %esi
movl $0x4, %edx
callq 0x1030
movl %eax, -0x1c(%rbp)
movzbl -0x71(%rbp), %eax
shll $0x18, %eax
movzbl -0x72(%rbp), %ecx
shll $0x10, %ecx
orl %ecx, %eax
movzbl -0x73(%rbp), %ecx
shll $0x8, %ecx
orl %ecx, %eax
movzbl -0x74(%rbp), %ecx
orl %ecx, %eax
movl %eax, -0x78(%rbp)
cmpl $0x0, -0x1c(%rbp)
je 0x12c3
cmpl $-0x1, -0x78(%rbp)
jne 0x12d6
leaq 0xd8e(%rip), %rdi       # 0x2058
movb $0x0, %al
callq 0x1050
jmp 0x14e1
movl -0x78(%rbp), %eax
andl $0x80000000, %eax       # imm = 0x80000000
cmpl $0x0, %eax
je 0x12ff
movl -0x24(%rbp), %esi
leaq 0xd81(%rip), %rdi       # 0x206e
movb $0x0, %al
callq 0x1050
movl -0x78(%rbp), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, -0x78(%rbp)
cmpl $0x0, -0x78(%rbp)
jne 0x134c
cmpl $0x0, -0x7c(%rbp)
je 0x131e
leaq 0xd77(%rip), %rdi       # 0x2089
movb $0x0, %al
callq 0x1050
jmp 0x14e1
movl $0x1, -0x7c(%rbp)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
movl $0x1, -0x24(%rbp)
movl -0x28(%rbp), %eax
addl $0x4, %eax
movl %eax, -0x28(%rbp)
jmp 0x14dc
cmpl $0x10000, -0x78(%rbp)   # imm = 0x10000
jbe 0x136b
movl -0x78(%rbp), %esi
leaq 0xd3f(%rip), %rdi       # 0x209e
movb $0x0, %al
callq 0x1050
jmp 0x14e1
movl -0x28(%rbp), %eax
addl $0x8, %eax
movl -0x78(%rbp), %ecx
addl $0x1, %ecx
andl $-0x2, %ecx
addl %ecx, %eax
movl %eax, -0x28(%rbp)
movl $0x0, -0x7c(%rbp)
cmpl $0x0, -0x20(%rbp)
je 0x14d1
cmpl $0x1, -0x24(%rbp)
jne 0x14d1
cmpl $0x34, -0x78(%rbp)
je 0x13b6
movl -0x78(%rbp), %esi
leaq 0xcf4(%rip), %rdi       # 0x209e
movb $0x0, %al
callq 0x1050
jmp 0x14e1
leaq -0x70(%rbp), %rdi
movq -0x88(%rbp), %rcx
movl $0x1, %esi
movl $0x34, %edx
callq 0x1030
movzbl -0x5e(%rbp), %eax
shll $0x10, %eax
movzbl -0x5d(%rbp), %ecx
shll $0x8, %ecx
orl %ecx, %eax
movzbl -0x5c(%rbp), %ecx
orl %ecx, %eax
movl %eax, -0x2c(%rbp)
movzbl -0x5b(%rbp), %eax
shll $0x10, %eax
movzbl -0x5a(%rbp), %ecx
shll $0x8, %ecx
orl %ecx, %eax
movzbl -0x59(%rbp), %ecx
orl %ecx, %eax
movl %eax, -0x30(%rbp)
movzbl -0x55(%rbp), %eax
sarl $0x4, %eax
movl %eax, -0x34(%rbp)
movzbl -0x55(%rbp), %eax
andl $0xf, %eax
movl %eax, -0x38(%rbp)
movl -0x20(%rbp), %esi
movzbl -0x70(%rbp), %edx
movzbl -0x6f(%rbp), %ecx
movzbl -0x6e(%rbp), %r8d
movzbl -0x6d(%rbp), %r9d
movzbl -0x6c(%rbp), %r10d
movzbl -0x6b(%rbp), %eax
leaq 0xc8a(%rip), %rdi       # 0x20c5
movl %r10d, (%rsp)
movl %eax, 0x8(%rsp)
movb $0x0, %al
callq 0x1050
cmpl $0x0, -0x34(%rbp)
je 0x1463
movl -0x34(%rbp), %esi
leaq 0xc80(%rip), %rdi       # 0x20da
movb $0x0, %al
callq 0x1050
jmp 0x1471
leaq 0xc75(%rip), %rdi       # 0x20df
movb $0x0, %al
callq 0x1050
movzbl -0x6a(%rbp), %esi
movzbl -0x69(%rbp), %edx
movzbl -0x57(%rbp), %ecx
movzbl -0x56(%rbp), %r8d
movzbl -0x54(%rbp), %r9d
movzbl -0x53(%rbp), %eax
leaq 0xc51(%rip), %rdi       # 0x20e3
movl %eax, (%rsp)
movb $0x0, %al
callq 0x1050
movb $0x0, -0x3c(%rbp)
movb $0x0, -0x3d(%rbp)
movb $0x0, -0x5e(%rbp)
leaq -0x70(%rbp), %rsi
addq $0x8, %rsi
leaq -0x70(%rbp), %rdx
addq $0x1e, %rdx
movl -0x2c(%rbp), %ecx
movl -0x30(%rbp), %r8d
movl -0x38(%rbp), %r9d
leaq 0xc2a(%rip), %rdi       # 0x20f4
movb $0x0, %al
callq 0x1050
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x14dc
jmp 0x1266
movq -0x88(%rbp), %rdi
callq 0x1040
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x11d5
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xa0, %rsp
popq %rbp
retq