// File: 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
subq $0x1560, %rsp           # imm = 0x1560
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movq -0x18(%rbp), %rsi
leaq -0x228(%rbp), %rdi
movl $0x8, %edx
callq 0x23c0
leaq -0x1250(%rbp), %rdi
callq 0x2320
leaq -0x13d8(%rbp), %rdi
callq 0x2190
jmp 0x3c59
movl $0x1, -0x13e8(%rbp)
leaq -0x1418(%rbp), %rdi
callq 0xd4a0
leaq -0x228(%rbp), %rdi
leaq -0x1230(%rbp), %rsi
movl $0x1000, %edx           # imm = 0x1000
callq 0x20b0
movq %rax, -0x1508(%rbp)
jmp 0x3c90
movq -0x1508(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x22e0
movb %al, -0x1509(%rbp)
jmp 0x3cae
movb -0x1509(%rbp), %al
testb $0x1, %al
jne 0x3cbd
jmp 0x3f3c
leaq -0x1250(%rbp), %rdi
leaq -0x1230(%rbp), %rsi
callq 0x2310
jmp 0x3cd2
leaq -0x13c8(%rbp), %rdi
leaq -0x1250(%rbp), %rsi
callq 0x2200
jmp 0x3ce7
leaq -0x1438(%rbp), %rdi
callq 0x2320
leaq -0x13d8(%rbp), %rdi
leaq -0x1438(%rbp), %rsi
callq 0x22f0
movq %rax, -0x1518(%rbp)
jmp 0x3d0f
movq -0x1518(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x22e0
movb %al, -0x1519(%rbp)
jmp 0x3d2d
movb -0x1519(%rbp), %al
testb $0x1, %al
jne 0x3d3c
jmp 0x3eef
leaq -0x1418(%rbp), %rdi
leaq -0x1438(%rbp), %rsi
callq 0xd4f0
movq %rax, -0x1528(%rbp)
jmp 0x3d58
movq -0x1528(%rbp), %rax
movq %rax, -0x1440(%rbp)
leaq -0x1418(%rbp), %rdi
callq 0xd520
movq %rax, -0x1448(%rbp)
leaq -0x1440(%rbp), %rdi
leaq -0x1448(%rbp), %rsi
callq 0xd4c0
testb $0x1, %al
jne 0x3d95
jmp 0x3eb7
leaq -0x1460(%rbp), %rdi
movq %rdi, -0x1530(%rbp)
callq 0x4500
movq -0x1530(%rbp), %rdi
leaq -0x13e8(%rbp), %rsi
callq 0x4750
jmp 0x3dbd
leaq -0x1498(%rbp), %rdi
leaq -0x1438(%rbp), %rsi
leaq -0x1460(%rbp), %rdx
callq 0xd590
jmp 0x3dd9
leaq -0x1418(%rbp), %rdi
leaq -0x1498(%rbp), %rsi
callq 0xd550
movb %dl, -0x1539(%rbp)
movq %rax, -0x1538(%rbp)
jmp 0x3dfb
movb -0x1539(%rbp), %al
movq -0x1538(%rbp), %rcx
movq %rcx, -0x14a8(%rbp)
movb %al, -0x14a0(%rbp)
leaq -0x1498(%rbp), %rdi
callq 0xd5f0
leaq -0x1460(%rbp), %rdi
callq 0x4860
jmp 0x3eea
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x13e0(%rbp)
movl %eax, -0x13e4(%rbp)
jmp 0x4131
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x13e0(%rbp)
movl %eax, -0x13e4(%rbp)
jmp 0x4119
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x13e0(%rbp)
movl %eax, -0x13e4(%rbp)
jmp 0x3f2b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x13e0(%rbp)
movl %eax, -0x13e4(%rbp)
jmp 0x3ea9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x13e0(%rbp)
movl %eax, -0x13e4(%rbp)
leaq -0x1498(%rbp), %rdi
callq 0xd5f0
leaq -0x1460(%rbp), %rdi
callq 0x4860
jmp 0x3f2b
leaq -0x1418(%rbp), %rdi
leaq -0x1438(%rbp), %rsi
callq 0xd620
movq %rax, -0x1548(%rbp)
jmp 0x3ed3
movq -0x1548(%rbp), %rdi
leaq -0x13e8(%rbp), %rsi
callq 0x4750
jmp 0x3ee8
jmp 0x3eea
jmp 0x3cf3
movq -0x13d8(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x13d8(%rbp,%rax), %rdi
xorl %esi, %esi
callq 0x2370
jmp 0x3f0b
movl -0x13e8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x13e8(%rbp)
leaq -0x1438(%rbp), %rdi
callq 0x2160
jmp 0x3c6f
leaq -0x1438(%rbp), %rdi
callq 0x2160
jmp 0x4119
movq 0x16095(%rip), %rdi     # 0x19fd8
movq 0x16076(%rip), %rsi     # 0x19fc0
callq 0x2260
jmp 0x3f51
movl $0x0, -0x14ac(%rbp)
leaq -0x14b8(%rbp), %rdi
callq 0xd700
leaq -0x1418(%rbp), %rdi
callq 0xd720
movq %rax, -0x14c0(%rbp)
movq -0x14c0(%rbp), %rax
movq %rax, -0x14b8(%rbp)
leaq -0x1418(%rbp), %rdi
callq 0xd520
movq %rax, -0x14c8(%rbp)
leaq -0x14b8(%rbp), %rdi
leaq -0x14c8(%rbp), %rsi
callq 0xd750
testb $0x1, %al
jne 0x3fb7
jmp 0x40d2
leaq -0x14b8(%rbp), %rdi
callq 0xd780
movq %rax, %rdi
addq $0x20, %rdi
callq 0x4a40
movslq -0x1c(%rbp), %rcx
cmpq %rcx, %rax
jb 0x40bf
movq -0x10(%rbp), %rdi
movq %rdi, -0x1558(%rbp)
callq 0x43b0
movq %rax, -0x1550(%rbp)
jmp 0x3ff5
leaq -0x14b8(%rbp), %rdi
callq 0xd780
movq %rax, %rsi
leaq -0x14e8(%rbp), %rdi
callq 0x20e0
jmp 0x4012
leaq -0x14b8(%rbp), %rdi
callq 0xd780
movq %rax, %rsi
addq $0x20, %rsi
leaq -0x1500(%rbp), %rdi
callq 0x4b50
jmp 0x4033
movq -0x1550(%rbp), %rsi
movq -0x1558(%rbp), %rdi
leaq -0x14e8(%rbp), %rdx
leaq -0x1500(%rbp), %rcx
callq 0xd7a0
jmp 0x4056
leaq -0x1500(%rbp), %rdi
callq 0x4860
leaq -0x14e8(%rbp), %rdi
callq 0x2160
movl -0x14ac(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14ac(%rbp)
jmp 0x40bf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x13e0(%rbp)
movl %eax, -0x13e4(%rbp)
jmp 0x40b1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x13e0(%rbp)
movl %eax, -0x13e4(%rbp)
leaq -0x1500(%rbp), %rdi
callq 0x4860
leaq -0x14e8(%rbp), %rdi
callq 0x2160
jmp 0x4119
jmp 0x40c1
leaq -0x14b8(%rbp), %rdi
callq 0xd8f0
jmp 0x3f88
leaq -0x228(%rbp), %rdi
callq 0x2070
jmp 0x40e0
leaq -0x1418(%rbp), %rdi
callq 0xd920
leaq -0x13d8(%rbp), %rdi
callq 0x21b0
leaq -0x1250(%rbp), %rdi
callq 0x2160
leaq -0x228(%rbp), %rdi
callq 0x2090
addq $0x1560, %rsp           # imm = 0x1560
popq %rbp
retq
leaq -0x1418(%rbp), %rdi
callq 0xd920
leaq -0x13d8(%rbp), %rdi
callq 0x21b0
leaq -0x1250(%rbp), %rdi
callq 0x2160
leaq -0x228(%rbp), %rdi
callq 0x2090
movq -0x13e0(%rbp), %rdi
callq 0x2390
nopw %cs:(%rax,%rax)
nop