// File: /workspace/github_c_makefile_star2_O1/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
movq %rdi, %r14
xorl %eax, %eax
testq %rdi, %rdi
je 0x5ed2
movq %r14, %r15
movl $0x1, %esi
movq %rax, %rdi
callq 0x8924
movq 0x48(%r15), %r15
testq %r15, %r15
jne 0x5ebc
leaq 0x8(%rsp), %rdi
movq %rax, (%rdi)
movl $0x8, %esi
movq %rbx, %rdx
callq 0x7ba8
testq %r14, %r14
je 0x6066
leaq 0x8(%rsp), %r15
movq (%r14), %rax
movq (%rax), %rax
movq %rax, 0x8(%rsp)
movl $0x8, %esi
movq %r15, %rdi
movq %rbx, %rdx
callq 0x7ba8
movb 0x8(%r14), %al
movb %al, 0x8(%rsp)
movl $0x1, %esi
movq %r15, %rdi
movq %rbx, %rdx
callq 0x7ba8
cmpl $0x0, 0x8(%r14)
je 0x5f5f
movl 0xc(%r14), %eax
movl %eax, 0x8(%rsp)
movl $0x4, %esi
movq %r15, %rdi
movq %rbx, %rdx
callq 0x7ba8
movl 0x10(%r14), %eax
movl %eax, 0x8(%rsp)
movl $0x4, %esi
movq %r15, %rdi
movq %rbx, %rdx
callq 0x7ba8
movl 0x8(%r14), %eax
cmpl $0x3, %eax
je 0x601b
cmpl $0x2, %eax
je 0x5ff6
cmpl $0x1, %eax
jne 0x604c
movl 0x18(%r14), %eax
movl %eax, 0x8(%rsp)
movl $0x4, %esi
movq %r15, %rdi
movq %rbx, %rdx
callq 0x7ba8
movq 0x20(%r14), %rax
movq %rax, 0x8(%rsp)
movl $0x8, %esi
movq %r15, %rdi
movq %rbx, %rdx
callq 0x7ba8
movq 0x28(%r14), %rax
movq %rax, 0x8(%rsp)
movl $0x8, %esi
movq %r15, %rdi
movq %rbx, %rdx
callq 0x7ba8
movq 0x28(%r14), %rsi
cmpq $0x15, %rsi
jb 0x605b
leaq 0x30(%r14), %rdi
movl $0x14, %esi
movq %rbx, %rdx
callq 0x7ba8
movb 0x44(%r14), %al
movb %al, 0x8(%rsp)
movl $0x1, %esi
jmp 0x6041
movq 0x18(%r14), %r12
movq 0x20(%r14), %r13
movq %r13, 0x8(%rsp)
movl $0x8, %esi
movq %r15, %rdi
movq %rbx, %rdx
callq 0x7ba8
movq %r12, %rdi
movq %r13, %rsi
jmp 0x6044
movl 0x18(%r14), %eax
movl %eax, 0x8(%rsp)
movl $0x4, %esi
movq %r15, %rdi
movq %rbx, %rdx
callq 0x7ba8
movq 0x20(%r14), %rax
movq %rax, 0x8(%rsp)
movl $0x8, %esi
movq %r15, %rdi
movq %rbx, %rdx
callq 0x7ba8
movq 0x48(%r14), %r14
testq %r14, %r14
jne 0x5ef5
jmp 0x6066
testq %rsi, %rsi
je 0x604c
leaq 0x30(%r14), %rdi
jmp 0x6044
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq