// File: /workspace/github_c_makefile_star2_O0/simh[P]simtools/converters/fsio/dos11.c
// Function: dos11UpdateFile
void dos11UpdateFile(
  struct mountedFS *mount,
  struct dos11OpenFile *file
)
{
  struct DOS11data *data = &mount->dos11data;

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

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

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

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

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
addq $0x48, %rax
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movzwl 0x12(%rax), %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x7380
cmpl $0x0, %eax
jne 0x7ecb
jmp 0x809a
movq -0x10(%rbp), %rax
movw (%rax), %dx
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rcx
movzwl 0x14(%rcx), %ecx
addl $0x0, %ecx
movslq %ecx, %rcx
movw %dx, 0x50c(%rax,%rcx,2)
movq -0x10(%rbp), %rax
movw 0x2(%rax), %dx
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rcx
movzwl 0x14(%rcx), %ecx
addl $0x0, %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movw %dx, 0x50c(%rax,%rcx,2)
movq -0x10(%rbp), %rax
movw 0x4(%rax), %dx
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rcx
movzwl 0x14(%rcx), %ecx
addl $0x2, %ecx
movslq %ecx, %rcx
movw %dx, 0x50c(%rax,%rcx,2)
movq -0x10(%rbp), %rax
movw 0x6(%rax), %dx
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rcx
movzwl 0x14(%rcx), %ecx
addl $0x3, %ecx
movslq %ecx, %rcx
movw %dx, 0x50c(%rax,%rcx,2)
movq -0x10(%rbp), %rax
movw 0x8(%rax), %dx
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rcx
movzwl 0x14(%rcx), %ecx
addl $0x4, %ecx
movslq %ecx, %rcx
movw %dx, 0x50c(%rax,%rcx,2)
movq -0x10(%rbp), %rax
movw 0xa(%rax), %dx
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rcx
movzwl 0x14(%rcx), %ecx
addl $0x5, %ecx
movslq %ecx, %rcx
movw %dx, 0x50c(%rax,%rcx,2)
movq -0x10(%rbp), %rax
movw 0xc(%rax), %dx
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rcx
movzwl 0x14(%rcx), %ecx
addl $0x6, %ecx
movslq %ecx, %rcx
movw %dx, 0x50c(%rax,%rcx,2)
movq -0x10(%rbp), %rax
movw 0xe(%rax), %dx
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rcx
movzwl 0x14(%rcx), %ecx
addl $0x7, %ecx
movslq %ecx, %rcx
movw %dx, 0x50c(%rax,%rcx,2)
movq -0x10(%rbp), %rax
movzwl 0x10(%rax), %eax
movl %eax, -0x1c(%rbp)
movl $0x8000, %edi           # imm = 0x8000
callq 0x6c50
movw %ax, %cx
movl -0x1c(%rbp), %eax
movzwl %cx, %ecx
xorl $-0x1, %ecx
andl %ecx, %eax
movw %ax, %dx
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rcx
movzwl 0x14(%rcx), %ecx
addl $0x8, %ecx
movslq %ecx, %rcx
movw %dx, 0x50c(%rax,%rcx,2)
movq -0x8(%rbp), %rax
movzwl 0x30(%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x8085
movq -0x10(%rbp), %rax
movzwl 0x14(%rax), %eax
cmpl $0x1, %eax
je 0x8062
movq -0x18(%rbp), %rdi
addq $0x50c, %rdi            # imm = 0x50C
movq -0x10(%rbp), %rax
movzwl 0x14(%rax), %eax
subl $0x9, %eax
cltq
shlq %rax
addq %rax, %rdi
movl $0x1, %esi
callq 0x6af0
movq -0x18(%rbp), %rdi
addq $0x50c, %rdi            # imm = 0x50C
movq -0x10(%rbp), %rax
movzwl 0x14(%rax), %eax
shlq %rax
addq %rax, %rdi
movl $0x1, %esi
callq 0x6af0
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movzwl 0x12(%rax), %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x75a0
addq $0x20, %rsp
popq %rbp
retq