// File: /workspace/github_cpp_makefile_star2_O1/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 0x4b5f
testq %r14, %r14
je 0x4c2c
movq (%rbx), %rsi
movq (%r15), %rdi
movq %r14, %rdx
callq 0x2220
testl %eax, %eax
je 0x4c2c
incq %r14
leaq -0x60(%rbp), %r12
movq %r12, %rdi
movq %rbx, %rsi
xorl %edx, %edx
movq %r14, %rcx
callq 0x2230
leaq 0x28(%r15), %rdi
movq %rdi, -0x38(%rbp)
movq %r12, %rsi
callq 0x4d1f
movq %rax, %r13
cmpq 0x30(%r15), %rax
je 0x4c36
movq (%r13), %r14
movq -0x58(%rbp), %r12
cmpq 0x8(%r14), %r12
jne 0x4bc1
testq %r12, %r12
je 0x4c9c
movq (%r14), %rsi
movq -0x60(%rbp), %rdi
movq %r12, %rdx
callq 0x2220
testl %eax, %eax
je 0x4c9c
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 0x3da6
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 0x517a
movq -0x38(%rbp), %r14
movq %r14, %rdi
movq %r13, %rsi
callq 0x5346
leaq -0x30(%rbp), %rsi
movq %r14, %rdi
callq 0x517a
jmp 0x4c82
movb $0x1, 0x20(%r15)
jmp 0x4cbd
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 0x3da6
movq -0x38(%rbp), %rdi
movb $0x0, 0x20(%r14)
xorps %xmm0, %xmm0
movups %xmm0, 0x28(%r14)
movq $0x0, 0x38(%r14)
leaq -0x30(%rbp), %rsi
movq %r14, (%rsi)
callq 0x517a
movq 0x30(%r15), %rax
movq -0x8(%rax), %r14
movq -0x30(%rbp), %rsi
testq %rsi, %rsi
je 0x4c9c
leaq -0x30(%rbp), %rdi
callq 0x5138
movq -0x40(%rbp), %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x4b16
leaq -0x50(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x4cbd
callq 0x21e0
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x4ce8
jmp 0x4cd2
jmp 0x4ce3
movq %rax, %rbx
movq %r14, %rdi
callq 0x21e0
jmp 0x4d05
jmp 0x4ce3
jmp 0x4ce3
movq %rax, %rbx
jmp 0x4d05
movq %rax, %rbx
movq -0x30(%rbp), %rsi
testq %rsi, %rsi
je 0x4cfd
leaq -0x30(%rbp), %rdi
callq 0x5138
movq $0x0, -0x30(%rbp)
leaq -0x50(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x4d17
callq 0x21e0
movq %rbx, %rdi
callq 0x2360