LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O2/simh[P]simtools/converters/fsio/declib.c
// Function: dos11Date
char *dos11Date(
  uint16_t value,
  char *buf
)
{
  unsigned short year, doyr, leapyr;
  unsigned short *table;

  /*
   * The DOS/BATCH-11 date format is documented as having 3 reserved bit.
   * Version 9.20C (and later?) makes use of these bits to allow dates up
   * to 2035. Unfortunately, the date input routine only allows up to 1999!
   */
  year = 1970 + value / 1000;
  doyr = value % 1000;
  leapyr = ((year % 4) == 0) && (year != 2000);

  table = leapyr ? mnthl : mnth;

  /*
   * Check for valid day of year.
   */
  if (doyr < (leapyr ? 366 : 365)) {
    int i = 0;

    while (doyr > table[i])
      doyr -= table[i++];

    sprintf(buf, "%2d-%s-%4d", doyr, month[i], year);
  } else strcpy(buf, "xx-yyy-xxxx");
  return buf;
}

// Assembly:
pushq %rbx
movq %rsi, %rbx
movl %edi, %eax
movw $0x3e8, %cx             # imm = 0x3E8
xorl %edx, %edx
divw %cx
addl $0x7b2, %eax            # imm = 0x7B2
testb $0x3, %al
sete %cl
cmpw $0x7d0, %ax             # imm = 0x7D0
setne %sil
andb %cl, %sil
leaq 0x124cb(%rip), %rdi     # 0x176d0
leaq 0x124a4(%rip), %rcx     # 0x176b0
cmovneq %rdi, %rcx
movzwl %dx, %edi
movzbl %sil, %esi
addl $0x16d, %esi            # imm = 0x16D
cmpl %edi, %esi
jbe 0x5259
movzwl %ax, %r8d
leaq 0x12424(%rip), %rax     # 0x17650
movzwl (%rcx), %esi
cmpw %si, %dx
jbe 0x5240
subl %esi, %edx
addq $0x8, %rax
addq $0x2, %rcx
jmp 0x522c
movzwl %dx, %edx
movq (%rax), %rcx
leaq 0xb5c8(%rip), %rsi      # 0x10815
movq %rbx, %rdi
xorl %eax, %eax
callq 0x32b0
jmp 0x526d
movabsq $0x782d7979792d7878, %rax # imm = 0x782D7979792D7878
movq %rax, (%rbx)
movl $0x787878, 0x8(%rbx)    # imm = 0x787878
movq %rbx, %rax
popq %rbx
retq
nop
// File: /workspace/github_c_makefile_star2_O2/simh[P]simtools/converters/fsio/tape.c
// Function: tapeReadRecordLength
uint32_t tapeReadRecordLength(
  FILE *container
)
{
  off_t pos = ftello(container);
  uint32_t meta, bc, erflag;

  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;

      /*
       * 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 | bc;
  }
  return ST_FAIL;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
callq 0x30d0
movq %rax, %r15
leaq 0xc(%rsp), %rdi
pushq $0x4
popq %rsi
pushq $0x1
popq %rdx
movq %rbx, %rcx
callq 0x30f0
movl $0xfefefefe, %r14d      # imm = 0xFEFEFEFE
cmpq $0x1, %rax
jne 0x5471
movl 0xc(%rsp), %r14d
leal 0x1(%r14), %eax
cmpl $0x2, %eax
jb 0x5471
movl %r14d, %eax
andl $0xffffff, %eax         # imm = 0xFFFFFF
incl %eax
andl $-0x2, %eax
leaq (%rax,%r15), %rsi
addq $0x8, %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x3270
andl $0x80ffffff, %r14d      # imm = 0x80FFFFFF
testl %eax, %eax
movl $0xfefefefe, %eax       # imm = 0xFEFEFEFE
cmovel %r14d, %eax
movl %eax, %r14d
movl %r14d, %eax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/simh[P]simtools/converters/fsio/tape.c
// Function: tapeReadRecordLengthReverse
uint32_t tapeReadRecordLengthReverse(
  FILE *container
)
{
  uint32_t meta, bc, erflag;
  off_t delta;

  if ((fseeko(container, -sizeof(meta), SEEK_CUR) != 0) ||
      (fread(&meta, sizeof(meta), 1, container) != 1))
    return ST_FAIL;

  bc = le32toh(meta);

  switch (bc) {
    case ST_EOM:
    case ST_TM:
      if (fseeko(container, -sizeof(meta), SEEK_CUR) != 0)
        return ST_FAIL;
      return bc;

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

      /*
       * Now position the file before this record.
       */
      delta = RECLEN(bc) + (2 * sizeof(meta));
      if (fseeko(container, -delta, SEEK_CUR) != 0)
        return ST_FAIL;

      return erflag | bc;
  }
  return ST_FAIL;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
