// File: /workspace/github_c_makefile_star2_O2/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 0x1463f(%rip), %rax     # 0x180b8
movq (%rax), %rsi
leaq 0xb5cd(%rip), %rdi      # 0xf050
leaq 0xf(%rsp), %rdx
leaq 0x17(%rsp), %rcx
leaq 0x18(%rsp), %r8
callq 0x4e24
testq %rax, %rax
je 0x3da9
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 0x3dbb
movq %rax, %r14
movl 0x1450c(%rip), %eax     # 0x17fd8
movl %eax, %ecx
andl $0x8, %ecx
shrl $0x2, %ecx
addl $0x2, %ecx
testb $0x6, %al
pushq $0x1
popq %rax
cmovel %ecx, %eax
movb $0x0, 0x20(%rsp)
cmpl $0x1, %eax
je 0x3c92
cmpl $0x2, %eax
je 0x3bc7
cmpl $0x4, %eax
jne 0x3d9f
leaq 0x10(%rsp), %r15
pushq $0x4
popq %r12
leaq 0x20(%rsp), %r13
xorl %ebp, %ebp
movq 0x20(%rbx), %rax
movq %r14, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq *0x80(%rax)
testq %rax, %rax
je 0x3d80
movq %r13, %rdi
callq 0x3130
btl $0x17, 0x1449d(%rip)    # 0x17fd8
leaq 0xb995(%rip), %rsi      # 0xf4d7
jae 0x3b4b
leaq 0xb984(%rip), %rsi      # 0xf4cf
leaq (%rsp,%rax), %rdi
addq $0x20, %rdi
xorl %edx, %edx
xorl %eax, %eax
callq 0x32b0
movl %ebp, %eax
notl %eax
testb $0xc, %al
jne 0x3bb9
movq 0x28(%rbx), %rsi
movl %ebp, %ecx
andl $-0x10, %ecx
testq %rsi, %rsi
je 0x3ba1
movl %ecx, %eax
xorl %edx, %edx
divq %rsi
leaq 0xdeff(%rip), %rsi      # 0x11a7f
testq %rdx, %rdx
je 0x3b8c
leaq 0xdef4(%rip), %rsi      # 0x11a80
leaq 0xb922(%rip), %rdi      # 0xf4b5
movl %ecx, %edx
movq %r13, %rcx
xorl %eax, %eax
callq 0x3160
jmp 0x3bb4
leaq 0xb90f(%rip), %rdi      # 0xf4b7
movl %ecx, %esi
movq %r13, %rdx
xorl %eax, %eax
callq 0x3160
movb $0x0, 0x20(%rsp)
addl $0x4, %ebp
andw $0x0, 0xc(%rsp)
jmp 0x3b0f
leaq 0xc(%rsp), %r15
pushq $0x2
popq %r12
leaq 0x20(%rsp), %r13
xorl %ebp, %ebp
movq 0x20(%rbx), %rax
movq %r14, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq *0x80(%rax)
testq %rax, %rax
je 0x3d80
movq %r13, %rdi
callq 0x3130
btl $0x17, 0x143d5(%rip)    # 0x17fd8
leaq 0xb8bf(%rip), %rsi      # 0xf4c9
jae 0x3c13
leaq 0xb8ae(%rip), %rsi      # 0xf4c1
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 0x3c84
movq 0x28(%rbx), %rsi
movl %ebp, %ecx
andl $-0x10, %ecx
testq %rsi, %rsi
je 0x3c6c
movl %ecx, %eax
xorl %edx, %edx
divq %rsi
leaq 0xde34(%rip), %rsi      # 0x11a7f
testq %rdx, %rdx
je 0x3c57
leaq 0xde29(%rip), %rsi      # 0x11a80
leaq 0xb857(%rip), %rdi      # 0xf4b5
movl %ecx, %edx
movq %r13, %rcx
xorl %eax, %eax
callq 0x3160
jmp 0x3c7f
leaq 0xb844(%rip), %rdi      # 0xf4b7
movl %ecx, %esi
movq %r13, %rdx
xorl %eax, %eax
callq 0x3160
movb $0x0, 0x20(%rsp)
addl $0x2, %ebp
andw $0x0, 0xc(%rsp)
jmp 0x3bd7
pushq $0x1
popq %r12
leaq 0x20(%rsp), %r13
xorl %ebp, %ebp
movq 0x20(%rbx), %rax
movq %r14, %rdi
leaq 0x10(%rsp), %rsi
movq %r12, %rdx
callq *0x80(%rax)
testq %rax, %rax
je 0x3d80
movl 0x14316(%rip), %r15d    # 0x17fd8
movq %r13, %rdi
callq 0x3130
leaq (%rsp,%rax), %rdi
addq $0x20, %rdi
testb $0x2, %r15b
jne 0x3cfb
movzbl 0x10(%rsp), %eax
andl $0x7f, %eax
leaq 0x13a09(%rip), %rcx     # 0x176f0
movq (%rcx,%rax,8), %rdx
leaq 0xb7be(%rip), %rsi      # 0xf4b0
xorl %eax, %eax
callq 0x32b0
jmp 0x3d1c
btl $0x17, %r15d
leaq 0xb7a2(%rip), %rsi      # 0xf4a9
jae 0x3d10
leaq 0xb791(%rip), %rsi      # 0xf4a1
movzbl 0x10(%rsp), %edx
xorl %eax, %eax
callq 0x32b0
movl %ebp, %eax
notl %eax
testb $0x7, %al
jne 0x3d79
movq 0x28(%rbx), %rsi
movl %ebp, %ecx
andl $-0x8, %ecx
testq %rsi, %rsi
je 0x3d61
movl %ecx, %eax
xorl %edx, %edx
divq %rsi
leaq 0xdd3f(%rip), %rsi      # 0x11a7f
testq %rdx, %rdx
je 0x3d4c
leaq 0xdd34(%rip), %rsi      # 0x11a80
leaq 0xb762(%rip), %rdi      # 0xf4b5
movl %ecx, %edx
movq %r13, %rcx
xorl %eax, %eax
callq 0x3160
jmp 0x3d74
leaq 0xb74f(%rip), %rdi      # 0xf4b7
movl %ecx, %esi
movq %r13, %rdx
xorl %eax, %eax
callq 0x3160
movb $0x0, 0x20(%rsp)
incl %ebp
jmp 0x3c9d
cmpb $0x0, 0x20(%rsp)
je 0x3d9f
andl $-0x8, %ebp
leaq 0xb726(%rip), %rdi      # 0xf4b7
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 0x13236(%rip), %rax     # 0x16ff8
movq (%rax), %rdi
leaq 0xb712(%rip), %rsi      # 0xf4de
movq %r15, %rdx
xorl %eax, %eax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x31e0