// File: /workspace/github_c_makefile_star2_O2/AlxHnr[P]nano-backup/src/backup.c
// Function: initiateMetadataRecursively
static SearchResultType initiateMetadataRecursively(
  AllocatorPair *allocator_pair, Metadata *metadata, PathNode **node_list,
  SearchIterator *context, const RegexList *ignore_list)
{
  const SearchResult result = searchGetNext(context);
  if(result.type == SRT_end_of_directory ||
     result.type == SRT_end_of_search || result.type == SRT_other)
  {
    return result.type;
  }

  PathNode *node = strTableGet(metadata->path_table, result.path);

  if(node == NULL)
  {
    node = CR_RegionAlloc(metadata->r, sizeof *node);

    strSet(&node->path, strCopy(result.path, allocator_pair->a));

    node->hint = BH_added;
    node->policy = result.policy;
    node->history =
      buildPathHistoryPoint(allocator_pair->a, metadata, result);
    node->subnodes = NULL;

    /* Prepend the new node to the current node list. */
    node->next = *node_list;
    *node_list = node;

    metadata->total_path_count = sSizeAdd(metadata->total_path_count, 1);
  }
  else
  {
    handleFoundNode(allocator_pair, metadata, node, result);
  }

  if(result.type == SRT_directory)
  {
    while(initiateMetadataRecursively(allocator_pair, metadata,
                                      &node->subnodes, context,
                                      ignore_list) != SRT_end_of_directory)
      ;
  }

  if(backupHintNoPol(node->hint) == BH_directory_to_regular ||
     backupHintNoPol(node->hint) == BH_directory_to_symlink)
  {
    if(result.policy == BPOL_none || result.policy == BPOL_track)
    {
      for(PathNode *subnode = node->subnodes; subnode != NULL;
          subnode = subnode->next)
      {
        markAsRemovedRecursively(metadata, subnode,
                                 result.policy == BPOL_track);
      }
    }
    else
    {
      for(PathNode *subnode = node->subnodes; subnode != NULL;
          subnode = subnode->next)
      {
        prepareNodeForWipingRecursively(metadata, subnode);
      }
    }
  }
  else if(result.policy == BPOL_track &&
          node->history->state.type == PST_regular_file)
  {
    for(PathNode *subnode = node->subnodes; subnode != NULL;
        subnode = subnode->next)
    {
      markAsRemovedRecursively(metadata, subnode, false);
    }
  }
  else
  {
    handleNotFoundSubnodes(metadata, result.node, result.policy,
                           node->subnodes, ignore_list);
  }

  /* Mark nodes without a policy and needed subnodes for purging. */
  if(result.policy == BPOL_none)
  {
    bool has_needed_subnode = false;
    for(PathNode *subnode = node->subnodes; subnode != NULL;
        subnode = subnode->next)
    {
      if(backupHintNoPol(subnode->hint) != BH_not_part_of_repository)
      {
        has_needed_subnode = true;
        break;
      }
    }

    if(!has_needed_subnode)
    {
      prepareNodeForWiping(metadata, node);
    }
  }

  if(node->hint == BH_none)
  {
    backupHintSet(node->hint, BH_unchanged);
  }

  return result.type;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2a8, %rsp            # imm = 0x2A8
movq %r8, %r15
movq %rcx, %r12
movq %rdx, %rbp
movq %rsi, %rbx
movq %rdi, %r13
leaq 0x128(%rsp), %r14
movq %r14, %rdi
movq %rcx, %rsi
callq 0x9ee5
movl (%r14), %eax
cmpq $0x20, %rax
ja 0x297c
movabsq $0x100010100, %rcx      # imm = 0x100010100
btq %rax, %rcx
jb 0x2d03
movq 0x40(%rbx), %rdi
movq 0x140(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x130(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0xa908
testq %rax, %rax
je 0x2aad
movq %rax, %r14
leaq 0x1e8(%rsp), %rbp
leaq 0x128(%rsp), %rsi
movl $0xc0, %edx
movq %rbp, %rdi
callq 0x2280
movl 0x28(%rbp), %ebp
movq %rbx, %rdi
movq %r14, %rsi
movl %ebp, %edx
callq 0x367c
movq 0x20(%r14), %rdx
addq $0x8, %rdx
cmpl $0x3, %ebp
jne 0x2b65
cmpl $0x0, (%rdx)
je 0x2bc0
movups (%rdx), %xmm0
movups 0x10(%rdx), %xmm1
movups 0x20(%rdx), %xmm2
movups 0x30(%rdx), %xmm3
leaq 0xe0(%rsp), %rdx
movaps %xmm3, 0x30(%rdx)
movaps %xmm2, 0x20(%rdx)
movaps %xmm1, 0x10(%rdx)
movaps %xmm0, (%rdx)
pushq $0x18
popq %rcx
leaq 0x1e8(%rsp), %rsi
movq %rsp, %rdi
rep  movsq (%rsi), %es:(%rdi)
movq %r13, %rdi
movq %r14, %rsi
callq 0x3705
movzwl 0x18(%r14), %eax
testw $0x1ff, %ax             # imm = 0x1FF
je 0x2bfc
movq (%rbx), %rdi
pushq $0x50
popq %rsi
callq 0xd104
movq %rax, %rbp
movaps 0xe0(%rsp), %xmm0
movaps 0xf0(%rsp), %xmm1
movaps 0x100(%rsp), %xmm2
movaps 0x110(%rsp), %xmm3
movups %xmm0, 0x8(%rax)
movups %xmm1, 0x18(%rax)
movups %xmm2, 0x28(%rax)
movups %xmm3, 0x38(%rax)
leaq 0x8(%rbx), %rax
movq %rax, (%rbp)
movq 0x18(%rbx), %rdi
pushq $0x1
popq %rsi
callq 0x8188
movq (%rbp), %rcx
movq %rax, 0x10(%rcx)
movq 0x20(%r14), %rax
movq %rax, 0x48(%rbp)
movq %rbp, 0x20(%r14)
jmp 0x2bfc
movq (%rbx), %rdi
pushq $0x38
popq %rsi
callq 0xd104
movq %rax, %r14
movq (%r13), %rsi
leaq 0x130(%rsp), %rcx
movq 0x10(%rcx), %rax
movq %rax, 0x10(%rsp)
movups (%rcx), %xmm0
movups %xmm0, (%rsp)
leaq 0xc8(%rsp), %rdi
callq 0xa466
leaq 0xc8(%rsp), %rcx
movq 0x10(%rcx), %rax
movq %rax, 0x10(%rsp)
movups (%rcx), %xmm0
movups %xmm0, (%rsp)
movq %r14, %rdi
callq 0xa454
movl $0x2, 0x18(%r14)
leaq 0x130(%rsp), %rax
movl 0x20(%rax), %eax
movl %eax, 0x1c(%r14)
movq (%r13), %rax
pushq $0x18
popq %rcx
leaq 0x128(%rsp), %rsi
movq %rsp, %rdi
rep  movsq (%rsi), %es:(%rdi)
movq %rax, %rdi
movq %rbx, %rsi
callq 0x3417
movq %rax, 0x20(%r14)
andq $0x0, 0x28(%r14)
movq (%rbp), %rax
movq %rax, 0x30(%r14)
movq %r14, (%rbp)
movq 0x38(%rbx), %rdi
pushq $0x1
popq %rsi
callq 0x8188
movq %rax, 0x38(%rbx)
jmp 0x2bfc
pushq $0x18
popq %rcx
leaq 0x1e8(%rsp), %rsi
movq %rsp, %rdi
rep  movsq (%rsi), %es:(%rdi)
movq %r13, %rdi
movq %r14, %rsi
callq 0x3705
movzwl 0x18(%r14), %eax
testw $0x1ff, %ax             # imm = 0x1FF
jne 0x2b96
cmpl $0x0, 0x210(%rsp)
jne 0x2bfc
movq 0x20(%r14), %rbp
movq (%rbp), %rax
decq 0x10(%rax)
leaq 0x8(%rbx), %rax
movq %rax, (%rbp)
movq 0x18(%rbx), %rdi
pushq $0x1
popq %rsi
callq 0x8188
movq (%rbp), %rcx
movq %rax, 0x10(%rcx)
jmp 0x2bfc
movl $0xfffffe00, %eax       # imm = 0xFFFFFE00
andl 0x18(%r14), %eax
orl $0x2, %eax
movl %eax, 0x18(%r14)
movq (%r13), %rax
pushq $0x18
popq %rcx
leaq 0x1e8(%rsp), %rsi
movq %rsp, %rdi
rep  movsq (%rsi), %es:(%rdi)
movq %rax, %rdi
movq %rbx, %rsi
callq 0x3417
movq 0x20(%r14), %rcx
movq %rcx, 0x48(%rax)
movq %rax, 0x20(%r14)
cmpl $0x4, 0x128(%rsp)
jne 0x2c23
leaq 0x28(%r14), %rbp
movq %r13, %rdi
movq %rbx, %rsi
movq %rbp, %rdx
movq %r12, %rcx
movq %r15, %r8
callq 0x292c
cmpl $0x10, %eax
jne 0x2c0a
movl $0x1ff, %eax            # imm = 0x1FF
andl 0x18(%r14), %eax
addl $-0x9, %eax
movl 0x150(%rsp), %edx
cmpl $0x1, %eax
ja 0x2c72
cmpl $0x3, %edx
je 0x2c48
testl %edx, %edx
jne 0x2d15
leaq 0x28(%r14), %r15
movq (%r15), %r15
testq %r15, %r15
je 0x2cb7
xorl %edx, %edx
cmpl $0x3, 0x150(%rsp)
sete %dl
movq %rbx, %rdi
movq %r15, %rsi
callq 0x3486
addq $0x30, %r15
jmp 0x2c4c
cmpl $0x3, %edx
jne 0x2ca0
movq 0x20(%r14), %rax
cmpl $0x1, 0x8(%rax)
jne 0x2ca0
leaq 0x28(%r14), %r15
movq (%r15), %r15
testq %r15, %r15
je 0x2cb7
movq %rbx, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x3486
addq $0x30, %r15
jmp 0x2c85
movq 0x148(%rsp), %rsi
movq 0x28(%r14), %rcx
movq %rbx, %rdi
movq %r15, %r8
callq 0x2d32
cmpl $0x0, 0x150(%rsp)
jne 0x2ced
leaq 0x28(%r14), %rax
movl $0x1ff, %ecx            # imm = 0x1FF
movq (%rax), %rax
testq %rax, %rax
je 0x2ce2
movl 0x18(%rax), %edx
andl %ecx, %edx
addq $0x30, %rax
cmpl $0x4, %edx
je 0x2cca
jmp 0x2ced
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3573
cmpl $0x0, 0x18(%r14)
jne 0x2cfc
movl $0x1, 0x18(%r14)
movl 0x128(%rsp), %eax
addq $0x2a8, %rsp            # imm = 0x2A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x28(%r14), %r15
movq (%r15), %r15
testq %r15, %r15
je 0x2cb7
movq %rbx, %rdi
movq %r15, %rsi
callq 0x353f
addq $0x30, %r15
jmp 0x2d19