pushq $-0x4
popq %rsi
pushq $0x1
popq %rdx
callq 0x3270
movl $0xfefefefe, %ebp       # imm = 0xFEFEFEFE
testl %eax, %eax
jne 0x5509
leaq 0xc(%rsp), %rdi
pushq $0x4
popq %rsi
pushq $0x1
popq %rdx
movq %rbx, %rcx
callq 0x30f0
cmpq $0x1, %rax
jne 0x5509
movl 0xc(%rsp), %r14d
leal 0x1(%r14), %eax
cmpl $0x1, %eax
ja 0x54d9
pushq $-0x4
popq %rsi
pushq $0x1
popq %rdx
movq %rbx, %rdi
callq 0x3270
jmp 0x54fe
movl %r14d, %eax
andl $0xffffff, %eax         # imm = 0xFFFFFF
incl %eax
andl $-0x2, %eax
pushq $-0x8
popq %rsi
subq %rax, %rsi
pushq $0x1
popq %rdx
movq %rbx, %rdi
callq 0x3270
andl $0x80ffffff, %r14d      # imm = 0x80FFFFFF
testl %eax, %eax
movl $0xfefefefe, %ebp       # imm = 0xFEFEFEFE
cmovel %r14d, %ebp
movl %ebp, %eax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/simh[P]simtools/converters/fsio/tape.c
// Function: tapePeekRecordLength
uint32_t tapePeekRecordLength(
  FILE *container
)
{
  off_t pos = ftello(container);
  uint32_t meta;

  if ((fread(&meta, sizeof(meta), 1, container) != 1) ||
      (fseeko(container, pos, SEEK_SET) != 0))
    return ST_FAIL;

  return le32toh(meta);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
callq 0x30d0
movq %rax, %r14
leaq 0x4(%rsp), %rdi
pushq $0x4
popq %rsi
pushq $0x1
popq %rdx
movq %rbx, %rcx
callq 0x30f0
movq %rax, %rcx
movl $0xfefefefe, %eax       # imm = 0xFEFEFEFE
cmpq $0x1, %rcx
jne 0x5560
movq %rbx, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x3270
movl %eax, %ecx
movl $0xfefefefe, %eax       # imm = 0xFEFEFEFE
testl %ecx, %ecx
jne 0x5560
movl 0x4(%rsp), %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/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
pushq $0x4
popq %rsi
pushq $0x1
popq %rdx
movq %r14, %rcx
callq 0x30f0
movl $0xfefefefe, %ebp       # imm = 0xFEFEFEFE
cmpq $0x1, %rax
jne 0x55b5
movl 0xc(%rsp), %r13d
leal 0x1(%r13), %eax
cmpl $0x2, %eax
jae 0x55c6
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
pushq $0x1
popq %rsi
movq %r12, %rdi
movq %rbx, %rdx
movq %r14, %rcx
callq 0x30f0
cmpq %rbx, %rax
jne 0x55b5
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 0x3270
orl %r13d, %ebx
testl %eax, %eax
movl $0xfefefefe, %ebp       # imm = 0xFEFEFEFE
cmovel %ebx, %ebp
jmp 0x55b5
// File: /workspace/github_c_makefile_star2_O2/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)
pushq $0x4
popq %rsi
pushq $0x1
popq %rdx
movq %rbx, %rcx
callq 0x32d0
xorl %ebp, %ebp
cmpq $0x1, %rax
jne 0x5692
incl %r15d
andl $-0x2, %r15d
movslq %r15d, %rsi
pushq $0x1
popq %rdx
movq %r14, %rdi
movq %rbx, %rcx
callq 0x32d0
cmpq $0x1, %rax
jne 0x5692
leaq 0x4(%rsp), %rdi
pushq $0x4
popq %rsi
pushq $0x1
popq %rdx
movq %rbx, %rcx
callq 0x32d0
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_O2/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
orl $-0x1, (%rdi)
pushq $0x4
popq %rsi
pushq $0x1
popq %rdx
movq %r14, %rcx
callq 0x32d0
xorl %ebx, %ebx
cmpq $0x1, %rax
jne 0x56e3
testl %ebp, %ebp
je 0x56e0
pushq $-0x4
popq %rsi
pushq $0x1
popq %rdx
movq %r14, %rdi
callq 0x3270
testl %eax, %eax
jne 0x56e3
pushq $0x1
popq %rbx
movl %ebx, %eax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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 %r12
pushq %rbx
movq %rdi, %rbx
xorl %ebp, %ebp
testq %rsi, %rsi
sete %bpl
addl %ebp, %ebp
testq %rsi, %rsi
je 0x5732
movq (%rsi), %r14
jmp 0x5735
xorl %r14d, %r14d
movq %rbx, %rdi
movq %r14, %rsi
movl %ebp, %edx
callq 0x3270
testl %eax, %eax
je 0x5755
xorl %r15d, %r15d
movl %r15d, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, %rdi
callq 0x30d0
pushq $0x1
popq %r12
testq %rax, %rax
je 0x57c3
movq %rbx, %rdi
callq 0x5483
xorl %r15d, %r15d
cmpl $0xfefefefe, %eax       # imm = 0xFEFEFEFE
je 0x5749
incl %eax
cmpl $0x1, %eax
ja 0x5746
movq %rbx, %rdi
callq 0x30d0
testq %rax, %rax
je 0x57c3
movq %rbx, %rdi
callq 0x5483
cmpl $0xfefefefe, %eax       # imm = 0xFEFEFEFE
je 0x5749
testl %eax, %eax
jne 0x57c8
movq %rbx, %rdi
callq 0x30d0
movl %r12d, %r15d
testq %rax, %rax
je 0x5749
pushq $0x4
popq %rsi
pushq $0x1
popq %r15
movq %rbx, %rdi
movl %r15d, %edx
callq 0x3270
jmp 0x57d8
movl %r12d, %r15d
jmp 0x5749
movq %rbx, %rdi
movq %r14, %rsi
movl %ebp, %edx
callq 0x3270
movl %r12d, %r15d
testl %eax, %eax
jne 0x5746
jmp 0x5749
// File: /workspace/github_c_makefile_star2_O2/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 %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rsi, %r14
movq %rdi, %r15
xorl %r13d, %r13d
pushq $0x1
popq %rbx
pushq $-0x4
popq %r12
cmpq %r14, %r13
je 0x5858
movq %r15, %rdi
callq 0x5514
leal 0x1(%rax), %ecx
cmpl $0x2, %ecx
jb 0x5858
cmpl $0xfefefefe, %eax       # imm = 0xFEFEFEFE
je 0x5856
movq %r15, %rdi
callq 0x53fc
cmpl $0xfefefefe, %eax       # imm = 0xFEFEFEFE
je 0x5856
cmpl $-0x1, %eax
je 0x5840
decl %eax
cmpl $-0x2, %eax
jb 0x5823
jmp 0x5851
movq %r15, %rdi
movq %r12, %rsi
movl %ebx, %edx
callq 0x3270
testl %eax, %eax
jne 0x5856
incq %r13
jmp 0x5807
xorl %ebx, %ebx
movl %ebx, %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/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 %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
xorl %r13d, %r13d
pushq $0x1
popq %rbp
pushq $0x4
popq %r15
xorl %r12d, %r12d
cmpq %rbx, %r13
je 0x58d5
movq %r14, %rdi
callq 0x30d0
testq %rax, %rax
je 0x58d5
movq %r14, %rdi
callq 0x5483
testl %eax, %eax
jne 0x58d8
movq %r14, %rdi
callq 0x5483
cmpl $0xfefefefe, %eax       # imm = 0xFEFEFEFE
je 0x58d8
movq %r14, %rdi
testl %eax, %eax
je 0x58c2
callq 0x30d0
testq %rax, %rax
jne 0x58a0
jmp 0x58d0
movq %r15, %rsi
movl %ebp, %edx
callq 0x3270
testl %eax, %eax
jne 0x58d8
incq %r13
jmp 0x5882
movl %ebp, %r12d
movl %r12d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O2/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 0x5068
movzwl 0x2(%rbx), %edi
leaq 0x3(%rsp), %rsi
callq 0x5068
movzwl 0x4(%rbx), %eax
testw %ax, %ax
je 0x5930
leaq 0x7(%rsp), %rsi
movb $0x2e, -0x1(%rsi)
movzwl %ax, %edi
callq 0x5068
jmp 0x5938
movl $0x20202020, 0x6(%rsp)  # imm = 0x20202020
testl %ebp, %ebp
je 0x5987
leaq 0xa(%rsp), %r14
movzwl 0xc(%rbx), %ebp
movzwl 0x6(%rbx), %edi
testw %di, %di
pushq $0x20
popq %rax
pushq $0x43
popq %r15
cmovnsl %eax, %r15d
andl $0x7fff, %edi           # imm = 0x7FFF
leaq 0x40(%rsp), %rsi
callq 0x51da
movzbl 0x10(%rbx), %r9d
leaq 0xaf0d(%rip), %rsi      # 0x10880
movq %r14, %rdi
movl %ebp, %edx
movl %r15d, %ecx
movq %rax, %r8
xorl %eax, %eax
callq 0x32b0
jmp 0x598c
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_O2/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 %r15
pushq %r14
pushq %rbx
pushq %rax
movl %esi, %r14d
movq %rdi, %rbx
leaq 0x554(%rdi), %r15
testq %rdx, %rdx
cmovneq %rdx, %r15
cmpl %esi, 0x48(%rdi)
jbe 0x6060
testb $0x2, 0x30(%rbx)
je 0x603f
leaq 0x11fa1(%rip), %rax     # 0x17fc8
movq (%rax), %rdi
leaq 0x8(%rbx), %rdx
leaq 0xa911(%rip), %rsi      # 0x10946
movl %r14d, %ecx
xorl %eax, %eax
callq 0x31e0
movq %rbx, %rdi
movl %r14d, %esi
movq %r15, %rdx
callq 0x4c23
movl %eax, %ebp
testl %eax, %eax
je 0x60b7
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq 0x10f91(%rip), %rax     # 0x16ff8
movq (%rax), %rdi
addq $0x8, %rbx
leaq 0xa89c(%rip), %rsi      # 0x10911
xorl %ebp, %ebp
movl %r14d, %edx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x31e0
leaq 0x11f3d(%rip), %rax     # 0x17fc8
movq (%rax), %rdi
testq %rdi, %rdi
je 0x6053
movq 0x10f26(%rip), %rax     # 0x16fc0
cmpq (%rax), %rdi
je 0x6053
leaq 0xa86b(%rip), %rsi      # 0x10911
xorl %ebp, %ebp
movl %r14d, %edx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x31e0
jmp 0x6053
movq 0x10f3a(%rip), %rax     # 0x16ff8
movq (%rax), %rdi
addq $0x8, %rbx
leaq 0xa8a3(%rip), %rsi      # 0x1096f
xorl %ebp, %ebp
movq %rbx, %rdx
xorl %eax, %eax
callq 0x31e0
leaq 0x11ee9(%rip), %rax     # 0x17fc8
movq (%rax), %rdi
testq %rdi, %rdi
je 0x6053
movq 0x10ece(%rip), %rax     # 0x16fc0
cmpq (%rax), %rdi
je 0x6053
leaq 0xa86d(%rip), %rsi      # 0x1096f
xorl %ebp, %ebp
movq %rbx, %rdx
xorl %eax, %eax
callq 0x31e0
jmp 0x6053
// File: /workspace/github_c_makefile_star2_O2/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 0x6597
movl %eax, %ebx
testw %ax, %ax
je 0x615e
movzwl %bx, %esi
movq %rsp, %rdx
movq %r14, %rdi
callq 0x616b
testl %eax, %eax
je 0x615c
movq %r14, %rdi
callq 0x667c
testl %eax, %eax
jne 0x615e
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x408, %rsp            # imm = 0x408
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/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 %r15
pushq %r14
pushq %rbx
pushq %rax
movl %esi, %r14d
movq %rdi, %rbx
leaq 0x554(%rdi), %r15
testq %rdx, %rdx
cmovneq %rdx, %r15
cmpl %esi, 0x48(%rdi)
jbe 0x61d1
testb $0x2, 0x30(%rbx)
je 0x61b0
leaq 0x11e30(%rip), %rax     # 0x17fc8
movq (%rax), %rdi
leaq 0x8(%rbx), %rdx
leaq 0xa812(%rip), %rsi      # 0x109b8
movl %r14d, %ecx
xorl %eax, %eax
callq 0x31e0
movq %rbx, %rdi
movl %r14d, %esi
movq %r15, %rdx
callq 0x4c6a
movl %eax, %ebp
testl %eax, %eax
je 0x6228
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq 0x10e20(%rip), %rax     # 0x16ff8
movq (%rax), %rdi
addq $0x8, %rbx
leaq 0xa79c(%rip), %rsi      # 0x10982
xorl %ebp, %ebp
movl %r14d, %edx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x31e0
leaq 0x11dcc(%rip), %rax     # 0x17fc8
movq (%rax), %rdi
testq %rdi, %rdi
je 0x61c4
movq 0x10db5(%rip), %rax     # 0x16fc0
cmpq (%rax), %rdi
je 0x61c4
leaq 0xa76b(%rip), %rsi      # 0x10982
xorl %ebp, %ebp
movl %r14d, %edx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x31e0
jmp 0x61c4
movq 0x10dc9(%rip), %rax     # 0x16ff8
movq (%rax), %rdi
addq $0x8, %rbx
leaq 0xa732(%rip), %rsi      # 0x1096f
xorl %ebp, %ebp
movq %rbx, %rdx
xorl %eax, %eax
callq 0x31e0
leaq 0x11d78(%rip), %rax     # 0x17fc8
movq (%rax), %rdi
testq %rdi, %rdi
je 0x61c4
movq 0x10d5d(%rip), %rax     # 0x16fc0
cmpq (%rax), %rdi
je 0x61c4
leaq 0xa6fc(%rip), %rsi      # 0x1096f
xorl %ebp, %ebp
movq %rbx, %rdx
xorl %eax, %eax
callq 0x31e0
jmp 0x61c4
// File: /workspace/github_c_makefile_star2_O2/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 0x5ffa
testl %eax, %eax
je 0x655c
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 0x6583
leaq 0x554(%rbx), %r15
movzwl 0x14(%r14), %eax
cmpq $0x1, %rax
jne 0x6562
pushq $0x1
popq %rax
jmp 0x6577
popq %rbx
popq %r14
popq %r15
retq
leaq (%r15,%rax,2), %rdi
addq $-0x12, %rdi
pushq $0x1
popq %rsi
callq 0x58ec
movzwl 0x14(%r14), %eax
leaq (%r15,%rax,2), %rdi
pushq $0x1
popq %rsi
callq 0x58ec
movzwl 0x12(%r14), %esi
movq %rbx, %rdi
xorl %edx, %edx
popq %rbx
popq %r14
popq %r15
jmp 0x616b
// File: /workspace/github_c_makefile_star2_O2/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), %eax
movw $0x3c0, %cx             # imm = 0x3C0
xorl %edx, %edx
divw %cx
movl %edx, %r14d
movl %eax, %ebp
imull $0xfffffc40, %ebp, %r15d # imm = 0xFFFFFC40
leaq 0x10efb(%rip), %r12     # 0x174c0
cmpw 0x4c(%rbx), %bp
jae 0x6678
movzwl %bp, %esi
movq %rbx, %rdi
callq 0x8129
testl %eax, %eax
je 0x6678
movl %r14d, %eax
andl $0xf, %eax
movzwl %r14w, %ecx
imull $0x3c0, %ebp, %edx      # imm = 0x3C0
shrl $0x4, %ecx
andl $-0x10, %r14d
movl %r15d, %esi
subl %r14d, %esi
movzwl %si, %esi
cmpq $0x3b, %rcx
ja 0x6649
movzwl 0x15c(%rbx,%rcx,2), %edi
cmpw $-0x1, %di
je 0x663e
movl %ecx, %r8d
shll $0x4, %r8d
addl %edx, %r8d
movw %r8w, 0x150(%rbx)
cmpq $0x10, %rax
je 0x663e
movzwl (%r12,%rax,2), %r8d
testw %di, %r8w
je 0x665a
incq %rax
jmp 0x6628
incq %rcx
addq $-0x10, %rsi
xorl %eax, %eax
jmp 0x6602
incl %ebp
addl $0xfffffc40, %r15d      # imm = 0xFFFFFC40
xorl %r14d, %r14d
jmp 0x65c5
orl %edi, %r8d
movw %r8w, 0x15c(%rbx,%rcx,2)
movb $0x1, 0x152(%rbx)
subl %esi, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
xorl %eax, %eax
jmp 0x666f
// File: /workspace/github_c_makefile_star2_O2/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 %r12
pushq %rbx
movl %edx, %ebx
movq %rsi, %r14
movq %rdi, %r15
cmpw $0x0, 0x30(%rdi)
jne 0x6a2a
movzwl 0xa(%r15), %esi
movw %si, 0x30(%r15)
movq 0x20(%r15), %rdi
movq 0x28(%r15), %rdx
callq 0x5ffa
testl %eax, %eax
je 0x6ad7
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 0x6a1d
movzwl 0x8(%r15), %eax
jmp 0x6a25
movq 0x20(%r15), %rax
movzwl 0x28(%rax), %eax
movw %ax, 0x34(%r15)
xorl %ebp, %ebp
movl %ebx, %r12d
subl $0x1, %r12d
jb 0x6add
movzwl 0x32(%r15), %eax
movzwl 0x34(%r15), %ecx
cmpw %cx, %ax
jne 0x6ab8
movzwl 0x30(%r15), %eax
cmpw 0xe(%r15), %ax
je 0x6adb
cmpw $0x0, 0x6(%r15)
js 0x6a69
movq 0x28(%r15), %rdx
movzwl (%rdx), %eax
jmp 0x6a6f
incl %eax
movq 0x28(%r15), %rdx
movw %ax, 0x30(%r15)
movq 0x20(%r15), %rdi
movzwl %ax, %esi
callq 0x5ffa
testl %eax, %eax
je 0x6ad7
movzwl 0x6(%r15), %eax
notl %eax
shrl $0xe, %eax
andl $0x2, %eax
movw %ax, 0x32(%r15)
movzwl 0x30(%r15), %ecx
cmpw 0xe(%r15), %cx
jne 0x6aa9
movzwl 0x8(%r15), %ecx
jmp 0x6ab1
movq 0x20(%r15), %rcx
movzwl 0x28(%rcx), %ecx
movw %cx, 0x34(%r15)
jmp 0x6a43
movq 0x28(%r15), %rcx
leal 0x1(%rax), %edx
movw %dx, 0x32(%r15)
movzwl %ax, %eax
movb (%rcx,%rax), %al
movb %al, (%r14)
incq %r14
incl %ebp
jmp 0x6a2f
xorl %ebx, %ebx
jmp 0x6add
movl %ebp, %ebx
movl %ebx, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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 %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
leaq 0x1128c(%rip), %rax     # 0x17fd8
testb $0x1, (%rax)
jne 0x6d63
movq %r15, %rdi
movq %r14, %rsi
movl %ebx, %edx
callq 0x6ae8
movslq %eax, %r12
jmp 0x6d96
xorl %r12d, %r12d
leaq 0x7(%rsp), %r13
pushq $0x1
popq %rbp
cmpq %r12, %rbx
je 0x6d93
movb (%r14,%r12), %al
incq %r12
andb $0x7f, %al
movb %al, 0x7(%rsp)
movq %r15, %rdi
movq %r13, %rsi
movl %ebp, %edx
callq 0x6ae8
testl %eax, %eax
jne 0x6d6e
jmp 0x6d96
movq %rbx, %r12
movq %r12, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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 0x66c1
testl %eax, %eax
je 0x7d26
pushq $0x1
popq %rdi
pushq $0x38
popq %rsi
callq 0x31c0
testq %rax, %rax
je 0x7d17
movq %rax, %rbx
leaq 0x6(%rsp), %rsi
movq %r14, %rdi
movq %rax, %rdx
callq 0x6284
testl %eax, %eax
je 0x7d0f
movq 0x28(%r14), %rdi
callq 0x3220
movq %rax, 0x28(%rbx)
testq %rax, %rax
je 0x7d0f
andl $0x0, 0x18(%rbx)
jmp 0x7d19
movq %rbx, %rdi
callq 0x3050
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
movq 0xf2cb(%rip), %rax      # 0x16ff8
movq (%rax), %rdi
leaq 0x90a0(%rip), %rsi      # 0x10dd7
xorl %ebx, %ebx
movq %r15, %rdx
xorl %eax, %eax
callq 0x31e0
jmp 0x7d19
// File: /workspace/github_c_makefile_star2_O2/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 0x7fd3
movq 0x20(%rbx), %r14
movzwl 0x6(%rbx), %ecx
xorl %eax, %eax
testw %cx, %cx
setns %al
addl %eax, %eax
testw %cx, %cx
jns 0x7fa1
movzwl 0x30(%rbx), %ecx
cmpw 0xe(%rbx), %cx
jne 0x7feb
movzwl 0x32(%rbx), %ecx
movw %cx, 0x8(%rbx)
movzwl %cx, %ecx
cmpl %ecx, %eax
je 0x7fc0
movzwl 0x30(%rbx), %esi
movq 0x28(%rbx), %rdx
movq %r14, %rdi
callq 0x616b
movq %r14, %rdi
callq 0x667c
movq %r14, %rdi
movq %rbx, %rsi
callq 0x647b
movq 0x28(%rbx), %rdi
callq 0x3050
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x3050
movzwl 0x28(%r14), %ecx
movw %cx, 0x8(%rbx)
movzwl 0x32(%rbx), %ecx
jmp 0x7fa9
// File: /workspace/github_c_makefile_star2_O2/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 %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
leaq 0xffc3(%rip), %rax      # 0x17fd8
testb $0x1, (%rax)
jne 0x802b
movq %r15, %rdi
movq %r14, %rsi
movl %ebx, %edx
callq 0x69c2
cltq
jmp 0x8079
testq %rbx, %rbx
je 0x8072
decq %rbx
xorl %r13d, %r13d
leaq 0x7(%rsp), %r12
pushq $0x1
popq %rbp
movq %r15, %rdi
movq %r12, %rsi
movl %ebp, %edx
callq 0x69c2
cmpl $0x1, %eax
jne 0x8076
movb 0x7(%rsp), %cl
andb $0x7f, %cl
movb %cl, 0x7(%rsp)
leaq 0x1(%r13), %rax
movb %cl, (%r14,%r13)
cmpb $0xa, %cl
je 0x8079
cmpq %r13, %rbx
movq %rax, %r13
jne 0x803e
jmp 0x8079
xorl %eax, %eax
jmp 0x8079
movq %r13, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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
andl $0x0, (%rdi)
andw $0x0, 0x4(%rdi)
movq %r14, %rdi
movq %rbx, %rsi
callq 0x647b
movzwl 0xa(%rbx), %r15d
cmpw $0x0, 0x6(%rbx)
js 0x80e8
testw %r15w, %r15w
je 0x8111
movzwl %r15w, %ebp
movq %r14, %rdi
movl %ebp, %esi
xorl %edx, %edx
callq 0x5ffa
testl %eax, %eax
je 0x8108
movq %r14, %rdi
movl %ebp, %esi
callq 0x829b
testl %eax, %eax
je 0x8108
movzwl 0x554(%r14), %r15d
jmp 0x80b6
xorl %r12d, %r12d
cmpw 0xc(%rbx), %r12w
jae 0x8111
leal (%r15,%r12), %eax
movzwl %ax, %esi
movq %r14, %rdi
callq 0x829b
incl %r12d
testl %eax, %eax
jne 0x80eb
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq %r14, %rdi
callq 0x667c
movq %rbx, %rdi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x7f73
// File: /workspace/github_c_makefile_star2_O2/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 0x81a5
movzwl 0x14e(%r14), %eax
cmpw %bx, %ax
je 0x8197
cmpb $0x0, 0x152(%r14)
je 0x8173
movzwl 0x4e(%r14,%rax,2), %esi
leaq 0x154(%r14), %rdx
movq %r14, %rdi
callq 0x616b
testl %eax, %eax
je 0x819c
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 0x5ffa
testl %eax, %eax
je 0x819c
pushq $0x1
popq %rbp
jmp 0x819e
xorl %ebp, %ebp
movl %ebp, %eax
popq %rbx
popq %r14
popq %rbp
retq
movq 0xee4c(%rip), %rax      # 0x16ff8
movq (%rax), %rdi
leaq 0x88ee(%rip), %rsi      # 0x10aa4
xorl %ebp, %ebp
movl %ebx, %edx
xorl %eax, %eax
callq 0x31e0
leaq 0xfe00(%rip), %rax      # 0x17fc8
movq (%rax), %rdi
testq %rdi, %rdi
je 0x819e
movq 0xede9(%rip), %rax      # 0x16fc0
cmpq (%rax), %rdi
je 0x819e
movzwl 0x4c(%r14), %ecx
leaq 0x88bc(%rip), %rsi      # 0x10aa4
xorl %ebp, %ebp
movl %ebx, %edx
xorl %eax, %eax
callq 0x31e0
jmp 0x819e
// File: /workspace/github_c_makefile_star2_O2/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, %eax
movq %rdi, %rbx
movw $0x3c0, %cx             # imm = 0x3C0
xorl %edx, %edx
divw %cx
movl %edx, %ebp
xorl %r14d, %r14d
movzwl %ax, %esi
callq 0x8129
testl %eax, %eax
je 0x8244
movl %ebp, %eax
andl $0xf, %eax
movzwl %bp, %ecx
shrl $0x4, %ecx
addl $0x4, %ecx
leaq 0xf293(%rip), %rdx      # 0x174c0
movzwl (%rdx,%rax,2), %eax
orw %ax, 0x154(%rbx,%rcx,2)
movb $0x1, 0x152(%rbx)
pushq $0x1
popq %r14
movl %r14d, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/simh[P]simtools/converters/fsio/dos11.c
// Function: bitmapGetWord
static int bitmapGetWord(
  struct mountedFS *mount,
  uint16_t block,
  uint16_t *value
)
{
  struct DOS11data *data = &mount->dos11data;
  uint16_t map = block / MAP_BLOCKS;
  uint16_t offset = block % MAP_BLOCKS;
  uint16_t wrd = offset / 16;

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

  *value = le16toh(data->bmbuf[MAP_BMSTART + wrd]);
  return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdx, %rbx
movl %esi, %eax
movq %rdi, %r14
movw $0x3c0, %cx             # imm = 0x3C0
xorl %edx, %edx
divw %cx
movl %edx, %r15d
xorl %ebp, %ebp
movzwl %ax, %esi
callq 0x8129
testl %eax, %eax
je 0x828e
movzwl %r15w, %eax
shrl $0x4, %eax
addl $0x4, %eax
movzwl 0x154(%r14,%rax,2), %eax
movw %ax, (%rbx)
pushq $0x1
popq %rbp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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 %r12
pushq %rbx
subq $0x10, %rsp
movl %ecx, %ebp
movl %edx, %r14d
movl %esi, %eax
movq %rdi, %rbx
movabsq $-0x100000000, %r15     # imm = 0xFFFFFFFF00000000
movq %rsp, %rsi
movl %eax, %edi
callq 0x5068
leaq 0x3(%rsp), %rsi
movl %r14d, %edi
callq 0x5068
pushq $0x5
popq %rcx
movabsq $0xb00000000, %r14      # imm = 0xB00000000
leaq 0x9(%rsp), %r12
pushq $-0x1
popq %rax
testl %ecx, %ecx
js 0x8522
movl %ecx, %edx
cmpb $0x20, (%rsp,%rdx)
jne 0x8520
decl %ecx
addq %r15, %r14
decq %r12
jmp 0x850a
movl %ecx, %eax
leal 0x1(%rax), %ecx
movb $0x2e, (%rsp,%rcx)
addl $0x2, %eax
leaq (%rsp,%rax), %rsi
movzwl %bp, %edi
callq 0x5068
addq %r15, %r14
cmpb $0x20, (%r12)
leaq -0x1(%r12), %r12
je 0x8538
sarq $0x20, %r14
movb $0x0, (%rsp,%r14)
movq %rsp, %rsi
movq %rbx, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x3240
xorl %ecx, %ecx
testl %eax, %eax
sete %cl
movl %ecx, %eax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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
pushq $0x1a
popq %rsi
xorl %edx, %edx
divl %esi
movl %eax, %ecx
xorl %edi, %edi
cmpl $0xd, %edx
setae %dil
imull $0x6, %eax, %eax
leal (%rax,%rdx,2), %eax
orl %edi, %eax
xorl %edx, %edx
divl %esi
imull $0x1a, %ecx, %eax
addl %edx, %eax
retq
// File: /workspace/github_c_makefile_star2_O2/simh[P]simtools/converters/fsio/rt11.c
// Function: rt11ReadDirSegment
int rt11ReadDirSegment(
  struct mountedFS *mount,
  uint8_t unit,
  uint16_t segment
)
{
  struct RT11data *data = &mount->rt11data;
  unsigned int block = data->first[unit] + ((segment - 1) * 2);

  if (rt11ReadBlock(mount, unit, block, &data->buf[0]) != 0)
    if (rt11ReadBlock(mount, unit, block + 1, &data->buf[256]) != 0)
      return 1;

  return 0;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movl %esi, %ebp
movq %rdi, %rbx
movl %esi, %eax
movzwl 0x272(%rdi,%rax,2), %eax
leal (%rax,%rdx,2), %r14d
addl $-0x2, %r14d
leaq 0x472(%rdi), %rcx
movl %r14d, %edx
callq 0x859e
testl %eax, %eax
je 0x8a16
incl %r14d
leaq 0x672(%rbx), %rcx
movzbl %bpl, %esi
movq %rbx, %rdi
movl %r14d, %edx
callq 0x859e
testl %eax, %eax
je 0x8a16
pushq $0x1
popq %rax
jmp 0x8a18
xorl %eax, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/simh[P]simtools/converters/fsio/rt11.c
// Function: rt11WriteDirSegment
int rt11WriteDirSegment(
  struct mountedFS *mount,
  uint8_t unit,
  uint16_t segment
)
{
  struct RT11data *data = &mount->rt11data;
  unsigned int block = data->first[unit] + ((segment - 1) * 2);

  if (rt11WriteBlock(mount, unit, block, &data->buf[0]) != 0)
    if (rt11WriteBlock(mount, unit, block + 1, &data->buf[256]) != 0)
      return 1;

  return 0;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movl %esi, %ebp
movq %rdi, %rbx
movl %esi, %eax
movzwl 0x272(%rdi,%rax,2), %eax
leal (%rax,%rdx,2), %r14d
addl $-0x2, %r14d
leaq 0x472(%rdi), %rcx
movl %r14d, %edx
callq 0x87b2
testl %eax, %eax
je 0x8a6d
incl %r14d
leaq 0x672(%rbx), %rcx
movzbl %bpl, %esi
movq %rbx, %rdi
movl %r14d, %edx
callq 0x87b2
testl %eax, %eax
je 0x8a6d
pushq $0x1
popq %rax
jmp 0x8a6f
xorl %eax, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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
movzwl %cx, %r9d
leal (%rcx,%rsi), %eax
movl $0x200, %r8d            # imm = 0x200
subl %r9d, %r8d
testb $0x8, 0x473(%rdi,%r9,2)
movl %eax, %ecx
jne 0x8a98
cmpl %esi, %r8d
jge 0x8a76
xorl %eax, %eax
cmpl %esi, %r8d
jle 0x8afe
pushq %rbp
pushq %rbx
movl %ecx, %r8d
subl %esi, %r8d
subl %esi, %r8d
subl %esi, %ecx
addl %esi, %r9d
movw $0x800, 0x472(%rdi,%r9,2) # imm = 0x800
movzwl %si, %r9d
addq $0x472, %rdi            # imm = 0x472
movl $0x1, %eax
cmpw %dx, %cx
je 0x8afc
movzwl %r8w, %r10d
leaq (%rdi,%r10,2), %r10
movzwl %cx, %r11d
leaq (%rdi,%r11,2), %r11
subl %esi, %ecx
xorl %ebx, %ebx
cmpq %rbx, %r9
je 0x8af7
movzwl (%r10,%rbx,2), %ebp
movw %bp, (%r11,%rbx,2)
incq %rbx
jmp 0x8ae3
subl %esi, %r8d
jmp 0x8aca
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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 0xeb36(%rip), %rcx      # 0x17650
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 0x852b(%rip), %rsi      # 0x11067
movq %rbx, %rdi
xorl %eax, %eax
callq 0x32b0
movq %rbx, %rax
popq %rbx
retq