// File: /workspace/github_c_makefile_star2_O3/simh[P]simtools/extracters/dbtap/dos11.c
// Function: listDirectory
void listDirectory(void)
{
  unsigned int status;

  do {
    switch (status = ReadTapeRecord(record, sizeof(record))) {
      case ST_EOM:
        break;

      case ST_TM:
        /* Second tape mark in a row - treat as end of medium */
        status = ST_EOM;
        break;

      default:
        if ((status & ST_ERROR) == 0) {
          status &= ST_LENGTH;

          if ((status == sizeof(struct dos11hdr1)) ||
              (status == sizeof(struct dos11hdr2))) {
            char filename[14], sdate[12];
            struct dos11hdr2 *hdr = (struct dos11hdr2 *)record;
            uint32 errorCount = 0, length = 0;

            memset(filename, ' ', sizeof(filename));
            filename[13] = '\0';

            r50Asc(hdr->fname[0], &filename[0]);
            r50Asc(hdr->fname[1], &filename[3]);
            if (status == sizeof(struct dos11hdr2))
              r50Asc(hdr->fname3, &filename[6]);
            filename[9] = '.';
            r50Asc(hdr->ext, &filename[10]);

            dos11Date(hdr->date, sdate);

            printf("%s %s <%03o> [%3o,%3o] ",
                   filename, sdate, hdr->prot, hdr->prog, hdr->proj);

            do {
              switch (status = ReadTapeRecordLength()) {
                case ST_EOM:
                case ST_TM:
                  printf("%u bytes%s\n", length, errorCount ? "(E)" : "");
                  break;

                default:
                  if ((status & ST_ERROR) != 0)
                    errorCount++;
                  length += status & ST_LENGTH;
                  break;
              }
            } while ((status != ST_EOM) && (status != ST_TM));
            break;
          } else fprintf(stderr, "   *** Unexpected record size\n");
        } else fprintf(stderr, "   *** Directory entry contains error\n");

        /*
         * Scan forward to the end of this file
         */
        do {
          status = ReadTapeRecordLength();
        } while ((status != ST_EOM) && (status != ST_TM));
    }
  } while (status != ST_EOM);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl $0xffff, %ebp           # imm = 0xFFFF
leaq 0x28e5(%rip), %rbx      # 0x5130
leaq 0x18(%rsp), %r12
leaq 0x129e9(%rip), %rdi     # 0x15240
movl $0x10000, %esi          # imm = 0x10000
callq 0x1e57
leal 0x1(%rax), %ecx
cmpl $0x2, %ecx
jb 0x2b6a
testl %eax, %eax
js 0x2b4b
andl $0xffffff, %eax         # imm = 0xFFFFFF
movl %eax, %ecx
orl $0x2, %ecx
cmpl $0xe, %ecx
jne 0x2b52
leaq 0x10(%rsp), %rcx
movb $0x20, 0x2(%rcx)
movw $0x2020, (%rcx)         # imm = 0x2020
movzwl 0x129a3(%rip), %esi     # 0x15240
imull $0xcccd, %esi, %ecx     # imm = 0xCCCD
shrl $0x15, %ecx
leal (,%rcx,8), %edx
leal (%rdx,%rdx,4), %edi
movl %esi, %edx
subl %edi, %edx
andl %ebp, %edx
imull $0x667, %ecx, %edi      # imm = 0x667
shrl $0xd, %edi
andl $-0x8, %edi
leal (%rdi,%rdi,4), %edi
subl %edi, %ecx
andl %ebp, %ecx
shrl $0x6, %esi
imull $0xa3e, %esi, %edi      # imm = 0xA3E
shrl $0x10, %edi
movzwl 0x12965(%rip), %r9d     # 0x15242
imull $0xcccd, %r9d, %esi     # imm = 0xCCCD
shrl $0x15, %esi
leal (,%rsi,8), %r8d
leal (%r8,%r8,4), %r10d
movl %r9d, %r8d
subl %r10d, %r8d
andl %ebp, %r8d
imull $0x667, %esi, %r10d     # imm = 0x667
shrl $0xd, %r10d
andl $-0x8, %r10d
leal (%r10,%r10,4), %r10d
subl %r10d, %esi
andl %ebp, %esi
shrl $0x6, %r9d
imull $0xa3e, %r9d, %r9d      # imm = 0xA3E
shrl $0x10, %r9d
movb $0x0, 0x17(%rsp)
movb (%rdx,%rbx), %dl
movb %dl, 0xc(%rsp)
movb (%rcx,%rbx), %cl
movb %cl, 0xb(%rsp)
movb (%rdi,%rbx), %cl
movb %cl, 0xa(%rsp)
movb (%r8,%rbx), %cl
movb %cl, 0xf(%rsp)
movb (%rsi,%rbx), %cl
movb %cl, 0xe(%rsp)
movb (%r9,%rbx), %cl
movb %cl, 0xd(%rsp)
cmpl $0xe, %eax
jne 0x29ad
movzwl 0x128ec(%rip), %eax     # 0x1524c
imull $0xcccd, %eax, %ecx     # imm = 0xCCCD
shrl $0x15, %ecx
leal (,%rcx,8), %edx
leal (%rdx,%rdx,4), %edx
movl %eax, %esi
subl %edx, %esi
andl %ebp, %esi
movb (%rsi,%rbx), %dl
movb %dl, 0x12(%rsp)
imull $0x667, %ecx, %edx      # imm = 0x667
shrl $0xd, %edx
andl $-0x8, %edx
leal (%rdx,%rdx,4), %edx
subl %edx, %ecx
andl %ebp, %ecx
movb (%rcx,%rbx), %cl
movb %cl, 0x11(%rsp)
shrl $0x6, %eax
imull $0xa3e, %eax, %eax      # imm = 0xA3E
shrl $0x10, %eax
movb (%rax,%rbx), %al
movb %al, 0x10(%rsp)
movb $0x2e, 0x13(%rsp)
movzwl 0x1288b(%rip), %eax     # 0x15244
imull $0xcccd, %eax, %ecx     # imm = 0xCCCD
shrl $0x15, %ecx
leal (,%rcx,8), %edx
leal (%rdx,%rdx,4), %edx
movl %eax, %esi
subl %edx, %esi
andl %ebp, %esi
movb (%rsi,%rbx), %dl
movb %dl, 0x16(%rsp)
imull $0x667, %ecx, %edx      # imm = 0x667
shrl $0xd, %edx
andl $-0x8, %edx
leal (%rdx,%rdx,4), %edx
subl %edx, %ecx
andl %ebp, %ecx
movb (%rcx,%rbx), %cl
movb %cl, 0x15(%rsp)
shrl $0x6, %eax
imull $0xa3e, %eax, %eax      # imm = 0xA3E
shrl $0x10, %eax
movb (%rax,%rbx), %al
movb %al, 0x14(%rsp)
movzwl 0x1283d(%rip), %eax     # 0x1524a
movl %eax, %ecx
shrl $0x3, %ecx
imull $0x20c5, %ecx, %r8d     # imm = 0x20C5
shrl $0x14, %r8d
imull $0x3e8, %r8d, %ecx      # imm = 0x3E8
addl $0x7b2, %r8d            # imm = 0x7B2
subl %ecx, %eax
testb $0x3, %r8b
sete %cl
cmpl $0x7d0, %r8d            # imm = 0x7D0
setne %sil
andb %cl, %sil
leaq 0x2717(%rip), %rcx      # 0x5160
leaq 0x2730(%rip), %rdx      # 0x5180
cmovneq %rdx, %rcx
movl %eax, %edx
andl %ebp, %edx
movzbl %sil, %esi
addl $0x16d, %esi            # imm = 0x16D
cmpl %edx, %esi
jbe 0x2aa0
movzwl (%rcx), %edi
xorl %esi, %esi
cmpw %di, %ax
jbe 0x2a82
subl %edi, %eax
movzwl 0x2(%rcx,%rsi,2), %edi
incq %rsi
cmpw %di, %ax
ja 0x2a70
movzwl %ax, %edx
leaq 0x2717(%rip), %rax      # 0x51a0
movq (%rax,%rsi,8), %rcx
movq %r12, %rdi
leaq 0xaed(%rip), %rsi       # 0x3584
xorl %eax, %eax
callq 0x11c0
jmp 0x2ab7
movabsq $0x782d7979792d7878, %rax # imm = 0x782D7979792D7878
movq %rax, 0x18(%rsp)
movl $0x787878, 0x20(%rsp)   # imm = 0x787878
movzwl 0x1278a(%rip), %ecx     # 0x15248
movzbl 0x12781(%rip), %r8d     # 0x15247
movzbl 0x12778(%rip), %r9d     # 0x15246
xorl %r15d, %r15d
leaq 0xa84(%rip), %rdi       # 0x355c
leaq 0xa(%rsp), %rsi
movq %r12, %r13
movq %r12, %rdx
xorl %eax, %eax
callq 0x10e0
xorl %r12d, %r12d
callq 0x1f2d
movl %eax, %r14d
leal 0x1(%r14), %eax
cmpl $0x2, %eax
jb 0x2b16
movl %r14d, %eax
shrl $0x1f, %eax
addl %eax, %r15d
andl $0xffffff, %r14d        # imm = 0xFFFFFF
addl %r12d, %r14d
movl %r14d, %r12d
jmp 0x2aed
testl %r15d, %r15d
leaq 0xa60(%rip), %rdx       # 0x3580
leaq 0x647(%rip), %rax       # 0x316e
cmoveq %rax, %rdx
leaq 0xa42(%rip), %rdi       # 0x3574
movl %r12d, %esi
xorl %eax, %eax
callq 0x10e0
movq %r13, %r12
cmpl $-0x1, %r14d
jne 0x2850
jmp 0x2b6a
callq 0x145c
jmp 0x2b57
callq 0x147e
callq 0x1f2d
movl %eax, %r14d
leal -0x1(%r14), %eax
cmpl $-0x2, %eax
jb 0x2b57
jmp 0x2b3f
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq