// File: /workspace/github_c_makefile_star2_O2/AlxHnr[P]nano-backup/src/search.c
// Function: finishSearchStep
static SearchResult finishSearchStep(SearchIterator *iterator)
{
  StringView entry = sDirGetNext(iterator->state.access.search.dir);
  if(strIsEmpty(entry))
  {
    sDirClose(iterator->state.access.search.dir);
    return finishDirectory(iterator);
  }

  /* Create new path for matching. */
  StringView dir_entry_name = strSplitPath(entry).tail;
  replaceCurrentFilename(iterator, dir_entry_name);

  /* Match subnodes against dir_entry. */
  SearchNode *matched_node = NULL;
  for(SearchNode *node = iterator->state.access.search.subnodes;
      node != NULL; node = node->next)
  {
    if(nodeMatches(node, dir_entry_name))
    {
      if(matched_node == NULL)
      {
        matched_node = node;
      }
      else
      {
        warnNodeMatches(node, dir_entry_name);
        warnNodeMatches(matched_node, dir_entry_name);
        die("ambiguous rules for path: \"" PRI_STR "\"",
            STR_FMT(iterator->current_path));
      }
    }
  }

  if(matched_node != NULL)
  {
    return finishNodeStep(iterator, matched_node, matched_node->policy);
  }

  /* Skip current path, if no fallback policy was defined. */
  if(iterator->state.access.search.fallback_policy == BPOL_none)
  {
    return finishSearchStep(iterator);
  }

  /* Match against ignore expressions. */
  for(RegexList *element = iterator->ignore_expressions; element != NULL;
      element = element->next)
  {
    if(sRegexIsMatching(element->regex, iterator->current_path))
    {
      element->has_matched = true;
      return finishSearchStep(iterator);
    }
  }

  return finishNodeStep(iterator, NULL,
                        iterator->state.access.search.fallback_policy);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movq 0x48(%rsi), %rsi
leaq 0x50(%rsp), %r15
movq %r15, %rdi
callq 0x86e8
movq 0x10(%r15), %rax
movq %rax, 0x10(%rsp)
movups (%r15), %xmm0
movups %xmm0, (%rsp)
callq 0xa55a
testb %al, %al
je 0x9fd9
movq 0x48(%r14), %rdi
callq 0x87b1
movq %rbx, %rdi
movq %r14, %rsi
callq 0xa16e
jmp 0xa102
movq 0x60(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x50(%rsp), %xmm0
movups %xmm0, (%rsp)
leaq 0x68(%rsp), %r15
movq %r15, %rdi
callq 0xa4e3
movq 0x28(%r15), %rax
movq %rax, 0x40(%rsp)
movups 0x18(%r15), %xmm0
movaps %xmm0, 0x30(%rsp)
movq 0x28(%r15), %rax
movq %rax, 0x10(%rsp)
movups 0x18(%r15), %xmm0
movups %xmm0, (%rsp)
movq %r14, %rdi
callq 0xa1d0
leaq 0x50(%r14), %r12
xorl %r15d, %r15d
movq (%r12), %r12
testq %r12, %r12
je 0xa0a3
movq 0x20(%r12), %rdi
testq %rdi, %rdi
je 0xa05a
movq 0x40(%rsp), %rax
movq %rax, 0x10(%rsp)
movaps 0x30(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0x9418
jmp 0xa086
movq 0x40(%rsp), %rax
movq %rax, 0x28(%rsp)
movaps 0x30(%rsp), %xmm0
movups %xmm0, 0x18(%rsp)
movq 0x10(%r12), %rax
movq %rax, 0x10(%rsp)
movups (%r12), %xmm0
movups %xmm0, (%rsp)
callq 0xa564
testb %al, %al
je 0xa097
movq %r12, %rax
testq %r15, %r15
je 0xa09a
jmp 0xa122
movq %r15, %rax
addq $0x60, %r12
movq %rax, %r15
jmp 0xa02d
testq %r15, %r15
je 0xa0bc
movl 0x2c(%r15), %ecx
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0xa27c
jmp 0xa102
cmpl $0x0, 0x58(%r14)
je 0xa0f7
leaq 0x8(%r14), %r12
movq %r14, %r15
movq 0x30(%r15), %r15
testq %r15, %r15
je 0xa114
movq (%r15), %rdi
movq 0x10(%r12), %rax
movq %rax, 0x10(%rsp)
movups (%r12), %xmm0
movups %xmm0, (%rsp)
callq 0x9418
testb %al, %al
je 0xa0ca
movb $0x1, 0x28(%r15)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x9f81
movq %rbx, %rax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movl 0x58(%r14), %ecx
movq %rbx, %rdi
movq %r14, %rsi
xorl %edx, %edx
jmp 0xa0b5
movq 0x40(%rsp), %rax
movq %rax, 0x10(%rsp)
movaps 0x30(%rsp), %xmm0
movups %xmm0, (%rsp)
movq %r12, %rdi
callq 0x459d
movq 0x40(%rsp), %rax
movq %rax, 0x10(%rsp)
movaps 0x30(%rsp), %xmm0
movups %xmm0, (%rsp)
movq %r15, %rdi
callq 0x459d
movl 0x10(%r14), %esi
movq 0x8(%r14), %rdx
leaq 0x4e8d(%rip), %rdi      # 0xeff4
xorl %eax, %eax
callq 0x3918