LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O1/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 %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %edx, %ebp
movq %rsi, %rbx
movq %rdi, %r14
cmpw $0x0, 0x30(%rdi)
jne 0xacba
movq 0x28(%r14), %rdi
movl $0x200, %edx            # imm = 0x200
xorl %esi, %esi
callq 0x3170
movzwl 0x36(%r14), %eax
movw %ax, 0x30(%r14)
movw $0x0, 0x34(%r14)
addw 0x8(%r14), %ax
decl %eax
movw %ax, 0x32(%r14)
testl %ebp, %ebp
je 0xad2d
movl %ebp, %r15d
xorl %r12d, %r12d
cmpw $0x200, 0x34(%r14)      # imm = 0x200
jne 0xad0b
movzwl 0x30(%r14), %edx
cmpw 0x32(%r14), %dx
je 0xad32
movzbl 0x20(%r14), %esi
movq 0x18(%r14), %rdi
movq 0x28(%r14), %rcx
callq 0x9e88
testl %eax, %eax
je 0xad2d
movq 0x28(%r14), %rdi
movl $0x200, %edx            # imm = 0x200
xorl %esi, %esi
callq 0x3170
incw 0x30(%r14)
movw $0x0, 0x34(%r14)
movb (%rbx,%r12), %al
movq 0x28(%r14), %rcx
movzwl 0x34(%r14), %edx
leal 0x1(%rdx), %esi
movw %si, 0x34(%r14)
movb %al, (%rcx,%rdx)
incq %r12
cmpl %r12d, %r15d
jne 0xacc4
jmp 0xad35
xorl %r15d, %r15d
jmp 0xad35
movl %r12d, %r15d
movl %r15d, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/simh[P]simtools/converters/fsio/rt11.c
// Function: rt11OpenFileW
void *rt11OpenFileW(
  struct mountedFS *mount,
  uint8_t unit,
  char *fname,
  off_t size
)
{
  struct rt11OpenFile *file;
  struct rt11FileSpec spec;
  uint16_t blocks = 0;

  if (size != 0)
    blocks = (size + (RT11_BLOCKSIZE - 1)) / RT11_BLOCKSIZE;

  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) {
        if (rt11CreateFile(mount, unit, &spec, file, blocks) == 0) {
          ERROR("Failed to create file \"%s\"\n", fname);
          free(file->buffer);
          free(file);
          return NULL;
        } else file->mode = M_WR;
      } else {
        ERROR("Buffer allocation failure for \"%s\"\n", fname);
        free(file);
        return NULL;
      }
    } else {
      ERROR("File \"%s\" already exists\n", fname);
      free(file);
      return NULL;
    }
  } else ERROR("Memory allocation failure\n");
  return file;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x20, %rsp
movq %rdx, %rbx
movl %esi, %ebp
movq %rdi, %r15
testq %rcx, %rcx
je 0xad75
addq $0x1ff, %rcx            # imm = 0x1FF
leal 0x1ff(%rcx), %r12d
testq %rcx, %rcx
cmovnsl %ecx, %r12d
shrl $0x9, %r12d
jmp 0xad78
xorl %r12d, %r12d
leaq 0x6(%rsp), %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x9a00
testl %eax, %eax
je 0xae1c
movl $0x38, %edi
callq 0x3210
movq %rax, %r14
testq %rax, %rax
je 0xae3c
xorps %xmm0, %xmm0
movups %xmm0, 0x20(%r14)
movups %xmm0, 0x10(%r14)
movups %xmm0, (%r14)
movq $0x0, 0x30(%r14)
movzbl %bpl, %ebp
leaq 0x6(%rsp), %rdx
movq %r15, %rdi
movl %ebp, %esi
movq %r14, %rcx
callq 0xa8ff
testl %eax, %eax
jne 0xae51
movq 0x28(%r15), %rdi
callq 0x3210
movq %rax, 0x28(%r14)
testq %rax, %rax
je 0xae5e
movzwl %r12w, %r8d
leaq 0x6(%rsp), %rdx
movq %r15, %rdi
movl %ebp, %esi
movq %r14, %rcx
callq 0xa25f
testl %eax, %eax
je 0xae6b
movl $0x1, 0x10(%r14)
movq %r14, %rax
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq 0xd1cd(%rip), %rax      # 0x17ff0
movq (%rax), %rdi
leaq 0x6faa(%rip), %rsi      # 0x11dd7
xorl %r14d, %r14d
movq %rbx, %rdx
xorl %eax, %eax
callq 0x31d0
jmp 0xae0c
leaq 0x18(%rsp), %rbx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x41c4
movq (%rbx), %r14
jmp 0xae0c
movq %rbx, %rdi
movq %r14, %rsi
callq 0x4097
jmp 0xae7d
movq %rbx, %rdi
movq %r14, %rsi
callq 0x4163
jmp 0xae7d
movq %r14, %rsi
addq $0x28, %rsi
movq %rbx, %rdi
movq %r14, %rdx
callq 0x40f8
xorl %r14d, %r14d
jmp 0xae0c
// File: /workspace/github_c_makefile_star2_O1/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 0xdada(%rip), %rax      # 0x18fc8
movl $0x1fffe00, %r14d       # imm = 0x1FFFE00
testb $0x8, 0x2(%rax)
je 0xb563
leaq 0xdacf(%rip), %rax      # 0x18fd0
movq 0x98(%rax), %rbx
leaq 0x6df6(%rip), %rdi      # 0x12305
movq %rbx, %rsi
callq 0x31c0
testl %eax, %eax
je 0xb547
xorl %ecx, %ecx
leaq 0xc81c(%rip), %r14      # 0x17d40
leaq 0x10(%rcx), %r15
cmpq $0x50, %r15
je 0xb554
movq 0x10(%rcx,%r14), %rdi
movq %rbx, %rsi
callq 0x31c0
movq %r15, %rcx
testl %eax, %eax
jne 0xb524
addq %r15, %r14
jmp 0xb54e
leaq 0xc7f2(%rip), %r14      # 0x17d40
movq 0x8(%r14), %r14
jmp 0xb55a
movl $0x1fffe00, %r14d       # imm = 0x1FFFE00
cmpq $0x1fffe00, %r14        # imm = 0x1FFFE00
je 0xb56c
movq %r14, %rax
popq %rbx
popq %r14
popq %r15
retq
movq 0xca7d(%rip), %rax      # 0x17ff0
movq (%rax), %rdi
leaq 0x6d58(%rip), %rsi      # 0x122d5
movq %rbx, %rdx
xorl %eax, %eax
callq 0x31d0
jmp 0xb563
// File: /workspace/github_c_makefile_star2_O1/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 0xb821
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 0xb862
movq %rbx, %rdi
popq %rbx
popq %r14
popq %rbp
jmp 0xbed7
movzwl 0x50(%rbx), %ebp
testw %bp, %bp
je 0xb862
xorl %r14d, %r14d
movl %r14d, %eax
shrl $0x4, %eax
movzwl 0x52(%rbx,%rax,2), %eax
movl %r14d, %ecx
andl $0xf, %ecx
btl %ecx, %eax
jae 0xb851
movzbl %r14b, %esi
movq %rbx, %rdi
callq 0xbed7
decl %ebp
cmpl $0xfe, %r14d
ja 0xb862
incl %r14d
testw %bp, %bp
jne 0xb82d
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/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 0x9a00
testl %eax, %eax
je 0xbbec
movl $0x38, %edi
callq 0x3210
movq %rax, %rbx
testq %rax, %rax
je 0xbbde
xorps %xmm0, %xmm0
movups %xmm0, 0x20(%rbx)
movups %xmm0, 0x10(%rbx)
movups %xmm0, (%rbx)
movq $0x0, 0x30(%rbx)
movzbl %bpl, %esi
leaq 0x6(%rsp), %rdx
movq %r14, %rdi
movq %rbx, %rcx
callq 0xa8ff
testl %eax, %eax
je 0xbbd4
movq 0x28(%r14), %rdi
callq 0x3210
movq %rax, 0x28(%rbx)
testq %rax, %rax
je 0xbbd4
movl $0x0, 0x10(%rbx)
jmp 0xbbde
movq %rbx, %rdi
callq 0x3050
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq 0xc3fd(%rip), %rax      # 0x17ff0
movq (%rax), %rdi
leaq 0x61da(%rip), %rsi      # 0x11dd7
xorl %ebx, %ebx
movq %r15, %rdx
xorl %eax, %eax
callq 0x31d0
jmp 0xbbde
// File: /workspace/github_c_makefile_star2_O1/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 0xbc85
leaq 0xd3a0(%rip), %rax      # 0x18fc8
movl $0x8001, %ecx           # imm = 0x8001
andl (%rax), %ecx
cmpl $0x1, %ecx
jne 0xbc51
cmpw $0x200, 0x34(%rbx)      # imm = 0x200
je 0xbc51
leaq 0xf(%rsp), %rsi
movb $0x1a, (%rsi)
movq %rbx, %rdi
movl $0x1, %edx
callq 0xac76
cmpw $0x0, 0x30(%rbx)
jne 0xbc60
movzwl 0x36(%rbx), %eax
movw %ax, 0x30(%rbx)
movzbl 0x20(%rbx), %esi
movzwl 0x30(%rbx), %edx
movq 0x18(%rbx), %rdi
movq 0x28(%rbx), %rcx
callq 0x9e88
movq 0x18(%rbx), %rdi
movzbl 0x20(%rbx), %esi
movq %rbx, %rdx
callq 0xaa97
testq %rbx, %rbx
je 0xbca5
movq 0x28(%rbx), %rdi
testq %rdi, %rdi
je 0xbc98
callq 0x3050
movq %rbx, %rdi
addq $0x10, %rsp
popq %rbx
jmp 0x3050
addq $0x10, %rsp
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O1/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 %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
leaq 0xd300(%rip), %rax      # 0x18fc8
testb $0x1, (%rax)
jne 0xbcdf
movq %rbx, %rdi
movq %r15, %rsi
movl %r14d, %edx
callq 0xaba0
cltq
jmp 0xbd3a
testq %r14, %r14
je 0xbd24
decq %r14
xorl %r13d, %r13d
leaq 0xf(%rsp), %r12
movq %rbx, %rdi
movq %r12, %rsi
movl $0x1, %edx
callq 0xaba0
cmpl $0x1, %eax
jne 0xbd37
movb 0xf(%rsp), %cl
cmpb $0x1a, %cl
je 0xbd28
leaq 0x1(%r13), %rax
movb %cl, (%r15,%r13)
cmpb $0xa, %cl
je 0xbd3a
cmpq %r13, %r14
movq %rax, %r13
jne 0xbcef
jmp 0xbd3a
xorl %eax, %eax
jmp 0xbd3a
movzwl 0x34(%rbx), %eax
testw %ax, %ax
je 0xbd37
decl %eax
movw %ax, 0x34(%rbx)
movq %r13, %rax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/simh[P]simtools/converters/fsio/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 %r14
pushq %rbx
movq %rdi, %rbx
movq 0x18(%rdi), %r14
movzbl 0x20(%rdi), %esi
movzbl 0xc(%rdi), %edx
movq %r14, %rdi
callq 0xa037
testl %eax, %eax
je 0xbed2
movzwl 0xe(%rbx), %eax
movw $0x200, 0x472(%r14,%rax,2) # imm = 0x200
movzwl 0xe(%rbx), %r8d
movl %r8d, %edx
movzwl 0x478(%r14), %eax
movl %eax, %ecx
shrl %ecx
addl $0x7, %ecx
movzwl 0x47a(%r14,%r8,2), %esi
cmpl $0x5, %r8d
je 0xbdbd
movl %edx, %edi
subl %ecx, %edi
movzwl %di, %r9d
testb $0x2, 0x473(%r14,%r9,2)
jne 0xbdc1
movl %edx, %edi
jmp 0xbdca
addw 0x47a(%r14,%r9,2), %si
addl %ecx, %r8d
movl $0x200, %r9d            # imm = 0x200
subl %r8d, %r9d
cmpl %ecx, %r9d
jl 0xbdf9
movzwl %r8w, %r9d
testb $0x2, 0x473(%r14,%r9,2)
je 0xbdf9
movl %r9d, %edx
addw 0x47a(%r14,%rdx,2), %si
movl %r8d, %edx
cmpw %di, %dx
je 0xbeb2
movzwl %di, %r8d
movw %si, 0x47a(%r14,%r8,2)
movl $0x0, 0x474(%r14,%r8,2)
movw $0x0, 0x478(%r14,%r8,2)
leal (%rdi,%rcx), %esi
addl %ecx, %edx
shrl %eax
addq $0x6, %rax
leaq 0x474(%r14), %rdi
movzwl %dx, %r9d
cmpl $0x1ff, %r9d            # imm = 0x1FF
ja 0xbea4
movzwl 0x472(%r14,%r9,2), %r8d
movzwl %si, %r10d
movw %r8w, 0x472(%r14,%r10,2)
btl $0xb, %r8d
setae %r11b
movl $0x200, %r8d            # imm = 0x200
subl %r9d, %r8d
cmpw %cx, %r8w
setae %r8b
andb %r11b, %r8b
cmpb $0x1, %r8b
jne 0xbe9f
leaq (%rdi,%r10,2), %r10
leaq (%rdi,%r9,2), %r9
xorl %r11d, %r11d
movzwl (%r9,%r11,2), %ebp
movw %bp, (%r10,%r11,2)
incq %r11
cmpq %r11, %rax
jne 0xbe89
addl %ecx, %esi
addl %ecx, %edx
testb %r8b, %r8b
jne 0xbe38
movzwl %si, %eax
movw $0x800, 0x472(%r14,%rax,2) # imm = 0x800
movzbl 0x20(%rbx), %esi
movzbl 0xc(%rbx), %edx
movq %r14, %rdi
callq 0xa090
testl %eax, %eax
je 0xbed2
movq %rbx, %rdi
popq %rbx
popq %r14
popq %rbp
jmp 0xbc13
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/simh[P]simtools/converters/fsio/dosmt.c
// Function: dosmtSet
static void dosmtSet(
  struct mountedFS *mount,
  uint8_t UNUSED(unit),
  uint8_t UNUSED(present)
)
{
  struct DOSMTdata *data = &mount->dosmtdata;
  int idx = 0;
  uint8_t prog, proj, prot;

  while (setCmds[idx] != NULL) {
    if (strcmp(words[1], setCmds[idx]) == 0) {
      switch (idx) {
        case DOSMTSET_UIC:
          if (args == 3) {
            if (sscanf(words[2], "[%hho,%hho]", &proj, &prog) == 2) {
              data->proj = proj;
              data->prog = prog;
            } else fprintf(stderr,
                           "dosmt: UIC syntax error \"%s\"\n", words[2]);
          } else fprintf(stderr, "dosmt: Invalid syntax for \"set uic\"\n");
          return;

        case DOSMTSET_PROT:
          if (args == 3) {
            if (sscanf(words[2], "<%hho>", &prot) == 1) {
              data->prot = prot;
            } else fprintf(stderr,
                           "dosmt: Protection syntax error \"%s\"\n", words[2]);
          } else fprintf(stderr, "dosmt: Invalid syntax for \"set prot\"\n");
          return;
      }
    }
    idx++;
  }
  fprintf(stderr, "dosmt: Unknown set command \"%s\"\n", words[1]);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
leaq 0xc9b0(%rip), %rax      # 0x190a8
movq (%rax), %r15
movq 0x8(%r15), %r14
leaq 0xb69a(%rip), %r12      # 0x17da0
xorl %r13d, %r13d
movq (%r12), %rsi
movq %r14, %rdi
callq 0x31c0
testl %eax, %eax
jne 0xc724
cmpl $0x1, %r13d
je 0xc77b
testl %r13d, %r13d
je 0xc738
incq %r13
addq $0x8, %r12
cmpq $0x2, %r13
jne 0xc709
callq 0x4313
jmp 0xc7ad
leaq 0xc961(%rip), %rax      # 0x190a0
cmpl $0x3, (%rax)
jne 0xc7bb
movq 0x10(%r15), %rdi
leaq 0x5421(%rip), %rsi      # 0x11b70
leaq 0xe(%rsp), %rdx
leaq 0xf(%rsp), %rcx
xorl %eax, %eax
callq 0x3220
cmpl $0x2, %eax
jne 0xc7c9
movb 0xe(%rsp), %al
movb %al, 0x250(%rbx)
movb 0xf(%rsp), %al
movb %al, 0x251(%rbx)
jmp 0xc7ad
leaq 0xc91e(%rip), %rax      # 0x190a0
cmpl $0x3, (%rax)
jne 0xc7c2
movq 0x10(%r15), %rdi
leaq 0x5d4e(%rip), %rsi      # 0x124e0
leaq 0xd(%rsp), %rdx
xorl %eax, %eax
callq 0x3220
cmpl $0x1, %eax
jne 0xc7d0
movb 0xd(%rsp), %al
movb %al, 0x252(%rbx)
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
callq 0x42cb
jmp 0xc7ad
callq 0x4283
jmp 0xc7ad
callq 0x42e7
jmp 0xc7ad
callq 0x429f
jmp 0xc7ad
// File: /workspace/github_c_makefile_star2_O1/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
movq %r15, %rsi
movl $0x2, %ecx
callq 0xc0bc
testl %eax, %eax
je 0xcc8f
movl $0x218, %edi            # imm = 0x218
callq 0x3210
movq %rax, %rbx
testq %rax, %rax
je 0xccac
leaq 0x4(%rsp), %rsi
movq %r14, %rdi
movq %rbx, %rdx
callq 0xc439
testl %eax, %eax
je 0xcc83
movl $0x0, (%rbx)
movl $0x200, 0x210(%rbx)     # imm = 0x200
jmp 0xccac
movq %rbx, %rdi
callq 0x3050
xorl %ebx, %ebx
jmp 0xccac
movq 0xb35a(%rip), %rax      # 0x17ff0
movq (%rax), %rdi
leaq 0x5137(%rip), %rsi      # 0x11dd7
xorl %ebx, %ebx
movq %r15, %rdx
xorl %eax, %eax
callq 0x31d0
movq %rbx, %rax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/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 0x31f0
movq %rax, 0x10(%rsp)
leaq 0x4(%rsp), %rdx
movq %rbx, %rdi
movq %r15, %rsi
xorl %ecx, %ecx
callq 0xc0bc
testl %eax, %eax
je 0xcdae
movl $0x218, %edi            # imm = 0x218
callq 0x3210
movq %rax, %r14
testq %rax, %rax
je 0xcdcc
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 0x1a(%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
movl $0xe, %edx
callq 0x6c3a
testl %eax, %eax
je 0xcda1
movl $0x1, (%r14)
movq %rbx, 0x8(%r14)
movl $0x0, 0x210(%r14)
jmp 0xcdcc
movq %r14, %rdi
callq 0x3050
xorl %r14d, %r14d
jmp 0xcdcc
movq 0xb23b(%rip), %rax      # 0x17ff0
movq (%rax), %rdi
leaq 0x5018(%rip), %rsi      # 0x11dd7
xorl %r14d, %r14d
movq %r15, %rdx
xorl %eax, %eax
callq 0x31d0
movq %r14, %rax
addq $0x60, %rsp
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/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 %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
movq 0x8(%rdi), %r14
cmpl $0x0, (%rdi)
je 0xcebc
cmpw $0x0, 0x210(%rbx)
je 0xce6e
movq 0x38(%r14), %rdi
leaq 0x10(%rbx), %rsi
movl $0x200, %edx            # imm = 0x200
callq 0x6c3a
testl %eax, %eax
jne 0xce6e
movb $0x1, 0x213(%rbx)
movq 0x38(%r14), %rdi
callq 0x6d1b
testl %eax, %eax
jne 0xce82
movb $0x1, 0x213(%rbx)
movq 0x38(%r14), %rdi
callq 0x69cf
movq %rax, 0x248(%r14)
movq 0x38(%r14), %rdi
movl $0x1, %esi
callq 0x6cbd
testl %eax, %eax
jne 0xceab
movb $0x1, 0x213(%rbx)
cmpb $0x0, 0x213(%rbx)
je 0xcf02
movq %r14, %rdi
callq 0x43a7
cmpb $0x0, 0x212(%rbx)
jne 0xcf02
leaq 0x38(%r14), %r15
addq $0x8, %r14
movq (%r15), %rdi
callq 0x69ec
cmpl $0xfefefefe, %eax       # imm = 0xFEFEFEFE
je 0xcee6
leal -0x1(%rax), %ecx
cmpl $-0x2, %ecx
jb 0xcecd
jmp 0xcef5
movq %r14, %rdi
movq %r15, %rsi
callq 0x43fe
xorl %eax, %eax
jmp 0xcedc
cmpl $-0x1, %eax
jne 0xcf02
movq (%r15), %rdi
callq 0x6a72
movq %rbx, %rdi
popq %rbx
popq %r14
popq %r15
jmp 0x3050
// File: /workspace/github_c_makefile_star2_O1/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 0xbf16(%rip), %rax      # 0x18fc8
testb $0x1, (%rax)
jne 0xd0cc
callq 0x3200
leaq 0x8(%rsp), %rsi
movl %eax, %edi
callq 0x32e0
testl %eax, %eax
je 0xd0d6
xorl %eax, %eax
addq $0x98, %rsp
retq
movq 0x38(%rsp), %rax
jmp 0xd0ce
// File: /workspace/github_c_makefile_star2_O1/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 0xbed8(%rip), %rax      # 0x18fc8
testb $0x1, (%rax)
jne 0xd103
movl $0x1, %esi
movq %rbx, %rdi
popq %rbx
jmp 0x30f0
decl %edx
movq %rbx, %rdi
movl %edx, %esi
movq %rcx, %rdx
callq 0x31b0
testq %rax, %rax
je 0xd172
movq %rbx, %rdi
callq 0x3130
testl %eax, %eax
je 0xd169
movq %rax, %rdx
shlq $0x20, %rdx
movabsq $-0x100000000, %rcx     # imm = 0xFFFFFFFF00000000
addq %rdx, %rcx
sarq $0x20, %rcx
cmpb $0xa, (%rbx,%rcx)
jne 0xd169
cmpl $0x1, %eax
je 0xd15d
movabsq $-0x200000000, %rax     # imm = 0xFFFFFFFE00000000
addq %rax, %rdx
sarq $0x20, %rdx
cmpb $0xd, (%rbx,%rdx)
je 0xd169
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_O1/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 0xd1a6
leaq 0xbe3f(%rip), %rsi      # 0x18fc8
movl (%rsi), %esi
andl $0x1, %esi
je 0xd1a6
cmpb $0xd, -0x2(%rax,%rdx)
jne 0xd1a6
cmpb $0xa, -0x1(%rax,%rdx)
jne 0xd1a6
movb $0xa, -0x2(%rax,%rdx)
decq %rdx
movl $0x1, %esi
movq %rax, %rdi
jmp 0x32c0
// File: /workspace/github_c_makefile_star2_O1/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 0xd23f
leal 0xcb0(%r15), %esi
testb %bl, %bl
cmovel %r15d, %esi
movq %r14, %rdi
movq %rcx, %rdx
callq 0x6234
movl %eax, %ebp
testl %eax, %eax
je 0xd29c
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq 0xadaa(%rip), %rax      # 0x17ff0
movq (%rax), %rdi
addq $0x8, %r14
leaq 0x4d20(%rip), %rsi      # 0x11f74
xorl %ebp, %ebp
movl %r15d, %edx
movq %r14, %rcx
movl %ebx, %r8d
xorl %eax, %eax
callq 0x31d0
leaq 0xbd4b(%rip), %rax      # 0x18fb8
movq (%rax), %rdi
testq %rdi, %rdi
je 0xd232
movq 0xad3c(%rip), %rax      # 0x17fb8
cmpq (%rax), %rdi
je 0xd232
leaq 0x4cec(%rip), %rsi      # 0x11f74
xorl %ebp, %ebp
movl %r15d, %edx
movq %r14, %rcx
movl %ebx, %r8d
xorl %eax, %eax
callq 0x31d0
jmp 0xd232
leaq 0x4(%rsp), %r15
movq %r14, %rdi
movl %ebx, %esi
movl %ebp, %edx
movq %r15, %rcx
callq 0x4496
movl (%r15), %ebp
jmp 0xd232
// File: /workspace/github_c_makefile_star2_O1/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 0xd2fa
leal 0xcb0(%r15), %esi
testb %bl, %bl
cmovel %r15d, %esi
movq %r14, %rdi
movq %rcx, %rdx
callq 0x627d
movl %eax, %ebp
testl %eax, %eax
je 0xd357
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq 0xacef(%rip), %rax      # 0x17ff0
movq (%rax), %rdi
addq $0x8, %r14
leaq 0x4cf5(%rip), %rsi      # 0x12004
xorl %ebp, %ebp
movl %r15d, %edx
movq %r14, %rcx
movl %ebx, %r8d
xorl %eax, %eax
callq 0x31d0
leaq 0xbc90(%rip), %rax      # 0x18fb8
movq (%rax), %rdi
testq %rdi, %rdi
je 0xd2ed
movq 0xac81(%rip), %rax      # 0x17fb8
cmpq (%rax), %rdi
je 0xd2ed
leaq 0x4cc1(%rip), %rsi      # 0x12004
xorl %ebp, %ebp
movl %r15d, %edx
movq %r14, %rcx
movl %ebx, %r8d
xorl %eax, %eax
callq 0x31d0
jmp 0xd2ed
leaq 0x4(%rsp), %r15
movq %r14, %rdi
movl %ebx, %esi
movl %ebp, %edx
movq %r15, %rcx
callq 0x4506
movl (%r15), %ebp
jmp 0xd2ed
// File: /workspace/github_c_makefile_star2_O1/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, %r14
leaq 0x5c(%rdi), %r15
testq %rcx, %rcx
cmovneq %rcx, %r15
movl %esi, %ebp
movq 0x50(%rdi), %rax
cmpb %bpl, 0x8(%rax)
jbe 0xd9ee
movzbl 0x59(%r14), %eax
btl %ebp, %eax
jae 0xd9ee
movl %edx, %ebx
testb $0x2, 0x30(%r14)
je 0xd9ce
leaq 0xb604(%rip), %rax      # 0x18fb8
movq (%rax), %rdi
leaq 0x8(%r14), %rdx
leaq 0x4eee(%rip), %rsi      # 0x128b0
movl %ebp, %ecx
movl %ebx, %r8d
xorl %eax, %eax
callq 0x31d0
movq 0x50(%r14), %rax
movq 0x38(%rax), %rax
movzbl %bpl, %esi
movq %r14, %rdi
movl %ebx, %edx
movq %r15, %rcx
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmpq *%rax
leaq 0x4(%rsp), %rbx
movq %r14, %rdi
movl %ebp, %esi
movq %rbx, %rdx
callq 0x4722
movl (%rbx), %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/simh[P]simtools/converters/fsio/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, %r14
leaq 0x5c(%rdi), %r15
testq %rcx, %rcx
cmovneq %rcx, %r15
movl %esi, %ebp
movq 0x50(%rdi), %rax
cmpb %bpl, 0x8(%rax)
jbe 0xda82
movzbl 0x59(%r14), %eax
btl %ebp, %eax
jae 0xda82
movl %edx, %ebx
testb $0x2, 0x30(%r14)
je 0xda62
leaq 0xb570(%rip), %rax      # 0x18fb8
movq (%rax), %rdi
leaq 0x8(%r14), %rdx
leaq 0x4e83(%rip), %rsi      # 0x128d9
movl %ebp, %ecx
movl %ebx, %r8d
xorl %eax, %eax
callq 0x31d0
movq 0x50(%r14), %rax
movq 0x40(%rax), %rax
movzbl %bpl, %esi
movq %r14, %rdi
movl %ebx, %edx
movq %r15, %rcx
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmpq *%rax
leaq 0x4(%rsp), %rbx
movq %r14, %rdi
movl %ebp, %esi
movq %rbx, %rdx
callq 0x4785
movl (%rbx), %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/simh[P]simtools/converters/fsio/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 0xe77a
subw 0x38(%r14), %r13w
jmp 0xe77d
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 0xd979
testl %eax, %eax
je 0xe81f
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 0xe7fe
addl $0x7, %r15d
movzwl 0x10(%r14), %ecx
movzwl 0x14(%r14), %r8d
movzwl %r15w, %edx
movq %rbx, %rdi
callq 0xe82e
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 0xda0d
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/simh[P]simtools/converters/fsio/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 0xe891
pushq %rbx
xorl %eax, %eax
movl $0x2, %r9d
movzwl %dx, %r10d
movzwl 0x5c(%rdi,%r10,2), %r10d
testl $0xfff, %r10d           # imm = 0xFFF
movl %ecx, %r10d
cmovel %r9d, %r10d
testw %r10w, %r10w
je 0xe87e
leal 0x1(%rdx), %r11d
movzwl %dx, %edx
movzwl 0x5c(%rdi,%rdx,2), %edx
leal 0x1(%rsi), %ebx
movzwl %si, %esi
movw %dx, 0x5c(%rdi,%rsi,2)
movl %ebx, %esi
movl %r11d, %edx
decw %r10w
jne 0xe85a
jmp 0xe883
movl %edx, %r11d
movl %esi, %ebx
incl %eax
movl %ebx, %esi
movl %r11d, %edx
cmpw %r8w, %ax
jne 0xe83c
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O1/simh[P]simtools/converters/fsio/os8.c
// Function: os8OpenFileW
void *os8OpenFileW(
  struct mountedFS *mount,
  uint8_t unit,
  char *fname,
  off_t size
)
{
  struct os8OpenFile *file;
  struct os8FileSpec spec;
  uint16_t blocks = 0;

  if (size != 0)
    blocks = (size + ((OS8_BLOCKSIZE * 3) / 2) - 1) / (((OS8_BLOCKSIZE) * 3) / 2);

  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) {
        memset(file->buffer, 0, mount->blocksz);

        if (os8CreateFile(mount, unit, &spec, file, blocks) == 0) {
          ERROR("Failed to create file \"%s\"\n", fname);
          free(file->buffer);
          free(file);
          return NULL;
        } else file->mode = M_WR;
      } else {
        ERROR("Buffer allocation failure for \"%s\"\n", fname);
        free(file);
        return NULL;
      }
    } else {
      ERROR("File \"%s\" already exists\n", fname);\
      free(file);
      return NULL;
    }
  } else ERROR("Memory allocation failure\n");
  return file;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdx, %rbx
movl %esi, %ebp
movq %rdi, %r15
testq %rcx, %rcx
je 0xeb6e
addq $0x17f, %rcx            # imm = 0x17F
movabsq $0x2aaaaaaaaaaaaaab, %rdx # imm = 0x2AAAAAAAAAAAAAAB
movq %rcx, %rax
imulq %rdx
movq %rdx, %r12
movq %rdx, %rax
shrq $0x3f, %rax
shrl $0x6, %r12d
addl %eax, %r12d
jmp 0xeb71
xorl %r12d, %r12d
leaq 0xe(%rsp), %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0xdaa1
testl %eax, %eax
je 0xec31
movl $0x50, %edi
callq 0x3210
movq %rax, %r14
testq %rax, %rax
je 0xec51
xorps %xmm0, %xmm0
movups %xmm0, 0x40(%r14)
movups %xmm0, 0x30(%r14)
movups %xmm0, 0x20(%r14)
movups %xmm0, 0x10(%r14)
movups %xmm0, (%r14)
movzbl %bpl, %ebp
leaq 0xe(%rsp), %rdx
movq %r15, %rdi
movl %ebp, %esi
movq %r14, %rcx
callq 0xe4d9
testl %eax, %eax
jne 0xec66
movq 0x28(%r15), %r13
movq %r13, %rdi
callq 0x3210
movq %rax, 0x30(%r14)
testq %rax, %rax
je 0xec73
movq %rax, %rdi
xorl %esi, %esi
movq %r13, %rdx
callq 0x3170
movzwl %r12w, %r8d
leaq 0xe(%rsp), %rdx
movq %r15, %rdi
movl %ebp, %esi
movq %r14, %rcx
callq 0xdca4
testl %eax, %eax
je 0xec80
movl $0x1, 0x18(%r14)
movq %r14, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x93b8(%rip), %rax      # 0x17ff0
movq (%rax), %rdi
leaq 0x3195(%rip), %rsi      # 0x11dd7
xorl %r14d, %r14d
movq %rbx, %rdx
xorl %eax, %eax
callq 0x31d0
jmp 0xec1f
leaq 0x20(%rsp), %rbx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x49dc
movq (%rbx), %r14
jmp 0xec1f
movq %rbx, %rdi
movq %r14, %rsi
callq 0x48b2
jmp 0xec92
movq %rbx, %rdi
movq %r14, %rsi
callq 0x497c
jmp 0xec92
movq %r14, %rsi
addq $0x30, %rsi
movq %rbx, %rdi
movq %r14, %rdx
callq 0x4912
xorl %r14d, %r14d
jmp 0xec1f
// File: /workspace/github_c_makefile_star2_O1/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:
leaq 0x9f4e(%rip), %rax      # 0x18fc8
testb $0x8, 0x2(%rax)
je 0xf0df
pushq %rbp
pushq %r14
pushq %rbx
movq 0x9d35(%rip), %rsi      # 0x18dc0
testq %rsi, %rsi
sete %bpl
je 0xf0d0
leaq 0x9f35(%rip), %rax      # 0x18fd0
movq 0x98(%rax), %rbx
movq %rbx, %rdi
callq 0x31c0
leaq 0x9d0f(%rip), %r14      # 0x18dc0
testl %eax, %eax
je 0xf0d2
movq 0x48(%r14), %rsi
testq %rsi, %rsi
sete %bpl
je 0xf0d0
addq $0x48, %r14
movq %rbx, %rdi
callq 0x31c0
jmp 0xf0b1
jmp 0xf0d6
movq 0x10(%r14), %rax
testb %bpl, %bpl
popq %rbx
popq %r14
popq %rbp
je 0xf0e6
movq 0x9cea(%rip), %rax      # 0x18dd0
retq
// File: /workspace/github_c_makefile_star2_O1/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 %rbx
subq $0x50, %rsp
movq %rdi, %rbx
leaq 0x9e1f(%rip), %rax      # 0x190a8
movq (%rax), %r14
movq 0x8(%r14), %rdi
leaq 0x38de(%rip), %rsi      # 0x12b75
callq 0x31c0
testl %eax, %eax
jne 0xf33f
leaq 0x9df5(%rip), %rax      # 0x190a0
cmpl $0x3, (%rax)
jne 0xf338
movq 0x10(%r14), %r14
leaq 0x386e(%rip), %rsi      # 0x12b2d
movq %r14, %rdi
callq 0x31c0
testl %eax, %eax
je 0xf330
leaq 0x10(%rsp), %r15
movq %r14, %rdi
movq %r15, %rsi
movl $0xa, %edx
callq 0x3290
movq %rax, %r14
movq (%r15), %rax
cmpb $0x0, (%rax)
jne 0xf338
cmpq $0x7, %r14
ja 0xf338
xorl %edi, %edi
callq 0x31f0
leaq 0x8(%rsp), %rdi
movq %rax, (%rdi)
leaq 0x18(%rsp), %r15
movq %r15, %rsi
callq 0x30b0
movl 0x10(%r15), %eax
shll $0x8, %eax
addl $0x100, %eax            # imm = 0x100
movw %ax, 0x5a(%rbx)
movl 0xc(%r15), %ecx
leal (%r14,%rcx,8), %ecx
addl $0x8, %ecx
orl %eax, %ecx
movw %cx, 0x5a(%rbx)
jmp 0xf344
movw $0x0, 0x5a(%rbx)
jmp 0xf344
callq 0x4aa2
jmp 0xf344
callq 0x4a7c
addq $0x50, %rsp
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/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 %r14
pushq %rbx
movq %rdi, %rbx
movq 0x50(%rdi), %r14
testl %edx, %edx
je 0xf381
testq %r14, %r14
je 0xf3b9
cmpb %sil, 0x8(%r14)
jbe 0xf3b9
movzbl 0x59(%rbx), %eax
movzbl %sil, %esi
btl %esi, %eax
jae 0xf3b9
movq %rbx, %rdi
popq %rbx
popq %r14
popq %rbp
jmp 0xf86f
cmpb $0x0, 0x8(%r14)
je 0xf3b9
xorl %ebp, %ebp
movq 0x50(%rbx), %rax
testq %rax, %rax
je 0xf3ae
cmpb %bpl, 0x8(%rax)
jbe 0xf3ae
movzbl 0x59(%rbx), %eax
btl %ebp, %eax
jae 0xf3ae
movzbl %bpl, %esi
movq %rbx, %rdi
callq 0xf86f
incl %ebp
movzbl 0x8(%r14), %eax
cmpl %eax, %ebp
jb 0xf38a
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/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 0xdaa1
testl %eax, %eax
je 0xf71c
movl $0x50, %edi
callq 0x3210
movq %rax, %rbx
testq %rax, %rax
je 0xf70e
xorps %xmm0, %xmm0
movups %xmm0, 0x40(%rbx)
movups %xmm0, 0x30(%rbx)
movups %xmm0, 0x20(%rbx)
movups %xmm0, 0x10(%rbx)
movups %xmm0, (%rbx)
movzbl %bpl, %esi
leaq 0x6(%rsp), %rdx
movq %r14, %rdi
movq %rbx, %rcx
callq 0xe4d9
testl %eax, %eax
je 0xf704
movq 0x28(%r14), %rdi
callq 0x3210
movq %rax, 0x30(%rbx)
testq %rax, %rax
je 0xf704
movl $0x0, 0x18(%rbx)
jmp 0xf70e
movq %rbx, %rdi
callq 0x3050
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq 0x88cd(%rip), %rax      # 0x17ff0
movq (%rax), %rdi
leaq 0x26aa(%rip), %rsi      # 0x11dd7
xorl %ebx, %ebx
movq %r15, %rdx
xorl %eax, %eax
callq 0x31d0
jmp 0xf70e
// File: /workspace/github_c_makefile_star2_O1/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 0xf788
movzwl 0x3a(%rbx), %edx
testl %edx, %edx
je 0xf778
movzbl 0x28(%rbx), %esi
leal 0x1(%rdx), %eax
movw %ax, 0x3a(%rbx)
movq 0x20(%rbx), %rdi
movq 0x30(%rbx), %rcx
callq 0xda0d
movq 0x20(%rbx), %rdi
movzbl 0x28(%rbx), %esi
movq %rbx, %rdx
callq 0xe752
movq 0x30(%rbx), %rdi
testq %rdi, %rdi
je 0xf796
callq 0x3050
movq %rbx, %rdi
popq %rbx
jmp 0x3050
// File: /workspace/github_c_makefile_star2_O1/simh[P]simtools/converters/fsio/os8.c
// Function: os8DeleteFile
static void os8DeleteFile(
  void *filep,
  char *UNUSED(fname)
)
{
  struct os8OpenFile *file = filep;
  struct mountedFS *mount = file->mount;
  struct OS8data *data = &mount->os8data;

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

  data->buf[file->offset + OS8_DI_FNAME1] = 0;
  data->buf[file->offset + OS8_ED_LENGTH] =
    data->buf[file->offset + file->extra + OS8_DI_LENGTH];
  data->buf[OS8_DH_ENTRIES] =
    htole16(os8Value(-(os8Neg(le16toh(data->buf[OS8_DH_ENTRIES])) - 1)));

  os8SlideUp(mount, file->offset + OS8_ED_SIZE,
             file->offset + file->entrysz, file->entrysz, file->remain);

  /*
   * Merge any adjacent empty directory entries.
   */
  if (os8MergeEmptyRegions(mount) != 0)
    os8MergeEmptyRegions(mount);

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

  os8CloseFile(file);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x20(%rdi), %r14
movzbl 0x28(%rdi), %esi
movzbl 0xc(%rdi), %edx
movq %r14, %rdi
xorl %ecx, %ecx
callq 0xd979
testl %eax, %eax
je 0xf867
movzwl 0xe(%rbx), %eax
movw $0x0, 0x5c(%r14,%rax,2)
movzwl 0xe(%rbx), %eax
movzwl 0x12(%rbx), %ecx
addl %eax, %ecx
movzwl 0x64(%r14,%rcx,2), %ecx
movw %cx, 0x5e(%r14,%rax,2)
movl 0x5c(%r14), %eax
incl %eax
andl $0xfff, %eax            # imm = 0xFFF
movw %ax, 0x5c(%r14)
movzwl 0xe(%rbx), %esi
movzwl 0x10(%rbx), %ecx
leal (%rcx,%rsi), %edx
addl $0x2, %esi
movzwl 0x14(%rbx), %r8d
movl $0xffff, %eax           # imm = 0xFFFF
andl %eax, %esi
andl %eax, %edx
movq %r14, %rdi
callq 0xe82e
movq %r14, %rdi
callq 0xfb48
testl %eax, %eax
je 0xf842
movq %r14, %rdi
callq 0xfb48
movzbl 0x28(%rbx), %esi
movzbl 0xc(%rbx), %edx
movq %r14, %rdi
xorl %ecx, %ecx
callq 0xda0d
testl %eax, %eax
je 0xf867
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0xf74e
addq $0x8, %rsp
popq %rbx
popq %r14
retq