LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O2/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 0x5068
movzwl 0x4(%rbx), %edi
leaq 0x3(%rsp), %r14
movq %r14, %rsi
callq 0x5068
movb $0x2e, 0x3(%r14)
movzwl 0x6(%rbx), %edi
leaq 0x7(%rsp), %rsi
callq 0x5068
testl %ebp, %ebp
je 0x8bbe
leaq 0xa(%rsp), %r14
movzwl 0x8(%rbx), %ebp
movzwl 0xc(%rbx), %edi
leaq 0x40(%rsp), %rbx
movq %rbx, %rsi
callq 0x8aff
leaq 0x84c6(%rip), %rsi      # 0x11073
movq %r14, %rdi
movl %ebp, %edx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x32b0
jmp 0x8bc3
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_O2/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 %r14
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rdi, %r14
movzbl 0xc(%rdx), %edx
callq 0x89c6
testl %eax, %eax
je 0x95c5
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 0x95d8
addl $0x7, %ecx
movl %edx, %esi
addl %ecx, %esi
shrl %eax
addq $0x6, %rax
leaq 0x474(%r14), %rdi
movzwl %dx, %r8d
cmpw $0x200, %si             # imm = 0x200
jae 0x95cd
movzwl %si, %r9d
movzwl 0x472(%r14,%r9,2), %r10d
movw %r10w, 0x472(%r14,%r8,2)
btl $0xb, %r10d
jb 0x95cd
movl $0x200, %r10d           # imm = 0x200
subl %esi, %r10d
cmpw %cx, %r10w
jb 0x95cd
leaq (%rdi,%r8,2), %r8
leaq (%rdi,%r9,2), %r9
xorl %r10d, %r10d
cmpq %r10, %rax
je 0x95bf
movzwl (%r9,%r10,2), %r11d
movw %r11w, (%r8,%r10,2)
incq %r10
jmp 0x95ab
addl %ecx, %edx
addl %ecx, %esi
jmp 0x9569
addq $0x8, %rsp
popq %rbx
popq %r14
retq
movw $0x800, 0x472(%r14,%r8,2) # imm = 0x800
movzbl 0x20(%rbx), %esi
movzbl 0xc(%rbx), %edx
movq %r14, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x8a1d
// File: /workspace/github_c_makefile_star2_O2/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 0x9647
movzwl 0x36(%r14), %edx
movw %dx, 0x30(%r14)
movzbl 0x20(%r14), %esi
movq 0x28(%r14), %rcx
movq %r15, %rdi
callq 0x859e
testl %eax, %eax
je 0x96b1
andw $0x0, 0x34(%r14)
movzwl 0x36(%r14), %eax
addw 0x8(%r14), %ax
decl %eax
movw %ax, 0x32(%r14)
movl %ebp, %r12d
xorl %r13d, %r13d
cmpl %r13d, %r12d
je 0x96a7
movzwl 0x34(%r14), %eax
cmpw $0x200, %ax             # imm = 0x200
jne 0x968c
movzwl 0x30(%r14), %eax
cmpw 0x32(%r14), %ax
je 0x96ac
incl %eax
movw %ax, 0x30(%r14)
movzbl 0x20(%r14), %esi
movzwl %ax, %edx
movq 0x28(%r14), %rcx
movq %r15, %rdi
callq 0x859e
movl %eax, %ecx
xorl %eax, %eax
testl %ecx, %ecx
je 0x96b3
movq 0x28(%r14), %rcx
leal 0x1(%rax), %edx
movw %dx, 0x34(%r14)
movzwl %ax, %eax
movb (%rcx,%rax), %al
movb %al, (%rbx,%r13)
incq %r13
jmp 0x964d
movl %r12d, %eax
jmp 0x96b3
movl %r13d, %eax
jmp 0x96b3
xorl %eax, %eax
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/rt11.c
// Function: rt11WriteBytes
int rt11WriteBytes(
  struct rt11OpenFile *file,
  char *buf,
  int len
)
{
  int count = 0;

  if (file->current == 0) {
    memset(file->buffer, 0, RT11_BLOCKSIZE);

    file->current = le16toh(file->start);
    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;

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

      memset(file->buffer, 0, RT11_BLOCKSIZE);

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

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rsi, %r14
movq %rdi, %r15
cmpw $0x0, 0x30(%rdi)
movl %edx, %ebx
jne 0x9706
movq 0x28(%r15), %rdi
movl $0x200, %edx            # imm = 0x200
xorl %esi, %esi
callq 0x3170
movzwl 0x36(%r15), %eax
movw %ax, 0x30(%r15)
andw $0x0, 0x34(%r15)
addw 0x8(%r15), %ax
decl %eax
movw %ax, 0x32(%r15)
xorl %r12d, %r12d
cmpl %r12d, %ebx
je 0x977f
movzwl 0x34(%r15), %r13d
cmpw $0x200, %r13w           # imm = 0x200
jne 0x975b
movzwl 0x30(%r15), %edx
cmpw 0x32(%r15), %dx
je 0x9778
movzbl 0x20(%r15), %esi
movq 0x18(%r15), %rdi
movq 0x28(%r15), %rcx
callq 0x87b2
testl %eax, %eax
je 0x977d
movq 0x28(%r15), %rdi
xorl %r13d, %r13d
movl $0x200, %edx            # imm = 0x200
xorl %esi, %esi
callq 0x3170
incw 0x30(%r15)
andw $0x0, 0x34(%r15)
movb (%r14,%r12), %al
movq 0x28(%r15), %rcx
leal 0x1(%r13), %edx
movw %dx, 0x34(%r15)
movzwl %r13w, %edx
movb %al, (%rcx,%rdx)
incq %r12
jmp 0x9709
movl %r12d, %ebx
jmp 0x977f
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/rt11.c
// Function: rt11Size
static size_t rt11Size(void)
{
  size_t size = (RT11_MAXPARTSZ - 1) * RT11_BLOCKSIZE;

  if (SWISSET('t')) {
    int i = 0;
    char *type = SWGETVAL('t');

    while (rt11DiskSize[i].name != NULL) {
      if (strcmp(rt11DiskSize[i].name, type) == 0) {
        size = rt11DiskSize[i].size;
        break;
      }
      i++;
    }
    if (size == ((RT11_MAXPARTSZ - 1) * RT11_BLOCKSIZE))
      fprintf(stderr,
              "newfs: Invalid device type \"%s\", using default\n", type);
  }
  return size;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
leaq 0xe0a1(%rip), %rcx      # 0x17fd8
movl $0x1fffe00, %eax        # imm = 0x1FFFE00
testb $0x8, 0x2(%rcx)
je 0x9f83
leaq 0xe097(%rip), %rax      # 0x17fe0
movq 0x98(%rax), %rbx
xorl %ecx, %ecx
leaq 0xcdd7(%rip), %r14      # 0x16d30
leaq 0x10(%rcx), %r15
cmpq $0x60, %r15
je 0x9f89
movq (%rcx,%r14), %rdi
movq %rbx, %rsi
callq 0x31d0
movq %r15, %rcx
testl %eax, %eax
jne 0x9f59
movq -0x8(%r15,%r14), %rax
cmpq $0x1fffe00, %rax        # imm = 0x1FFFE00
je 0x9f89
popq %rbx
popq %r14
popq %r15
retq
movq 0xd068(%rip), %rax      # 0x16ff8
movq (%rax), %rdi
leaq 0x733b(%rip), %rsi      # 0x112d5
movq %rbx, %rdx
xorl %eax, %eax
callq 0x31e0
movl $0x1fffe00, %eax        # imm = 0x1FFFE00
jmp 0x9f83
// File: /workspace/github_c_makefile_star2_O2/simh[P]simtools/converters/fsio/rt11.c
// Function: rt11Info
static void rt11Info(
  struct mountedFS *mount,
  uint8_t unit,
  uint8_t present
)
{
  struct RT11data *data = &mount->rt11data;

  if (present) {
    if (RT11_PARTITIONVALID(data, unit))
      info(mount, unit);
  } else {
    uint16_t i, count = data->filesystems;

    /*
     * Display information about all valid partitions
     */
    for (i = 0; (i < 256) && (count != 0); i++)
      if (RT11_PARTITIONVALID(data, i)) {
        info(mount, i);
        count--;
      }
  }
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
testl %edx, %edx
je 0xa279
movl %esi, %eax
movzbl %al, %esi
shrb $0x3, %al
movzbl %al, %eax
andl $0x1e, %eax
movzwl 0x52(%rbx,%rax), %eax
movl %esi, %ecx
andl $0xf, %ecx
btl %ecx, %eax
jae 0xa2b7
movq %rbx, %rdi
popq %rbx
popq %r14
popq %rbp
jmp 0xa8cb
movzwl 0x50(%rbx), %ebp
xorl %r14d, %r14d
cmpl $0xff, %r14d
ja 0xa2b7
testw %bp, %bp
je 0xa2b7
movl %r14d, %eax
shrl $0x4, %eax
movzwl 0x52(%rbx,%rax,2), %eax
movl %r14d, %ecx
andl $0xf, %ecx
btl %ecx, %eax
jae 0xa2b2
movzbl %r14b, %esi
movq %rbx, %rdi
callq 0xa8cb
decl %ebp
incl %r14d
jmp 0xa280
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/simh[P]simtools/converters/fsio/rt11.c
// Function: rt11OpenFileR
static void *rt11OpenFileR(
  struct mountedFS *mount,
  uint8_t unit,
  char *fname
)
{
  struct rt11OpenFile *file;
  struct rt11FileSpec spec;

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

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

    if (rt11LookupFile(mount, unit, &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 %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x18, %rsp
movq %rdx, %r15
movl %esi, %ebp
movq %rdi, %r14
leaq 0x6(%rsp), %rsi
movq %rdx, %rdi
xorl %edx, %edx
callq 0x82f4
testl %eax, %eax
je 0xa5d7
pushq $0x1
popq %rdi
pushq $0x38
popq %rsi
callq 0x31c0
testq %rax, %rax
je 0xa5c7
movq %rax, %rbx
movzbl %bpl, %esi
leaq 0x6(%rsp), %rdx
movq %r14, %rdi
movq %rax, %rcx
callq 0x9391
testl %eax, %eax
je 0xa5bf
movq 0x28(%r14), %rdi
callq 0x3220
movq %rax, 0x28(%rbx)
testq %rax, %rax
je 0xa5bf
andl $0x0, 0x10(%rbx)
jmp 0xa5c9
movq %rbx, %rdi
callq 0x3050
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq 0xca1a(%rip), %rax      # 0x16ff8
movq (%rax), %rdi
leaq 0x67ef(%rip), %rsi      # 0x10dd7
xorl %ebx, %ebx
movq %r15, %rdx
xorl %eax, %eax
callq 0x31e0
jmp 0xa5c9
// File: /workspace/github_c_makefile_star2_O2/simh[P]simtools/converters/fsio/rt11.c
// Function: rt11CloseFile
static void rt11CloseFile(
  void *filep
)
{
  struct rt11OpenFile *file = filep;
  
  if (file->mode == M_WR) {
    if (SWISSET('a') &&
        !SWISSET('p') &&
        (file->count != RT11_BLOCKSIZE)) {
      char ch = '\032';

      rt11WriteBytes(file, &ch, 1);
    }

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

    /*
     * Flush the current buffer
     */
    rt11WriteBlock(file->mount, file->unit, file->current, file->buffer);
    rt11UpdateFile(file->mount, file->unit, file);
  }

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

// Assembly:
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
cmpl $0x1, 0x10(%rdi)
jne 0xa66f
leaq 0xd9c5(%rip), %rax      # 0x17fd8
movl $0x8001, %ecx           # imm = 0x8001
andl (%rax), %ecx
cmpl $0x1, %ecx
jne 0xa63a
cmpw $0x200, 0x34(%rbx)      # imm = 0x200
je 0xa63a
leaq 0xf(%rsp), %rsi
movb $0x1a, (%rsi)
pushq $0x1
popq %rdx
movq %rbx, %rdi
callq 0x96c2
movzwl 0x30(%rbx), %eax
testw %ax, %ax
jne 0xa64b
movzwl 0x36(%rbx), %eax
movw %ax, 0x30(%rbx)
movzbl 0x20(%rbx), %esi
movzwl %ax, %edx
movq 0x18(%rbx), %rdi
movq 0x28(%rbx), %rcx
callq 0x87b2
movq 0x18(%rbx), %rdi
movzbl 0x20(%rbx), %esi
movq %rbx, %rdx
callq 0x94f3
movq 0x28(%rbx), %rdi
callq 0x3050
movq %rbx, %rdi
addq $0x10, %rsp
popq %rbx
jmp 0x3050
// File: /workspace/github_c_makefile_star2_O2/simh[P]simtools/converters/fsio/rt11.c
// Function: rt11ReadFile
static size_t rt11ReadFile(
  void *filep,
  void *buf,
  size_t buflen
)
{
  struct rt11OpenFile *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) && (rt11ReadBytes(file, &ch, 1) == 1)) {
      if (ch == '\032') {
        /*
         * ^Z indicating EOF
         */
        rt11UngetByte(file);
        break;
      }
      bufr[count++] = ch;
      buflen--;
      if (ch == '\n')
        break;
    }
    return count;
  }

  return rt11ReadBytes(file, bufr, buflen);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
leaq 0xd938(%rip), %rax      # 0x17fd8
testb $0x1, (%rax)
jne 0xa6b7
movq %rbx, %rdi
movq %r15, %rsi
movl %r14d, %edx
callq 0x95ef
cltq
jmp 0xa712
testq %r14, %r14
je 0xa6fc
decq %r14
xorl %r13d, %r13d
leaq 0x7(%rsp), %r12
pushq $0x1
popq %rbp
movq %rbx, %rdi
movq %r12, %rsi
movl %ebp, %edx
callq 0x95ef
cmpl $0x1, %eax
jne 0xa70f
movb 0x7(%rsp), %cl
cmpb $0x1a, %cl
je 0xa700
leaq 0x1(%r13), %rax
movb %cl, (%r15,%r13)
cmpb $0xa, %cl
je 0xa712
cmpq %r13, %r14
movq %rax, %r13
jne 0xa6ca
jmp 0xa712
xorl %eax, %eax
jmp 0xa712
movzwl 0x34(%rbx), %eax
testw %ax, %ax
je 0xa70f
decl %eax
movw %ax, 0x34(%rbx)
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/rt11.c
// Function: rt11DeleteFile
static void rt11DeleteFile(
  void *filep,
  char *UNUSED(fname)
)
{
  struct rt11OpenFile *file = filep;
  struct mountedFS *mount = file->mount;
  struct RT11data *data = &mount->rt11data;

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

  data->buf[file->offset + RT11_DI_STATUS] = le16toh(RT11_E_MPTY);

  rt11MergeEmptyRegions(mount, file->offset);

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

  rt11CloseFile(file);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x18(%rdi), %r14
movzbl 0x20(%rdi), %esi
movzbl 0xc(%rdi), %edx
movq %r14, %rdi
callq 0x89c6
testl %eax, %eax
je 0xa8c0
movzwl 0xe(%rbx), %eax
movw $0x200, 0x472(%r14,%rax,2) # imm = 0x200
movzwl 0xe(%rbx), %r9d
movl %r9d, %edx
movzwl 0x478(%r14), %eax
movl %eax, %r8d
shrl %r8d
leal 0x7(%r8), %ecx
movzwl 0x47a(%r14,%r9,2), %edi
movw $0x5, %si
cmpl $0x5, %r9d
je 0xa7ad
movl %edx, %esi
subl %ecx, %esi
movzwl %si, %r10d
testb $0x2, 0x473(%r14,%r10,2)
jne 0xa7a4
movl %edx, %esi
jmp 0xa7ad
addw 0x47a(%r14,%r10,2), %di
addl %ecx, %r9d
movl $0x200, %r10d           # imm = 0x200
subl %r9d, %r10d
cmpl %ecx, %r10d
jl 0xa7dc
movzwl %r9w, %r10d
testb $0x2, 0x473(%r14,%r10,2)
je 0xa7dc
movl %r10d, %edx
addw 0x47a(%r14,%rdx,2), %di
movl %r9d, %edx
cmpw %si, %dx
je 0xa89a
movzwl %si, %r9d
movw %di, 0x47a(%r14,%r9,2)
andl $0x0, 0x474(%r14,%r9,2)
andw $0x0, 0x478(%r14,%r9,2)
leaq 0x474(%r14), %rdi
movzwl %r8w, %r9d
leal (%rsi,%r9), %r8d
addl $0x7, %r8d
addl %edx, %r9d
addl $0x7, %r9d
shrl %eax
addq $0x6, %rax
addl %ecx, %edx
addl %ecx, %esi
movzwl %si, %r10d
cmpw $0x200, %dx             # imm = 0x200
jae 0xa88f
movzwl %dx, %r11d
movzwl 0x472(%r14,%r11,2), %r11d
movw %r11w, 0x472(%r14,%r10,2)
btl $0xb, %r11d
jb 0xa88f
movl $0x200, %r11d           # imm = 0x200
subl %edx, %r11d
cmpw %cx, %r11w
jb 0xa88f
movzwl %r8w, %r10d
leaq (%rdi,%r10,2), %r10
movzwl %r9w, %r11d
leaq (%rdi,%r11,2), %r11
xorl %r15d, %r15d
cmpq %r15, %rax
je 0xa887
movzwl (%r11,%r15,2), %ebp
movw %bp, (%r10,%r15,2)
incq %r15
jmp 0xa873
addl %ecx, %r8d
addl %ecx, %r9d
jmp 0xa825
movw $0x800, 0x472(%r14,%r10,2) # imm = 0x800
movzbl 0x20(%rbx), %esi
movzbl 0xc(%rbx), %edx
movq %r14, %rdi
callq 0x8a1d
testl %eax, %eax
je 0xa8c0
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0xa5fe
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/simh[P]simtools/converters/fsio/dosmt.c
// Function: dosmtOpenFileR
static void *dosmtOpenFileR(
  struct mountedFS *mount,
  uint8_t UNUSED(unit),
  char *fname
)
{
  struct dosmtOpenFile *file;
  struct dosmtFileSpec spec;

  if (dosmtParseFilespec(mount, fname, &spec, DOSMT_M_NONAME) == 0) {
    fprintf(stderr, "Failed to parse filename \"%s\"\n", fname);
    return NULL;
  }

  if ((file = malloc(sizeof(struct dosmtOpenFile))) != NULL) {
    if (dosmtLookupFile(mount, &spec, file) != 0) {
      file->mode = M_RD;
      file->nextb = DOSMTRCLNT;
      file->tm = 0;
      file->error = 0;
    } else {
      free(file);
      return NULL;
    }
  }
  return file;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rdx, %r15
movq %rdi, %r14
leaq 0x4(%rsp), %rdx
pushq $0x2
popq %rcx
movq %r15, %rsi
callq 0xaa88
testl %eax, %eax
je 0xb720
movl $0x218, %edi            # imm = 0x218
callq 0x3220
testq %rax, %rax
je 0xb711
movq %rax, %rbx
leaq 0x4(%rsp), %rsi
movq %r14, %rdi
movq %rax, %rdx
callq 0xae01
testl %eax, %eax
je 0xb709
andl $0x0, (%rbx)
movl $0x200, 0x210(%rbx)     # imm = 0x200
jmp 0xb713
movq %rbx, %rdi
callq 0x3050
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
movq 0xb8d1(%rip), %rax      # 0x16ff8
movq (%rax), %rdi
leaq 0x56a6(%rip), %rsi      # 0x10dd7
xorl %ebx, %ebx
movq %r15, %rdx
xorl %eax, %eax
callq 0x31e0
jmp 0xb713
// File: /workspace/github_c_makefile_star2_O2/simh[P]simtools/converters/fsio/dosmt.c
// Function: dosmtOpenFileW
static void *dosmtOpenFileW(
  struct mountedFS *mount,
  uint8_t UNUSED(unit),
  char *fname,
  off_t UNUSED(size)
)
{
  struct dosmtOpenFile *file;
  struct dosmtFileSpec spec;
  struct dosmthdr hdr;
  struct tm tm;
  time_t now = time(NULL);
  uint16_t today;

  if (dosmtParseFilespec(mount, fname, &spec, DOSMT_M_NONE) == 0) {
    fprintf(stderr, "Failed to parse filename \"%s\"\n", fname);
    return NULL;
  }

  if ((file = malloc(sizeof(struct dosmtOpenFile))) != NULL) {
    /*
     * Compute a suitable year for file creation date. This year will have
     * the same calendar as the current year but will be in the 20th century
     * so that DOS/BATCH-11 will be able to interpret it correctly.
     */
    localtime_r(&now, &tm);
    tm.tm_year -= 28;

    today = ((tm.tm_year - 70) * 1000) + tm.tm_yday + 1;

    hdr.fname[0] = htole16(spec.name[0]);
    hdr.fname[1] = htole16(spec.name[1]);
    if ((mount->flags & FS_DOSMTEXT) != 0)
      hdr.fname3 = htole16(spec.name[2]);
    else hdr.fname3 = 0;
    hdr.ext = htole16(spec.ext);
    hdr.prog = spec.prog;
    hdr.proj = spec.proj;
    hdr.prot = htole16(mount->dosmtdata.prot);
    hdr.date = htole16(today);

    if (tapeWriteRecord(mount->container, &hdr, sizeof(hdr)) == 0) {
      free(file);
      return NULL;
    }

    file->mode = M_WR;
    file->mount = mount;
    file->nextb = 0;
    file->tm = 0;
    file->error = 0;
  }
  return file;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x60, %rsp
movq %rdx, %r15
movq %rdi, %rbx
xorl %edi, %edi
callq 0x3200
movq %rax, 0x10(%rsp)
leaq 0x4(%rsp), %rdx
movq %rbx, %rdi
movq %r15, %rsi
xorl %ecx, %ecx
callq 0xaa88
testl %eax, %eax
je 0xb83a
movl $0x218, %edi            # imm = 0x218
callq 0x3220
testq %rax, %rax
je 0xb82a
movq %rax, %r14
leaq 0x10(%rsp), %rdi
leaq 0x28(%rsp), %r15
movq %r15, %rsi
callq 0x30b0
movl 0x14(%r15), %eax
movl 0x1c(%r15), %ecx
leal -0x1c(%rax), %edx
movl %edx, 0x14(%r15)
imull $0x3e8, %eax, %eax      # imm = 0x3E8
movl 0x6(%rsp), %edx
leaq 0x18(%rsp), %rsi
movl %edx, (%rsi)
movl 0x30(%rbx), %edx
shll $0x7, %edx
movswl %dx, %edx
shrl $0xf, %edx
andw 0xa(%rsp), %dx
addl %ecx, %eax
addl $0xffff8131, %eax       # imm = 0xFFFF8131
movw %dx, 0xc(%rsi)
movzwl 0xc(%rsp), %ecx
movw %cx, 0x4(%rsi)
movzwl 0xe(%rsp), %ecx
rolw $0x8, %cx
movw %cx, 0x6(%rsi)
movzbl 0x252(%rbx), %ecx
movw %cx, 0x8(%rsi)
movw %ax, 0xa(%rsi)
movq 0x38(%rbx), %rdi
pushq $0xe
popq %rdx
callq 0x5626
testl %eax, %eax
je 0xb822
movl $0x1, (%r14)
movq %rbx, 0x8(%r14)
andl $0x0, 0x210(%r14)
jmp 0xb82d
movq %r14, %rdi
callq 0x3050
xorl %r14d, %r14d
movq %r14, %rax
addq $0x60, %rsp
popq %rbx
popq %r14
popq %r15
retq
movq 0xb7b7(%rip), %rax      # 0x16ff8
movq (%rax), %rdi
leaq 0x558c(%rip), %rsi      # 0x10dd7
xorl %r14d, %r14d
movq %r15, %rdx
xorl %eax, %eax
callq 0x31e0
jmp 0xb82d
// File: /workspace/github_c_makefile_star2_O2/simh[P]simtools/converters/fsio/dosmt.c
// Function: dosmtCloseFile
static void dosmtCloseFile(
  void *filep
)
{
  struct dosmtOpenFile *file = filep;
  struct mountedFS *mount = file->mount;
  struct DOSMTdata *data = &mount->dosmtdata;
  uint32_t status;

  if (file->mode == M_RD) {
    if (file->tm == 0) {
      /*
       * Tape mark not seen, skip to end of current file.
       */
      do {
        if ((status = tapeReadRecordLength(mount->container)) == ST_FAIL) {
          fprintf(stderr,
                  "Error positioning \"%s\", rewinding\n", mount->name);
          tapeRewind(mount->container);
          status = ST_TM;
        }
      } while ((status != ST_EOM) && (status != ST_TM));

      if (status == ST_EOM)
        tapeSkipRecordR(mount->container);
    }
  } else {
    if (file->nextb != 0) {
      /*
       * The are some pending output byte(s), flush a final record to the tape.
       */
      if (tapeWriteRecord(mount->container, file->buf, DOSMTRCLNT) == 0)
        file->error = 1;
    }
    if (tapeWriteTM(mount->container) == 0)
      file->error = 1;

    data->eot = tapeGetPosition(mount->container);

    if (tapeWriteEOM(mount->container, 1) == 0)
      file->error = 1;

    if (file->error != 0) {
      ERROR("Panic: Error writing on \"%s\"\n", mount->name);
      exit(3);
    }
  }

  free(file);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %r14
movq 0x8(%rdi), %rbx
cmpl $0x0, (%rdi)
je 0xb923
cmpw $0x0, 0x210(%r14)
je 0xb8e2
movq 0x38(%rbx), %rdi
leaq 0x10(%r14), %rsi
movl $0x200, %edx            # imm = 0x200
callq 0x5626
testl %eax, %eax
jne 0xb8e2
movb $0x1, 0x213(%r14)
movq 0x38(%rbx), %rdi
callq 0x56ee
testl %eax, %eax
jne 0xb8f7
movb $0x1, 0x213(%r14)
movq 0x38(%rbx), %rdi
callq 0x53df
movq %rax, 0x248(%rbx)
movq 0x38(%rbx), %rdi
pushq $0x1
popq %rsi
callq 0x569f
testl %eax, %eax
je 0xb966
cmpb $0x0, 0x213(%r14)
je 0xb957
jmp 0xb96e
cmpb $0x0, 0x212(%r14)
jne 0xb957
movq 0x38(%rbx), %rdi
callq 0x53fc
cmpl $0xfefefefe, %eax       # imm = 0xFEFEFEFE
je 0xb9c1
leal -0x1(%rax), %ecx
cmpl $-0x2, %ecx
jb 0xb92d
cmpl $-0x1, %eax
jne 0xb957
movq 0x38(%rbx), %rdi
callq 0x547e
movq %r14, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x3050
movb $0x1, 0x213(%r14)
movq 0xb683(%rip), %rax      # 0x16ff8
movq (%rax), %rdi
addq $0x8, %rbx
leaq 0x5ce1(%rip), %rsi      # 0x11664
movq %rbx, %rdx
xorl %eax, %eax
callq 0x31e0
leaq 0xc634(%rip), %rax      # 0x17fc8
movq (%rax), %rdi
testq %rdi, %rdi
je 0xb9b9
movq 0xb61d(%rip), %rax      # 0x16fc0
cmpq (%rax), %rdi
je 0xb9b9
leaq 0x5cb5(%rip), %rsi      # 0x11664
movq %rbx, %rdx
xorl %eax, %eax
callq 0x31e0
pushq $0x3
popq %rdi
callq 0x32c0
movq 0xb630(%rip), %rax      # 0x16ff8
movq (%rax), %rdi
leaq 0x8(%rbx), %rdx
leaq 0x5c6b(%rip), %rsi      # 0x11641
xorl %eax, %eax
callq 0x31e0
movq 0x38(%rbx), %rdi
callq 0x57e5
jmp 0xb957
// File: /workspace/github_c_makefile_star2_O2/simh[P]simtools/converters/fsio/local.c
// Function: localFileSize
static off_t localFileSize(
  void *filep
)
{
  FILE *file = filep;
  struct stat stat;

  if (!SWISSET('a'))
    if (fstat(fileno(file), &stat) == 0)
      return stat.st_size;

  return 0;
}

// Assembly:
subq $0x98, %rsp
leaq 0xc406(%rip), %rax      # 0x17fd8
testb $0x1, (%rax)
jne 0xbbec
callq 0x3210
leaq 0x8(%rsp), %rsi
movl %eax, %edi
callq 0x32f0
testl %eax, %eax
je 0xbbf6
xorl %eax, %eax
addq $0x98, %rsp
retq
movq 0x38(%rsp), %rax
jmp 0xbbee
// File: /workspace/github_c_makefile_star2_O2/simh[P]simtools/converters/fsio/local.c
// Function: localReadFile
static size_t localReadFile(
  void *file,
  void *buf,
  size_t buflen
)
{
  if (SWISSET('a')) {
    char *bufr = buf;
    int readlen;

    if (fgets(bufr, buflen - 1, file) == NULL)
      return 0;

    /*
     * Translate terminating \n into \r\n unless it is already there
     */
    if ((readlen = strlen(bufr)) != 0) {
      if (bufr[readlen - 1] == '\n') {
        if ((readlen == 1) || (bufr[readlen - 2] != '\r'))
          strcpy(&bufr[readlen - 1], "\r\n");
      }
    }
    return strlen(bufr);
  }
  return fread(buf, sizeof(char), buflen, file);
}

// Assembly:
pushq %rbx
movq %rsi, %rbx
movq %rdi, %rcx
leaq 0xc3c8(%rip), %rax      # 0x17fd8
testb $0x1, (%rax)
jne 0xbc21
pushq $0x1
popq %rsi
movq %rbx, %rdi
popq %rbx
jmp 0x30f0
decl %edx
movq %rbx, %rdi
movl %edx, %esi
movq %rcx, %rdx
callq 0x31b0
testq %rax, %rax
je 0xbc90
movq %rbx, %rdi
callq 0x3130
testl %eax, %eax
je 0xbc87
movq %rax, %rdx
shlq $0x20, %rdx
movabsq $-0x100000000, %rcx     # imm = 0xFFFFFFFF00000000
addq %rdx, %rcx
sarq $0x20, %rcx
cmpb $0xa, (%rbx,%rcx)
jne 0xbc87
cmpl $0x1, %eax
je 0xbc7b
movabsq $-0x200000000, %rax     # imm = 0xFFFFFFFE00000000
addq %rax, %rdx
sarq $0x20, %rdx
cmpb $0xd, (%rbx,%rdx)
je 0xbc87
addq %rbx, %rcx
movb $0x0, 0x2(%rcx)
movw $0xa0d, (%rcx)          # imm = 0xA0D
movq %rbx, %rdi
popq %rbx
jmp 0x3130
xorl %eax, %eax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/simh[P]simtools/converters/fsio/local.c
// Function: localWriteFile
static size_t localWriteFile(
  void *file,
  void *buf,
  size_t buflen
)
{
  if (SWISSET('a')) {
    char *bufw = buf;

    if (buflen >= 2)
      if ((bufw[buflen - 2] == '\r') && (bufw[buflen - 1] == '\n')) {
        bufw[buflen - 2] = '\n';
        buflen--;
      }
  }
  return fwrite(buf, sizeof(char), buflen, file);
}

// Assembly:
movq %rsi, %rax
movq %rdi, %rcx
cmpq $0x2, %rdx
jb 0xbcc4
leaq 0xc331(%rip), %rsi      # 0x17fd8
movl (%rsi), %esi
andl $0x1, %esi
je 0xbcc4
cmpb $0xd, -0x2(%rax,%rdx)
jne 0xbcc4
cmpb $0xa, -0x1(%rax,%rdx)
jne 0xbcc4
movb $0xa, -0x2(%rax,%rdx)
decq %rdx
pushq $0x1
popq %rsi
movq %rax, %rdi
jmp 0x32d0
// File: /workspace/github_c_makefile_star2_O2/simh[P]simtools/converters/fsio/os8.c
// Function: rk05ReadBlock
static int rk05ReadBlock(
  struct mountedFS *mount,
  uint8_t unit,
  unsigned int block,
  void *buf
)
{
  int status = 0;
  unsigned int base = unit == 0 ? 0 : OS8_RK05FS_BLKS;

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

  status = FSioReadBlock(mount, base + block, buf);

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

  return status;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %edx, %r15d
movl %esi, %ebx
movq %rdi, %r14
cmpl $0xcb0, %edx            # imm = 0xCB0
jae 0xbd5b
leal 0xcb0(%r15), %esi
testb %bl, %bl
cmovel %r15d, %esi
movq %r14, %rdi
movq %rcx, %rdx
callq 0x4c23
movl %eax, %ebp
testl %eax, %eax
je 0xbdb8
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq 0xb296(%rip), %rax      # 0x16ff8
movq (%rax), %rdi
addq $0x8, %r14
leaq 0x5204(%rip), %rsi      # 0x10f74
xorl %ebp, %ebp
movl %r15d, %edx
movq %r14, %rcx
movl %ebx, %r8d
xorl %eax, %eax
callq 0x31e0
leaq 0xc23f(%rip), %rax      # 0x17fc8
movq (%rax), %rdi
testq %rdi, %rdi
je 0xbd4e
movq 0xb228(%rip), %rax      # 0x16fc0
cmpq (%rax), %rdi
je 0xbd4e
leaq 0x51d0(%rip), %rsi      # 0x10f74
xorl %ebp, %ebp
movl %r15d, %edx
movq %r14, %rcx
movl %ebx, %r8d
xorl %eax, %eax
callq 0x31e0
jmp 0xbd4e
movq 0xb239(%rip), %rax      # 0x16ff8
movq (%rax), %rdi
addq $0x8, %r14
leaq 0x5209(%rip), %rsi      # 0x10fd6
xorl %ebp, %ebp
movq %r14, %rdx
movl %ebx, %ecx
xorl %eax, %eax
callq 0x31e0
leaq 0xc1e6(%rip), %rax      # 0x17fc8
movq (%rax), %rdi
testq %rdi, %rdi
je 0xbd4e
movq 0xb1cb(%rip), %rax      # 0x16fc0
cmpq (%rax), %rdi
je 0xbd4e
leaq 0x51d1(%rip), %rsi      # 0x10fd6
xorl %ebp, %ebp
movq %r14, %rdx
movl %ebx, %ecx
xorl %eax, %eax
callq 0x31e0
jmp 0xbd4e
// File: /workspace/github_c_makefile_star2_O2/simh[P]simtools/converters/fsio/os8.c
// Function: rk05WriteBlock
static int rk05WriteBlock(
  struct mountedFS *mount,
  uint8_t unit,
  unsigned int block,
  void *buf
)
{
  int status = 0;
  unsigned int base = unit == 0 ? 0 : OS8_RK05FS_BLKS;

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

  status = FSioWriteBlock(mount, base + block, buf);

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

  return status;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %edx, %r15d
movl %esi, %ebx
movq %rdi, %r14
cmpl $0xcb0, %edx            # imm = 0xCB0
jae 0xbe5a
leal 0xcb0(%r15), %esi
testb %bl, %bl
cmovel %r15d, %esi
movq %r14, %rdi
movq %rcx, %rdx
callq 0x4c6a
movl %eax, %ebp
testl %eax, %eax
je 0xbeb7
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq 0xb197(%rip), %rax      # 0x16ff8
movq (%rax), %rdi
addq $0x8, %r14
leaq 0x5195(%rip), %rsi      # 0x11004
xorl %ebp, %ebp
movl %r15d, %edx
movq %r14, %rcx
movl %ebx, %r8d
xorl %eax, %eax
callq 0x31e0
leaq 0xc140(%rip), %rax      # 0x17fc8
movq (%rax), %rdi
testq %rdi, %rdi
je 0xbe4d
movq 0xb129(%rip), %rax      # 0x16fc0
cmpq (%rax), %rdi
je 0xbe4d
leaq 0x5161(%rip), %rsi      # 0x11004
xorl %ebp, %ebp
movl %r15d, %edx
movq %r14, %rcx
movl %ebx, %r8d
xorl %eax, %eax
callq 0x31e0
jmp 0xbe4d
movq 0xb13a(%rip), %rax      # 0x16ff8
movq (%rax), %rdi
addq $0x8, %r14
leaq 0x510a(%rip), %rsi      # 0x10fd6
xorl %ebp, %ebp
movq %r14, %rdx
movl %ebx, %ecx
xorl %eax, %eax
callq 0x31e0
leaq 0xc0e7(%rip), %rax      # 0x17fc8
movq (%rax), %rdi
testq %rdi, %rdi
je 0xbe4d
movq 0xb0cc(%rip), %rax      # 0x16fc0
cmpq (%rax), %rdi
je 0xbe4d
leaq 0x50d2(%rip), %rsi      # 0x10fd6
xorl %ebp, %ebp
movq %r14, %rdx
movl %ebx, %ecx
xorl %eax, %eax
callq 0x31e0
jmp 0xbe4d
// File: /workspace/github_c_makefile_star2_O2/simh[P]simtools/converters/fsio/os8.c
// Function: os8ReadBlock
int os8ReadBlock(
  struct mountedFS *mount,
  uint8_t unit,
  unsigned int block,
  void *buf
)
{
  struct OS8data *data = &mount->os8data;
  void *buffer = buf == NULL ? data->buf : buf;

  if ((unit >= data->device->filesys) || ((data->valid & (1 << unit)) == 0)) {
    ERROR("Invalid device \"%s%o:\"\n", mount->name, unit);
    return 0;
  }

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

  return (*data->device->readBlock)(mount, unit, block, buffer);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x5c(%rdi), %r15
testq %rcx, %rcx
cmovneq %rcx, %r15
movl %esi, %ebp
movq 0x50(%rdi), %rax
cmpb %bpl, 0x8(%rax)
jbe 0xc64c
movzbl 0x59(%rbx), %ecx
btl %ebp, %ecx
jae 0xc64c
movl %edx, %r14d
testb $0x2, 0x30(%rbx)
je 0xc62f
leaq 0xb9b7(%rip), %rax      # 0x17fc8
movq (%rax), %rdi
leaq 0x8(%rbx), %rdx
leaq 0x5291(%rip), %rsi      # 0x118b0
movl %ebp, %ecx
movl %r14d, %r8d
xorl %eax, %eax
callq 0x31e0
movq 0x50(%rbx), %rax
movq 0x38(%rax), %rax
movzbl %bpl, %esi
movq %rbx, %rdi
movl %r14d, %edx
movq %r15, %rcx
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmpq *%rax
movq 0xa9a5(%rip), %rax      # 0x16ff8
movq (%rax), %rdi
addq $0x8, %rbx
leaq 0x498b(%rip), %rsi      # 0x10fec
movq %rbx, %rdx
movl %ebp, %ecx
xorl %eax, %eax
callq 0x31e0
leaq 0xb954(%rip), %rax      # 0x17fc8
movq (%rax), %rdi
testq %rdi, %rdi
je 0xc69b
movq 0xa93d(%rip), %rax      # 0x16fc0
cmpq (%rax), %rdi
je 0xc69b
leaq 0x495d(%rip), %rsi      # 0x10fec
movq %rbx, %rdx
movl %ebp, %ecx
xorl %eax, %eax
callq 0x31e0
xorl %eax, %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/os8.c
// Function: os8WriteBlock
int os8WriteBlock(
  struct mountedFS *mount,
  uint8_t unit,
  unsigned int block,
  void *buf
)
{
  struct OS8data *data = &mount->os8data;
  void *buffer = buf == NULL ? data->buf : buf;

  if ((unit >= data->device->filesys) || ((data->valid & (1 << unit)) == 0)) {
    ERROR("Invalid device \"%s%o:\"\n", mount->name, unit);
    return 0;
  }

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

  return (*data->device->writeBlock)(mount, unit, block, buffer);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x5c(%rdi), %r15
testq %rcx, %rcx
cmovneq %rcx, %r15
movl %esi, %ebp
movq 0x50(%rdi), %rax
cmpb %bpl, 0x8(%rax)
jbe 0xc71d
movzbl 0x59(%rbx), %ecx
btl %ebp, %ecx
jae 0xc71d
movl %edx, %r14d
testb $0x2, 0x30(%rbx)
je 0xc700
leaq 0xb8e6(%rip), %rax      # 0x17fc8
movq (%rax), %rdi
leaq 0x8(%rbx), %rdx
leaq 0x51e9(%rip), %rsi      # 0x118d9
movl %ebp, %ecx
movl %r14d, %r8d
xorl %eax, %eax
callq 0x31e0
movq 0x50(%rbx), %rax
movq 0x40(%rax), %rax
movzbl %bpl, %esi
movq %rbx, %rdi
movl %r14d, %edx
movq %r15, %rcx
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmpq *%rax
movq 0xa8d4(%rip), %rax      # 0x16ff8
movq (%rax), %rdi
addq $0x8, %rbx
leaq 0x48ba(%rip), %rsi      # 0x10fec
movq %rbx, %rdx
movl %ebp, %ecx
xorl %eax, %eax
callq 0x31e0
leaq 0xb883(%rip), %rax      # 0x17fc8
movq (%rax), %rdi
testq %rdi, %rdi
je 0xc76c
movq 0xa86c(%rip), %rax      # 0x16fc0
cmpq (%rax), %rdi
je 0xc76c
leaq 0x488c(%rip), %rsi      # 0x10fec
movq %rbx, %rdx
movl %ebp, %ecx
xorl %eax, %eax
callq 0x31e0
xorl %eax, %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/os8.c
// Function: toSixbit
static void toSixbit(
  char ch,
  uint16_t *ptr,
  int which
)
{
  unsigned long i;

  for (i = 0; i < sizeof(sixbit); i++)
    if (ch == sixbit[i]) {
      if (which == 0)
        *ptr = (i << 6) | (*ptr & 0x3F);
      else *ptr = (*ptr & 0xFC0) | i;
      return;
    }
}

// Assembly:
xorl %ecx, %ecx
leaq 0x4f12(%rip), %r8       # 0x11830
xorl %eax, %eax
cmpq $0x40, %rax
je 0xc952
cmpb %dil, (%rax,%r8)
je 0xc934
incq %rax
addl $-0x40, %ecx
jmp 0xc920
movzwl (%rsi), %edi
testl %edx, %edx
je 0xc94a
shrl $0x6, %edi
andl $0x3f, %edi
shll $0x6, %edi
addl %edi, %eax
movl %eax, %edi
jmp 0xc94f
andl $0x3f, %edi
subl %ecx, %edi
movw %di, (%rsi)
retq
// File: /workspace/github_c_makefile_star2_O2/simh[P]simtools/converters/fsio/os8.c
// Function: os8UnitValid
static int os8UnitValid(
  struct OS8data *data,
  uint8_t unit
)
{
  struct OS8device *device;

  if ((device = data->device) != NULL) {
    if (unit < device->filesys)
      return (data->valid & (1 << unit)) != 0 ? 1 : 0;
  }
  return 0;
}

// Assembly:
movq 0x8(%rdi), %rcx
xorl %eax, %eax
testq %rcx, %rcx
je 0xd366
cmpb %sil, 0x8(%rcx)
jbe 0xd366
movzbl 0x11(%rdi), %ecx
movzbl %sil, %edx
xorl %eax, %eax
btl %edx, %ecx
setb %al
retq
// File: /workspace/github_c_makefile_star2_O2/simh[P]simtools/converters/fsio/os8.c
// Function: os8UpdateFile
void os8UpdateFile(
  struct mountedFS *mount,
  uint8_t unit,
  struct os8OpenFile *file
)
{
  struct OS8data *data = &mount->os8data;
  uint16_t off = file->offset;
  uint16_t empty = off + file->extra + OS8_DI_SIZE;
  uint16_t length = file->current == 0 ? 0 : file->current - file->start;
  uint16_t left = file->length - length;
  uint16_t space;

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

  /*
   * The directory entry is complete except for the # of blocks in use
   * which we can now update.
   */
  data->buf[off + file->extra + OS8_DI_LENGTH] = htole16(os8Value(-length));

  /*
   * Update the remaining space in the following empty file descriptor.
   */
  space = os8Neg(le16toh(data->buf[empty + OS8_ED_LENGTH])) + left;
  data->buf[empty + OS8_ED_LENGTH] = htole16(os8Value(-space));

  if (space == 0)
    /*
     * Remove the empty directory entry since it now occupies 0 blocks
     */
    os8SlideUp(mount, empty, empty + OS8_ED_SIZE, file->entrysz, file->remain);

  os8WriteBlock(mount, unit, file->segment, NULL);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r14
movq %rdi, %rbx
movzwl 0xe(%rdx), %r12d
movzwl 0x3a(%rdx), %r13d
testw %r13w, %r13w
je 0xd38f
subw 0x38(%r14), %r13w
jmp 0xd392
xorl %r13d, %r13d
movzwl 0x12(%r14), %r15d
addw %r12w, %r15w
movzwl 0xa(%r14), %ebp
movzbl 0xc(%r14), %edx
movzbl %sil, %esi
movq %rbx, %rdi
movl %esi, 0x4(%rsp)
xorl %ecx, %ecx
callq 0xc5d7
testl %eax, %eax
je 0xd434
leal 0x5(%r15), %eax
subl %r13d, %ebp
negl %r13d
movl $0xfff, %ecx            # imm = 0xFFF
andl %ecx, %r13d
movzwl 0x12(%r14), %edx
addl %edx, %r12d
movw %r13w, 0x64(%rbx,%r12,2)
movzwl %ax, %esi
xorl %eax, %eax
subw 0x5e(%rbx,%rsi,2), %ax
andl %ecx, %eax
addl %ebp, %eax
movl %eax, %edx
negl %edx
andl %ecx, %edx
movw %dx, 0x5e(%rbx,%rsi,2)
testw %ax, %ax
jne 0xd413
addl $0x7, %r15d
movzwl 0x10(%r14), %ecx
movzwl 0x14(%r14), %r8d
movzwl %r15w, %edx
movq %rbx, %rdi
callq 0xd443
movzbl 0xc(%r14), %edx
movq %rbx, %rdi
movl 0x4(%rsp), %esi
xorl %ecx, %ecx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xc6a8
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/os8.c
// Function: os8SlideUp
static void os8SlideUp(
  struct mountedFS *mount,
  uint16_t dst,
  uint16_t src,
  uint16_t entrysz,
  uint16_t count
)
{
  struct OS8data *data = &mount->os8data;
  uint16_t i, j, len;

  if (count != 0) {
    for (i = 0; i < count; i++) {
      len = os8Word(le16toh(data->buf[src + OS8_DI_FNAME1])) ? entrysz : OS8_ED_SIZE;

      for (j = 0; j < len; j++)
        data->buf[dst++] = data->buf[src++];
    }
  }
}

// Assembly:
testl %r8d, %r8d
je 0xd493
pushq %rbx
xorl %eax, %eax
movl $0x2, %r9d
cmpw %r8w, %ax
je 0xd492
movzwl %dx, %r10d
movzwl 0x5c(%rdi,%r10,2), %r10d
testw $0xfff, %r10w           # imm = 0xFFF
movl %ecx, %r10d
cmovel %r9d, %r10d
subw $0x1, %r10w
jb 0xd48e
movzwl %dx, %r11d
incl %edx
movzwl 0x5c(%rdi,%r11,2), %r11d
movzwl %si, %ebx
incl %esi
movw %r11w, 0x5c(%rdi,%rbx,2)
jmp 0xd46e
incl %eax
jmp 0xd451
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/simh[P]simtools/converters/fsio/os8.c
// Function: os8Size
static size_t os8Size(void)
{
  if (SWISSET('t')) {
    struct OS8device *dev = OS8Devices;
    
    while (dev->name != NULL) {
      if (strcmp(SWGETVAL('t'), dev->name) == 0)
        return dev->diskSize;
     
      dev++;
    }
  }
  return OS8Devices[0].diskSize;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
leaq 0xa2cc(%rip), %rax      # 0x17fd8
testb $0x8, 0x2(%rax)
jne 0xdd1b
leaq 0xa0c7(%rip), %rbx      # 0x17de0
jmp 0xdd4e
leaq 0xa0be(%rip), %rbx      # 0x17de0
leaq 0xa2b7(%rip), %r15      # 0x17fe0
movq %rbx, %r14
movq -0x10(%r14), %rsi
testq %rsi, %rsi
je 0xdd4e
movq 0x98(%r15), %rdi
callq 0x31d0
testl %eax, %eax
je 0xdd4b
addq $0x48, %r14
jmp 0xdd2c
movq %r14, %rbx
movq (%rbx), %rax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/simh[P]simtools/converters/fsio/os8.c
// Function: os8Set
static void os8Set(
  struct mountedFS *mount,
  uint8_t UNUSED(unit),
  uint8_t UNUSED(present)
)
{
  struct OS8data *data = &mount->os8data;
  int idx = 0;
  unsigned long year;
  char *endptr;

  while (setCmds[idx] != NULL) {
    if (strcmp(words[1], setCmds[idx]) == 0) {
      switch (idx) {
        case OS8SET_YEAR:
          if (args == 3) {
            if (strcmp(words[2], "none") == 0) {
              data->date = 0;
              return;
            }
            year = strtoul(words[2], &endptr, 10);
            if ((*endptr == '\0') && (year <= 7)) {
              struct tm tm;
              time_t now = time(NULL);

              localtime_r(&now, &tm);

              data->date = (tm.tm_mon + 1) << 8;
              data->date |= (tm.tm_mday + 1) << 3;
              data->date |= year;
              return;
            }
          }
          fprintf(stderr, "os8: Invalid syntax for \"set year\"\n");
          return;

        default:
          fprintf(stderr, "os8: \"%s\" not implemented\n", words[1]);
          return;
      }
    }
    idx++;
  }
  fprintf(stderr, "os8: Unknown set command \"%s\"\n", words[1]);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x50, %rsp
movq %rdi, %rbx
leaq 0xa1dd(%rip), %rax      # 0x180b8
movq (%rax), %r15
movq 0x8(%r15), %r14
xorl %r12d, %r12d
leaq 0x8ec4(%rip), %r13      # 0x16db0
cmpq $0x8, %r12
je 0xdfcd
movq (%r12,%r13), %rsi
movq %r14, %rdi
callq 0x31d0
addq $0x8, %r12
testl %eax, %eax
jne 0xdeec
leaq 0xa19f(%rip), %rax      # 0x180b0
cmpl $0x3, (%rax)
jne 0xdfa4
movq 0x10(%r15), %r14
leaq 0x3c08(%rip), %rsi      # 0x11b2d
movq %r14, %rdi
callq 0x31d0
testl %eax, %eax
je 0xdf91
leaq 0x10(%rsp), %r15
pushq $0xa
popq %rdx
movq %r14, %rdi
movq %r15, %rsi
callq 0x32a0
movq %rax, %r14
movq (%r15), %rax
cmpb $0x0, (%rax)
jne 0xdfa4
cmpq $0x7, %r14
ja 0xdfa4
xorl %edi, %edi
callq 0x3200
leaq 0x8(%rsp), %rdi
movq %rax, (%rdi)
leaq 0x18(%rsp), %r15
movq %r15, %rsi
callq 0x30b0
movl 0xc(%r15), %eax
movl 0x10(%r15), %ecx
shll $0x8, %ecx
addl $0x100, %ecx            # imm = 0x100
leal (%r14,%rax,8), %eax
addl $0x8, %eax
orl %ecx, %eax
movw %ax, 0x5a(%rbx)
jmp 0xdf96
andw $0x0, 0x5a(%rbx)
addq $0x50, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movq 0x904d(%rip), %rax      # 0x16ff8
movq (%rax), %rcx
leaq 0x3b7d(%rip), %rdi      # 0x11b32
pushq $0x23
popq %rsi
pushq $0x1
popq %rdx
addq $0x50, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x32d0
movq 0x9024(%rip), %rax      # 0x16ff8
movq (%rax), %rdi
leaq 0x3b78(%rip), %rsi      # 0x11b56
movq %r14, %rdx
xorl %eax, %eax
addq $0x50, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x31e0
// File: /workspace/github_c_makefile_star2_O2/simh[P]simtools/converters/fsio/os8.c
// Function: os8Info
static void os8Info(
  struct mountedFS *mount,
  uint8_t unit,
  uint8_t present
)
{
  struct OS8data *data = &mount->os8data;
  struct OS8device *device = data->device;

  if (present) {
    if (os8UnitValid(data, unit))
      info(mount, unit);
  } else {
    uint16_t i;

    /*
     * Display information about all valid units
     */
    for (i = 0; i < device->filesys; i++)
      if (os8UnitValid(data, i))
        info(mount, i);
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x48(%rdi), %r14
testl %edx, %edx
je 0xe02d
movzbl %sil, %ebp
movq %r14, %rdi
movl %ebp, %esi
callq 0xd345
testl %eax, %eax
je 0xe05d
movq %rbx, %rdi
movl %ebp, %esi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0xe4b9
movq 0x50(%rbx), %r15
xorl %ebp, %ebp
movzbl 0x8(%r15), %eax
cmpw %ax, %bp
jae 0xe05d
movzbl %bpl, %esi
movq %r14, %rdi
callq 0xd345
testl %eax, %eax
je 0xe059
movzbl %bpl, %esi
movq %rbx, %rdi
callq 0xe4b9
incl %ebp
jmp 0xe033
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/simh[P]simtools/converters/fsio/os8.c
// Function: os8OpenFileR
static void *os8OpenFileR(
  struct mountedFS *mount,
  uint8_t unit,
  char *fname
)
{
  struct os8OpenFile *file;
  struct os8FileSpec spec;

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

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

    if (os8LookupFile(mount, unit, &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 %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x18, %rsp
movq %rdx, %r15
movl %esi, %ebp
movq %rdi, %r14
leaq 0x6(%rsp), %rsi
movq %rdx, %rdi
xorl %edx, %edx
callq 0xc779
testl %eax, %eax
je 0xe370
pushq $0x1
popq %rdi
pushq $0x50
popq %rsi
callq 0x31c0
testq %rax, %rax
je 0xe360
movq %rax, %rbx
movzbl %bpl, %esi
leaq 0x6(%rsp), %rdx
movq %r14, %rdi
movq %rax, %rcx
callq 0xd129
testl %eax, %eax
je 0xe358
movq 0x28(%r14), %rdi
callq 0x3220
movq %rax, 0x30(%rbx)
testq %rax, %rax
je 0xe358
andl $0x0, 0x18(%rbx)
jmp 0xe362
movq %rbx, %rdi
callq 0x3050
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq 0x8c81(%rip), %rax      # 0x16ff8
movq (%rax), %rdi
leaq 0x2a56(%rip), %rsi      # 0x10dd7
xorl %ebx, %ebx
movq %r15, %rdx
xorl %eax, %eax
callq 0x31e0
jmp 0xe362
// File: /workspace/github_c_makefile_star2_O2/simh[P]simtools/converters/fsio/os8.c
// Function: os8CloseFile
static void os8CloseFile(
  void *filep
)
{
  struct os8OpenFile *file = filep;

  if (file->mode == M_WR) {
    if (file->current != 0)
      /*
       * Flush the current buffer.
       */
      os8WriteBlock(file->mount, file->unit, file->current++, file->buffer);

    os8UpdateFile(file->mount, file->unit, file);
  }

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

// Assembly:
pushq %rbx
movq %rdi, %rbx
cmpl $0x1, 0x18(%rdi)
jne 0xe3d8
movzwl 0x3a(%rbx), %edx
testl %edx, %edx
je 0xe3c8
movzbl 0x28(%rbx), %esi
leal 0x1(%rdx), %eax
movw %ax, 0x3a(%rbx)
movq 0x20(%rbx), %rdi
movq 0x30(%rbx), %rcx
callq 0xc6a8
movq 0x20(%rbx), %rdi
movzbl 0x28(%rbx), %esi
movq %rbx, %rdx
callq 0xd367
movq 0x30(%rbx), %rdi
callq 0x3050
movq %rbx, %rdi
popq %rbx
jmp 0x3050