// File: /workspace/github_c_makefile_star2_O1/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
leaq 0x129a0(%rip), %r15     # 0x15240
movl $0xffff, %r12d          # imm = 0xFFFF
leaq 0x8c1(%rip), %rbx       # 0x316e
leaq 0xccc(%rip), %r13       # 0x3580
leaq 0xcb9(%rip), %rbp       # 0x3574
movq %r15, %rdi
movl $0x10000, %esi          # imm = 0x10000
callq 0x1e89
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
leal 0x1(%rax), %ecx
cmpl $0x2, %ecx
jb 0x2b97
testl %eax, %eax
js 0x2ba3
andl $0xffffff, %eax         # imm = 0xFFFFFF
movl %eax, %ecx
orl $0x2, %ecx
cmpl $0xe, %ecx
jne 0x2baa
movzwl 0x12944(%rip), %edx     # 0x15240
imull $0xcccd, %edx, %ecx     # imm = 0xCCCD
shrl $0x15, %ecx
leal (,%rcx,8), %esi
leal (%rsi,%rsi,4), %esi
subl %esi, %edx
andl %r12d, %edx
imulq $0x6666667, %rcx, %rsi  # imm = 0x6666667
shrq $0x20, %rsi
leal (,%rsi,8), %edi
leal (%rdi,%rdi,4), %edi
subl %edi, %ecx
movzwl 0x1290f(%rip), %r8d     # 0x15242
imull $0xcccd, %r8d, %edi     # imm = 0xCCCD
shrl $0x15, %edi
leal (,%rdi,8), %r9d
leal (%r9,%r9,4), %r9d
subl %r9d, %r8d
andl %r12d, %r8d
imulq $0x6666667, %rdi, %r9   # imm = 0x6666667
shrq $0x20, %r9
leal (,%r9,8), %r10d
leal (%r10,%r10,4), %r10d
subl %r10d, %edi
movabsq $0x2020202020202020, %r10 # imm = 0x2020202020202020
movq %r10, 0xe(%rsp)
movq %r10, 0x8(%rsp)
movb $0x0, 0x15(%rsp)
leaq 0x27a7(%rip), %r10      # 0x5130
movb (%rdx,%r10), %dl
movb %dl, 0xa(%rsp)
movb (%rcx,%r10), %cl
movb %cl, 0x9(%rsp)
movb (%rsi,%r10), %cl
movb %cl, 0x8(%rsp)
movb (%r8,%r10), %cl
movb %cl, 0xd(%rsp)
movb (%rdi,%r10), %cl
movb %cl, 0xc(%rsp)
movb (%r9,%r10), %cl
movb %cl, 0xb(%rsp)
cmpl $0xe, %eax
jne 0x2a0c
movzwl 0x12887(%rip), %eax     # 0x1524c
imull $0xcccd, %eax, %ecx     # imm = 0xCCCD
shrl $0x15, %ecx
leal (,%rcx,8), %edx
leal (%rdx,%rdx,4), %edx
subl %edx, %eax
movzwl %ax, %eax
movb (%rax,%r10), %al
movb %al, 0x10(%rsp)
imulq $0x6666667, %rcx, %rax  # imm = 0x6666667
shrq $0x20, %rax
leal (,%rax,8), %edx
leal (%rdx,%rdx,4), %edx
subl %edx, %ecx
movb (%rcx,%r10), %cl
movb %cl, 0xf(%rsp)
movb (%rax,%r10), %al
movb %al, 0xe(%rsp)
movb $0x2e, 0x11(%rsp)
movzwl 0x1282c(%rip), %eax     # 0x15244
imull $0xcccd, %eax, %ecx     # imm = 0xCCCD
shrl $0x15, %ecx
leal (,%rcx,8), %edx
leal (%rdx,%rdx,4), %edx
subl %edx, %eax
andl %r12d, %eax
movb (%rax,%r10), %al
movb %al, 0x14(%rsp)
imulq $0x6666667, %rcx, %rax  # imm = 0x6666667
shrq $0x20, %rax
leal (,%rax,8), %edx
leal (%rdx,%rdx,4), %edx
subl %edx, %ecx
movb (%rcx,%r10), %cl
movb %cl, 0x13(%rsp)
movb (%rax,%r10), %al
movb %al, 0x12(%rsp)
movzwl 0x127e4(%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 %dl
andb %cl, %dl
leaq 0x26c0(%rip), %rcx      # 0x5160
leaq 0x26d9(%rip), %rsi      # 0x5180
cmovneq %rsi, %rcx
movl %eax, %esi
andl %r12d, %esi
movzbl %dl, %edx
addl $0x16d, %edx            # imm = 0x16D
cmpl %esi, %edx
leaq 0x18(%rsp), %r14
jbe 0x2ad8
movzwl (%rcx), %edx
xorl %esi, %esi
cmpw %dx, %ax
jbe 0x2af1
subl %edx, %eax
movzwl 0x2(%rcx,%rsi,2), %edx
incq %rsi
jmp 0x2ac7
movabsq $0x782d7979792d7878, %rax # imm = 0x782D7979792D7878
movq %rax, 0x18(%rsp)
movl $0x787878, 0x20(%rsp)   # imm = 0x787878
jmp 0x2b10
movzwl %ax, %edx
leaq 0x26a5(%rip), %rax      # 0x51a0
movq (%rax,%rsi,8), %rcx
movq %r14, %rdi
leaq 0xa7b(%rip), %rsi       # 0x3584
xorl %eax, %eax
callq 0x11c0
movzwl 0x12731(%rip), %ecx     # 0x15248
movzbl 0x12728(%rip), %r8d     # 0x15247
movzbl 0x1271f(%rip), %r9d     # 0x15246
xorl %r15d, %r15d
leaq 0xa2b(%rip), %rdi       # 0x355c
leaq 0x8(%rsp), %rsi
movq %r14, %rdx
xorl %eax, %eax
callq 0x10e0
xorl %r12d, %r12d
callq 0x1f6a
movl %eax, %r14d
leal 0x1(%r14), %eax
cmpl $0x1, %eax
ja 0x2b6d
testl %r15d, %r15d
movq %r13, %rdx
cmoveq %rbx, %rdx
movq %rbp, %rdi
movl %r12d, %esi
xorl %eax, %eax
callq 0x10e0
jmp 0x2b81
movl %r14d, %eax
shrl $0x1f, %eax
addl %eax, %r15d
movl %r14d, %eax
andl $0xffffff, %eax         # imm = 0xFFFFFF
addl %eax, %r12d
leal -0x1(%r14), %eax
cmpl $-0x2, %eax
jb 0x2b43
leaq 0x126af(%rip), %r15     # 0x15240
movl $0xffff, %r12d          # imm = 0xFFFF
cmpl $-0x1, %r14d
jne 0x28bb
jmp 0x2bc0
callq 0x145c
jmp 0x2baf
callq 0x147e
callq 0x1f6a
movl %eax, %r14d
decl %eax
cmpl $-0x2, %eax
jb 0x2baf
jmp 0x2b97
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq