// File: /workspace/github_c_makefile_star2_O3/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 0x1aab(%rip), %rsi      # 0x30c0
leaq -0xc0(%rbp), %rax
movl $0xc, %ecx
movq %rax, %rdi
rep  movsq (%rsi), %es:(%rdi)
movl $0x0, 0x60(%rax)
leaq 0x1a46(%rip), %rsi      # 0x307b
movq %rdx, -0x30(%rbp)
movq %rdx, %rdi
callq 0x1130
testq %rax, %rax
je 0x176c
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 0x174b
leaq -0x18760(%rbp), %r13
leaq 0x1a08(%rip), %rbx      # 0x3087
leaq -0xc0(%rbp), %r15
movq %r12, -0x50(%rbp)
movq %r13, %rdi
callq 0x1090
movq -0x58(%rbp), %rcx
addl %eax, (%rcx)
movq %r13, %rdi
leaq 0x19e3(%rip), %rsi      # 0x3085
callq 0x1150
movq %r13, %rdi
movq %rbx, %rsi
callq 0x1150
movq %rax, %r12
movq %r15, %rdi
movq %rax, %rsi
callq 0x11a0
testq %rax, %rax
jne 0x16de
movq -0x38(%rbp), %rdi
movq %r12, %rsi
movl %r14d, %edx
movq -0x30(%rbp), %rcx
callq 0x19f4
movq -0x40(%rbp), %rax
incl (%rax)
xorl %edi, %edi
movq %rbx, %rsi
callq 0x1150
testq %rax, %rax
je 0x172b
movq %rax, %r12
movq %r15, %rdi
movq %r12, %rsi
callq 0x11a0
testq %rax, %rax
jne 0x1719
movq -0x38(%rbp), %rdi
movq %r12, %rsi
movl %r14d, %edx
movq -0x30(%rbp), %rcx
callq 0x19f4
movq -0x40(%rbp), %rax
incl (%rax)
xorl %edi, %edi
movq %rbx, %rsi
callq 0x1150
movq %rax, %r12
testq %rax, %rax
jne 0x16f0
incl %r14d
movq %r13, %rdi
movl $0x1869f, %esi          # imm = 0x1869F
movq -0x50(%rbp), %r12
movq %r12, %rdx
callq 0x10d0
testq %rax, %rax
jne 0x168a
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 0x11c0