// File: /workspace/github_c_makefile_star2_O3/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, %rbx
movq %rdi, %r14
movq 0x48(%rsi), %rsi
leaq 0x50(%rsp), %r15
movq %r15, %rdi
callq 0x8d47
movq 0x10(%r15), %rax
movq %rax, 0x10(%rsp)
movups (%r15), %xmm0
movups %xmm0, (%rsp)
callq 0xad4c
testb %al, %al
je 0xa767
movq 0x48(%rbx), %rdi
callq 0x8e13
movq %r14, %rdi
movq %rbx, %rsi
callq 0xa8ed
jmp 0xa893
movq 0x60(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x50(%rsp), %xmm0
movups %xmm0, (%rsp)
leaq 0x68(%rsp), %r15
movq %r15, %rdi
callq 0xacd5
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 %rbx, %rdi
callq 0xa951
movq 0x50(%rbx), %r15
testq %r15, %r15
je 0xa83c
xorl %edx, %edx
movq %rdx, %r12
movq 0x20(%r15), %rdi
testq %rdi, %rdi
je 0xa7e5
movq 0x40(%rsp), %rax
movq %rax, 0x10(%rsp)
movaps 0x30(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0x9b87
jmp 0xa80f
movq 0x40(%rsp), %rax
movq %rax, 0x28(%rsp)
movaps 0x30(%rsp), %xmm0
movups %xmm0, 0x18(%rsp)
movq 0x10(%r15), %rax
movq %rax, 0x10(%rsp)
movups (%r15), %xmm0
movups %xmm0, (%rsp)
callq 0xad56
testb %al, %al
je 0xa820
movq %r15, %rdx
testq %r12, %r12
je 0xa823
jmp 0xa8a2
movq %r12, %rdx
movq 0x60(%r15), %r15
testq %r15, %r15
jne 0xa7bf
testq %rdx, %rdx
je 0xa83c
movl 0x2c(%rdx), %ecx
movq %r14, %rdi
movq %rbx, %rsi
jmp 0xa88e
cmpl $0x0, 0x58(%rbx)
je 0xa876
leaq 0x8(%rbx), %r12
movq %rbx, %r15
movq 0x30(%r15), %r15
testq %r15, %r15
je 0xa883
movq (%r15), %rdi
movq 0x10(%r12), %rax
movq %rax, 0x10(%rsp)
movups (%r12), %xmm0
movups %xmm0, (%rsp)
callq 0x9b87
testb %al, %al
je 0xa849
movb $0x1, 0x28(%r15)
movq %r14, %rdi
movq %rbx, %rsi
callq 0xa70f
jmp 0xa893
movl 0x58(%rbx), %ecx
movq %r14, %rdi
movq %rbx, %rsi
xorl %edx, %edx
callq 0xa9fd
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq 0x40(%rsp), %rax
movq %rax, 0x10(%rsp)
movaps 0x30(%rsp), %xmm0
movups %xmm0, (%rsp)
movq %r15, %rdi
callq 0x2410
movq 0x40(%rsp), %rax
movq %rax, 0x10(%rsp)
movaps 0x30(%rsp), %xmm0
movups %xmm0, (%rsp)
movq %r12, %rdi
callq 0x2410
movl 0x10(%rbx), %esi
movq 0x8(%rbx), %rdx
leaq 0x470e(%rip), %rdi      # 0xeff4
xorl %eax, %eax
callq 0x3ca8