// File: /workspace/github_c_makefile_star2_O3/AlxHnr[P]nano-backup/src/metadata.c
// Function: writePathHistoryList
static void writePathHistoryList(const PathHistory *starting_point,
                                 RepoWriter *writer)
{
  size_t history_length = 0;
  for(const PathHistory *point = starting_point; point != NULL;
      point = point->next)
  {
    history_length = sSizeAdd(history_length, 1);
  }

  write64(history_length, writer);
  for(const PathHistory *point = starting_point; point != NULL;
      point = point->next)
  {
    write64(point->backup->id, writer);
    write8(point->state.type, writer);

    if(point->state.type != PST_non_existing)
    {
      write32(point->state.uid, writer);
      write32(point->state.gid, writer);
    }

    if(point->state.type == PST_regular_file)
    {
      write32(point->state.metadata.file_info.permission_bits, writer);
      write64(point->state.metadata.file_info.modification_time, writer);
      write64(point->state.metadata.file_info.size, writer);

      if(point->state.metadata.file_info.size > FILE_HASH_SIZE)
      {
        repoWriterWrite(point->state.metadata.file_info.hash,
                        FILE_HASH_SIZE, writer);
        write8(point->state.metadata.file_info.slot, writer);
      }
      else if(point->state.metadata.file_info.size > 0)
      {
        repoWriterWrite(point->state.metadata.file_info.hash,
                        point->state.metadata.file_info.size, writer);
      }
    }
    else if(point->state.type == PST_symlink)
    {
      StringView target_path = point->state.metadata.symlink_target;
      write64(target_path.length, writer);
      repoWriterWrite(target_path.content, target_path.length, writer);
    }
    else if(point->state.type == PST_directory)
    {
      write32(point->state.metadata.directory_info.permission_bits,
              writer);
      write64(point->state.metadata.directory_info.modification_time,
              writer);
    }
  }
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rsi, %rbx
testq %rdi, %rdi
je 0x6008
movq %rdi, %r14
xorl %eax, %eax
movq %rdi, %r15
movl $0x1, %esi
movq %rax, %rdi
callq 0x8778
movq 0x48(%r15), %r15
testq %r15, %r15
jne 0x5e5a
leaq 0x8(%rsp), %rdi
movq %rax, (%rdi)
movl $0x8, %esi
movq %rbx, %rdx
callq 0x79d8
testq %r14, %r14
je 0x6021
leaq 0x8(%rsp), %r15
movq (%r14), %rax
movq (%rax), %rax
movq %rax, 0x8(%rsp)
movl $0x8, %esi
movq %r15, %rdi
movq %rbx, %rdx
callq 0x79d8
movb 0x8(%r14), %al
movb %al, 0x8(%rsp)
movl $0x1, %esi
movq %r15, %rdi
movq %rbx, %rdx
callq 0x79d8
cmpl $0x0, 0x8(%r14)
je 0x5fee
movl 0xc(%r14), %eax
movl %eax, 0x8(%rsp)
movl $0x4, %esi
movq %r15, %rdi
movq %rbx, %rdx
callq 0x79d8
movl 0x10(%r14), %eax
movl %eax, 0x8(%rsp)
movl $0x4, %esi
movq %r15, %rdi
movq %rbx, %rdx
callq 0x79d8
movl 0x8(%r14), %eax
cmpl $0x3, %eax
je 0x5fbd
cmpl $0x2, %eax
je 0x5f98
cmpl $0x1, %eax
jne 0x5fee
movl 0x18(%r14), %eax
movl %eax, 0x8(%rsp)
movl $0x4, %esi
movq %r15, %rdi
movq %rbx, %rdx
callq 0x79d8
movq 0x20(%r14), %rax
movq %rax, 0x8(%rsp)
movl $0x8, %esi
movq %r15, %rdi
movq %rbx, %rdx
callq 0x79d8
movq 0x28(%r14), %rax
movq %rax, 0x8(%rsp)
movl $0x8, %esi
movq %r15, %rdi
movq %rbx, %rdx
callq 0x79d8
movq 0x28(%r14), %rsi
cmpq $0x15, %rsi
jb 0x5ffd
leaq 0x30(%r14), %rdi
movl $0x14, %esi
movq %rbx, %rdx
callq 0x79d8
movb 0x44(%r14), %al
movb %al, 0x8(%rsp)
movl $0x1, %esi
jmp 0x5fe3
movq 0x18(%r14), %r12
movq 0x20(%r14), %r13
movq %r13, 0x8(%rsp)
movl $0x8, %esi
movq %r15, %rdi
movq %rbx, %rdx
callq 0x79d8
movq %r12, %rdi
movq %r13, %rsi
jmp 0x5fe6
movl 0x18(%r14), %eax
movl %eax, 0x8(%rsp)
movl $0x4, %esi
movq %r15, %rdi
movq %rbx, %rdx
callq 0x79d8
movq 0x20(%r14), %rax
movq %rax, 0x8(%rsp)
movl $0x8, %esi
movq %r15, %rdi
movq %rbx, %rdx
callq 0x79d8
movq 0x48(%r14), %r14
testq %r14, %r14
jne 0x5e93
jmp 0x6021
testq %rsi, %rsi
je 0x5fee
leaq 0x30(%r14), %rdi
jmp 0x5fe6
leaq 0x8(%rsp), %rdi
movq $0x0, (%rdi)
movl $0x8, %esi
movq %rbx, %rdx
callq 0x79d8
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq