// File: /workspace/github_cpp_makefile_star2_O3/nachogoro[P]wordcrack-herminia/src/Trie.cpp
// Function: Trie::recursiveInsertion(TrieNode*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
void Trie::recursiveInsertion(TrieNode* parent, const std::string& word)
{
    if (parent->word == word)
    {
        parent->isValidWord = true;
        return;
    }

    size_t parentLength = parent->word.size();
    std::string prefix = word.substr(0, parentLength+1);

    auto node = findNodeInSetStartingWith(parent->childrenWords, prefix);
    TrieNode* newParent = NULL;
    if (node == parent->childrenWords.end())
    {
        std::unique_ptr<TrieNode> newNode(new TrieNode(prefix, false));
        parent->childrenWords.push_back(std::move(newNode));
        newParent = parent->childrenWords.back().get();
    }
    else if (prefix != (*node)->word)
    {
        // Since the trie optimises space by not creating intermediate nodes
        // with just one child, it is possible that some reorganising of the
        // trie is necessary at this point.
        std::unique_ptr<TrieNode> newNode(new TrieNode(prefix, false));
        newNode->childrenWords.push_back(std::move(*node));
        parent->childrenWords.erase(node);
        parent->childrenWords.push_back(std::move(newNode));
        newParent = parent->childrenWords.back().get();
    }
    else
    {
        newParent = node->get();
    }


    recursiveInsertion(newParent, word);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdx, %rbx
movq %rsi, %r15
movq %rdi, -0x40(%rbp)
callq 0x21a0
movq 0x8(%r15), %r14
cmpq 0x8(%rbx), %r14
jne 0x4b37
testq %r14, %r14
je 0x4c12
movq (%rbx), %rsi
movq (%r15), %rdi
movq %r14, %rdx
callq 0x2220
testl %eax, %eax
je 0x4c12
incq %r14
leaq -0x60(%rbp), %r12
movq %r12, %rdi
movq %rbx, %rsi
xorl %edx, %edx
movq %r14, %rcx
callq 0x2230
movq 0x28(%r15), %rdi
movq 0x30(%r15), %rsi
movq (%r12), %rdx
movq 0x8(%r12), %rcx
callq 0x4cfc
movq %rax, %r13
leaq 0x28(%r15), %r12
cmpq 0x30(%r15), %rax
je 0x4c1c
movq %r12, -0x38(%rbp)
movq (%r13), %r14
movq -0x58(%rbp), %r12
cmpq 0x8(%r14), %r12
jne 0x4ba7
testq %r12, %r12
je 0x4c81
movq (%r14), %rsi
movq -0x60(%rbp), %rdi
movq %r12, %rdx
callq 0x2220
testl %eax, %eax
je 0x4c81
movl $0x40, %edi
callq 0x2210
movq %rax, %r14
addq $0x10, %rax
movq %rax, (%r14)
movq -0x60(%rbp), %rsi
addq %rsi, %r12
movq %r14, %rdi
movq %r12, %rdx
callq 0x3dac
movb $0x0, 0x20(%r14)
movq %r14, %rdi
addq $0x28, %rdi
xorps %xmm0, %xmm0
movups %xmm0, 0x28(%r14)
movq $0x0, 0x38(%r14)
movq %r14, -0x30(%rbp)
movq %r13, %rsi
callq 0x5170
movq -0x38(%rbp), %r14
movq %r14, %rdi
movq %r13, %rsi
callq 0x533c
leaq -0x30(%rbp), %rsi
movq %r14, %rdi
callq 0x5170
jmp 0x4c67
movb $0x1, 0x20(%r15)
jmp 0x4ca2
movl $0x40, %edi
callq 0x2210
movq %rax, %r14
addq $0x10, %rax
movq %rax, (%r14)
movq -0x60(%rbp), %rsi
movq -0x58(%rbp), %rdx
addq %rsi, %rdx
movq %r14, %rdi
callq 0x3dac
movb $0x0, 0x20(%r14)
xorps %xmm0, %xmm0
movups %xmm0, 0x28(%r14)
movq $0x0, 0x38(%r14)
leaq -0x30(%rbp), %rsi
movq %r14, (%rsi)
movq %r12, %rdi
callq 0x5170
movq 0x30(%r15), %rax
movq -0x8(%rax), %r14
movq -0x30(%rbp), %rsi
testq %rsi, %rsi
je 0x4c81
leaq -0x30(%rbp), %rdi
callq 0x5134
movq -0x40(%rbp), %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x4aee
leaq -0x50(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x4ca2
callq 0x21e0
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x4ccd
jmp 0x4cb7
jmp 0x4cc8
movq %rax, %rbx
movq %r14, %rdi
callq 0x21e0
jmp 0x4ce2
jmp 0x4cc8
jmp 0x4cc8
movq %rax, %rbx
jmp 0x4ce2
movq %rax, %rbx
movq -0x30(%rbp), %rsi
testq %rsi, %rsi
je 0x4ce2
leaq -0x30(%rbp), %rdi
callq 0x5134
leaq -0x50(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x4cf4
callq 0x21e0
movq %rbx, %rdi
callq 0x2360