// File: /workspace/github_c_makefile_star2_O1/devkot[P]SearchEngine/Crawler/functions.c
// Function: readFile
int readFile(char *inputFile, TrieNode *trie, int *nWords, int *nChars, int *nLines){
    char lineBuffer[100000], *word, whitespaces[3] = " \t";
    char tags[100] = "<html></html><head></head><body></body><!DOCTYPE html></a><a href html";
    int lineNumber = 0;
    FILE *file;
    file = fopen(inputFile, "r");                           // Open file

    if (file == NULL){
        perror("Error: ");
        exit(EXIT_FAILURE);
    }

    while(fgets(lineBuffer, 99999, file)){
        (*nChars) += strlen(lineBuffer);                    // calculate total file characters (with whitespaces and \n)

        strtok(lineBuffer, "\n");                           // remove the useless \n character at the end of the line

        word = strtok(lineBuffer, whitespaces);             // feed strtok

        if(!strstr(tags,word)) {                            // filter out tags
            insertWord(trie, word, lineNumber, inputFile);  // insert to trie
            (*nWords)++;                                    // increase the total number of words of Trie
        }

        while ((word = strtok(NULL, whitespaces))){         // start reading the document word by word
            if(!strstr(tags,word)){                         // filter out tags
//                continue;

                insertWord(trie, word, lineNumber, inputFile);  // insert to trie (filename, line, n)
                (*nWords)++;                                    // increase the total number of words of Trie
//			    docWords++;                                     // increase the total number of words of current document
            }
        }
        lineNumber++;

    }
    (*nLines) += lineNumber;
    fclose(file);

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18738, %rsp          # imm = 0x18738
movq %r8, %rbx
movq %rcx, -0x58(%rbp)
movq %rdx, -0x40(%rbp)
movq %rsi, -0x38(%rbp)
movq %rdi, %rdx
leaq 0x1abe(%rip), %rsi      # 0x30d0
leaq -0xc0(%rbp), %rax
movl $0xc, %ecx
movq %rax, %rdi
rep  movsq (%rsi), %es:(%rdi)
movl $0x0, 0x60(%rax)
leaq 0x1a49(%rip), %rsi      # 0x307b
movq %rdx, -0x30(%rbp)
movq %rdx, %rdi
callq 0x1120
testq %rax, %rax
je 0x1769
movq %rax, %r12
movq %rbx, -0x48(%rbp)
leaq -0x18760(%rbp), %rdi
movl $0x1869f, %esi          # imm = 0x1869F
movq %rax, %rdx
callq 0x10d0
xorl %r14d, %r14d
testq %rax, %rax
je 0x1748
leaq -0x18760(%rbp), %r13
leaq 0x1a0e(%rip), %rbx      # 0x308a
leaq -0xc0(%rbp), %r15
movq %r12, -0x50(%rbp)
movq %r13, %rdi
callq 0x1090
movq -0x58(%rbp), %rcx
addl %eax, (%rcx)
movq %r13, %rdi
leaq 0x19e9(%rip), %rsi      # 0x3088
callq 0x1140
movq %r13, %rdi
movq %rbx, %rsi
callq 0x1140
movq %rax, %r12
movq %r15, %rdi
movq %rax, %rsi
callq 0x1190
testq %rax, %rax
jne 0x16db
movq -0x38(%rbp), %rdi
movq %r12, %rsi
movl %r14d, %edx
movq -0x30(%rbp), %rcx
callq 0x19ee
movq -0x40(%rbp), %rax
incl (%rax)
xorl %edi, %edi
movq %rbx, %rsi
callq 0x1140
testq %rax, %rax
je 0x1728
movq %rax, %r12
movq %r15, %rdi
movq %r12, %rsi
callq 0x1190
testq %rax, %rax
jne 0x1716
movq -0x38(%rbp), %rdi
movq %r12, %rsi
movl %r14d, %edx
movq -0x30(%rbp), %rcx
callq 0x19ee
movq -0x40(%rbp), %rax
incl (%rax)
xorl %edi, %edi
movq %rbx, %rsi
callq 0x1140
movq %rax, %r12
testq %rax, %rax
jne 0x16ed
incl %r14d
movq %r13, %rdi
movl $0x1869f, %esi          # imm = 0x1869F
movq -0x50(%rbp), %r12
movq %r12, %rdx
callq 0x10d0
testq %rax, %rax
jne 0x1687
movq -0x48(%rbp), %rax
addl %r14d, (%rax)
movq %r12, %rdi
callq 0x1070
addq $0x18738, %rsp          # imm = 0x18738
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x11b0