// File: /workspace/github_c_makefile_star2_O0/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
subq $0x18750, %rsp          # imm = 0x18750
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movw 0x19cb(%rip), %ax       # 0x3081
movw %ax, -0x186db(%rbp)
movb 0x19c0(%rip), %al       # 0x3083
movb %al, -0x186d9(%rbp)
leaq -0x18740(%rbp), %rdi
leaq 0x19f9(%rip), %rsi      # 0x30d0
movl $0x64, %edx
callq 0x10f0
movl $0x0, -0x18744(%rbp)
movq -0x10(%rbp), %rdi
leaq 0x1986(%rip), %rsi      # 0x307c
callq 0x1130
movq %rax, -0x18750(%rbp)
cmpq $0x0, -0x18750(%rbp)
jne 0x1722
leaq 0x1971(%rip), %rdi      # 0x3084
callq 0x1140
movl $0x1, %edi
callq 0x1190
jmp 0x1724
leaq -0x186d0(%rbp), %rdi
movq -0x18750(%rbp), %rdx
movl $0x1869f, %esi          # imm = 0x1869F
callq 0x10d0
cmpq $0x0, %rax
je 0x183f
leaq -0x186d0(%rbp), %rdi
callq 0x1080
movq %rax, %rdx
movq -0x28(%rbp), %rax
movslq (%rax), %rcx
addq %rdx, %rcx
movl %ecx, (%rax)
leaq -0x186d0(%rbp), %rdi
leaq 0x18bf(%rip), %rsi      # 0x302e
callq 0x1150
leaq -0x186d0(%rbp), %rdi
leaq -0x186db(%rbp), %rsi
callq 0x1150
movq %rax, -0x186d8(%rbp)
leaq -0x18740(%rbp), %rdi
movq -0x186d8(%rbp), %rsi
callq 0x11a0
cmpq $0x0, %rax
jne 0x17cc
movq -0x18(%rbp), %rdi
movq -0x186d8(%rbp), %rsi
movl -0x18744(%rbp), %edx
movq -0x10(%rbp), %rcx
callq 0x1cf0
movq -0x20(%rbp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
jmp 0x17ce
leaq -0x186db(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edi
callq 0x1150
movq %rax, -0x186d8(%rbp)
cmpq $0x0, %rax
je 0x182b
leaq -0x18740(%rbp), %rdi
movq -0x186d8(%rbp), %rsi
callq 0x11a0
cmpq $0x0, %rax
jne 0x1829
movq -0x18(%rbp), %rdi
movq -0x186d8(%rbp), %rsi
movl -0x18744(%rbp), %edx
movq -0x10(%rbp), %rcx
callq 0x1cf0
movq -0x20(%rbp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
jmp 0x17ce
movl -0x18744(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18744(%rbp)
jmp 0x1724
movl -0x18744(%rbp), %ecx
movq -0x30(%rbp), %rax
addl (%rax), %ecx
movl %ecx, (%rax)
movq -0x18750(%rbp), %rdi
callq 0x1060
movl -0x4(%rbp), %eax
addq $0x18750, %rsp          # imm = 0x18750
popq %rbp
retq
nopw %cs:(%rax,%rax)