// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x120, %rsp            # imm = 0x120
leaq 0x10(%rbp), %rax
movq %rax, -0xc8(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
leaq -0x50(%rbp), %rdi
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
callq 0xf390
movq -0x18(%rbp), %rdi
leaq -0x50(%rbp), %rax
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
callq 0xfb50
movq %rax, -0x58(%rbp)
cmpq $0x0, -0x58(%rbp)
jne 0xe26f
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
leaq -0x50(%rbp), %rax
movq -0x20(%rbp), %rcx
movq (%rax), %r8
movq %r8, (%rsp)
movq 0x8(%rax), %r8
movq %r8, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
callq 0xe1c0
movq %rax, -0x58(%rbp)
movq -0x10(%rbp), %rdi
movl $0x68, %esi
callq 0x24c0
movq %rax, -0x60(%rbp)
cmpq $0x2, -0x30(%rbp)
jb 0xe3a8
movq -0x38(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2f, %eax
jne 0xe3a8
movq -0x38(%rbp), %rsi
addq $0x1, %rsi
movq -0x30(%rbp), %rdx
subq $0x1, %rdx
leaq -0x78(%rbp), %rdi
callq 0xf140
movq -0x60(%rbp), %rax
movq %rax, -0xe0(%rbp)
movq -0x10(%rbp), %rsi
leaq -0x90(%rbp), %rdi
leaq -0x78(%rbp), %rax
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
callq 0xf270
movq -0xe0(%rbp), %rdi
leaq -0x90(%rbp), %rax
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
callq 0xf240
movq -0x8(%rbp), %rax
movq %rax, -0xd8(%rbp)
movq -0x60(%rbp), %rax
movq %rax, -0xd0(%rbp)
leaq -0xa8(%rbp), %rdi
leaq 0x15e7a(%rip), %rsi     # 0x241b7
callq 0xf100
movq -0xd8(%rbp), %rdi
movq -0xd0(%rbp), %rcx
movq -0x20(%rbp), %rsi
leaq -0xa8(%rbp), %rax
movq (%rcx), %rdx
movq %rdx, (%rsp)
movq 0x8(%rcx), %rdx
movq %rdx, 0x8(%rsp)
movq 0x10(%rcx), %rcx
movq %rcx, 0x10(%rsp)
movq (%rax), %rcx
movq %rcx, 0x18(%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x20(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x28(%rsp)
callq 0xd670
movq %rax, %rcx
movq -0x60(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x58(%rbp), %rax
movb $0x1, 0x48(%rax)
jmp 0xe41c
movq -0x60(%rbp), %rax
movq %rax, -0xe8(%rbp)
leaq -0x50(%rbp), %rax
addq $0x18, %rax
movq -0x10(%rbp), %rsi
leaq -0xc0(%rbp), %rdi
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
callq 0xf270
movq -0xe8(%rbp), %rdi
leaq -0xc0(%rbp), %rax
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
callq 0xf240
movq -0x60(%rbp), %rax
movq $0x0, 0x20(%rax)
movq -0xc8(%rbp), %rax
movq -0x20(%rbp), %rdx
movq -0x60(%rbp), %rcx
movq %rdx, 0x18(%rcx)
movq -0x60(%rbp), %rcx
movl $0x0, 0x28(%rcx)
movq -0x58(%rbp), %rcx
movl 0x2c(%rcx), %edx
movq -0x60(%rbp), %rcx
movl %edx, 0x2c(%rcx)
movq -0x58(%rbp), %rcx
cmpl $0x0, 0x2c(%rcx)
setne %dl
movq -0x60(%rbp), %rcx
andb $0x1, %dl
movb %dl, 0x30(%rcx)
movq -0x20(%rbp), %rdx
movq -0x60(%rbp), %rcx
movq %rdx, 0x38(%rcx)
movq -0x60(%rbp), %rcx
movq $0x0, 0x40(%rcx)
movq -0x60(%rbp), %rcx
movb $0x0, 0x48(%rcx)
movq -0x58(%rbp), %rcx
movq 0x50(%rcx), %rdx
movq -0x60(%rbp), %rcx
movq %rdx, 0x50(%rcx)
movq -0x58(%rbp), %rcx
movq 0x40(%rcx), %rdx
movq -0x60(%rbp), %rcx
movq %rdx, 0x60(%rcx)
movq -0x60(%rbp), %rdx
movq -0x58(%rbp), %rcx
movq %rdx, 0x40(%rcx)
movq -0x18(%rbp), %rdi
movq -0x60(%rbp), %rsi
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
callq 0xf940
movq -0x60(%rbp), %rax
addq $0x120, %rsp            # imm = 0x120
popq %rbp
retq
nopl (%rax)