// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x40, %rsp
leaq 0x13391(%rip), %rdi     # 0x16240
movl $0x10000, %esi          # imm = 0x10000
callq 0x1f70
movl %eax, -0x4(%rbp)
movl %eax, %ecx
movl %ecx, -0x34(%rbp)
subl $-0x1, %eax
je 0x2ed1
jmp 0x2ec8
movl -0x34(%rbp), %eax
testl %eax, %eax
je 0x2ed6
jmp 0x2ee2
jmp 0x30ca
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x30ca
movl -0x4(%rbp), %eax
andl $0x80000000, %eax       # imm = 0x80000000
cmpl $0x0, %eax
jne 0x308a
movl -0x4(%rbp), %eax
andl $0xffffff, %eax         # imm = 0xFFFFFF
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
cmpq $0xc, %rax
je 0x2f14
movl -0x4(%rbp), %eax
cmpq $0xe, %rax
jne 0x3070
leaq 0x13325(%rip), %rax     # 0x16240
movq %rax, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
movl $0x0, -0x30(%rbp)
leaq -0x12(%rbp), %rdi
movl $0x20, %esi
movl $0xe, %edx
callq 0x1100
movb $0x0, -0x5(%rbp)
movq -0x28(%rbp), %rax
movw (%rax), %ax
leaq -0x12(%rbp), %rsi
movzwl %ax, %edi
callq 0x30e0
movq -0x28(%rbp), %rax
movw 0x2(%rax), %ax
leaq -0x12(%rbp), %rsi
addq $0x3, %rsi
movzwl %ax, %edi
callq 0x30e0
movl -0x4(%rbp), %eax
cmpq $0xe, %rax
jne 0x2f90
movq -0x28(%rbp), %rax
movw 0xc(%rax), %ax
leaq -0x12(%rbp), %rsi
addq $0x6, %rsi
movzwl %ax, %edi
callq 0x30e0
movb $0x2e, -0x9(%rbp)
movq -0x28(%rbp), %rax
movw 0x4(%rax), %ax
leaq -0x12(%rbp), %rsi
addq $0xa, %rsi
movzwl %ax, %edi
callq 0x30e0
movq -0x28(%rbp), %rax
movw 0xa(%rax), %ax
leaq -0x1e(%rbp), %rsi
movzwl %ax, %edi
callq 0x3160
leaq -0x12(%rbp), %rsi
leaq -0x1e(%rbp), %rdx
movq -0x28(%rbp), %rax
movzwl 0x8(%rax), %ecx
movq -0x28(%rbp), %rax
movzbl 0x7(%rax), %r8d
movq -0x28(%rbp), %rax
movzbl 0x6(%rax), %r9d
leaq 0x1643(%rip), %rdi      # 0x462c
movb $0x0, %al
callq 0x10d0
callq 0x2080
movl %eax, -0x4(%rbp)
incl %eax
subl $0x1, %eax
ja 0x302c
jmp 0x3001
movl -0x30(%rbp), %esi
movl -0x2c(%rbp), %ecx
leaq 0x1230(%rip), %rdx      # 0x423e
leaq 0x163b(%rip), %rax      # 0x4650
cmpl $0x0, %ecx
cmovneq %rax, %rdx
leaq 0x1621(%rip), %rdi      # 0x4644
movb $0x0, %al
callq 0x10d0
jmp 0x3050
movl -0x4(%rbp), %eax
andl $0x80000000, %eax       # imm = 0x80000000
cmpl $0x0, %eax
je 0x3042
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
movl -0x4(%rbp), %eax
andl $0xffffff, %eax         # imm = 0xFFFFFF
addl -0x30(%rbp), %eax
movl %eax, -0x30(%rbp)
jmp 0x3052
xorl %eax, %eax
cmpl $-0x1, -0x4(%rbp)
movb %al, -0x35(%rbp)
je 0x3067
cmpl $0x0, -0x4(%rbp)
setne %al
movb %al, -0x35(%rbp)
movb -0x35(%rbp), %al
testb $0x1, %al
jne 0x2ff0
jmp 0x30ca
movq 0x2f81(%rip), %rax      # 0x5ff8
movq (%rax), %rdi
leaq 0x1565(%rip), %rsi      # 0x45e6
movb $0x0, %al
callq 0x1110
jmp 0x30a2
movq 0x2f67(%rip), %rax      # 0x5ff8
movq (%rax), %rdi
leaq 0x156a(%rip), %rsi      # 0x4605
movb $0x0, %al
callq 0x1110
jmp 0x30a4
callq 0x2080
movl %eax, -0x4(%rbp)
xorl %eax, %eax
cmpl $-0x1, -0x4(%rbp)
movb %al, -0x36(%rbp)
je 0x30c1
cmpl $0x0, -0x4(%rbp)
setne %al
movb %al, -0x36(%rbp)
movb -0x36(%rbp), %al
testb $0x1, %al
jne 0x30a4
jmp 0x30ca
jmp 0x30cc
cmpl $-0x1, -0x4(%rbp)
jne 0x2ea8
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)