// File: /workspace/github_c_makefile_star2_O0/devkot[P]SearchEngine/Crawler/helpers.c
// Function: addWordSearchNode
WordSearchNode *addWordSearchNode(WordSearchNode *head, char *fileName, int line, char *contents, int *numOfDocs, char *word){
    WordSearchNode *curNode = head, *prevNode = head, *newNode;
    int done = 0;

    if(!head){              // if list is empty
        head = (WordSearchNode *) malloc(sizeof(WordSearchNode));
        head->fileName = (char *) malloc(strlen(fileName) + 1);
        head->contents = (char *) malloc(strlen(contents) + 1);
        head->word     = (char *) malloc(strlen(word) + 1);

        strcpy(head->fileName, fileName);
        strcpy(head->contents, contents);
        strcpy(head->word, word);

        head->line     = line;
        head->next     = NULL;
        (*numOfDocs)++;
    }
    else{                   // if list is not empty
        while(!done){
            if((!curNode || !strcmp(curNode->fileName, fileName))){

                newNode = (WordSearchNode *) malloc(sizeof(WordSearchNode));
                newNode->fileName = (char *) malloc(strlen(fileName) + 1);
                newNode->contents = (char *) malloc(strlen(contents) + 1);
                newNode->word     = (char *) malloc(strlen(word) + 1);

                strcpy(newNode->fileName, fileName);
                strcpy(newNode->contents, contents);
                strcpy(newNode->word, word);

                newNode->line = line;
                newNode->next = curNode;

                if (head == curNode)
                    head = newNode;
                else
                    prevNode->next = newNode;
                (*numOfDocs)++;
                done = 1;
            }
            else if(strcmp(curNode->fileName, fileName) != 0){      // we still need to traverse the list
                prevNode = curNode;
                curNode = curNode->next;
            }
            else if(!strcmp(curNode->word, word))
                done = 1;
            else
                done = 1;
        }
    }
    return head;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x40(%rbp)
movl $0x0, -0x4c(%rbp)
cmpq $0x0, -0x8(%rbp)
jne 0x24e6
movl $0x28, %edi
callq 0x1110
movq %rax, -0x8(%rbp)
movq -0x10(%rbp), %rdi
callq 0x1080
movq %rax, %rdi
addq $0x1, %rdi
callq 0x1110
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, (%rax)
movq -0x20(%rbp), %rdi
callq 0x1080
movq %rax, %rdi
addq $0x1, %rdi
callq 0x1110
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x30(%rbp), %rdi
callq 0x1080
movq %rax, %rdi
addq $0x1, %rdi
callq 0x1110
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x8(%rbp), %rax
movq (%rax), %rdi
movq -0x10(%rbp), %rsi
callq 0x1040
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x20(%rbp), %rsi
callq 0x1040
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x30(%rbp), %rsi
callq 0x1040
movl -0x14(%rbp), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x8(%rbp), %rax
movq $0x0, 0x20(%rax)
movq -0x28(%rbp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
jmp 0x265f
jmp 0x24e8
cmpl $0x0, -0x4c(%rbp)
setne %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x24fa
jmp 0x265d
cmpq $0x0, -0x38(%rbp)
je 0x251a
movq -0x38(%rbp), %rax
movq (%rax), %rdi
movq -0x10(%rbp), %rsi
callq 0x10e0
cmpl $0x0, %eax
jne 0x2603
movl $0x28, %edi
callq 0x1110
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rdi
callq 0x1080
movq %rax, %rdi
addq $0x1, %rdi
callq 0x1110
movq %rax, %rcx
movq -0x48(%rbp), %rax
movq %rcx, (%rax)
movq -0x20(%rbp), %rdi
callq 0x1080
movq %rax, %rdi
addq $0x1, %rdi
callq 0x1110
movq %rax, %rcx
movq -0x48(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x30(%rbp), %rdi
callq 0x1080
movq %rax, %rdi
addq $0x1, %rdi
callq 0x1110
movq %rax, %rcx
movq -0x48(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x48(%rbp), %rax
movq (%rax), %rdi
movq -0x10(%rbp), %rsi
callq 0x1040
movq -0x48(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x20(%rbp), %rsi
callq 0x1040
movq -0x48(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x30(%rbp), %rsi
callq 0x1040
movl -0x14(%rbp), %ecx
movq -0x48(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x38(%rbp), %rcx
movq -0x48(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x8(%rbp), %rax
cmpq -0x38(%rbp), %rax
jne 0x25e3
movq -0x48(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x25ef
movq -0x48(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x28(%rbp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
movl $0x1, -0x4c(%rbp)
jmp 0x2658
movq -0x38(%rbp), %rax
movq (%rax), %rdi
movq -0x10(%rbp), %rsi
callq 0x10e0
cmpl $0x0, %eax
je 0x262e
movq -0x38(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x38(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x38(%rbp)
jmp 0x2656
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x30(%rbp), %rsi
callq 0x10e0
cmpl $0x0, %eax
jne 0x264d
movl $0x1, -0x4c(%rbp)
jmp 0x2654
movl $0x1, -0x4c(%rbp)
jmp 0x2656
jmp 0x2658
jmp 0x24e8
jmp 0x265f
movq -0x8(%rbp), %rax
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax)