// File: /workspace/github_c_makefile_star2_O0/devkot[P]SearchEngine/Crawler/trie.c
// Function: findNextTrieNode
TrieNode * findNextTrieNode(TrieNode *root, char c, int searchMode){
    int done = 0;
    TrieNodeList *curNode = root->charList, *prevNode = root->charList, *newNode;

    if (!curNode){                          // if our trie node does not have a list of child nodes
        if (searchMode)                     // if we are simply searching for a word
            return NULL;                    // return NULL
        root->charList = curNode = newNode = (TrieNodeList *) malloc(sizeof(TrieNodeList)); // create the first node of the list
        newNode->letter = c;                // assign the letter
        newNode->next   = NULL;             // next pointer is null
        newNode->node   = createTrieNode(); // create the actual trie node
    }
    else{                                   // if our trie node has at least one child node
        while (!done){                      // start iterating the list of nodes
            if (!curNode || c < curNode->letter){ // if the current node corresponds to a letter bigger than the one we want
                if (searchMode)                   // if we are simply searching for a word
                    return NULL;                  // return NULL

                newNode = (TrieNodeList *) malloc(sizeof(TrieNodeList));
                newNode->letter = c;              // assign the letter
                newNode->next = curNode;          // next node of the new node is the current node
                newNode->node = createTrieNode(); // create the actual trie node
                if (prevNode != curNode)          // if the new node is not actually going to be the first node
                    prevNode->next = newNode;     // previous node will point to current node
                else                              // if this is the new head of the list
                    root->charList = newNode;     // make sure it now points to the new node
                curNode = newNode;                // store it here to return it at the end of the function
                done = 1;
            }
            else if (c == curNode->letter){ // if the node we are looking for already exists
                done = 1;
            }
            else{                         // if the current node corresponds to a letter lower than the one we want
                prevNode = curNode;       // go to next node
                curNode = curNode->next;  // go to next node
            }
        }
    }

    return curNode->node;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movb %sil, %al
movq %rdi, -0x10(%rbp)
movb %al, -0x11(%rbp)
movl %edx, -0x18(%rbp)
movl $0x0, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x1e45
cmpl $0x0, -0x18(%rbp)
je 0x1dfe
movq $0x0, -0x8(%rbp)
jmp 0x1f2b
movl $0x18, %edi
callq 0x1110
movq %rax, %rcx
movq %rcx, -0x38(%rbp)
movq %rcx, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq %rcx, 0x8(%rax)
movb -0x11(%rbp), %cl
movq -0x38(%rbp), %rax
movb %cl, (%rax)
movq -0x38(%rbp), %rax
movq $0x0, 0x10(%rax)
callq 0x1ca0
movq %rax, %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x8(%rax)
jmp 0x1f1f
jmp 0x1e47
cmpl $0x0, -0x1c(%rbp)
setne %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x1e59
jmp 0x1f1d
cmpq $0x0, -0x28(%rbp)
je 0x1e6f
movsbl -0x11(%rbp), %eax
movq -0x28(%rbp), %rcx
movsbl (%rcx), %ecx
cmpl %ecx, %eax
jge 0x1eea
cmpl $0x0, -0x18(%rbp)
je 0x1e82
movq $0x0, -0x8(%rbp)
jmp 0x1f2b
movl $0x18, %edi
callq 0x1110
movq %rax, -0x38(%rbp)
movb -0x11(%rbp), %cl
movq -0x38(%rbp), %rax
movb %cl, (%rax)
movq -0x28(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x10(%rax)
callq 0x1ca0
movq %rax, %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x30(%rbp), %rax
cmpq -0x28(%rbp), %rax
je 0x1ecd
movq -0x38(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x10(%rax)
jmp 0x1ed9
movq -0x38(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x38(%rbp), %rax
movq %rax, -0x28(%rbp)
movl $0x1, -0x1c(%rbp)
jmp 0x1f18
movsbl -0x11(%rbp), %eax
movq -0x28(%rbp), %rcx
movsbl (%rcx), %ecx
cmpl %ecx, %eax
jne 0x1f02
movl $0x1, -0x1c(%rbp)
jmp 0x1f16
movq -0x28(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x28(%rbp)
jmp 0x1f18
jmp 0x1e47
jmp 0x1f1f
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)