// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x30, %rsp
movl 0x1bdfa(%rip), %edx     # 0x1f1f8
andl $0x20000, %edx          # imm = 0x20000
leaq 0x14d45(%rip), %rax     # 0x18150
leaq 0x1623e(%rip), %rcx     # 0x19650
cmpl $0x0, %edx
cmovneq %rcx, %rax
movq %rax, -0x20(%rbp)
movq 0x1beb4(%rip), %rax     # 0x1f2d8
movq (%rax), %rdi
callq 0x5720
cmpl $0x0, %eax
je 0x36c5
movq 0x1be9c(%rip), %rax     # 0x1f2d8
movq (%rax), %rdi
callq 0x5830
cmpq $0x0, %rax
jne 0x36a1
movq 0x1be83(%rip), %rax     # 0x1f2d8
movq 0x10(%rax), %rdi
callq 0x5890
movq %rax, -0x8(%rbp)
cmpq $0x0, %rax
je 0x367c
movq -0x8(%rbp), %rax
cmpq $0x0, 0x28(%rax)
jne 0x349f
movq 0x1ab7a(%rip), %rax     # 0x1dff8
movq (%rax), %rdi
movq 0x1be50(%rip), %rax     # 0x1f2d8
movq 0x10(%rax), %rdx
leaq 0x14cc0(%rip), %rsi     # 0x18153
movb $0x0, %al
callq 0x31c0
jmp 0x36c5
movq 0x1be32(%rip), %rax     # 0x1f2d8
movq 0x8(%rax), %rdi
movq -0x20(%rbp), %rsi
callq 0x3260
movq %rax, -0x10(%rbp)
cmpq $0x0, %rax
je 0x3657
movl $0x958, %edi            # imm = 0x958
callq 0x3200
movq %rax, -0x28(%rbp)
cmpq $0x0, %rax
je 0x3634
movq -0x28(%rbp), %rdi
xorl %esi, %esi
movl $0x958, %edx            # imm = 0x958
callq 0x3170
movq -0x28(%rbp), %rdi
addq $0x8, %rdi
movq 0x1bde0(%rip), %rax     # 0x1f2d8
movq (%rax), %rsi
callq 0x30b0
movq -0x8(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x28(%rax)
movl 0x1bcd6(%rip), %edx     # 0x1f1f8
andl $0x20000, %edx          # imm = 0x20000
xorl %eax, %eax
movl $0x1, %ecx
cmpl $0x0, %edx
cmovnel %ecx, %eax
movw %ax, %cx
movq -0x28(%rbp), %rax
movw %cx, 0x30(%rax)
movl 0x1bcb2(%rip), %eax     # 0x1f1f8
andl $0x8, %eax
cmpl $0x0, %eax
je 0x35b4
movq -0x28(%rbp), %rax
movzwl 0x30(%rax), %ecx
orl $0x2, %ecx
movw %cx, 0x30(%rax)
cmpq $0x0, 0x1bc83(%rip)     # 0x1f1e8
jne 0x3597
leaq 0x14c10(%rip), %rdi     # 0x1817e
callq 0x3030
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0x3595
movq -0x30(%rbp), %rdi
leaq 0x14c02(%rip), %rsi     # 0x1818b
callq 0x3260
movq %rax, 0x1bc53(%rip)     # 0x1f1e8
jmp 0x3597
cmpq $0x0, 0x1bc49(%rip)     # 0x1f1e8
jne 0x35b2
movq 0x1aa18(%rip), %rax     # 0x1dfc0
movq (%rax), %rax
movq %rax, 0x1bc36(%rip)     # 0x1f1e8
jmp 0x35b4
movq -0x10(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x38(%rax)
movq -0x28(%rbp), %rax
movq $0x0, 0x40(%rax)
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x28(%rbp), %rdi
callq *%rax
movl %eax, -0x14(%rbp)
cmpl $0x0, %eax
jle 0x3600
movq 0x1ccf7(%rip), %rcx     # 0x202e0
movq -0x28(%rbp), %rax
movq %rcx, (%rax)
movq -0x28(%rbp), %rax
movq %rax, 0x1cce5(%rip)     # 0x202e0
jmp 0x36c5
movq -0x28(%rbp), %rdi
callq 0x3040
cmpl $0x0, -0x14(%rbp)
jne 0x3632
movq 0x1a9e2(%rip), %rax     # 0x1dff8
movq (%rax), %rdi
movq 0x1bcb8(%rip), %rax     # 0x1f2d8
movq 0x8(%rax), %rdx
leaq 0x14b62(%rip), %rsi     # 0x1818d
movb $0x0, %al
callq 0x31c0
jmp 0x364c
movq 0x1a9bd(%rip), %rax     # 0x1dff8
movq (%rax), %rdi
leaq 0x14b7a(%rip), %rsi     # 0x181bf
movb $0x0, %al
callq 0x31c0
movq -0x10(%rbp), %rdi
callq 0x3110
jmp 0x367a
movq 0x1a99a(%rip), %rax     # 0x1dff8
movq (%rax), %rdi
movq 0x1bc70(%rip), %rax     # 0x1f2d8
movq 0x8(%rax), %rdx
leaq 0x14b62(%rip), %rsi     # 0x181d5
movb $0x0, %al
callq 0x31c0
jmp 0x369f
movq 0x1a975(%rip), %rax     # 0x1dff8
movq (%rax), %rdi
movq 0x1bc4b(%rip), %rax     # 0x1f2d8
movq 0x10(%rax), %rdx
leaq 0x14b59(%rip), %rsi     # 0x181f1
movb $0x0, %al
callq 0x31c0
jmp 0x36c3
movq 0x1a950(%rip), %rax     # 0x1dff8
movq (%rax), %rdi
movq 0x1bc26(%rip), %rax     # 0x1f2d8
movq (%rax), %rdx
leaq 0x14b66(%rip), %rsi     # 0x18222
movb $0x0, %al
callq 0x31c0
jmp 0x36c5
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax,%rax)