// File: /workspace/github_c_makefile_star2_O3/AlxHnr[P]nano-backup/src/search-tree.c
// Function: newNode
static SearchNode *newNode(CR_Region *r, Allocator *region_wrapper,
                           StringTable *existing_nodes, StringView path,
                           const size_t line_nr)
{
  PathSplit paths = strSplitPath(path);

  /* Ensure that a parent node exists. */
  SearchNode *parent_node = strTableGet(existing_nodes, paths.head);
  if(parent_node == NULL)
  {
    parent_node =
      newNode(r, region_wrapper, existing_nodes, paths.head, line_nr);
  }

  /* Initialize a new node. */
  SearchNode *node = allocate(region_wrapper, sizeof *node);

  /* Build regular expression. */
  if(paths.tail.length >= 2 && paths.tail.content[0] == '/')
  {
    /* Slice out the part after the first slash. */
    StringView expression =
      strUnterminated(&paths.tail.content[1], paths.tail.length - 1);

    strSet(&node->name, strCopy(expression, region_wrapper));
    node->regex = sRegexCompile(r, node->name, str("config"), line_nr);

    parent_node->subnodes_contain_regex = true;
  }
  else
  {
    strSet(&node->name, strCopy(paths.tail, region_wrapper));
    node->regex = NULL;
  }

  node->line_nr = line_nr;
  node->search_match = SRT_none;

  /* Inherit policy from parent node. */
  node->policy = parent_node->policy;
  node->policy_inherited = parent_node->policy != BPOL_none;
  node->policy_line_nr = line_nr;

  node->subnodes = NULL;
  node->subnodes_contain_regex = false;
  node->ignore_expressions = parent_node->ignore_expressions;

  /* Prepend node to the parents subnodes. */
  node->next = parent_node->subnodes;
  parent_node->subnodes = node;

  strTableMap(existing_nodes, path, node);

  return node;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc8, %rsp
movq %rcx, %r14
movq %rdx, %rbx
movq %rsi, %rbp
movq %rdi, %r13
movq 0x110(%rsp), %rax
movq %rax, 0x10(%rsp)
movaps 0x100(%rsp), %xmm0
movups %xmm0, (%rsp)
leaq 0x38(%rsp), %r15
movq %r15, %rdi
callq 0xacd5
movq 0x10(%r15), %rax
movq %rax, 0x10(%rsp)
movups (%r15), %xmm0
movups %xmm0, (%rsp)
movq %rbx, %rdi
callq 0xb15e
movq %rax, %r15
testq %rax, %rax
jne 0xa280
movq 0x48(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x38(%rsp), %xmm0
movups %xmm0, (%rsp)
movq %r13, %rdi
movq %rbp, %rsi
movq %rbx, %rdx
movq %r14, %rcx
callq 0xa1f5
movq %rax, %r15
movl $0x68, %esi
movq %rbp, %rdi
callq 0x27ac
movq %rax, %r12
movq 0x58(%rsp), %rdx
cmpq $0x2, %rdx
jb 0xa35d
movq 0x50(%rsp), %rsi
cmpb $0x2f, (%rsi)
jne 0xa35d
incq %rsi
decq %rdx
movq %r13, 0x30(%rsp)
leaq 0xb0(%rsp), %r13
movq %r13, %rdi
callq 0xab78
movq 0x10(%r13), %rax
movq %rax, 0x10(%rsp)
movups (%r13), %xmm0
movups %xmm0, (%rsp)
leaq 0x98(%rsp), %r13
movq %r13, %rdi
movq %rbp, %rsi
callq 0xac37
movq 0x10(%r13), %rax
movq %rax, 0x10(%rsp)
movups (%r13), %xmm0
movups %xmm0, (%rsp)
movq %r12, %rdi
callq 0xac25
leaq 0x3ed4(%rip), %rsi      # 0xe1e2
leaq 0x80(%rsp), %r13
movq %r13, %rdi
callq 0xab5c
movq 0x10(%r13), %rax
movq %rax, 0x28(%rsp)
movups (%r13), %xmm0
movups %xmm0, 0x18(%rsp)
movq 0x10(%r12), %rax
movq %rax, 0x10(%rsp)
movups (%r12), %xmm0
movups %xmm0, (%rsp)
movq 0x30(%rsp), %rdi
movq %r14, %rsi
callq 0x9a9e
movq %rax, 0x20(%r12)
movb $0x1, 0x48(%r15)
jmp 0xa3a5
leaq 0x50(%rsp), %rax
movq 0x10(%rax), %rcx
movq %rcx, 0x10(%rsp)
movups (%rax), %xmm0
movups %xmm0, (%rsp)
leaq 0x68(%rsp), %r13
movq %r13, %rdi
movq %rbp, %rsi
callq 0xac37
movq 0x10(%r13), %rax
movq %rax, 0x10(%rsp)
movups (%r13), %xmm0
movups %xmm0, (%rsp)
movq %r12, %rdi
callq 0xac25
movq $0x0, 0x20(%r12)
movq %r14, 0x18(%r12)
movl $0x0, 0x28(%r12)
movl 0x2c(%r15), %eax
movl %eax, 0x2c(%r12)
testl %eax, %eax
setne 0x30(%r12)
movq %r14, 0x38(%r12)
movq $0x0, 0x40(%r12)
movb $0x0, 0x48(%r12)
movq 0x50(%r15), %rax
movq %rax, 0x50(%r12)
movq 0x40(%r15), %rax
movq %rax, 0x60(%r12)
movq %r12, 0x40(%r15)
leaq 0x100(%rsp), %rcx
movq 0x10(%rcx), %rax
movq %rax, 0x10(%rsp)
movups (%rcx), %xmm0
movups %xmm0, (%rsp)
movq %rbx, %rdi
movq %r12, %rsi
callq 0xb043
movq %r12, %rax
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq