// File: /workspace/github_c_makefile_star2_O0/WojciechMula[P]pyahocorasick/src/trie.c
// Function: trie_add_word
static TrieNode*
trie_add_word(Automaton* automaton, const TRIE_LETTER_TYPE* word, const size_t wordlen, bool* new_word) {

    TrieNode* node;
    TrieNode* child;
    unsigned i;

    if (automaton->kind == EMPTY) {
        ASSERT(automaton->root == NULL);
        automaton->root = trienode_new(false);
        if (automaton->root == NULL)
            return NULL;
    }

    node = automaton->root;

    for (i=0; i < wordlen; i++) {
        const TRIE_LETTER_TYPE letter = word[i];

        child = trienode_get_next(node, letter);
        if (child == NULL) {
            child = trienode_new(false);
            if (LIKELY(child != NULL)) {
                if (UNLIKELY(trienode_set_next(node, letter, child) == NULL)) {
                    memory_free(child);
                    return NULL;
                }
            } else {
                // Note: in case of memory error, the already allocate nodes
                //       are still reachable from the root and will be free
                //       upon automaton destruction.
                return NULL;
            }
        }

        node = child;
    }

    if (node->eow == false) {
        node->eow = true;
        *new_word = true;
        automaton->count += 1;
    }
    else
        *new_word = false;

    automaton->kind = TRIE;

    return node;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x10(%rax)
jne 0x8c9d
jmp 0x8c18
movq -0x10(%rbp), %rax
cmpq $0x0, 0x28(%rax)
je 0x8c6f
movq 0x93ce(%rip), %rax      # 0x11ff8
movq (%rax), %rdi
leaq 0x33dc(%rip), %rsi      # 0xc010
leaq 0x398f(%rip), %rdx      # 0xc5ca
leaq 0x5aaa(%rip), %rcx      # 0xe6ec
movl $0x16, %r8d
leaq 0x5aab(%rip), %r9       # 0xe6fa
movb $0x0, %al
callq 0x31b0
movq 0x939b(%rip), %rax      # 0x11ff8
movq (%rax), %rdi
callq 0x3230
movl $0x1, %edi
callq 0x3310
jmp 0x8c71
xorl %edi, %edi
callq 0x8db0
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x28(%rax)
jne 0x8c9b
movq $0x0, -0x8(%rbp)
jmp 0x8da1
jmp 0x8c9d
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x30(%rbp)
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpq -0x20(%rbp), %rax
jae 0x8d5c
movq -0x18(%rbp), %rax
movl -0x3c(%rbp), %ecx
movl (%rax,%rcx,4), %eax
movl %eax, -0x40(%rbp)
movq -0x30(%rbp), %rdi
movl -0x40(%rbp), %esi
callq 0x6510
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0x8d46
xorl %edi, %edi
callq 0x8db0
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
setne %al
andb $0x1, %al
movzbl %al, %eax
cltq
cmpq $0x0, %rax
je 0x8d3a
movq -0x30(%rbp), %rdi
movl -0x40(%rbp), %esi
movq -0x38(%rbp), %rdx
callq 0x8e20
cmpq $0x0, %rax
sete %al
andb $0x1, %al
movzbl %al, %eax
cltq
cmpq $0x0, %rax
je 0x8d38
movq -0x38(%rbp), %rdi
callq 0x34b0
movq $0x0, -0x8(%rbp)
jmp 0x8da1
jmp 0x8d44
movq $0x0, -0x8(%rbp)
jmp 0x8da1
jmp 0x8d46
movq -0x38(%rbp), %rax
movq %rax, -0x30(%rbp)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x8cb0
movq -0x30(%rbp), %rax
movzbl 0x14(%rax), %eax
cmpl $0x0, %eax
jne 0x8d87
movq -0x30(%rbp), %rax
movb $0x1, 0x14(%rax)
movq -0x28(%rbp), %rax
movb $0x1, (%rax)
movq -0x10(%rbp), %rax
movl 0x1c(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x1c(%rax)
jmp 0x8d8e
movq -0x28(%rbp), %rax
movb $0x0, (%rax)
movq -0x10(%rbp), %rax
movl $0x1, 0x10(%rax)
movq -0x30(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax,%rax)