// File: /workspace/github_c_makefile_star2_O1/AlxHnr[P]nano-backup/src/metadata.c
// Function: readPathHistory
static PathHistory *readPathHistory(Allocator *region_wrapper,
                                    const FileContent content,
                                    size_t *reader_position,
                                    StringView metadata_path,
                                    Metadata *metadata)
{
  PathHistory *point = allocate(region_wrapper, sizeof *point);

  const size_t id = readSize(content, reader_position, metadata_path);
  if(id >= metadata->backup_history_length)
  {
    die("backup id is out of range in \"" PRI_STR "\"",
        STR_FMT(metadata_path));
  }

  point->backup = &metadata->backup_history[id];
  point->backup->ref_count = sSizeAdd(point->backup->ref_count, 1);

  point->state.type = read8(content, reader_position, metadata_path);

  if(point->state.type != PST_non_existing)
  {
    point->state.uid = read32(content, reader_position, metadata_path);
    point->state.gid = read32(content, reader_position, metadata_path);
  }

  if(point->state.type == PST_regular_file)
  {
    point->state.metadata.file_info.permission_bits =
      read32(content, reader_position, metadata_path);

    point->state.metadata.file_info.modification_time =
      readTime(content, reader_position, metadata_path);

    point->state.metadata.file_info.size =
      read64(content, reader_position, metadata_path);

    if(point->state.metadata.file_info.size > FILE_HASH_SIZE)
    {
      readBytes(content, reader_position,
                point->state.metadata.file_info.hash, FILE_HASH_SIZE,
                metadata_path);
      point->state.metadata.file_info.slot =
        read8(content, reader_position, metadata_path);
    }
    else if(point->state.metadata.file_info.size > 0)
    {
      readBytes(content, reader_position,
                point->state.metadata.file_info.hash,
                point->state.metadata.file_info.size, metadata_path);
    }
  }
  else if(point->state.type == PST_symlink)
  {
    const size_t target_length =
      readSize(content, reader_position, metadata_path);

    char *buffer = allocate(region_wrapper, sSizeAdd(target_length, 1));

    readBytes(content, reader_position, (uint8_t *)buffer, target_length,
              metadata_path);

    buffer[target_length] = '\0';

    strSet(&point->state.metadata.symlink_target, str(buffer));
  }
  else if(point->state.type == PST_directory)
  {
    point->state.metadata.directory_info.permission_bits =
      read32(content, reader_position, metadata_path);
    point->state.metadata.directory_info.modification_time =
      readTime(content, reader_position, metadata_path);
  }
  else if(point->state.type != PST_non_existing)
  {
    die("invalid PathStateType in \"" PRI_STR "\"",
        STR_FMT(metadata_path));
  }

  point->next = NULL;
  return point;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %r8, %rbp
movq %rcx, %r15
movq %rdx, %r14
movq %rsi, %r12
leaq 0x80(%rsp), %r13
movl $0x50, %esi
movq %rdi, 0x18(%rsp)
callq 0x284c
movq %rax, %rbx
movq 0x10(%r13), %rax
movq %rax, 0x10(%rsp)
movaps (%r13), %xmm0
movups %xmm0, (%rsp)
movq %r12, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x6181
cmpq 0x20(%rbp), %rax
jae 0x6554
movq 0x28(%rbp), %rcx
leaq (%rax,%rax,2), %rax
leaq (%rcx,%rax,8), %rax
movq %rax, (%rbx)
movq 0x10(%rax), %rdi
movl $0x1, %esi
callq 0x8924
movq (%rbx), %rcx
movq %rax, 0x10(%rcx)
movq 0x10(%r13), %rax
movq %rax, 0x10(%rsp)
movups (%r13), %xmm0
movups %xmm0, (%rsp)
movq %r12, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x65fc
movzbl %al, %eax
movl %eax, 0x8(%rbx)
testb %al, %al
je 0x62ec
movq 0x10(%r13), %rax
movq %rax, 0x10(%rsp)
movups (%r13), %xmm0
movups %xmm0, (%rsp)
movq %r12, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x6674
movl %eax, 0xc(%rbx)
movq 0x10(%r13), %rax
movq %rax, 0x10(%rsp)
movups (%r13), %xmm0
movups %xmm0, (%rsp)
movq %r12, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x6674
movl %eax, 0x10(%rbx)
movl 0x8(%rbx), %eax
cmpq $0x3, %rax
ja 0x656a
leaq 0x8198(%rip), %rcx      # 0xe498
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x10(%r13), %rax
movq %rax, 0x10(%rsp)
movups (%r13), %xmm0
movups %xmm0, (%rsp)
movq %r12, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x6674
movl %eax, 0x18(%rbx)
movq 0x10(%r13), %rax
movq %rax, 0x10(%rsp)
movups (%r13), %xmm0
movups %xmm0, (%rsp)
movq %r12, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x6181
movq %rax, 0x20(%rbx)
movq 0x10(%r13), %rax
movq %rax, 0x10(%rsp)
movups (%r13), %xmm0
movups %xmm0, (%rsp)
movq %r12, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x6181
movq %rax, 0x28(%rbx)
cmpq $0x15, %rax
jb 0x64f1
movq (%r13), %rax
movq %rax, 0x18(%rsp)
movq 0x8(%r13), %rax
movq %rax, 0x20(%rsp)
movq (%r15), %rbp
movl $0x14, %esi
movq %rbp, %rdi
callq 0x8924
cmpq %r14, %rax
ja 0x65ad
movq (%r15), %rax
movl 0x10(%r12,%rax), %ecx
movl %ecx, 0x40(%rbx)
movups (%r12,%rax), %xmm0
movups %xmm0, 0x30(%rbx)
addq $0x14, (%r15)
movq 0x10(%r13), %rax
movq %rax, 0x10(%rsp)
movups (%r13), %xmm0
movups %xmm0, (%rsp)
movq %r12, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x65fc
movb %al, 0x44(%rbx)
jmp 0x653a
movq 0x10(%r13), %rax
movq %rax, 0x10(%rsp)
movups (%r13), %xmm0
movups %xmm0, (%rsp)
movq %r12, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x6181
movq %rax, %rbp
movl $0x1, %esi
movq %rax, %rdi
callq 0x8924
movq 0x18(%rsp), %rdi
movq %rax, %rsi
callq 0x284c
movq %rax, 0x18(%rsp)
movq (%r13), %rax
movq %rax, 0x20(%rsp)
movq 0x8(%r13), %rax
movq %rax, 0x28(%rsp)
movq (%r15), %rdi
movq %rdi, %r13
movq %rbp, %rsi
callq 0x8924
cmpq %r14, %rax
ja 0x657b
addq (%r15), %r12
movq 0x18(%rsp), %r13
movq %r13, %rdi
movq %r12, %rsi
movq %rbp, %rdx
callq 0x2280
addq %rbp, (%r15)
movb $0x0, (%r13,%rbp)
movq %rbx, %r14
addq $0x18, %r14
leaq 0x30(%rsp), %r15
movq %r15, %rdi
movq %r13, %rsi
callq 0xaf28
movq 0x10(%r15), %rax
movq %rax, 0x10(%rsp)
movups (%r15), %xmm0
movups %xmm0, (%rsp)
movq %r14, %rdi
callq 0xaff1
jmp 0x653a
movq 0x10(%r13), %rax
movq %rax, 0x10(%rsp)
movups (%r13), %xmm0
movups %xmm0, (%rsp)
movq %r12, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x6674
movl %eax, 0x18(%rbx)
movq 0x10(%r13), %rax
movq %rax, 0x10(%rsp)
movups (%r13), %xmm0
movups %xmm0, (%rsp)
movq %r12, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x6181
movq %rax, 0x20(%rbx)
jmp 0x653a
movq %rax, %rbp
testq %rax, %rax
je 0x653a
movq (%r13), %rax
movq %rax, 0x18(%rsp)
movq 0x8(%r13), %rax
movq %rax, 0x20(%rsp)
movq (%r15), %r13
movq %r13, %rdi
movq %rbp, %rsi
callq 0x8924
cmpq %r14, %rax
ja 0x65c5
movq %rbx, %rdi
addq $0x30, %rdi
addq (%r15), %r12
movq %r12, %rsi
movq %rbp, %rdx
callq 0x2280
addq %rbp, (%r15)
movq $0x0, 0x48(%rbx)
movq %rbx, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl 0x8(%r13), %esi
movq (%r13), %rdx
leaq 0x7fa0(%rip), %rdi      # 0xe503
xorl %eax, %eax
callq 0x3dc4
movl 0x8(%r13), %esi
movq (%r13), %rdx
leaq 0x7fae(%rip), %rdi      # 0xe527
jmp 0x6563
cmpq $0x1, %rbp
leaq 0x821c(%rip), %rax      # 0xe7a2
leaq 0x7ed0(%rip), %rdx      # 0xe45d
cmoveq %rax, %rdx
subq %r13, %r14
leaq 0x7f2f(%rip), %rdi      # 0xe4ca
movq %rbp, %rsi
movq %r14, %rcx
movq 0x28(%rsp), %r8
movq 0x20(%rsp), %r9
jmp 0x65f5
subq %rbp, %r14
leaq 0x7f13(%rip), %rdi      # 0xe4ca
leaq 0x7e9f(%rip), %rdx      # 0xe45d
movl $0x14, %esi
jmp 0x65e8
cmpq $0x1, %rbp
leaq 0x81d2(%rip), %rax      # 0xe7a2
leaq 0x7e86(%rip), %rdx      # 0xe45d
cmoveq %rax, %rdx
subq %r13, %r14
leaq 0x7ee5(%rip), %rdi      # 0xe4ca
movq %rbp, %rsi
movq %r14, %rcx
movq 0x20(%rsp), %r8
movq 0x18(%rsp), %r9
xorl %eax, %eax
callq 0x3dc4