// File: /workspace/github_c_makefile_star2_O2/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
movabsq $0x2020202020202020, %rbx # imm = 0x2020202020202020
leaq 0x8(%rsp), %r13
leaq 0x18(%rsp), %r14
leaq 0x12cd5(%rip), %rdi     # 0x15240
movl $0x10000, %esi          # imm = 0x10000
callq 0x1ba5
movl %eax, %r15d
leal 0x1(%r15), %eax
cmpl $0x2, %eax
jb 0x2765
testl %r15d, %r15d
js 0x2721
andl $0xffffff, %r15d        # imm = 0xFFFFFF
movl %r15d, %eax
orl $0x2, %eax
cmpl $0xe, %eax
jne 0x2736
movq %rbx, 0x8(%rsp)
movq %rbx, 0xd(%rsp)
movb $0x0, 0x15(%rsp)
movzwl 0x12c86(%rip), %edi     # 0x15240
movq %r13, %rsi
callq 0x2774
movzwl 0x12c79(%rip), %edi     # 0x15242
leaq 0xb(%rsp), %rsi
callq 0x2774
cmpl $0xe, %r15d
jne 0x25ea
movzwl 0x12c6c(%rip), %edi     # 0x1524c
leaq 0xe(%rsp), %rsi
callq 0x2774
movb $0x2e, 0x11(%rsp)
movzwl 0x12c4e(%rip), %edi     # 0x15244
leaq 0x12(%rsp), %rsi
callq 0x2774
movzwl 0x12c43(%rip), %eax     # 0x1524a
xorl %edx, %edx
movw $0x3e8, %cx             # imm = 0x3E8
divw %cx
addl $0x7b2, %eax            # imm = 0x7B2
testb $0x3, %al
sete %cl
cmpw $0x7d0, %ax             # imm = 0x7D0
setne %sil
andb %cl, %sil
leaq 0x2b34(%rip), %rcx      # 0x5160
leaq 0x2b4d(%rip), %rdi      # 0x5180
cmovneq %rdi, %rcx
movzwl %dx, %edi
movzbl %sil, %esi
addl $0x16d, %esi            # imm = 0x16D
cmpl %edi, %esi
jbe 0x2667
movzwl %ax, %r8d
leaq 0x2b4d(%rip), %rax      # 0x51a0
movzwl (%rcx), %esi
cmpw %si, %dx
jbe 0x2680
subl %esi, %edx
addq $0x8, %rax
addq $0x2, %rcx
jmp 0x2653
movabsq $0x782d7979792d7878, %rax # imm = 0x782D7979792D7878
movq %rax, 0x18(%rsp)
movl $0x787878, 0x20(%rsp)   # imm = 0x787878
jmp 0x2697
movzwl %dx, %edx
movq (%rax), %rcx
movq %r14, %rdi
leaq 0xef4(%rip), %rsi       # 0x3584
xorl %eax, %eax
callq 0x11c0
movzwl 0x12baa(%rip), %ecx     # 0x15248
movzbl 0x12ba1(%rip), %r8d     # 0x15247
movzbl 0x12b98(%rip), %r9d     # 0x15246
xorl %r12d, %r12d
leaq 0xea4(%rip), %rdi       # 0x355c
movq %r13, %rsi
movq %r14, %rdx
xorl %eax, %eax
callq 0x10e0
xorl %ebp, %ebp
callq 0x1c73
movl %eax, %r15d
leal 0x1(%r15), %eax
cmpl $0x2, %eax
jb 0x26f0
movl %r15d, %eax
shrl $0x1f, %eax
addl %eax, %r12d
andl $0xffffff, %r15d        # imm = 0xFFFFFF
addl %ebp, %r15d
movl %r15d, %ebp
jmp 0x26c7
testl %r12d, %r12d
leaq 0xe86(%rip), %rdx       # 0x3580
leaq 0xa6d(%rip), %rax       # 0x316e
cmoveq %rax, %rdx
leaq 0xe68(%rip), %rdi       # 0x3574
movl %ebp, %esi
xorl %eax, %eax
callq 0x10e0
cmpl $-0x1, %r15d
jne 0x2564
jmp 0x2765
movq 0x28d0(%rip), %rax      # 0x4ff8
movq (%rax), %rcx
leaq 0xe03(%rip), %rdi       # 0x3535
pushq $0x26
jmp 0x2749
movq 0x28bb(%rip), %rax      # 0x4ff8
movq (%rax), %rcx
leaq 0xdcf(%rip), %rdi       # 0x3516
pushq $0x1e
popq %rsi
pushq $0x1
popq %rdx
callq 0x11e0
callq 0x1c73
movl %eax, %r15d
leal -0x1(%r15), %eax
cmpl $-0x2, %eax
jb 0x2752
jmp 0x2715
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq