// File: /workspace/github_c_makefile_star2_O3/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, 0x1444c(%rip)    # 0x18fd8
leaq 0xb561(%rip), %rax      # 0x100f4
leaq 0xca59(%rip), %rbx      # 0x115f3
cmovaeq %rax, %rbx
movq 0x14513(%rip), %rax     # 0x190b8
movq (%rax), %rdi
callq 0x62fc
testl %eax, %eax
je 0x4d10
movq 0x144fc(%rip), %r12     # 0x190b8
movq (%r12), %r14
leaq 0x154f9(%rip), %r15     # 0x1a0c0
movq (%r15), %r15
testq %r15, %r15
je 0x4bf5
leaq 0x8(%r15), %rsi
movq %r14, %rdi
callq 0x31d0
testl %eax, %eax
jne 0x4bc7
movq 0x1340a(%rip), %rax     # 0x17ff0
movq (%rax), %rdi
leaq 0xb5d6(%rip), %rsi      # 0x101c6
jmp 0x4d5b
movq 0x10(%r12), %r14
leaq 0x143cf(%rip), %r15     # 0x18fd0
movq (%r15), %r15
testq %r15, %r15
je 0x4d37
movq 0x8(%r15), %rsi
movq %r14, %rdi
callq 0x31d0
testl %eax, %eax
jne 0x4c01
cmpq $0x0, 0x28(%r15)
je 0x4d4a
movq 0x8(%r12), %rdi
movq %rbx, %rsi
callq 0x3280
testq %rax, %rax
je 0x4d6d
movq %rax, %rbx
movl $0x1, %edi
movl $0x958, %esi            # imm = 0x958
callq 0x31c0
testq %rax, %rax
je 0x4d74
movq %rax, %r14
movq %rax, %rdi
addq $0x8, %rdi
movq 0x1444e(%rip), %rax     # 0x190b8
movq (%rax), %rsi
callq 0x30c0
movq %r15, 0x20(%r14)
movq 0x20(%r15), %rax
movq %rax, 0x28(%r14)
movl 0x14354(%rip), %ecx     # 0x18fd8
movl %ecx, %eax
shrl $0x11, %eax
andl $0x1, %eax
movw %ax, 0x30(%r14)
testb $0x8, %cl
je 0x4ce8
movzwl %ax, %eax
orl $0x2, %eax
movw %ax, 0x30(%r14)
cmpq $0x0, 0x1431f(%rip)     # 0x18fc8
jne 0x4ce8
leaq 0xb470(%rip), %rdi      # 0x10122
callq 0x3040
testq %rax, %rax
je 0x4cd7
leaq 0xb46c(%rip), %rsi      # 0x1012f
movq %rax, %rdi
callq 0x3280
movq %rax, 0x142f6(%rip)     # 0x18fc8
testq %rax, %rax
jne 0x4ce8
movq 0x132da(%rip), %rax     # 0x17fb8
movq (%rax), %rax
movq %rax, 0x142e0(%rip)     # 0x18fc8
movq %rbx, 0x38(%r14)
movq $0x0, 0x40(%r14)
movq %r14, %rdi
callq *0x28(%r15)
testl %eax, %eax
jle 0x4d19
movq 0x153ba(%rip), %rax     # 0x1a0c0
movq %rax, (%r14)
movq %r14, 0x153b0(%rip)     # 0x1a0c0
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movl %eax, %ebp
movq %r14, %rdi
callq 0x3050
testl %ebp, %ebp
je 0x4d7b
movq %rbx, %rdi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x3110
movq 0x132b2(%rip), %rax     # 0x17ff0
movq (%rax), %rdi
leaq 0xb44d(%rip), %rsi      # 0x10195
jmp 0x4d5b
movq 0x1329f(%rip), %rax     # 0x17ff0
movq (%rax), %rdi
leaq 0xb39c(%rip), %rsi      # 0x100f7
movq %r14, %rdx
xorl %eax, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x31e0
callq 0x335f
jmp 0x4d10
callq 0x3343
jmp 0x4d27
callq 0x3320
jmp 0x4d27