// File: /workspace/github_cpp_makefile_star2_O2/dianejdan[P]Eclat/./DbReader.hpp
// Function: void DbReader::read_txt<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>(PatternStore<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>&, char*, int)
void read_txt(PatternStore<Typ>& pS, char* filename, int minsup){

        ifstream in_(filename); // open input file
        char buffer[4096]; // store each line/transaction
        string line; // change char array to a string
        stringstream ss; // used for parse each item in a line/transaction

        int tid = 1; // transaction id, start from 1
        map<Typ, vector<int> > tidList; // use a map to store item and its transactions

        // parse the input file, add item and tid into the tid list
        while(in_.getline(buffer, 4096)){
            line = buffer; // change char array to string
            ss << line; // transform string to a stringstream so we can parse items
            Typ item;

            while(ss >> item){ // parse each item in the transaction

                if (tidList.find(item) == tidList.end()){ // if not find a item, create a new
                                                          // record in tidList for this item
                    vector<int> tids; // transaction list for the current item
                    tids.push_back(tid); // add this current transaction to transaction list
                    tidList.insert(std::pair<Typ, vector<int> >(item, tids)); // add <item, tids> to the map of tidList

                }else{

                    tidList[item].push_back(tid); // if the item is already in map of tidList, find the <item, tidList>
                                                  // add the current transaction id to the tid list

                }
            }

            ss.clear(); // clear state of stringstream for next transaction
            ++tid; // add one to the transaction id for next transaction
        }

        //cout << "Number of unique items in input file is  " << tidList.size() << "." << endl; // check how many items in the input file
        cout << endl;

        // now populate level-1 (single-item) frequency patterns
        int count = 0; // count level-1 (single-item) frequency patterns
        typename map<Typ, vector<int> >::iterator iter;

        for (iter = tidList.begin(); iter != tidList.end(); ++iter){ // iterate through tid list
            if (iter->second.size() >= minsup){ // store level-1 pattern only when |t(i)| > minsup
                pS.add_pattern(pS.root(), iter->first, iter->second); // add the frequent pattern to pattern store
                count++;
            }
        }

        in_.close(); // finish reading, close input file
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1498, %rsp           # imm = 0x1498
movl %ecx, -0x2c(%rbp)
movq %rsi, -0x38(%rbp)
leaq -0x4c0(%rbp), %rdi
pushq $0x8
popq %rax
movq %rdx, %rsi
movl %eax, %edx
callq 0x2300
leaq -0x80(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq -0x2b8(%rbp), %rdi
callq 0x2150
leaq -0xb8(%rbp), %rax
andl $0x0, (%rax)
andq $0x0, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
andq $0x0, 0x20(%rax)
leaq -0x30(%rbp), %r12
movl $0x1, (%r12)
leaq -0x58(%rbp), %rbx
leaq -0xc0(%rbp), %r14
leaq -0x70(%rbp), %r13
leaq -0x130(%rbp), %r15
movl $0x1000, %edx           # imm = 0x1000
leaq -0x4c0(%rbp), %rdi
leaq -0x14c0(%rbp), %rsi
callq 0x2090
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x336d
leaq -0x90(%rbp), %rdi
leaq -0x14c0(%rbp), %rsi
callq 0x2310
leaq -0x2a8(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x21b0
leaq -0x48(%rbp), %rax
movq %rax, -0x58(%rbp)
andq $0x0, -0x50(%rbp)
movb $0x0, -0x48(%rbp)
leaq -0x2b8(%rbp), %rdi
movq %rbx, %rsi
callq 0x2230
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x3341
movq %r14, %rdi
movq %rbx, %rsi
callq 0x5572
leaq -0xb8(%rbp), %rcx
cmpq %rcx, %rax
je 0x32fc
movq %r14, %rdi
movq %rbx, %rsi
callq 0x5432
movq %rax, %rdi
movq %r12, %rsi
callq 0x3712
jmp 0x32b0
xorps %xmm0, %xmm0
movaps %xmm0, -0x70(%rbp)
andq $0x0, -0x60(%rbp)
movq %r13, %rdi
movq %r12, %rsi
callq 0x3712
movq %r15, %rdi
movq %rbx, %rsi
movq %r13, %rdx
callq 0x53dc
movq %r14, %rdi
movq %r15, %rsi
callq 0x5612
movq %r15, %rdi
callq 0x5412
movq %r13, %rdi
callq 0x3c38
jmp 0x32b0
movq -0x2b8(%rbp), %rax
movq -0x18(%rax), %rdi
leaq -0x2b8(%rbp), %rax
addq %rax, %rdi
xorl %esi, %esi
callq 0x22c0
incl -0x30(%rbp)
movq %rbx, %rdi
callq 0x20d0
jmp 0x324f
movq 0x7c64(%rip), %rdi      # 0xafd8
callq 0x20e0
movq -0xa8(%rbp), %r15
movslq -0x2c(%rbp), %r13
leaq -0xf8(%rbp), %rbx
leaq -0xd8(%rbp), %r14
leaq -0xb8(%rbp), %rax
cmpq %rax, %r15
je 0x33fd
movq 0x48(%r15), %rax
subq 0x40(%r15), %rax
sarq $0x2, %rax
cmpq %r13, %rax
jb 0x33f0
leaq 0x20(%r15), %rsi
movq -0x38(%rbp), %rax
movq (%rax), %r12
movq %rbx, %rdi
callq 0x2260
leaq 0x40(%r15), %rsi
movq %r14, %rdi
callq 0x3818
movq -0x38(%rbp), %rdi
movq %r12, %rsi
movq %rbx, %rdx
movq %r14, %rcx
callq 0x549c
movq %r14, %rdi
callq 0x3c38
movq %rbx, %rdi
callq 0x20d0
movq %r15, %rdi
callq 0x2140
movq %rax, %r15
jmp 0x3392
leaq -0x4c0(%rbp), %rdi
callq 0x2050
leaq -0xc0(%rbp), %rdi
callq 0x5cde
leaq -0x2b8(%rbp), %rdi
callq 0x2170
leaq -0x90(%rbp), %rdi
callq 0x20d0
leaq -0x4c0(%rbp), %rdi
callq 0x2070
addq $0x1498, %rsp           # imm = 0x1498
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x3475
jmp 0x3475
movq %rax, %rbx
jmp 0x34c1
movq %rax, %rbx
jmp 0x346a
jmp 0x3475
movq %rax, %rbx
leaq -0xd8(%rbp), %rdi
callq 0x3c38
leaq -0xf8(%rbp), %rdi
jmp 0x34a4
jmp 0x349d
movq %rax, %rbx
jmp 0x34a9
movq %rax, %rbx
leaq -0x130(%rbp), %rdi
callq 0x5412
jmp 0x3490
jmp 0x348d
movq %rax, %rbx
leaq -0x70(%rbp), %rdi
callq 0x3c38
jmp 0x34a0
jmp 0x349d
movq %rax, %rbx
leaq -0x58(%rbp), %rdi
callq 0x20d0
leaq -0xc0(%rbp), %rdi
callq 0x5cde
leaq -0x2b8(%rbp), %rdi
callq 0x2170
leaq -0x90(%rbp), %rdi
callq 0x20d0
leaq -0x4c0(%rbp), %rdi
callq 0x2070
movq %rbx, %rdi
callq 0x22e0
nop