LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O1/simh[P]simtools/converters/fsio/tape.c
// Function: tapeReadRecord
uint32_t tapeReadRecord(
  FILE *container,
  void *buf,
  int len
)
{
  off_t pos = ftello(container);
  uint32_t meta, bc, erflag, length;

  if (fread(&meta, sizeof(meta), 1, container) != 1)
    return ST_FAIL;

  bc = le32toh(meta);

  switch (bc) {
    case ST_EOM:
    case ST_TM:
      return bc;

    default:
      erflag = bc & ST_ERROR;
      bc &= ST_LENGTH;

      length = (uint32_t)len;
      if (bc < length)
        length = bc;

      if (fread(buf, sizeof(uint8_t), length, container) != length)
        return ST_FAIL;

      /*
       * Now position the file after this record.
       */
      pos += RECLEN(bc) + (2 * sizeof(meta));
      if (fseeko(container, pos, SEEK_SET) != 0)
        return ST_FAIL;

      return erflag | length;
  }
  return ST_FAIL;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %edx, %ebx
movq %rsi, %r12
movq %rdi, %r14
callq 0x30d0
movq %rax, %r15
leaq 0xc(%rsp), %rdi
movl $0x4, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x30f0
movl $0xfefefefe, %ebp       # imm = 0xFEFEFEFE
cmpq $0x1, %rax
jne 0x6bc7
movl 0xc(%rsp), %r13d
leal 0x1(%r13), %eax
cmpl $0x2, %eax
jae 0x6bd8
movl %r13d, %ebp
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r15, 0x10(%rsp)
movl %r13d, %r15d
andl $0xffffff, %r15d        # imm = 0xFFFFFF
cmpl %ebx, %r15d
cmovbl %r15d, %ebx
movl $0x1, %esi
movq %r12, %rdi
movq %rbx, %rdx
movq %r14, %rcx
callq 0x30f0
cmpq %rbx, %rax
jne 0x6bc7
andl $0x80000000, %r13d      # imm = 0x80000000
incl %r15d
andl $-0x2, %r15d
movq 0x10(%rsp), %rax
leaq (%r15,%rax), %rsi
addq $0x8, %rsi
movq %r14, %rdi
xorl %edx, %edx
callq 0x3260
orl %r13d, %ebx
testl %eax, %eax
movl $0xfefefefe, %ebp       # imm = 0xFEFEFEFE
cmovel %ebx, %ebp
jmp 0x6bc7
// File: /workspace/github_c_makefile_star2_O1/simh[P]simtools/converters/fsio/tape.c
// Function: tapeWriteRecord
int tapeWriteRecord(
  FILE *container,
  void *buf,
  int len
)
{
  uint32_t meta = htole16(len);
  int datalen = (len + 1) & ~1;

  if ((fwrite(&meta, sizeof(meta), 1, container) != 1) ||
      (fwrite(buf, datalen, 1, container) != 1) ||
      (fwrite(&meta, sizeof(meta), 1, container) != 1))
    return 0;

  return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %edx, %r15d
movq %rsi, %r14
movq %rdi, %rbx
movzwl %r15w, %eax
leaq 0x4(%rsp), %rdi
movl %eax, (%rdi)
movl $0x4, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x32c0
xorl %ebp, %ebp
cmpq $0x1, %rax
jne 0x6cb0
incl %r15d
andl $-0x2, %r15d
movslq %r15d, %rsi
movl $0x1, %edx
movq %r14, %rdi
movq %rbx, %rcx
callq 0x32c0
cmpq $0x1, %rax
jne 0x6cb0
leaq 0x4(%rsp), %rdi
movl $0x4, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x32c0
xorl %ebp, %ebp
cmpq $0x1, %rax
sete %bpl
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/simh[P]simtools/converters/fsio/tape.c
// Function: tapeWriteEOM
int tapeWriteEOM(
  FILE *container,
  int backup
)
{
  uint32_t eom = htole32(ST_EOM);

  if (fwrite(&eom, sizeof(eom), 1, container) != 1)
    return 0;

  if (backup)
    if (fseeko(container, -sizeof(eom), SEEK_CUR) != 0)
      return 0;

  return 1;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
movl %esi, %ebp
movq %rdi, %r14
leaq 0xc(%rsp), %rdi
movl $0xffffffff, (%rdi)     # imm = 0xFFFFFFFF
movl $0x4, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x32c0
xorl %ebx, %ebx
cmpq $0x1, %rax
jne 0x6d10
testl %ebp, %ebp
je 0x6d0b
movq %r14, %rdi
movq $-0x4, %rsi
movl $0x1, %edx
callq 0x3260
testl %eax, %eax
jne 0x6d10
movl $0x1, %ebx
movl %ebx, %eax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/simh[P]simtools/converters/fsio/tape.c
// Function: tapeEOM
int tapeEOM(
  FILE *container,
  off_t *eot
)
{
  int whence = eot == NULL ? SEEK_END : SEEK_SET;
  off_t pos = eot == NULL ? 0 : *eot;
  uint32_t bc1, bc2;

  /*
   * Move to the end of the tape and then look backwards to see how it is
   * terminated.
   */
  if (fseeko(container, pos, whence) == 0) {
    if (ftello(container) == 0) {
      /*
       * Empty file, we are correctly positioned.
       */
      return 1;
    }

    if ((bc1 = tapeReadRecordLengthReverse(container)) == ST_FAIL)
      return 0;

    if ((bc1 == ST_EOM) || (bc1 == ST_TM)) {
      if (ftello(container) == 0) {
        /*
         * Only ST_EOM or ST_TM present, we are correctly positioned.
         */
        return 1;
      }

      if ((bc2 = tapeReadRecordLengthReverse(container)) == ST_FAIL)
        return 0;

      if (bc2 == ST_TM) {
        if (ftello(container) == 0) {
          /*
           * Only ST_TM followed by ST_TM or ST_EOM, we are correctly
           * positioned
           */
          return 1;
        }
      
        /*
         * ST_TM followed by ST_TM or ST_EOM with at least one data block
         * present, skip over the initial ST_TM.
         */
        if (fseeko(container, sizeof(uint32_t), SEEK_CUR) == 0)
          return 1;
      } else {
        /*
         * Only a single ST_TM at the end of the container file. This
         * indicates that there is a missing ST_TM or ST_EOM. Position
         * the tape at the logical end-of-tape so that any subsequent file
         * write will fix the problem.
         */
        if (fseeko(container, pos, whence) == 0)
          return 1;
      }
    }
  }
  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
xorl %ebp, %ebp
testq %rsi, %rsi
sete %bpl
addl %ebp, %ebp
testq %rsi, %rsi
je 0x6d65
movq (%rsi), %r14
jmp 0x6d68
xorl %r14d, %r14d
movq %rbx, %rdi
movq %r14, %rsi
movl %ebp, %edx
callq 0x3260
testl %eax, %eax
je 0x6d8a
xorl %r15d, %r15d
movl %r15d, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, %rdi
callq 0x30d0
testq %rax, %rax
je 0x6df7
movq %rbx, %rdi
callq 0x6a77
xorl %r15d, %r15d
cmpl $0xfefefefe, %eax       # imm = 0xFEFEFEFE
je 0x6d7c
incl %eax
cmpl $0x1, %eax
ja 0x6d79
movq %rbx, %rdi
callq 0x30d0
testq %rax, %rax
je 0x6df7
movq %rbx, %rdi
callq 0x6a77
cmpl $0xfefefefe, %eax       # imm = 0xFEFEFEFE
je 0x6d7c
testl %eax, %eax
jne 0x6e02
movq %rbx, %rdi
callq 0x30d0
movl $0x1, %r15d
testq %rax, %rax
je 0x6d7c
movl $0x4, %esi
movq %rbx, %rdi
movl $0x1, %edx
callq 0x3260
jmp 0x6e15
movl $0x1, %r15d
jmp 0x6d7c
movq %rbx, %rdi
movq %r14, %rsi
movl %ebp, %edx
callq 0x3260
movl $0x1, %r15d
testl %eax, %eax
jne 0x6d79
jmp 0x6d7c
// File: /workspace/github_c_makefile_star2_O1/simh[P]simtools/converters/fsio/tape.c
// Function: tapeSkipForward
int tapeSkipForward(
  FILE *container,
  unsigned long count
)
{
  unsigned long i;
  uint32_t bc;

  for (i = 0; i < count; i++) {
    /*
     * Peek at the next record. If it's a tape mark or end-of-media there
     * are not more files to skip.
     */
    switch (tapePeekRecordLength(container)) {
      case ST_FAIL:
        return 0;

      case ST_TM:
      case ST_EOM:
        return 1;
    }
    /*
     * Skip forward over 1 file.
     */
    do {
      switch (bc = tapeReadRecordLength(container)) {
        case ST_FAIL:
          return 0;

        case ST_EOM:
          if (fseeko(container, -sizeof(uint32_t), SEEK_CUR) != 0)
            return 0;
          break;
      }
    } while ((bc != ST_TM) && (bc != ST_EOM));
  }
  return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
testq %rsi, %rsi
je 0x6e9e
movq %rsi, %rbx
movq %rdi, %r14
xorl %r12d, %r12d
xorl %ebp, %ebp
movq %r14, %rdi
callq 0x6b1e
leal 0x1(%rax), %ecx
cmpl $0x2, %ecx
jb 0x6e9e
cmpl $0xfefefefe, %eax       # imm = 0xFEFEFEFE
je 0x6eae
movq %r14, %rdi
callq 0x69ec
movl %eax, %r15d
cmpl $-0x1, %eax
je 0x6e75
cmpl $0xfefefefe, %r15d      # imm = 0xFEFEFEFE
jne 0x6e8d
jmp 0x6ea3
movq %r14, %rdi
movq $-0x4, %rsi
movl $0x1, %edx
callq 0x3260
testl %eax, %eax
jne 0x6ea3
decl %r15d
cmpl $-0x2, %r15d
jb 0x6e5a
incq %r12
cmpq %rbx, %r12
jne 0x6e43
movl $0x1, %ebp
movl %ebp, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
xorl %ebp, %ebp
jmp 0x6ea3
// File: /workspace/github_c_makefile_star2_O1/simh[P]simtools/converters/fsio/tape.c
// Function: tapeSkipReverse
int tapeSkipReverse(
  FILE *container,
  unsigned long count
)
{
  unsigned long i;
  uint32_t bc;

  for (i = 0; i < count; i++) {
    /*
     * If we are at beginning-of-tape, there are no more files to skip.
     */
    if (ftello(container) == 0)
      return 1;

    /*
     * If we are not at the beginning of tape, the previous record should
     * be a tape mark.
     */
    if (tapeReadRecordLengthReverse(container) != ST_TM)
      return 0;

    /*
     * Now skip over the remainder of the file.
     */
    do {
      if ((bc = tapeReadRecordLengthReverse(container)) == ST_FAIL)
        return 0;
    } while ((bc != ST_TM) && (ftello(container) != 0));

    /*
     * Skip over the tape mark since it marks the end of the previous file.
     */
    if (bc == ST_TM) {
      if (fseeko(container, sizeof(uint32_t), SEEK_CUR) != 0)
        return 0;
    }
  }
  return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
testq %rsi, %rsi
je 0x6f29
movq %rsi, %rbx
movq %rdi, %r14
xorl %r12d, %r12d
xorl %ebp, %ebp
movq %r14, %rdi
callq 0x30d0
testq %rax, %rax
je 0x6f29
movq %r14, %rdi
callq 0x6a77
testl %eax, %eax
jne 0x6f2e
movq %r14, %rdi
callq 0x6a77
cmpl $0xfefefefe, %eax       # imm = 0xFEFEFEFE
je 0x6f2e
movl %eax, %r15d
testl %eax, %eax
je 0x6f0b
movq %r14, %rdi
callq 0x30d0
testq %rax, %rax
jne 0x6ee3
testl %r15d, %r15d
jne 0x6f21
movl $0x4, %esi
movq %r14, %rdi
movl $0x1, %edx
callq 0x3260
testl %eax, %eax
jne 0x6f2e
incq %r12
cmpq %rbx, %r12
jne 0x6eca
movl $0x1, %ebp
movl %ebp, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O1/simh[P]simtools/converters/fsio/dos11.c
// Function: dos11DisplayDir
void dos11DisplayDir(
  uint16_t *dir,
  int full
)
{
  char temp[64], creation[16];

  r50Asc(le16toh(dir[UFD_FILENAME]), &temp[0]);
  r50Asc(le16toh(dir[UFD_FILENAME + 1]), &temp[3]);
  if (le16toh(dir[UFD_EXTENSION]) != 0) {
    temp[6] = '.';
    r50Asc(le16toh(dir[UFD_EXTENSION]), &temp[7]);
  } else {
    temp[6] = ' ';
    temp[7] = ' ';
    temp[8] = ' ';
    temp[9] = ' ';
  }

  if (full) {
    sprintf(&temp[10], "  %5u%c    %s   <%03o>",
            le16toh(dir[UFD_FILELENGTH]),
            (le16toh(dir[UFD_CREATION]) & UFD_TYPE) ? 'C' : ' ',
            dos11Date(le16toh(dir[UFD_CREATION]) & UFD_DATE, creation),
            le16toh(dir[UFD_LUP]) & UFD_PROT);
  } else temp[10] ='\0';
  puts(temp);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x58, %rsp
movl %esi, %ebp
movq %rdi, %rbx
movzwl (%rdi), %edi
movq %rsp, %rsi
callq 0x65fc
movzwl 0x2(%rbx), %edi
leaq 0x3(%rsp), %rsi
callq 0x65fc
movzwl 0x4(%rbx), %eax
testw %ax, %ax
je 0x6f80
leaq 0x7(%rsp), %rsi
movb $0x2e, -0x1(%rsi)
movzwl %ax, %edi
callq 0x65fc
jmp 0x6f88
movl $0x20202020, 0x6(%rsp)  # imm = 0x20202020
testl %ebp, %ebp
je 0x6fdb
leaq 0xa(%rsp), %r14
movzwl 0xc(%rbx), %ebp
movzwl 0x6(%rbx), %edi
testw %di, %di
movl $0x20, %eax
movl $0x43, %r15d
cmovnsl %eax, %r15d
andl $0x7fff, %edi           # imm = 0x7FFF
leaq 0x40(%rsp), %rsi
callq 0x6787
movzbl 0x10(%rbx), %r9d
leaq 0xa8b9(%rip), %rsi      # 0x11880
movq %r14, %rdi
movl %ebp, %edx
movl %r15d, %ecx
movq %rax, %r8
xorl %eax, %eax
callq 0x32a0
jmp 0x6fe0
movb $0x0, 0xa(%rsp)
movq %rsp, %rdi
callq 0x30e0
addq $0x58, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/simh[P]simtools/converters/fsio/dos11.c
// Function: dos11ReadBlock
int dos11ReadBlock(
  struct mountedFS *mount,
  unsigned int block,
  void *buf
)
{
  struct DOS11data *data = &mount->dos11data;
  void *buffer = buf == NULL ? data->buf : buf;
  int status;

  if (block >= data->blocks) {
    ERROR("Attempt to read block (%u) outside file system \"%s\"\n",
          block, mount->name);
    return 0;
  }

#ifdef DEBUG
  if ((mount->flags & FS_DEBUG) != 0)
    fprintf(DEBUGout, ">> %s: (dos11) Reading logical block %o\n",
            mount->name, block);
#endif

  status = FSioReadBlock(mount, block, buffer);

  if (status == 0)
    ERROR("I/O error on \"%s\"\n", mount->name);

  return status;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
movl %esi, %ebp
movq %rdi, %rbx
leaq 0x554(%rdi), %r14
testq %rdx, %rdx
cmovneq %rdx, %r14
cmpl %esi, 0x48(%rdi)
jbe 0x7900
testb $0x2, 0x30(%rbx)
je 0x78e6
leaq 0x116e9(%rip), %rax     # 0x18fb8
movq (%rax), %rdi
leaq 0x8(%rbx), %rdx
leaq 0xa069(%rip), %rsi      # 0x11946
movl %ebp, %ecx
xorl %eax, %eax
callq 0x31d0
movq %rbx, %rdi
movl %ebp, %esi
movq %r14, %rdx
callq 0x6234
testl %eax, %eax
je 0x7914
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
leaq 0x8(%rsp), %r14
movq %rbx, %rdi
movl %ebp, %esi
movq %r14, %rdx
callq 0x3766
jmp 0x7926
leaq 0xc(%rsp), %r14
movq %rbx, %rdi
movl %eax, %esi
movq %r14, %rdx
callq 0x37c9
movl (%r14), %eax
jmp 0x78f7
// File: /workspace/github_c_makefile_star2_O1/simh[P]simtools/converters/fsio/dos11.c
// Function: dos11XtndDirectory
uint16_t dos11XtndDirectory(
  struct mountedFS *mount
)
{
  uint16_t buf[512], ufdblk;

  memset(buf, 0, sizeof(buf));

  if ((ufdblk = bitmapAllocBlock(mount)) != 0) {
    if (dos11WriteBlock(mount, ufdblk, buf) == 0)
      return 0;

    if (bitmapFlush(mount) == 0)
      return 0;
  }
  return ufdblk;
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x408, %rsp            # imm = 0x408
movq %rdi, %r14
movq %rsp, %rdi
movl $0x400, %edx            # imm = 0x400
xorl %esi, %esi
callq 0x3170
movq %r14, %rdi
callq 0x7d7f
movl %eax, %ebx
testw %ax, %ax
je 0x7976
movzwl %bx, %esi
movq %rsp, %rdx
movq %r14, %rdi
callq 0x7983
testl %eax, %eax
je 0x7974
movq %r14, %rdi
callq 0x7e7b
testl %eax, %eax
jne 0x7976
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x408, %rsp            # imm = 0x408
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/simh[P]simtools/converters/fsio/dos11.c
// Function: dos11WriteBlock
int dos11WriteBlock(
  struct mountedFS *mount,
  unsigned int block,
  void *buf
)
{
  struct DOS11data *data = &mount->dos11data;
  void *buffer = buf == NULL ? data->buf : buf;
  int status;

  if (block >= data->blocks) {
    ERROR("Attempt to write block (%u) outside file system \"%s\"\n",
          block, mount->name);
    return 0;
  }

#ifdef DEBUG
  if ((mount->flags & FS_DEBUG) != 0)
    fprintf(DEBUGout, ">> %s: (dos11) Writing logical block %o\n",
            mount->name, block);
#endif

  status = FSioWriteBlock(mount, block, buffer);

  if (status == 0)
    ERROR("I/O error on \"%s\"\n", mount->name);

  return status;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
movl %esi, %ebp
movq %rdi, %rbx
leaq 0x554(%rdi), %r14
testq %rdx, %rdx
cmovneq %rdx, %r14
cmpl %esi, 0x48(%rdi)
jbe 0x79e1
testb $0x2, 0x30(%rbx)
je 0x79c7
leaq 0x11608(%rip), %rax     # 0x18fb8
movq (%rax), %rdi
leaq 0x8(%rbx), %rdx
leaq 0x9ffa(%rip), %rsi      # 0x119b8
movl %ebp, %ecx
xorl %eax, %eax
callq 0x31d0
movq %rbx, %rdi
movl %ebp, %esi
movq %r14, %rdx
callq 0x627d
testl %eax, %eax
je 0x79f5
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
leaq 0x8(%rsp), %r14
movq %rbx, %rdi
movl %ebp, %esi
movq %r14, %rdx
callq 0x3827
jmp 0x7a07
leaq 0xc(%rsp), %r14
movq %rbx, %rdi
movl %eax, %esi
movq %r14, %rdx
callq 0x388a
movl (%r14), %eax
jmp 0x79d8
// File: /workspace/github_c_makefile_star2_O1/simh[P]simtools/converters/fsio/dos11.c
// Function: dos11UpdateFile
void dos11UpdateFile(
  struct mountedFS *mount,
  struct dos11OpenFile *file
)
{
  struct DOS11data *data = &mount->dos11data;

  if (dos11ReadBlock(mount, file->ufdblk, NULL) == 0)
    return;

  /*
   * Update the directory entry.
   */
  data->buf[file->ufdoffset + UFD_FILENAME] = file->name[0];
  data->buf[file->ufdoffset + UFD_FILENAME + 1] = file->name[1];
  data->buf[file->ufdoffset + UFD_EXTENSION] = file->ext;
  data->buf[file->ufdoffset + UFD_CREATION] = file->creation;
  data->buf[file->ufdoffset + UFD_NEXTFREEBYTE] = file->nfb;
  data->buf[file->ufdoffset + UFD_FILESTART] = file->start;
  data->buf[file->ufdoffset + UFD_FILELENGTH] = file->length;
  data->buf[file->ufdoffset + UFD_LASTBLOCKWRITTEN] = file->last;
  data->buf[file->ufdoffset + UFD_LUP] = file->lup & ~htole16(UFD_LOCK);;

#ifdef DEBUG
  if ((mount->flags & FS_DEBUG) != 0) {
    if (file->ufdoffset != 1)
      dos11DisplayDir(&data->buf[file->ufdoffset - UFD_LEN], 1);
    dos11DisplayDir(&data->buf[file->ufdoffset], 1);
  }
#endif

  dos11WriteBlock(mount, file->ufdblk, NULL);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rsi, %r14
movq %rdi, %rbx
movzwl 0x12(%rsi), %esi
xorl %edx, %edx
callq 0x78a2
testl %eax, %eax
je 0x7d79
movzwl (%r14), %eax
movzwl 0x14(%r14), %ecx
movw %ax, 0x554(%rbx,%rcx,2)
movzwl 0x2(%r14), %eax
movzwl 0x14(%r14), %ecx
movw %ax, 0x556(%rbx,%rcx,2)
movzwl 0x4(%r14), %eax
movzwl 0x14(%r14), %ecx
movw %ax, 0x558(%rbx,%rcx,2)
movzwl 0x6(%r14), %eax
movzwl 0x14(%r14), %ecx
movw %ax, 0x55a(%rbx,%rcx,2)
movzwl 0x8(%r14), %eax
movzwl 0x14(%r14), %ecx
movw %ax, 0x55c(%rbx,%rcx,2)
movzwl 0xa(%r14), %eax
movzwl 0x14(%r14), %ecx
movw %ax, 0x55e(%rbx,%rcx,2)
movzwl 0xc(%r14), %eax
movzwl 0x14(%r14), %ecx
movw %ax, 0x560(%rbx,%rcx,2)
movzwl 0xe(%r14), %eax
movzwl 0x14(%r14), %ecx
movw %ax, 0x562(%rbx,%rcx,2)
movzwl 0x10(%r14), %eax
andl $0x7fff, %eax           # imm = 0x7FFF
movzwl 0x14(%r14), %ecx
movw %ax, 0x564(%rbx,%rcx,2)
testb $0x2, 0x30(%rbx)
je 0x7d65
leaq 0x554(%rbx), %r15
movzwl 0x14(%r14), %eax
cmpq $0x1, %rax
je 0x7d52
leaq (%r15,%rax,2), %rdi
addq $-0x12, %rdi
movl $0x1, %esi
callq 0x6f3c
movzwl 0x14(%r14), %eax
leaq (%r15,%rax,2), %rdi
movl $0x1, %esi
callq 0x6f3c
movzwl 0x12(%r14), %esi
movq %rbx, %rdi
xorl %edx, %edx
popq %rbx
popq %r14
popq %r15
jmp 0x7983
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/simh[P]simtools/converters/fsio/dos11.c
// Function: bitmapAllocBlock
static uint16_t bitmapAllocBlock(
  struct mountedFS *mount
)
{
  struct DOS11data *data = &mount->dos11data;
  uint16_t map = data->bmscan / MAP_BLOCKS;
  uint16_t offset = data->bmscan % MAP_BLOCKS;

  /*
   * Iterate across all available bitmaps.
   */
  while (map < data->bitmaps) {
    uint16_t wrd = offset / 16;
    uint16_t bit = offset % 16;

    if (bitmapLoad(mount, map) == 0)
      return 0;

    /*
     * Iterate across a single bitmap.
     */
    while (wrd < MAP_LEN) {
      uint16_t val = le16toh(data->bmbuf[MAP_BMSTART + wrd]);

      if (val != 0177777) {
        data->bmscan = (map * MAP_BLOCKS) + (wrd * 16);

        while (bit < 16) {
          if ((val & bits[bit]) == 0) {
            val |= bits[bit];
            data->bmbuf[MAP_BMSTART + wrd] = htole16(val);
            data->bmdirty = 1;
            return (map * MAP_BLOCKS) + (wrd * 16) + bit;
          }
          bit++;
        }
      }
      wrd++;
      bit = 0;
    }
    map++;
    offset = 0;
  }
  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdi, %rbx
movzwl 0x150(%rdi), %r15d
imull $0x8889, %r15d, %r14d   # imm = 0x8889
shrl $0x19, %r14d
imull $0x3c0, %r14d, %eax     # imm = 0x3C0
subl %eax, %r15d
leaq 0x10702(%rip), %r12     # 0x184b0
cmpw 0x4c(%rbx), %r14w
jae 0x7e6e
movzwl %r14w, %esi
movq %rbx, %rdi
callq 0x986f
testl %eax, %eax
je 0x7e56
movl %r15d, %ecx
andl $0xf, %ecx
movzwl %r15w, %eax
shrl $0x4, %eax
imull $0x3c0, %r14d, %edx     # imm = 0x3C0
cmpw $0x3b, %ax
ja 0x7e5c
leal 0x4(%rax), %esi
movzwl %si, %esi
movzwl 0x154(%rbx,%rsi,2), %r8d
cmpw $-0x1, %r8w
je 0x7e2b
movl %eax, %edi
shll $0x4, %edi
movl %edi, %r9d
addl %edx, %r9d
movw %r9w, 0x150(%rbx)
movzwl %cx, %ecx
movzwl (%r12,%rcx,2), %r9d
testw %r8w, %r9w
je 0x7e34
leaq 0x1(%rcx), %r9
cmpq $0xf, %rcx
movq %r9, %rcx
jb 0x7e13
incl %eax
movb $0x1, %sil
xorl %ecx, %ecx
jmp 0x7e4f
orl %r8d, %r9d
movw %r9w, 0x154(%rbx,%rsi,2)
movb $0x1, 0x152(%rbx)
leal (%rdx,%rdi), %esi
leal (%rcx,%rsi), %ebp
xorl %esi, %esi
testb %sil, %sil
jne 0x7de1
jmp 0x7e58
xorl %ebp, %ebp
xorl %eax, %eax
jmp 0x7e64
incl %r14d
movb $0x1, %al
xorl %r15d, %r15d
testb %al, %al
jne 0x7dae
jmp 0x7e70
xorl %ebp, %ebp
movl %ebp, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/simh[P]simtools/converters/fsio/dos11.c
// Function: dos11ReadBytes
int dos11ReadBytes(
  struct dos11OpenFile *file,
  char *buf,
  int len
)
{
  int count = 0;

  if (file->current == 0) {
    file->current = le16toh(file->start);

    if (dos11ReadBlock(file->mount, file->current, file->buffer) == 0)
      return 0;

    file->nab = (le16toh(file->creation) & UFD_TYPE) == 0 ? 2 : 0;
    file->eob = file->current == le16toh(file->last) ?
      le16toh(file->nfb) : file->mount->blocksz;
  }

  while (len) {
    if (file->nab == file->eob) {
      if (file->current == le16toh(file->last))
        break;

      if ((le16toh(file->creation) & UFD_TYPE) == 0)
        file->current = le16toh(*((uint16_t *)(file->buffer)));
      else file->current++;

      if (dos11ReadBlock(file->mount, file->current, file->buffer) == 0)
        return 0;

      file->nab = (le16toh(file->creation) & UFD_TYPE) == 0 ? 2 : 0;
      file->eob = file->current == le16toh(file->last) ?
        le16toh(file->nfb) : file->mount->blocksz;
      continue;
    }
    *buf++ = file->buffer[file->nab++];
    len--;
    count++;
  }
  return count;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edx, %ebx
movq %rsi, %r14
movq %rdi, %r15
cmpw $0x0, 0x30(%rdi)
jne 0x8280
movzwl 0xa(%r15), %esi
movw %si, 0x30(%r15)
movq 0x20(%r15), %rdi
movq 0x28(%r15), %rdx
callq 0x78a2
testl %eax, %eax
je 0x8339
movzwl 0x6(%r15), %eax
notl %eax
shrl $0xe, %eax
andl $0x2, %eax
movw %ax, 0x32(%r15)
movzwl 0x30(%r15), %eax
cmpw 0xe(%r15), %ax
jne 0x8273
movzwl 0x8(%r15), %eax
jmp 0x827b
movq 0x20(%r15), %rax
movzwl 0x28(%rax), %eax
movw %ax, 0x34(%r15)
testl %ebx, %ebx
sete %r13b
je 0x8339
xorl %ebp, %ebp
movl %ebx, %r12d
movzwl 0x32(%r15), %eax
cmpw 0x34(%r15), %ax
jne 0x8313
movzwl 0x30(%r15), %eax
cmpw 0xe(%r15), %ax
je 0x833d
cmpw $0x0, 0x6(%r15)
js 0x82be
movq 0x28(%r15), %rax
movzwl (%rax), %eax
jmp 0x82c0
incl %eax
movw %ax, 0x30(%r15)
movzwl %ax, %esi
movq 0x20(%r15), %rdi
movq 0x28(%r15), %rdx
callq 0x78a2
testl %eax, %eax
je 0x8339
movzwl 0x6(%r15), %eax
notl %eax
shrl $0xe, %eax
andl $0x2, %eax
movw %ax, 0x32(%r15)
movzwl 0x30(%r15), %eax
cmpw 0xe(%r15), %ax
jne 0x82fe
movzwl 0x8(%r15), %eax
jmp 0x8306
movq 0x20(%r15), %rax
movzwl 0x28(%rax), %eax
movw %ax, 0x34(%r15)
testb $0x1, %r13b
je 0x8291
jmp 0x833d
movq 0x28(%r15), %rcx
leal 0x1(%rax), %edx
movw %dx, 0x32(%r15)
movb (%rcx,%rax), %al
movb %al, (%r14)
incq %r14
incl %ebp
decl %r12d
sete %r13b
jne 0x8291
jmp 0x833f
xorl %ebx, %ebx
jmp 0x833f
movl %ebp, %ebx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/simh[P]simtools/converters/fsio/dos11.c
// Function: dos11WriteFile
size_t dos11WriteFile(
  void *filep,
  void *buf,
  size_t buflen
)
{
  struct dos11OpenFile *file = filep;
  char *bufw = buf;

  if (SWISSET('a')) {
    size_t count = 0;

    /*
     * Write a line, terminated by <CRLF>, to the open file.
     */
    while (buflen != 0) {
      char ch;

      ch = bufw[count++] & 0177;
      buflen--;
      if (dos11WriteBytes(file, &ch, 1) == 0)
        break;
    }
    return count;
  }
  return dos11WriteBytes(file, bufw, buflen);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
leaq 0x10acb(%rip), %rax     # 0x18fc8
testb $0x1, (%rax)
jne 0x8514
movq %r15, %rdi
movq %r14, %rsi
movl %ebx, %edx
callq 0x8350
movslq %eax, %r12
jmp 0x8547
xorl %r12d, %r12d
leaq 0xf(%rsp), %r13
cmpq %r12, %rbx
je 0x8544
movb (%r14,%r12), %al
incq %r12
andb $0x7f, %al
movb %al, 0xf(%rsp)
movq %r15, %rdi
movq %r13, %rsi
movl $0x1, %edx
callq 0x8350
testl %eax, %eax
jne 0x851c
jmp 0x8547
movq %rbx, %r12
movq %r12, %rax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/simh[P]simtools/converters/fsio/dos11.c
// Function: dos11OpenFileR
static void *dos11OpenFileR(
  struct mountedFS *mount,
  uint8_t UNUSED(unit),
  char *fname
)
{
  struct DOS11data *data = &mount->dos11data;
  struct dos11OpenFile *file;
  struct dos11FileSpec spec;
  uint8_t user = data->user;
  uint8_t group = data->group;

  if (dos11ParseFilespec(fname, &spec, user, group, DOS11_M_NONE) == 0) {
    fprintf(stderr, "Failed to parse filename \"%s\"\n", fname);
    return NULL;
  }

  if ((file = malloc(sizeof(struct dos11OpenFile))) != NULL) {
    memset(file, 0, sizeof(struct dos11OpenFile));

    if (dos11LookupFile(mount, &spec, file) != 0) {
      /*
       * Allocate local buffer space for the file.
       */
      if ((file->buffer = malloc(mount->blocksz)) == NULL) {
        free(file);
        return NULL;
      }
      file->mode = M_RD;
    } else {
      free(file);
      return NULL;
    }
  }
  return file;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rdx, %r15
movq %rdi, %r14
movzbl 0x955(%rdi), %edx
movzbl 0x954(%rdi), %ecx
leaq 0x6(%rsp), %rsi
movq %r15, %rdi
xorl %r8d, %r8d
callq 0x7ec2
testl %eax, %eax
je 0x9534
movl $0x38, %edi
callq 0x3210
movq %rax, %rbx
testq %rax, %rax
je 0x9527
xorps %xmm0, %xmm0
movups %xmm0, 0x20(%rbx)
movups %xmm0, 0x10(%rbx)
movups %xmm0, (%rbx)
movq $0x0, 0x30(%rbx)
leaq 0x6(%rsp), %rsi
movq %r14, %rdi
movq %rbx, %rdx
callq 0x7a0c
testl %eax, %eax
je 0x951d
movq 0x28(%r14), %rdi
callq 0x3210
movq %rax, 0x28(%rbx)
testq %rax, %rax
je 0x951d
movl $0x0, 0x18(%rbx)
jmp 0x9527
movq %rbx, %rdi
callq 0x3050
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
movq 0xeab5(%rip), %rax      # 0x17ff0
movq (%rax), %rdi
leaq 0x8892(%rip), %rsi      # 0x11dd7
xorl %ebx, %ebx
movq %r15, %rdx
xorl %eax, %eax
callq 0x31d0
jmp 0x9527
// File: /workspace/github_c_makefile_star2_O1/simh[P]simtools/converters/fsio/dos11.c
// Function: dos11OpenFileW
static void *dos11OpenFileW(
  struct mountedFS *mount,
  uint8_t UNUSED(unit),
  char *fname,
  off_t size
)
{
  struct DOS11data *data = &mount->dos11data;
  struct dos11OpenFile *file;
  struct dos11FileSpec spec;
  unsigned long contig = (size + mount->blocksz - 1) / mount->blocksz;
  uint8_t user = data->user;
  uint8_t group = data->group;

  if (SWISSET('c') && (contig == 0)) {
      fprintf(stderr,"DOS-11 contiguous files must be at least 1 block\n");
      return NULL;
  }

  if (dos11ParseFilespec(fname, &spec, user, group, DOS11_M_NONE) == 0) {
    fprintf(stderr, "Failed to parse filename \"%s\"\n", fname);
    return NULL;
  }

  if ((file = malloc(sizeof(struct dos11OpenFile))) != NULL) {
    memset(file, 0, sizeof(struct dos11OpenFile));

    if (dos11LookupFile(mount, &spec, file) == 0) {
      /*
       * Allocate local bufferspace for the file.
       */
      if ((file->buffer = malloc(mount->blocksz)) != NULL) {
        if (dos11CreateFile(mount, &spec, file, contig) == 0) {
          ERROR("Failed to create file \"%s\"\n", fname);
          free(file->buffer);
          free(file);
          return NULL;
        } else file->mode = M_WR;
      } else {
        ERROR("Buffer allocation failure for \"%s\"\n", fname);
        free(file);
        return NULL;
      }
    } else {
      ERROR("File \"%s\" already exists\n", fname);
      free(file);
      return NULL;
    }
  } else fprintf(stderr, "Memory allocation failure\n");
  return file;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdx, %rbx
movq %rdi, %r15
movq 0x28(%rdi), %rsi
decq %rcx
leaq (%rcx,%rsi), %rax
xorl %edx, %edx
divq %rsi
movq %rax, %r12
addq %rsi, %rcx
jae 0x958e
leaq 0xfa45(%rip), %rax      # 0x18fc8
movl (%rax), %eax
andl $0x4, %eax
jne 0x9628
movzbl 0x954(%r15), %ecx
movzbl 0x955(%r15), %edx
leaq 0xe(%rsp), %rsi
movq %rbx, %rdi
xorl %r8d, %r8d
callq 0x7ec2
testl %eax, %eax
je 0x962f
movl $0x38, %edi
callq 0x3210
movq %rax, %r14
testq %rax, %rax
je 0x964f
xorps %xmm0, %xmm0
movups %xmm0, 0x20(%r14)
movups %xmm0, 0x10(%r14)
movups %xmm0, (%r14)
movq $0x0, 0x30(%r14)
leaq 0xe(%rsp), %rsi
movq %r15, %rdi
movq %r14, %rdx
callq 0x7a0c
testl %eax, %eax
jne 0x9656
movq 0x28(%r15), %rdi
callq 0x3210
movq %rax, 0x28(%r14)
testq %rax, %rax
je 0x9663
leaq 0xe(%rsp), %rsi
movq %r15, %rdi
movq %r14, %rdx
movq %r12, %rcx
callq 0x6ff3
testl %eax, %eax
je 0x9670
movl $0x1, 0x18(%r14)
jmp 0x9685
callq 0x3cfe
jmp 0x9682
movq 0xe9ba(%rip), %rax      # 0x17ff0
movq (%rax), %rdi
leaq 0x8797(%rip), %rsi      # 0x11dd7
xorl %r14d, %r14d
movq %rbx, %rdx
xorl %eax, %eax
callq 0x31d0
jmp 0x9685
callq 0x3ce2
jmp 0x9685
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3bb8
jmp 0x9682
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3c82
jmp 0x9682
movq %r14, %rsi
addq $0x28, %rsi
movq %rbx, %rdi
movq %r14, %rdx
callq 0x3c18
xorl %r14d, %r14d
movq %r14, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/simh[P]simtools/converters/fsio/dos11.c
// Function: dos11CloseFile
static void dos11CloseFile(
  void *filep
)
{
  struct dos11OpenFile *file = filep;
  struct mountedFS *mount = file->mount;

  if (file->mode == M_WR) {
    uint16_t start = (le16toh(file->creation) & UFD_TYPE) == 0 ? 2 : 0;

    /*
     * Flush any partial buffer, pending bitmap updates and update the
     * directory entry.
     */
    if (((le16toh(file->creation) & UFD_TYPE) == 0) ||
        (file->current == le16toh(file->last)))
      file->nfb = htole16(file->nab);
    else file->nfb = htole16(mount->blocksz);

    if (file->nab != start)
      dos11WriteBlock(mount, file->current, file->buffer);
    bitmapFlush(mount);
    dos11UpdateFile(mount, file);
  }

  if (file != NULL) {
    if (file->buffer != NULL)
      free(file->buffer);
    free(file);
  }
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
cmpl $0x1, 0x18(%rdi)
jne 0x9703
movq 0x20(%rbx), %r14
movzwl 0x6(%rbx), %ecx
xorl %eax, %eax
testw %cx, %cx
setns %al
addl %eax, %eax
testw %cx, %cx
jns 0x96d0
movzwl 0x30(%rbx), %ecx
cmpw 0xe(%rbx), %cx
jne 0x972d
movzwl 0x32(%rbx), %ecx
movw %cx, 0x8(%rbx)
movzwl 0x32(%rbx), %ecx
cmpl %ecx, %eax
je 0x96f0
movzwl 0x30(%rbx), %esi
movq 0x28(%rbx), %rdx
movq %r14, %rdi
callq 0x7983
movq %r14, %rdi
callq 0x7e7b
movq %r14, %rdi
movq %rbx, %rsi
callq 0x7c64
testq %rbx, %rbx
je 0x9725
movq 0x28(%rbx), %rdi
testq %rdi, %rdi
je 0x9716
callq 0x3050
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x3050
addq $0x8, %rsp
popq %rbx
popq %r14
retq
movzwl 0x28(%r14), %ecx
jmp 0x96d4
// File: /workspace/github_c_makefile_star2_O1/simh[P]simtools/converters/fsio/dos11.c
// Function: dos11ReadFile
static size_t dos11ReadFile(
  void *filep,
  void *buf,
  size_t buflen
)
{
  struct dos11OpenFile *file = filep;
  char *bufr = buf;

  if (SWISSET('a')) {
    char ch;
    size_t count = 0;

    /*
     * Read a full or partial line from the open file.
     */
    while ((buflen != 0) && (dos11ReadBytes(file, &ch, 1) == 1)) {
      ch &= 0177;
      bufr[count++] = ch;
      buflen--;
      if (ch == '\n')
        break;
    }
    return count;
  }

  return dos11ReadBytes(file, bufr, buflen);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
leaq 0xf877(%rip), %rax      # 0x18fc8
testb $0x1, (%rax)
jne 0x9767
movq %r15, %rdi
movq %r14, %rsi
movl %ebx, %edx
callq 0x8215
cltq
jmp 0x97b5
testq %rbx, %rbx
je 0x97ae
decq %rbx
xorl %r13d, %r13d
leaq 0xf(%rsp), %r12
movq %r15, %rdi
movq %r12, %rsi
movl $0x1, %edx
callq 0x8215
cmpl $0x1, %eax
jne 0x97b2
movb 0xf(%rsp), %cl
andb $0x7f, %cl
movb %cl, 0xf(%rsp)
leaq 0x1(%r13), %rax
movb %cl, (%r14,%r13)
cmpb $0xa, %cl
je 0x97b5
cmpq %r13, %rbx
movq %rax, %r13
jne 0x9777
jmp 0x97b5
xorl %eax, %eax
jmp 0x97b5
movq %r13, %rax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/simh[P]simtools/converters/fsio/dos11.c
// Function: dos11DeleteFile
static void dos11DeleteFile(
  void *filep,
  char *UNUSED(fname)
)
{
  struct dos11OpenFile *file = filep;
  struct mountedFS *mount = file->mount;
  struct DOS11data *data = &mount->dos11data;
  uint16_t i, block;

  file->name[0] = 0;
  file->name[1] = 0;
  file->ext = 0;

  dos11UpdateFile(mount, file);

  /*
   * The file has been removed from its UFD, release all disk blocks
   * allocated to the file.
   */
  block = le16toh(file->start);

  if ((le16toh(file->creation) & UFD_TYPE) != 0) {
    /*
     * Contiguous file
     */
    for (i = 0; i < le16toh(file->length); i++)
      if (bitmapReleaseBlock(mount, block + i) == 0)
        return;
  } else {
    /*
     * Linked file
     */
    while (block != 0) {
      if (dos11ReadBlock(mount, block, NULL) == 0)
        return;
      if (bitmapReleaseBlock(mount, block) == 0)
        return;

      block = le16toh(data->buf[FILE_LINK]);
    }
  }
  /*
   * Make sure the bitmaps on disk are up to date.
   */
  bitmapFlush(mount);

  dos11CloseFile(file);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdi, %rbx
movq 0x20(%rdi), %r14
movl $0x0, (%rdi)
movw $0x0, 0x4(%rdi)
movq %r14, %rdi
movq %rbx, %rsi
callq 0x7c64
movzwl 0xa(%rbx), %r15d
cmpw $0x0, 0x6(%rbx)
js 0x9827
testw %r15w, %r15w
je 0x984e
movzwl %r15w, %ebp
movq %r14, %rdi
movl %ebp, %esi
xorl %edx, %edx
callq 0x78a2
testl %eax, %eax
je 0x9866
movq %r14, %rdi
movl %ebp, %esi
callq 0x999c
testl %eax, %eax
je 0x9866
movzwl 0x554(%r14), %r15d
jmp 0x97f5
cmpw $0x0, 0xc(%rbx)
je 0x984e
xorl %r12d, %r12d
leal (%r15,%r12), %eax
movzwl %ax, %esi
movq %r14, %rdi
callq 0x999c
testl %eax, %eax
je 0x9866
incl %r12d
cmpw 0xc(%rbx), %r12w
jb 0x9831
movq %r14, %rdi
callq 0x7e7b
movq %rbx, %rdi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x96a2
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/simh[P]simtools/converters/fsio/dos11.c
// Function: bitmapLoad
static int bitmapLoad(
  struct mountedFS *mount,
  uint16_t map
)
{
  struct DOS11data *data = &mount->dos11data;

  if (map >= data->bitmaps) {
    ERROR("Invalid bitmap # (%d), max is %d\n", map, data->bitmaps);
    return 0;
  }

  /*
   * If the map is already loaded, nothing to do.
   */
  if (map != data->bmindex) {
    if (data->bmdirty != 0) {
      if (dos11WriteBlock(mount, data->bmblk[data->bmindex], data->bmbuf) == 0)
        return 0;
      data->bmdirty = 0;
    }

    data->bmindex = map;
    if (dos11ReadBlock(mount, data->bmblk[map], data->bmbuf) == 0)
      return 0;
  }

  return 1;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movl %esi, %ebx
movq %rdi, %r14
movzwl 0x4c(%rdi), %ecx
cmpw %bx, %cx
jbe 0x98ed
movzwl 0x14e(%r14), %eax
cmpw %bx, %ax
je 0x98dd
cmpb $0x0, 0x152(%r14)
je 0x98b9
movzwl 0x4e(%r14,%rax,2), %esi
leaq 0x154(%r14), %rdx
movq %r14, %rdi
callq 0x7983
testl %eax, %eax
je 0x98e4
movb $0x0, 0x152(%r14)
movw %bx, 0x14e(%r14)
movzwl %bx, %eax
movzwl 0x4e(%r14,%rax,2), %esi
leaq 0x154(%r14), %rdx
movq %r14, %rdi
callq 0x78a2
testl %eax, %eax
je 0x98e4
movl $0x1, %ebp
jmp 0x98e6
xorl %ebp, %ebp
movl %ebp, %eax
popq %rbx
popq %r14
popq %rbp
retq
movq 0xe6fc(%rip), %rax      # 0x17ff0
movq (%rax), %rdi
leaq 0x81a6(%rip), %rsi      # 0x11aa4
xorl %ebp, %ebp
movl %ebx, %edx
xorl %eax, %eax
callq 0x31d0
leaq 0xf6a8(%rip), %rax      # 0x18fb8
movq (%rax), %rdi
testq %rdi, %rdi
je 0x98e6
movq 0xe699(%rip), %rax      # 0x17fb8
cmpq (%rax), %rdi
je 0x98e6
movzwl 0x4c(%r14), %ecx
leaq 0x8174(%rip), %rsi      # 0x11aa4
xorl %ebp, %ebp
movl %ebx, %edx
xorl %eax, %eax
callq 0x31d0
jmp 0x98e6
// File: /workspace/github_c_makefile_star2_O1/simh[P]simtools/converters/fsio/dos11.c
// Function: bitmapSetBit
static int bitmapSetBit(
  struct mountedFS *mount,
  uint16_t block
)
{
  struct DOS11data *data = &mount->dos11data;
  uint16_t map = block / MAP_BLOCKS;
  uint16_t offset = block % MAP_BLOCKS;
  uint16_t wrd = offset / 16;
  uint16_t bit = offset % 16;

  if (bitmapLoad(mount, map) == 0)
    return 0;

  data->bmbuf[MAP_BMSTART + wrd] =
    htole16(le16toh(data->bmbuf[MAP_BMSTART + wrd]) | bits[bit]);
  data->bmdirty = 1;
  return 1;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movl %esi, %ebp
movq %rdi, %rbx
imull $0x8889, %esi, %r14d    # imm = 0x8889
shrl $0x19, %r14d
movl %r14d, %esi
callq 0x986f
testl %eax, %eax
je 0x9995
imull $0x3c0, %r14d, %eax     # imm = 0x3C0
subl %eax, %ebp
movl %ebp, %eax
andl $0xf, %eax
movzwl %bp, %ecx
shrl $0x4, %ecx
addl $0x4, %ecx
leaq 0xeb35(%rip), %rdx      # 0x184b0
movzwl (%rdx,%rax,2), %eax
orw %ax, 0x154(%rbx,%rcx,2)
movb $0x1, 0x152(%rbx)
movl $0x1, %eax
jmp 0x9997
xorl %eax, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/simh[P]simtools/converters/fsio/rt11.c
// Function: rt11MatchRegex
int rt11MatchRegex(
  regex_t *preg,
  uint16_t fname1,
  uint16_t fname2,
  uint16_t ftype
)
{
  char temp[16];
  int i = 5;

  /*
   * Build a filename + type string with no embedded spaces.
   */
  r50Asc(fname1, &temp[0]);
  r50Asc(fname2, &temp[3]);

  while ((i >= 0) && (temp[i] == ' '))
    i--;

  temp[++i] = '.';

  r50Asc(ftype, &temp[++i]);

  i += 2;
  while (temp[i] == ' ')
    i--;

  temp[i + 1] = '\0';

  if (regexec(preg, &temp[0], 0, NULL, 0) == 0)
    return 1;

  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x18, %rsp
movl %ecx, %ebp
movl %edx, %r15d
movq %rdi, %rbx
movq %rsp, %r14
movl %esi, %edi
movq %r14, %rsi
callq 0x65fc
leaq 0x3(%rsp), %rsi
movl %r15d, %edi
callq 0x65fc
movl $0x5, %eax
movl %eax, %ecx
cmpb $0x20, (%rsp,%rcx)
jne 0x9c22
addl $-0x1, %eax
jb 0x9c10
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movslq %eax, %r15
leaq (%r15,%r14), %rsi
addq $0x2, %rsi
movb $0x2e, -0x1(%rsi)
movzwl %bp, %edi
callq 0x65fc
leaq (%r15,%r14), %rcx
addq $0x4, %rcx
shlq $0x20, %r15
movabsq $0x600000000, %rax      # imm = 0x600000000
addq %r15, %rax
movabsq $-0x100000000, %rdx     # imm = 0xFFFFFFFF00000000
addq %rdx, %rax
cmpb $0x20, (%rcx)
leaq -0x1(%rcx), %rcx
je 0x9c5c
sarq $0x20, %rax
movb $0x0, (%rsp,%rax)
movq %rsp, %rsi
movq %rbx, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x3230
xorl %ecx, %ecx
testl %eax, %eax
sete %cl
movl %ecx, %eax
addq $0x18, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/simh[P]simtools/converters/fsio/rt11.c
// Function: MapLogToPhys
unsigned int MapLogToPhys(
  unsigned int sectno
)
{
  unsigned int i, track, sector;

  track = sectno / RT11_RX0xNSECT;
  i = (sectno % RT11_RX0xNSECT) << 1;
  if (i >= RT11_RX0xNSECT)
    i++;
  sector = (i + (6 * track)) % RT11_RX0xNSECT;
  return sector + (track * RT11_RX0xNSECT);
}

// Assembly:
movl %edi, %eax
imulq $0x4ec4ec4f, %rax, %rax # imm = 0x4EC4EC4F
shrq $0x23, %rax
leal (%rax,%rax,4), %ecx
leal (%rcx,%rcx,4), %ecx
addl %eax, %ecx
subl %ecx, %edi
leal (%rdi,%rdi), %edx
xorl %esi, %esi
cmpl $0xd, %edi
setae %sil
leal (%rax,%rax,2), %eax
leal (%rdx,%rax,2), %eax
orl %esi, %eax
imulq $0x4ec4ec4f, %rax, %rdx # imm = 0x4EC4EC4F
shrq $0x23, %rdx
leal (%rdx,%rdx,4), %esi
leal (%rsi,%rsi,4), %esi
addl %edx, %esi
subl %esi, %eax
addl %ecx, %eax
retq
// File: /workspace/github_c_makefile_star2_O1/simh[P]simtools/converters/fsio/rt11.c
// Function: rt11MakeDirectoryEntry
int rt11MakeDirectoryEntry(
  struct mountedFS *mount,
  uint16_t entrysz,
  uint16_t offset
)
{
  struct RT11data *data = &mount->rt11data;
  uint16_t off = offset;

  /*
   * Scan forward looking for the end-of-segment marker.
   */
  while (!RT11EOS(le16toh(data->buf[off + RT11_DI_STATUS])) &&
         ((RT11_DS_SIZE - off) >= entrysz))
    off += entrysz;
  
  if ((RT11_DS_SIZE - off) > entrysz) {
    /*
     * There is enough space available for a new directory entry. Slide
     * the existing entries up to make a new one available at the
     * requested position.
     */
    data->buf[off + entrysz + RT11_DI_STATUS] = htole16(RT11_E_EOS);

    while (off != offset) {
      uint16_t i, prev = off - entrysz;

      for (i = RT11_DI_STATUS; i < entrysz; i++)
        data->buf[off + i] = data->buf[prev + i];

      off -= entrysz;
    }
    return 1;
  }
  return 0;
}

// Assembly:
movl %edx, %ecx
subl %esi, %ecx
xorl %r8d, %r8d
movl %edx, %eax
movzwl %ax, %r9d
movl $0x200, %r10d           # imm = 0x200
subl %r9d, %r10d
subl %esi, %r8d
testb $0x8, 0x473(%rdi,%r9,2)
jne 0xa114
addl %esi, %eax
cmpl %esi, %r10d
jge 0xa0f2
xorl %eax, %eax
cmpl %esi, %r10d
jle 0xa189
leal (%rsi,%r8), %r10d
addl %esi, %r9d
movw $0x800, 0x472(%rdi,%r9,2) # imm = 0x800
movl $0x1, %eax
testw %r10w, %r10w
je 0xa189
pushq %rbp
pushq %rbx
movl %edx, %r9d
subl %esi, %r9d
subl %esi, %r9d
subl %r8d, %r9d
subl %r8d, %ecx
movzwl %si, %r8d
addq $0x472, %rdi            # imm = 0x472
testw %si, %si
je 0xa17d
movzwl %r9w, %r10d
leaq (%rdi,%r10,2), %r10
movzwl %cx, %r11d
leaq (%rdi,%r11,2), %r11
xorl %ebx, %ebx
movzwl (%r10,%rbx,2), %ebp
movw %bp, (%r11,%rbx,2)
incq %rbx
cmpq %rbx, %r8
jne 0xa16b
subl %esi, %ecx
subl %esi, %r9d
cmpw %dx, %cx
jne 0xa154
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/simh[P]simtools/converters/fsio/rt11.c
// Function: rt11Date
char *rt11Date(
  uint16_t value,
  char *buf
)
{
  sprintf(buf, "%02d-%s-%4d",
          (value & RT11_DW_DAY) >> 5,
          month[((value & RT11_DW_MONTH) >> 10) - 1],
          1972 + (value & RT11_DW_YEAR) + ((value & RT11_DW_AGE) >> 14) * 32);

  return buf;
}

// Assembly:
pushq %rbx
movq %rsi, %rbx
movl %edi, %edx
shrl $0x5, %edx
andl $0x1f, %edx
movl %edi, %eax
shrl $0x7, %eax
andl $0x78, %eax
leaq 0xe49b(%rip), %rcx      # 0x18640
movq -0x8(%rax,%rcx), %rcx
movl %edi, %eax
andl $0x1f, %eax
shrl $0x9, %edi
andl $-0x20, %edi
leal (%rax,%rdi), %r8d
addl $0x7b4, %r8d            # imm = 0x7B4
leaq 0x7ea0(%rip), %rsi      # 0x12067
movq %rbx, %rdi
xorl %eax, %eax
callq 0x32a0
movq %rbx, %rax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O1/simh[P]simtools/converters/fsio/rt11.c
// Function: rt11DisplayDir
void rt11DisplayDir(
  uint16_t *dir,
  int full
)
{
  char temp[64], creation[16];

  r50Asc(le16toh(dir[RT11_DI_FNAME1]), &temp[0]);
  r50Asc(le16toh(dir[RT11_DI_FNAME2]), &temp[3]);
  temp[6] = '.';
  r50Asc(le16toh(dir[RT11_DI_FTYPE]), &temp[7]);

  if (full)
    sprintf(&temp[10], "  %5u  %s",
            le16toh(dir[RT11_DI_LENGTH]),
            rt11Date(le16toh(dir[RT11_DI_CREATE]), creation));
  else temp[10] ='\0';
  puts(temp);
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x50, %rsp
movl %esi, %ebp
movq %rdi, %rbx
movzwl 0x2(%rdi), %edi
movq %rsp, %rsi
callq 0x65fc
movzwl 0x4(%rbx), %edi
leaq 0x3(%rsp), %r14
movq %r14, %rsi
callq 0x65fc
movb $0x2e, 0x3(%r14)
movzwl 0x6(%rbx), %edi
leaq 0x7(%rsp), %rsi
callq 0x65fc
testl %ebp, %ebp
je 0xa249
leaq 0xa(%rsp), %r14
movzwl 0x8(%rbx), %ebp
movzwl 0xc(%rbx), %edi
leaq 0x40(%rsp), %rbx
movq %rbx, %rsi
callq 0xa18a
leaq 0x7e3b(%rip), %rsi      # 0x12073
movq %r14, %rdi
movl %ebp, %edx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x32a0
jmp 0xa24e
movb $0x0, 0xa(%rsp)
movq %rsp, %rdi
callq 0x30e0
addq $0x50, %rsp
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/simh[P]simtools/converters/fsio/rt11.c
// Function: rt11UpdateFile
void rt11UpdateFile(
  struct mountedFS *mount,
  uint8_t unit,
  struct rt11OpenFile *file
)
{
  struct RT11data *data = &mount->rt11data;
  uint16_t offset, length, left, entrysz;

  if (rt11ReadDirSegment(mount, unit, file->segment) == 0)
    return;

  entrysz = RT11_DI_SIZE + (le16toh(data->buf[RT11_DH_EXTRA]) >> 1);
  offset = file->offset;

  length = file->current - file->start + 1;
  left = file->length - length;

  /*
   * Fix up the directory entry and the following empty entry
   */
  data->buf[offset + RT11_DI_STATUS] = htole16(RT11_E_PERM);
  data->buf[offset + RT11_DI_LENGTH] = htole16(length);

  data->buf[offset + entrysz + RT11_DI_LENGTH] =
    htole16(le16toh(data->buf[offset + entrysz + RT11_DI_LENGTH]) + left);

  if (le16toh(data->buf[offset + entrysz + RT11_DI_LENGTH]) == 0) {
    /*
     * Remove the now empty directory entry
     */
    uint16_t dest = offset + entrysz;
    uint16_t src = dest + entrysz;

    for (;src < RT11_DS_SIZE;) {
      uint16_t i;

      data->buf[dest + RT11_DI_STATUS] = data->buf[src + RT11_DI_STATUS];

      if (RT11EOS(le16toh(data->buf[dest + RT11_DI_STATUS])) ||
          ((RT11_DS_SIZE - src) < entrysz))
        break;

      for (i = RT11_DI_FNAME1;i < entrysz; i++)
        data->buf[dest + i] = data->buf[src + i];

      dest += entrysz;
      src += entrysz;
    }

    /*
     * Make sure the last entry contains the end-of-segment marker.
     */
    data->buf[dest + RT11_DI_STATUS] = htole16(RT11_E_EOS);
  }

  rt11WriteDirSegment(mount, file->unit, file->segment);
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rdx, %rbx
movq %rdi, %r14
movzbl 0xc(%rdx), %edx
callq 0xa037
testl %eax, %eax
je 0xab9b
movzwl 0x478(%r14), %eax
movl %eax, %ecx
shrl %ecx
movzwl 0xe(%rbx), %edx
movzwl 0x30(%rbx), %esi
subw 0x36(%rbx), %si
incl %esi
movl 0x8(%rbx), %edi
subl %esi, %edi
movw $0x400, 0x472(%r14,%rdx,2) # imm = 0x400
movw %si, 0x47a(%r14,%rdx,2)
addl %ecx, %edx
addl $0x7, %edx
addw %di, 0x47a(%r14,%rdx,2)
jne 0xab87
addl $0x7, %ecx
movl %edx, %esi
addl %ecx, %esi
leaq 0x474(%r14), %rdi
shrl %eax
addq $0x6, %rax
movzwl %si, %r9d
cmpl $0x1ff, %r9d            # imm = 0x1FF
ja 0xab79
movzwl 0x472(%r14,%r9,2), %r8d
movzwl %dx, %r10d
movw %r8w, 0x472(%r14,%r10,2)
btl $0xb, %r8d
setae %r11b
movl $0x200, %r8d            # imm = 0x200
subl %r9d, %r8d
cmpw %cx, %r8w
setae %r8b
andb %r11b, %r8b
cmpb $0x1, %r8b
jne 0xab74
leaq (%rdi,%r10,2), %r10
leaq (%rdi,%r9,2), %r9
xorl %r11d, %r11d
movzwl (%r9,%r11,2), %ebp
movw %bp, (%r10,%r11,2)
incq %r11
cmpq %r11, %rax
jne 0xab5e
addl %ecx, %edx
addl %ecx, %esi
testb %r8b, %r8b
jne 0xab0d
movzwl %dx, %eax
movw $0x800, 0x472(%r14,%rax,2) # imm = 0x800
movzbl 0x20(%rbx), %esi
movzbl 0xc(%rbx), %edx
movq %r14, %rdi
popq %rbx
popq %r14
popq %rbp
jmp 0xa090
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/simh[P]simtools/converters/fsio/rt11.c
// Function: rt11ReadBytes
int rt11ReadBytes(
  struct rt11OpenFile *file,
  char *buf,
  int len
)
{
  struct mountedFS *mount = file->mount;
  int count = 0;

  if (file->current == 0) {
    file->current = le16toh(file->start);

    if (rt11ReadBlock(mount, file->unit, file->current, file->buffer) == 0)
      return 0;

    file->count = 0;
    file->last = le16toh(file->start) + le16toh(file->length) - 1;
 }

  while (len) {
    if (file->count == RT11_BLOCKSIZE) {
      if (file->current == file->last)
        break;

      file->current++;

      if (rt11ReadBlock(mount, file->unit, file->current, file->buffer) == 0)
        return 0;

      file->count = 0;
    }
    *buf++ = file->buffer[file->count++];
    len--;
    count++;
  }
  return count;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edx, %ebp
movq %rsi, %rbx
movq %rdi, %r14
movq 0x18(%rdi), %r15
cmpw $0x0, 0x30(%rdi)
jne 0xabf5
movzwl 0x36(%r14), %edx
movw %dx, 0x30(%r14)
movzbl 0x20(%r14), %esi
movq 0x28(%r14), %rcx
movq %r15, %rdi
callq 0x9cd9
testl %eax, %eax
je 0xac5c
movw $0x0, 0x34(%r14)
movzwl 0x36(%r14), %eax
addw 0x8(%r14), %ax
decl %eax
movw %ax, 0x32(%r14)
testl %ebp, %ebp
je 0xac5c
movl %ebp, %r12d
xorl %r13d, %r13d
cmpw $0x200, 0x34(%r14)      # imm = 0x200
jne 0xac3a
movzwl 0x30(%r14), %eax
cmpw 0x32(%r14), %ax
je 0xac71
incl %eax
movw %ax, 0x30(%r14)
movzbl 0x20(%r14), %esi
movzwl %ax, %edx
movq 0x28(%r14), %rcx
movq %r15, %rdi
callq 0x9cd9
testl %eax, %eax
je 0xac5c
movw $0x0, 0x34(%r14)
movq 0x28(%r14), %rax
movzwl 0x34(%r14), %ecx
leal 0x1(%rcx), %edx
movw %dx, 0x34(%r14)
movb (%rax,%rcx), %al
movb %al, (%rbx,%r13)
incq %r13
cmpl %r13d, %r12d
jne 0xabff
jmp 0xac5f
xorl %r12d, %r12d
movl %r12d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %r13d, %r12d
jmp 0xac5f