// File: /workspace/github_c_makefile_star2_O1/simh[P]simtools/converters/fsio/fsio.c
// Function: doMount
static void doMount(void)
{
  struct FSdef *filesys;
  FILE *container;
  int status;
  char *mode = SWISSET('r') ? "r" : "r+";

  if (checkDev(words[0]) != 0) { 
    if (lookupDev(words[0]) == NULL) {
      if ((filesys = lookupFS(words[2])) != NULL) {
        if (filesys->mount == NULL) {
          fprintf(stderr,
                  "mount: \"%s\" is not a mountable filesystem\n", words[2]);
          return;
        }

        if ((container = fopen(words[1], mode)) != NULL) {
          struct mountedFS *mount;

          if ((mount = malloc(sizeof(struct mountedFS))) != NULL) {
            memset(mount, 0, sizeof(struct mountedFS));

            strcpy(mount->name, words[0]);
            mount->filesys = filesys;
            mount->blocksz = filesys->blocksz;
            mount->flags = SWISSET('r') ? FS_READONLY : 0;
#ifdef DEBUG
            if (SWISSET('d')) {
              mount->flags |= FS_DEBUG;

              if (DEBUGout == NULL) {
                char *dbg = getenv("FSioDebugLog");

                if (dbg != NULL)
                  DEBUGout = fopen(dbg, "a");
              }

              if (DEBUGout == NULL)
                DEBUGout = stdout;
            }
#endif
            mount->container = container;
            mount->skip = 0;

            /*
             * Verify that the container holds a valid file system
             */
            if ((status = (*filesys->mount)(mount)) > 0) {
              mount->next = mounts;
              mounts = mount;
              return;
            }
            free(mount);
            if (status == 0)
              fprintf(stderr,
                      "mount: \"%s\" does not contain a valid file system\n",
                      words[1]);
          } else fprintf(stderr, "mount: out of memory\n");
          fclose(container);
        } else fprintf(stderr, "mount: failed to open \"%s\"\n", words[1]);
      } else fprintf(stderr, "mount: \"%s\" is not a supported file system type\n", words[2]);
    } else fprintf(stderr, "mount: \"%s\" already mounted\n", words[0]);
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
btl $0x11, 0x1440c(%rip)    # 0x18fc8
leaq 0xb531(%rip), %rax      # 0x100f4
leaq 0xca29(%rip), %rbx      # 0x115f3
cmovaeq %rax, %rbx
movq 0x144d3(%rip), %rax     # 0x190a8
movq (%rax), %rdi
callq 0x635e
testl %eax, %eax
je 0x4d4c
movq 0x144bc(%rip), %r12     # 0x190a8
movq (%r12), %r14
leaq 0x154b9(%rip), %r15     # 0x1a0b0
movq (%r15), %r15
testq %r15, %r15
je 0x4c18
leaq 0x8(%r15), %rsi
movq %r14, %rdi
callq 0x31c0
testl %eax, %eax
jne 0x4bf7
testq %r15, %r15
jne 0x4da7
movq 0x10(%r12), %r14
leaq 0x1439c(%rip), %r15     # 0x18fc0
movq (%r15), %r15
testq %r15, %r15
je 0x4c3e
movq 0x8(%r15), %rsi
movq %r14, %rdi
callq 0x31c0
testl %eax, %eax
jne 0x4c24
jmp 0x4c41
xorl %r15d, %r15d
testq %r15, %r15
je 0x4d73
cmpq $0x0, 0x28(%r15)
je 0x4d86
movq 0x8(%r12), %rdi
movq %rbx, %rsi
callq 0x3270
testq %rax, %rax
je 0x4d99
movq %rax, %rbx
movl $0x958, %edi            # imm = 0x958
callq 0x3210
testq %rax, %rax
je 0x4da0
movq %rax, %r14
movl $0x958, %edx            # imm = 0x958
movq %rax, %rdi
xorl %esi, %esi
callq 0x3170
movq %r14, %rdi
addq $0x8, %rdi
movq 0x14407(%rip), %rax     # 0x190a8
movq (%rax), %rsi
callq 0x30c0
movq %r15, 0x20(%r14)
movq 0x20(%r15), %rax
movq %rax, 0x28(%r14)
movl 0x1430d(%rip), %ecx     # 0x18fc8
movl %ecx, %eax
shrl $0x11, %eax
andl $0x1, %eax
movw %ax, 0x30(%r14)
testb $0x8, %cl
je 0x4d24
movzwl %ax, %eax
orl $0x2, %eax
movw %ax, 0x30(%r14)
cmpq $0x0, 0x142d8(%rip)     # 0x18fb8
jne 0x4d09
leaq 0xb439(%rip), %rdi      # 0x10122
callq 0x3040
testq %rax, %rax
je 0x4d09
leaq 0xb435(%rip), %rsi      # 0x1012f
movq %rax, %rdi
callq 0x3270
movq %rax, 0x142af(%rip)     # 0x18fb8
cmpq $0x0, 0x142a7(%rip)     # 0x18fb8
jne 0x4d24
movq 0x1329e(%rip), %rax     # 0x17fb8
movq (%rax), %rax
movq %rax, 0x14294(%rip)     # 0x18fb8
movq %rbx, 0x38(%r14)
movq $0x0, 0x40(%r14)
movq %r14, %rdi
callq *0x28(%r15)
testl %eax, %eax
jle 0x4d55
movq 0x1536e(%rip), %rax     # 0x1a0b0
movq %rax, (%r14)
movq %r14, 0x15364(%rip)     # 0x1a0b0
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movl %eax, %ebp
movq %r14, %rdi
callq 0x3050
testl %ebp, %ebp
je 0x4dca
movq %rbx, %rdi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x3110
movq 0x13276(%rip), %rax     # 0x17ff0
movq (%rax), %rdi
leaq 0xb411(%rip), %rsi      # 0x10195
jmp 0x4db8
movq 0x13263(%rip), %rax     # 0x17ff0
movq (%rax), %rdi
leaq 0xb360(%rip), %rsi      # 0x100f7
jmp 0x4db8
callq 0x334f
jmp 0x4d4c
callq 0x3333
jmp 0x4d63
movq 0x13242(%rip), %rax     # 0x17ff0
movq (%rax), %rdi
leaq 0xb40e(%rip), %rsi      # 0x101c6
movq %r14, %rdx
xorl %eax, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x31d0
callq 0x3310
jmp 0x4d63