// File: /workspace/github_c_makefile_star2_O3/simh[P]simtools/converters/fsio/rt11.c
// Function: info
static void info(
  struct mountedFS *mount,
  uint8_t unit
)
{
  struct RT11data *data = &mount->rt11data;
  uint16_t entrysz, startblk, dsseg = 1;
  char temp[32];

  printf("%s%o:\n\n", mount->name, unit);

  do {
    uint16_t off = RT11_DH_SIZE;

    if (rt11ReadDirSegment(mount, unit, dsseg) == 0)
      return;

    printf("\nDirectory Segment %2d:\n\n", dsseg);
    printf(" File  Type     Date     Status   Class   Length    Disk Region\n\n");

    entrysz = RT11_DI_SIZE + (le16toh(data->buf[RT11_DH_EXTRA]) >> 1);
    startblk = le16toh(data->buf[RT11_DH_START]);

    /*
     * Loop until we see and end-of-segment marker or there is no room for
     * another directory entry.
     */
    while (!RT11EOS(le16toh(data->buf[off + RT11_DI_STATUS])) &&
           ((RT11_DS_SIZE - off) >= entrysz)) {
      uint16_t status = le16toh(data->buf[off + RT11_DI_STATUS]);

      /*
       * Tentative and empty files are reported as "UNUSED"
       */
      if ((status & (RT11_E_TENT | RT11_E_MPTY)) == 0) {
        r50Asc(le16toh(data->buf[off + RT11_DI_FNAME1]), &temp[0]);
        r50Asc(le16toh(data->buf[off + RT11_DI_FNAME2]), &temp[3]);
        temp[6] = '.';
        r50Asc(le16toh(data->buf[off + RT11_DI_FTYPE]), &temp[7]);
        temp[10] = ' ';
        temp[11] = ' ';
        rt11Date(le16toh(data->buf[off + RT11_DI_CREATE]), &temp[12]);

        printf("%s  %07o  %s     %5d     %5d-%5d\n",
               temp, status,
               (status & RT11_E_PRE) != 0 ? "PRE" : "   ",
               le16toh(data->buf[off + RT11_DI_LENGTH]),
               startblk,
               startblk + le16toh(data->buf[off + RT11_DI_LENGTH]) - 1);
      } else {
        printf("< UNUSED >                                %5d     %5d-%5d\n",
               le16toh(data->buf[off + RT11_DI_LENGTH]),
               startblk,
               le16toh(data->buf[off + RT11_DI_LENGTH]) == 0 ? startblk :
                 startblk + le16toh(data->buf[off + RT11_DI_LENGTH]) - 1);
      }
      startblk += le16toh(data->buf[off + RT11_DI_LENGTH]);

      off += entrysz;
    }

    dsseg = le16toh(data->buf[RT11_DH_NEXT]);
  } while (dsseg != 0);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %esi, %ebp
movq %rdi, %rbx
leaq 0x8(%rdi), %rsi
leaq 0x7055(%rip), %rdi      # 0x12b9b
movl %ebp, %edx
xorl %eax, %eax
callq 0x3160
movw $0x1, %ax
movzbl %bpl, %ecx
movl %ecx, 0x14(%rsp)
movzwl %ax, %r15d
movq %rbx, %rdi
movl 0x14(%rsp), %esi
movl %r15d, %edx
callq 0x9d20
testl %eax, %eax
je 0xbcf6
leaq 0x67dc(%rip), %rdi      # 0x12359
movl %r15d, %esi
xorl %eax, %eax
callq 0x3160
leaq 0x685d(%rip), %rdi      # 0x123eb
callq 0x30e0
movzwl 0x478(%rbx), %edx
movzwl 0x47c(%rbx), %eax
btl $0xb, %eax
setae %cl
movl %edx, %esi
cmpl $0x3ea, %edx            # imm = 0x3EA
setb %dl
andb %cl, %dl
cmpb $0x1, %dl
jne 0xbce6
shrl %esi
movl $0x1f9, %ecx            # imm = 0x1F9
subl %esi, %ecx
movl %ecx, 0x18(%rsp)
addl $0x7, %esi
movl %esi, 0x1c(%rsp)
movzwl 0x47a(%rbx), %r13d
movl $0x5, %r14d
movzwl %ax, %r12d
movl %r14d, %ebp
movzwl %r13w, %r15d
testl $0x300, %r12d           # imm = 0x300
je 0xbc21
movzwl 0x47a(%rbx,%rbp,2), %esi
addq $0x4, %rbp
testl %esi, %esi
leal -0x1(%r15,%rsi), %ecx
cmovel %r15d, %ecx
leaq 0x6787(%rip), %rdi      # 0x12399
movl %r15d, %edx
xorl %eax, %eax
callq 0x3160
jmp 0xbcba
movzwl 0x474(%rbx,%rbp,2), %edi
leaq 0x20(%rsp), %rsi
callq 0x658c
movzwl 0x476(%rbx,%rbp,2), %edi
leaq 0x23(%rsp), %rsi
callq 0x658c
movb $0x2e, 0x26(%rsp)
movzwl 0x478(%rbx,%rbp,2), %edi
leaq 0x27(%rsp), %rsi
callq 0x658c
movw $0x2020, 0x2a(%rsp)     # imm = 0x2020
movzwl 0x47e(%rbx,%rbp,2), %edi
leaq 0x2c(%rsp), %rsi
callq 0x9e73
testb $0x10, %r12b
leaq 0x6715(%rip), %rcx      # 0x12395
leaq 0x66ce(%rip), %rax      # 0x12355
cmoveq %rax, %rcx
movzwl 0x47a(%rbx,%rbp,2), %r8d
addq $0x4, %rbp
leal (%r15,%r8), %eax
decl %eax
movl %eax, (%rsp)
leaq 0x66cb(%rip), %rdi      # 0x12373
leaq 0x20(%rsp), %rsi
movl %r12d, %edx
movl %r15d, %r9d
xorl %eax, %eax
callq 0x3160
addl 0x1c(%rsp), %r14d
movzwl %r14w, %r14d
movzwl 0x472(%rbx,%r14,2), %eax
btl $0xb, %eax
jb 0xbce6
addw 0x472(%rbx,%rbp,2), %r13w
cmpl 0x18(%rsp), %r14d
jle 0xbbe0
movzwl 0x474(%rbx), %eax
testw %ax, %ax
jne 0xbb5b
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)