// File: /workspace/github_c_makefile_star2_O0/AlxHnr[P]nano-backup/src/search-tree.c
// Function: searchTreeParse
SearchNode *searchTreeParse(CR_Region *r, StringView config)
{
  if(memchr(config.content, '\0', config.length) != NULL)
  {
    die("config: contains null-bytes");
  }

  Allocator *region_wrapper = allocatorWrapRegion(r);

  /* Initialize the root node of this tree. */
  SearchNode *root_node = allocate(region_wrapper, sizeof *root_node);
  strSet(&root_node->name, str("/"));

  root_node->line_nr = 0;
  root_node->regex = NULL;
  root_node->search_match = SRT_none;
  root_node->policy = BPOL_none;
  root_node->policy_inherited = false;
  root_node->policy_line_nr = 0;
  root_node->subnodes = NULL;
  root_node->subnodes_contain_regex = false;
  root_node->next = NULL;

  /* Initialize expression lists, which are shared across all nodes of the
     tree. */
  root_node->ignore_expressions =
    allocate(region_wrapper, sizeof *root_node->ignore_expressions);
  *root_node->ignore_expressions = NULL;
  root_node->summarize_expressions =
    allocate(region_wrapper, sizeof *root_node->summarize_expressions);
  *root_node->summarize_expressions = NULL;

  /* This table maps paths to existing nodes, without a trailing slash. */
  CR_Region *existing_nodes_region = CR_RegionNew();
  StringTable *existing_nodes = strTableNew(existing_nodes_region);

  /* Associate an empty string with the root node. */
  strTableMap(existing_nodes, str(""), root_node);

  /* Parse the specified config file. */
  size_t line_nr = 1;
  size_t parser_position = 0;
  BackupPolicy current_policy = BPOL_none;

  /* Skip UTF-8 BOM. */
  if(config.length >= 3 && config.content[0] == (char)0xEF &&
     config.content[1] == (char)0xBB && config.content[2] == (char)0xBF)
  {
    parser_position = 3;
  }

  StringView copy_token = str("[copy]");
  StringView mirror_token = str("[mirror]");
  StringView track_token = str("[track]");
  StringView ignore_token = str("[ignore]");
  StringView summarize_token = str("[summarize]");
  while(parser_position < config.length)
  {
    StringView line = getLine(config, parser_position);

    if(strIsWhitespaceOnly(line) || line.content[0] == '#')
    {
      /* Ignore. */
    }
    else if(strIsEqual(line, copy_token))
    {
      current_policy = BPOL_copy;
    }
    else if(strIsEqual(line, mirror_token))
    {
      current_policy = BPOL_mirror;
    }
    else if(strIsEqual(line, track_token))
    {
      current_policy = BPOL_track;
    }
    else if(strIsEqual(line, ignore_token))
    {
      current_policy = BPOL_ignore;
    }
    else if(strIsEqual(line, summarize_token))
    {
      current_policy = BPOL_summarize;
    }
    else if(line.content[0] == '[' && line.content[line.length - 1] == ']')
    {
      StringView policy =
        strUnterminated(&line.content[1], line.length - 2);
      die("config: line %zu: invalid policy: \"" PRI_STR "\"", line_nr,
          STR_FMT(policy));
    }
    else if(current_policy == BPOL_none)
    {
      die("config: line %zu: pattern without policy: \"" PRI_STR "\"",
          line_nr, STR_FMT(line));
    }
    else if(current_policy == BPOL_ignore ||
            current_policy == BPOL_summarize)
    {
      RegexList *expression = allocate(region_wrapper, sizeof *expression);

      strSet(&expression->expression, strCopy(line, region_wrapper));
      expression->line_nr = line_nr;
      expression->regex =
        sRegexCompile(r, expression->expression, str("config"), line_nr);
      expression->has_matched = false;

      RegexList **shared_expression_list = current_policy == BPOL_summarize
        ? root_node->summarize_expressions
        : root_node->ignore_expressions;

      /* Prepend new expression to the shared expression list. */
      expression->next = *shared_expression_list;
      *shared_expression_list = expression;
    }
    else if(line.content[0] == '/')
    {
      if(strPathContainsDotElements(line))
      {
        die("config: line %zu: path contains \".\" or \"..\": \"" PRI_STR
            "\"",
            line_nr, STR_FMT(line));
      }

      StringView path = strStripTrailingSlashes(line);
      SearchNode *previous_definition = strTableGet(existing_nodes, path);

      /* Terminate with an error if the path was already defined. */
      if(previous_definition != NULL &&
         previous_definition->policy != BPOL_none &&
         !previous_definition->policy_inherited)
      {
        die("config: line %zu: redefining %sline %zu: \"" PRI_STR "\"",
            line_nr,
            previous_definition->policy != current_policy ? "policy of "
                                                          : "",
            previous_definition->policy_line_nr, STR_FMT(line));
      }

      /* Use either the existing node or create a new one. */
      SearchNode *node = previous_definition != NULL
        ? previous_definition
        : newNode(r, region_wrapper, existing_nodes, path, line_nr);

      node->policy = current_policy;
      node->policy_inherited = false;
      node->policy_line_nr = line_nr;
      inheritPolicyToSubnodes(node);
    }
    else
    {
      die("config: line %zu: invalid path: \"" PRI_STR "\"", line_nr,
          STR_FMT(line));
    }

    parser_position += line.length;
    parser_position += parser_position < config.length;
    line_nr++;
  }

  CR_RegionRelease(existing_nodes_region);

  return root_node;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1f0, %rsp            # imm = 0x1F0
leaq 0x10(%rbp), %rax
movq %rax, -0x188(%rbp)
movq %rdi, -0x8(%rbp)
movq (%rax), %rdi
movq 0x8(%rax), %rdx
xorl %esi, %esi
callq 0x21e0
cmpq $0x0, %rax
je 0xd83c
leaq 0x176ee(%rip), %rdi     # 0x24f23
movb $0x0, %al
callq 0x4680
movq -0x8(%rbp), %rdi
callq 0x25a0
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rdi
movl $0x68, %esi
callq 0x24c0
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x198(%rbp)
leaq -0x30(%rbp), %rdi
leaq 0x16b8d(%rip), %rsi     # 0x243fe
callq 0xf100
movq -0x198(%rbp), %rdi
leaq -0x30(%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 -0x18(%rbp), %rax
movq $0x0, 0x18(%rax)
movq -0x18(%rbp), %rax
movq $0x0, 0x20(%rax)
movq -0x18(%rbp), %rax
movl $0x0, 0x28(%rax)
movq -0x18(%rbp), %rax
movl $0x0, 0x2c(%rax)
movq -0x18(%rbp), %rax
movb $0x0, 0x30(%rax)
movq -0x18(%rbp), %rax
movq $0x0, 0x38(%rax)
movq -0x18(%rbp), %rax
movq $0x0, 0x40(%rax)
movq -0x18(%rbp), %rax
movb $0x0, 0x48(%rax)
movq -0x18(%rbp), %rax
movq $0x0, 0x60(%rax)
movq -0x10(%rbp), %rdi
movl $0x8, %esi
callq 0x24c0
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x50(%rax)
movq -0x18(%rbp), %rax
movq 0x50(%rax), %rax
movq $0x0, (%rax)
movq -0x10(%rbp), %rdi
movl $0x8, %esi
callq 0x24c0
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x58(%rax)
movq -0x18(%rbp), %rax
movq 0x58(%rax), %rax
movq $0x0, (%rax)
callq 0x22f30
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rdi
callq 0xf830
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movq %rax, -0x190(%rbp)
leaq -0x58(%rbp), %rdi
leaq 0x16e2d(%rip), %rsi     # 0x247aa
callq 0xf100
movq -0x190(%rbp), %rdi
movq -0x18(%rbp), %rsi
leaq -0x58(%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 0xf940
movq -0x188(%rbp), %rax
movq $0x1, -0x60(%rbp)
movq $0x0, -0x68(%rbp)
movl $0x0, -0x6c(%rbp)
cmpq $0x3, 0x8(%rax)
jb 0xda14
movq -0x188(%rbp), %rax
movq (%rax), %rax
movsbl (%rax), %eax
cmpl $-0x11, %eax
jne 0xda14
movq -0x188(%rbp), %rax
movq (%rax), %rax
movsbl 0x1(%rax), %eax
cmpl $-0x45, %eax
jne 0xda14
movq -0x188(%rbp), %rax
movq (%rax), %rax
movsbl 0x2(%rax), %eax
cmpl $-0x41, %eax
jne 0xda14
movq $0x3, -0x68(%rbp)
leaq -0x88(%rbp), %rdi
leaq 0x1751d(%rip), %rsi     # 0x24f3f
callq 0xf100
leaq -0xa0(%rbp), %rdi
leaq 0x17511(%rip), %rsi     # 0x24f46
callq 0xf100
leaq -0xb8(%rbp), %rdi
leaq 0x17507(%rip), %rsi     # 0x24f4f
callq 0xf100
leaq -0xd0(%rbp), %rdi
leaq 0x174fc(%rip), %rsi     # 0x24f57
callq 0xf100
leaq -0xe8(%rbp), %rdi
leaq 0x174f2(%rip), %rsi     # 0x24f60
callq 0xf100
movq -0x188(%rbp), %rcx
movq -0x68(%rbp), %rax
cmpq 0x8(%rcx), %rax
jae 0xe11a
movq -0x188(%rbp), %rax
movq -0x68(%rbp), %rsi
leaq -0x100(%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 0xe130
leaq -0x100(%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 0xf520
testb $0x1, %al
jne 0xdaf0
movq -0x100(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x23, %eax
jne 0xdaf5
jmp 0xe0d9
leaq -0x100(%rbp), %rcx
leaq -0x88(%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 0xf4c0
testb $0x1, %al
jne 0xdb41
jmp 0xdb4d
movl $0x1, -0x6c(%rbp)
jmp 0xe0d7
leaq -0x100(%rbp), %rcx
leaq -0xa0(%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 0xf4c0
testb $0x1, %al
jne 0xdb99
jmp 0xdba5
movl $0x2, -0x6c(%rbp)
jmp 0xe0d5
leaq -0x100(%rbp), %rcx
leaq -0xb8(%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 0xf4c0
testb $0x1, %al
jne 0xdbf1
jmp 0xdbfd
movl $0x3, -0x6c(%rbp)
jmp 0xe0d3
leaq -0x100(%rbp), %rcx
leaq -0xd0(%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 0xf4c0
testb $0x1, %al
jne 0xdc49
jmp 0xdc55
movl $0x4, -0x6c(%rbp)
jmp 0xe0d1
leaq -0x100(%rbp), %rcx
leaq -0xe8(%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 0xf4c0
testb $0x1, %al
jne 0xdca1
jmp 0xdcad
movl $0x5, -0x6c(%rbp)
jmp 0xe0cf
movq -0x100(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x5b, %eax
jne 0xdd1b
movq -0x100(%rbp), %rax
movq -0xf8(%rbp), %rcx
subq $0x1, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x5d, %eax
jne 0xdd1b
movq -0x100(%rbp), %rsi
addq $0x1, %rsi
movq -0xf8(%rbp), %rdx
subq $0x2, %rdx
leaq -0x118(%rbp), %rdi
callq 0xf140
movq -0x60(%rbp), %rsi
movq -0x110(%rbp), %rax
movl %eax, %edx
movq -0x118(%rbp), %rcx
leaq 0x17258(%rip), %rdi     # 0x24f6c
movb $0x0, %al
callq 0x4680
cmpl $0x0, -0x6c(%rbp)
jne 0xdd43
movq -0x60(%rbp), %rsi
movq -0xf8(%rbp), %rax
movl %eax, %edx
movq -0x100(%rbp), %rcx
leaq 0x17259(%rip), %rdi     # 0x24f95
movb $0x0, %al
callq 0x4680
cmpl $0x4, -0x6c(%rbp)
je 0xdd53
cmpl $0x5, -0x6c(%rbp)
jne 0xdedd
movq -0x10(%rbp), %rdi
movl $0x38, %esi
callq 0x24c0
movq %rax, -0x120(%rbp)
movq -0x120(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x1b0(%rbp)
movq -0x10(%rbp), %rsi
leaq -0x138(%rbp), %rdi
leaq -0x100(%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 -0x1b0(%rbp), %rdi
leaq -0x138(%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), %rcx
movq -0x120(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x8(%rbp), %rax
movq %rax, -0x1a8(%rbp)
movq -0x120(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x1a0(%rbp)
leaq -0x150(%rbp), %rdi
leaq 0x163a7(%rip), %rsi     # 0x241b7
callq 0xf100
movq -0x1a8(%rbp), %rdi
movq -0x1a0(%rbp), %rcx
movq -0x60(%rbp), %rsi
leaq -0x150(%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 -0x120(%rbp), %rax
movq %rcx, (%rax)
movq -0x120(%rbp), %rax
movb $0x0, 0x28(%rax)
cmpl $0x5, -0x6c(%rbp)
jne 0xde95
movq -0x18(%rbp), %rax
movq 0x58(%rax), %rax
movq %rax, -0x1b8(%rbp)
jmp 0xdea4
movq -0x18(%rbp), %rax
movq 0x50(%rax), %rax
movq %rax, -0x1b8(%rbp)
movq -0x1b8(%rbp), %rax
movq %rax, -0x158(%rbp)
movq -0x158(%rbp), %rax
movq (%rax), %rcx
movq -0x120(%rbp), %rax
movq %rcx, 0x30(%rax)
movq -0x120(%rbp), %rcx
movq -0x158(%rbp), %rax
movq %rcx, (%rax)
jmp 0xe0c9
movq -0x100(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2f, %eax
jne 0xe0a5
leaq -0x100(%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 0xf600
testb $0x1, %al
jne 0xdf1b
jmp 0xdf3d
movq -0x60(%rbp), %rsi
movq -0xf8(%rbp), %rax
movl %eax, %edx
movq -0x100(%rbp), %rcx
leaq 0x17090(%rip), %rdi     # 0x24fc6
movb $0x0, %al
callq 0x4680
leaq -0x170(%rbp), %rdi
leaq -0x100(%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 0xf2e0
movq -0x40(%rbp), %rdi
leaq -0x170(%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, -0x178(%rbp)
cmpq $0x0, -0x178(%rbp)
je 0xe00c
movq -0x178(%rbp), %rax
cmpl $0x0, 0x2c(%rax)
je 0xe00c
movq -0x178(%rbp), %rax
testb $0x1, 0x30(%rax)
jne 0xe00c
movq -0x60(%rbp), %rsi
movq -0x178(%rbp), %rax
movl 0x2c(%rax), %ecx
movl -0x6c(%rbp), %edi
leaq 0x167d5(%rip), %rdx     # 0x247aa
leaq 0x1704e(%rip), %rax     # 0x2502a
cmpl %edi, %ecx
cmovneq %rax, %rdx
movq -0x178(%rbp), %rax
movq 0x38(%rax), %rcx
movq -0xf8(%rbp), %rax
movl %eax, %r8d
movq -0x100(%rbp), %r9
leaq 0x16ff5(%rip), %rdi     # 0x24ffa
movb $0x0, %al
callq 0x4680
cmpq $0x0, -0x178(%rbp)
je 0xe026
movq -0x178(%rbp), %rax
movq %rax, -0x1c0(%rbp)
jmp 0xe062
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x40(%rbp), %rdx
movq -0x60(%rbp), %rcx
leaq -0x170(%rbp), %rax
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, -0x1c0(%rbp)
movq -0x1c0(%rbp), %rax
movq %rax, -0x180(%rbp)
movl -0x6c(%rbp), %ecx
movq -0x180(%rbp), %rax
movl %ecx, 0x2c(%rax)
movq -0x180(%rbp), %rax
movb $0x0, 0x30(%rax)
movq -0x60(%rbp), %rcx
movq -0x180(%rbp), %rax
movq %rcx, 0x38(%rax)
movq -0x180(%rbp), %rdi
callq 0xe4e0
jmp 0xe0c7
movq -0x60(%rbp), %rsi
movq -0xf8(%rbp), %rax
movl %eax, %edx
movq -0x100(%rbp), %rcx
leaq 0x16f75(%rip), %rdi     # 0x25035
movb $0x0, %al
callq 0x4680
jmp 0xe0c9
jmp 0xe0cb
jmp 0xe0cd
jmp 0xe0cf
jmp 0xe0d1
jmp 0xe0d3
jmp 0xe0d5
jmp 0xe0d7
jmp 0xe0d9
movq -0x188(%rbp), %rcx
movq -0xf8(%rbp), %rax
addq -0x68(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rax
cmpq 0x8(%rcx), %rax
setb %al
andb $0x1, %al
movzbl %al, %eax
cltq
addq -0x68(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x60(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x60(%rbp)
jmp 0xda73
movq -0x38(%rbp), %rdi
callq 0x23370
movq -0x18(%rbp), %rax
addq $0x1f0, %rsp            # imm = 0x1F0
popq %rbp
retq