// File: /workspace/github_c_makefile_star2_O3/simh[P]simtools/converters/fsio/fsio.c
// Function: doDump
static void doDump(void)
{
  struct mountedFS *mount;
  char *fname;
  void *file;
  uint8_t unit, present;

  if ((mount = findMount("dump", words[0], &unit, &present, &fname)) != NULL) {
    if ((file = (*mount->filesys->openFileR)(mount, unit, fname)) != NULL) {
      unsigned int offset = 0, datasz = 2;
      uint8_t data1;
      uint16_t data2;
      uint32_t data4;
      char output[128];

      if (SWISSET('b') || SWISSET('c'))
        datasz = 1;
      else if (SWISSET('d'))
        datasz = 4;
      else if (SWISSET('w'))
        datasz = 2;

      output[0] = '\0';

      switch (datasz) {
        case 1:
          while ((*mount->filesys->readFile)(file, &data1, 1) != 0) {
            if (SWISSET('b'))
              sprintf(&output[strlen(output)],
                      SWISSET('x') ? " 0x%02X" : " 0%03o", data1);
            else sprintf(&output[strlen(output)], " %s ", Ascii[data1 & 0177]);

            if ((offset & 07) == 07) {
              if (mount->blocksz != 0)
                printf("%s%011o %s\n",
                       ((offset & ~07) % mount->blocksz) == 0 ? "\n" : "",
                       offset & ~07, output);
              else printf("%011o %s\n", offset & ~07, output);
              output[0] = '\0';
            }
            offset++;
          }

          if (output[0] != '\0')
            printf("%011o %s\n", offset & ~07, output);
          break;

        case 2:
          while ((*mount->filesys->readFile)(file, &data2, 2) != 0) {
            sprintf(&output[strlen(output)],
                    SWISSET('x') ? " 0x%04X" : " %07o", data2);

            if ((offset & 017) == 016) {
              if (mount->blocksz != 0)
                printf("%s%011o %s\n",
                       ((offset & ~017) % mount->blocksz) == 0 ? "\n" : "",
                       offset & ~017, output);
              else printf("%011o %s\n", offset & ~017, output);
              output[0] = '\0';
            }
            offset += 2;
            data2 = 0;
          }

          if (output[0] != '\0')
            printf("%011o %s\n", offset & ~07, output);
          break;

        case 4:
          while ((*mount->filesys->readFile)(file, &data4, 4) != 0) {
            sprintf(&output[strlen(output)],
                    SWISSET('x') ? " 0x%08X" : " %011o", data2);

            if ((offset & 017) == 014) {
              if (mount->blocksz != 0)
                printf("%s%011o %s\n",
                       ((offset & ~017) % mount->blocksz) == 0 ? "\n" : "",
                       offset & ~017, output);
              else printf("%011o %s\n", offset & ~017, output);
              output[0] = '\0';
            }
            offset += 4;
            data2 = 0;
          }

          if (output[0] != '\0')
            printf("%011o %s\n", offset & ~07, output);
          break;
      }
      /*
       * Close the file
       */
      (*mount->filesys->closeFile)(file);
    } else fprintf(stderr, "dump: \"%s\" no such file\n", fname);
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq 0x13fb8(%rip), %rax     # 0x190b8
movq (%rax), %rsi
leaq 0xaf46(%rip), %rdi      # 0x10050
leaq 0xf(%rsp), %rdx
leaq 0x17(%rsp), %rcx
leaq 0x18(%rsp), %r8
callq 0x636e
testq %rax, %rax
je 0x5496
movq %rax, %rbx
movq 0x20(%rax), %rax
movzbl 0xf(%rsp), %esi
movq 0x18(%rsp), %r15
movq %rbx, %rdi
movq %r15, %rdx
callq *0x60(%rax)
testq %rax, %rax
je 0x54a8
movq %rax, %r14
movl 0x13e85(%rip), %eax     # 0x18fd8
movl %eax, %ecx
andl $0x8, %ecx
shrl $0x2, %ecx
addl $0x2, %ecx
testb $0x6, %al
movl $0x1, %eax
cmovel %ecx, %eax
movb $0x0, 0x20(%rsp)
cmpl $0x1, %eax
je 0x535f
cmpl $0x2, %eax
je 0x5272
cmpl $0x4, %eax
jne 0x548c
movq 0x20(%rbx), %rax
leaq 0x10(%rsp), %rsi
movl $0x4, %edx
movq %r14, %rdi
callq *0x80(%rax)
testq %rax, %rax
je 0x546e
leaq 0x20(%rsp), %r15
leaq 0xb323(%rip), %r13      # 0x104d7
leaq 0x10(%rsp), %r12
xorl %ebp, %ebp
movq %r15, %rdi
callq 0x3130
btl $0x17, 0x13e0d(%rip)    # 0x18fd8
movq %r13, %rsi
jae 0x51d7
leaq 0xb2f8(%rip), %rsi      # 0x104cf
leaq (%rsp,%rax), %rdi
addq $0x20, %rdi
xorl %edx, %edx
xorl %eax, %eax
callq 0x32b0
movl %ebp, %eax
notl %eax
testb $0xc, %al
jne 0x5245
movq 0x28(%rbx), %rsi
movl %ebp, %ecx
andl $-0x10, %ecx
testq %rsi, %rsi
je 0x522d
movl %ecx, %eax
xorl %edx, %edx
divq %rsi
leaq 0xd893(%rip), %rsi      # 0x12a9f
testq %rdx, %rdx
je 0x5218
leaq 0xd888(%rip), %rsi      # 0x12aa0
leaq 0xb296(%rip), %rdi      # 0x104b5
movl %ecx, %edx
movq %r15, %rcx
xorl %eax, %eax
callq 0x3160
jmp 0x5240
leaq 0xb283(%rip), %rdi      # 0x104b7
movl %ecx, %esi
movq %r15, %rdx
xorl %eax, %eax
callq 0x3160
movb $0x0, 0x20(%rsp)
addl $0x4, %ebp
movw $0x0, 0xc(%rsp)
movq 0x20(%rbx), %rax
movl $0x4, %edx
movq %r14, %rdi
movq %r12, %rsi
callq *0x80(%rax)
testq %rax, %rax
jne 0x51bb
jmp 0x5469
movq 0x20(%rbx), %rax
leaq 0xc(%rsp), %rsi
movl $0x2, %edx
movq %r14, %rdi
callq *0x80(%rax)
testq %rax, %rax
je 0x546e
leaq 0x20(%rsp), %r15
leaq 0xb22b(%rip), %r13      # 0x104c9
leaq 0xc(%rsp), %r12
xorl %ebp, %ebp
movq %r15, %rdi
callq 0x3130
btl $0x17, 0x13d23(%rip)    # 0x18fd8
movq %r13, %rsi
jae 0x52c1
leaq 0xb200(%rip), %rsi      # 0x104c1
leaq (%rsp,%rax), %rdi
addq $0x20, %rdi
movzwl 0xc(%rsp), %edx
xorl %eax, %eax
callq 0x32b0
movl %ebp, %eax
notl %eax
testb $0xe, %al
jne 0x5332
movq 0x28(%rbx), %rsi
movl %ebp, %ecx
andl $-0x10, %ecx
testq %rsi, %rsi
je 0x531a
movl %ecx, %eax
xorl %edx, %edx
divq %rsi
leaq 0xd7a6(%rip), %rsi      # 0x12a9f
testq %rdx, %rdx
je 0x5305
leaq 0xd79b(%rip), %rsi      # 0x12aa0
leaq 0xb1a9(%rip), %rdi      # 0x104b5
movl %ecx, %edx
movq %r15, %rcx
xorl %eax, %eax
callq 0x3160
jmp 0x532d
leaq 0xb196(%rip), %rdi      # 0x104b7
movl %ecx, %esi
movq %r15, %rdx
xorl %eax, %eax
callq 0x3160
movb $0x0, 0x20(%rsp)
addl $0x2, %ebp
movw $0x0, 0xc(%rsp)
movq 0x20(%rbx), %rax
movl $0x2, %edx
movq %r14, %rdi
movq %r12, %rsi
callq *0x80(%rax)
testq %rax, %rax
jne 0x52a5
jmp 0x5469
movq 0x20(%rbx), %rax
leaq 0x10(%rsp), %rsi
movl $0x1, %edx
movq %r14, %rdi
callq *0x80(%rax)
testq %rax, %rax
je 0x546e
leaq 0x20(%rsp), %r15
leaq 0x10(%rsp), %r13
xorl %ebp, %ebp
movl 0x13c46(%rip), %r12d    # 0x18fd8
movq %r15, %rdi
callq 0x3130
leaq (%rsp,%rax), %rdi
addq $0x20, %rdi
testb $0x2, %r12b
jne 0x53cb
movzbl 0x10(%rsp), %eax
andl $0x7f, %eax
leaq 0x13339(%rip), %rcx     # 0x186f0
movq (%rcx,%rax,8), %rdx
leaq 0xb0ee(%rip), %rsi      # 0x104b0
xorl %eax, %eax
callq 0x32b0
jmp 0x53ec
btl $0x17, %r12d
leaq 0xb0d2(%rip), %rsi      # 0x104a9
jae 0x53e0
leaq 0xb0c1(%rip), %rsi      # 0x104a1
movzbl 0x10(%rsp), %edx
xorl %eax, %eax
callq 0x32b0
movl %ebp, %eax
notl %eax
testb $0x7, %al
jne 0x5449
movq 0x28(%rbx), %rsi
movl %ebp, %ecx
andl $-0x8, %ecx
testq %rsi, %rsi
je 0x5431
movl %ecx, %eax
xorl %edx, %edx
divq %rsi
leaq 0xd68f(%rip), %rsi      # 0x12a9f
testq %rdx, %rdx
je 0x541c
leaq 0xd684(%rip), %rsi      # 0x12aa0
leaq 0xb092(%rip), %rdi      # 0x104b5
movl %ecx, %edx
movq %r15, %rcx
xorl %eax, %eax
callq 0x3160
jmp 0x5444
leaq 0xb07f(%rip), %rdi      # 0x104b7
movl %ecx, %esi
movq %r15, %rdx
xorl %eax, %eax
callq 0x3160
movb $0x0, 0x20(%rsp)
incl %ebp
movq 0x20(%rbx), %rax
movl $0x1, %edx
movq %r14, %rdi
movq %r13, %rsi
callq *0x80(%rax)
testq %rax, %rax
jne 0x538b
andl $-0x8, %ebp
jmp 0x5470
xorl %ebp, %ebp
cmpb $0x0, 0x20(%rsp)
je 0x548c
leaq 0xb039(%rip), %rdi      # 0x104b7
leaq 0x20(%rsp), %rdx
movl %ebp, %esi
xorl %eax, %eax
callq 0x3160
movq 0x20(%rbx), %rax
movq %r14, %rdi
callq *0x78(%rax)
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x12b41(%rip), %rax     # 0x17ff0
movq (%rax), %rdi
leaq 0xb025(%rip), %rsi      # 0x104de
movq %r15, %rdx
xorl %eax, %eax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x31e0