// File: /workspace/github_cpp_makefile_star2_O3/shangjingbo1226[P]MACFP/src/methods/MACFP.cpp
// Function: main
int main(int argc, char* argv[])
{
    loadConfiguration(argc, argv);

    cout << "settings:" << endl;
    cout << "\tfilename = " << DNA_FILENAME << endl;
    cout << "\tmin_sup = " << MIN_SUP << endl;
    cout << "\tlen_thres = " << LEN_THRES << endl;
    cout << "\tedit_thres = " << EDIT_DIS_THRES << endl;

    double start = clock();

    string dna = loadDNASequence();

    cerr << "n = " << dna.size() << endl;

    size_t n = dna.size();

    s = new String(dna);
    reverse(dna.begin(), dna.end());
    rev_s = new String(dna);
    reverse(dna.begin(), dna.end());

    prefixSum.resize(alphabet.size(), vector<int>(dna.size() + 1, 0));
    for (int i = 0; i < dna.size(); ++ i) {
        for (int j = 0; j < alphabet.size(); ++ j) {
            prefixSum[j][i + 1] = prefixSum[j][i];
        }
        int index = alphabet.find(dna[i]);
        prefixSum[index][i + 1] += 1;
    }

    cerr << "initialization done" << endl;

    FILE* out = tryOpen(OUTPUT_FILENAME, "w");
    int lastJ = -1;
    int cnt = 0;
    for (int i = 0, j = 0; i + LEN_THRES - 1 < n; ++ i) {
        j = max(j, i + LEN_THRES - 1);

        bufferLeft.clear();
        vector<PII> sup = getSup(i, j);
        while (j < n && sup.size() >= MIN_SUP) {
            bufferRight.clear();
            vector<PII> newSup = getSup(i, j);
            if (newSup.size() >= MIN_SUP) {
                sup = newSup;
                ++ j;
            } else {
                break;
            }
        }

        if (j > lastJ && sup.size() >= MIN_SUP) {
            //cerr << i << " " << j - 1 << endl;
            lastJ = j;
            fprintf(out, "%d %d ", i, j - 1);
            for (int k = i; k < j; ++ k) {
                fprintf(out, "%c", dna[k]);
            }
            fprintf(out, "\n");
            fprintf(out, "supports: %d\n", sup.size());
            FOR (pair, sup) {
                fprintf(out, "\t%d %d ", pair->first, pair->second);
                for (int k = pair->first; k <= pair->second; ++ k) {
                    fprintf(out, "%c", dna[k]);
                }
                fprintf(out, "\n");
            }
            cnt ++;
        }
    }
    cerr << "# approximate patterns = " << cnt << endl;
    cerr << "counter = " << counter << endl;
    fclose(out);

    cout << "running time: " << (clock() - start) / CLOCKS_PER_SEC << endl;
    cout << "# of patterns: " << cnt << endl;

    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xf8, %rsp
callq 0x2c14
movq 0x942d(%rip), %rbx      # 0xdfc8
leaq 0x55b7(%rip), %rsi      # 0xa159
movl $0x9, %edx
movq %rbx, %rdi
callq 0x2210
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21b0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2140
leaq 0x5586(%rip), %rsi      # 0xa163
movl $0xc, %edx
movq %rbx, %rdi
callq 0x2210
movq 0x5f67717(%rip), %rsi   # 0x5f6c308
movq 0x5f67718(%rip), %rdx   # 0x5f6c310
movq %rbx, %rdi
callq 0x2210
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x21b0
movsbl %al, %esi
movq %r14, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2140
leaq 0x553f(%rip), %rsi      # 0xa170
movl $0xb, %edx
movq %rbx, %rdi
callq 0x2210
movl 0x9588(%rip), %esi      # 0xe1cc
movq %rbx, %rdi
callq 0x2320
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x21b0
movsbl %al, %esi
movq %r14, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2140
leaq 0x54ff(%rip), %rsi      # 0xa17c
movl $0xd, %edx
movq %rbx, %rdi
callq 0x2210
movl 0x9544(%rip), %esi      # 0xe1d4
movq %rbx, %rdi
callq 0x2320
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x21b0
movsbl %al, %esi
movq %r14, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2140
leaq 0x54c1(%rip), %rsi      # 0xa18a
movl $0xe, %edx
movq %rbx, %rdi
callq 0x2210
movl 0x94f4(%rip), %esi      # 0xe1d0
movq %rbx, %rdi
callq 0x2320
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21b0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2140
callq 0x2120
movq %rax, %r12
leaq 0x38(%rsp), %rdi
callq 0x2e46
movq 0x92c9(%rip), %rdi      # 0xdff0
leaq 0x546b(%rip), %rsi      # 0xa199
movl $0x4, %edx
callq 0x2210
movq 0x40(%rsp), %rsi
movq 0x92ac(%rip), %rdi      # 0xdff0
callq 0x2130
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21b0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2140
movq 0x40(%rsp), %rax
movq %rax, 0x8(%rsp)
movl $0x38, %edi
callq 0x21e0
movq %rax, %r14
leaq 0xc8(%rsp), %r15
movq %r15, -0x10(%r15)
movq 0x38(%rsp), %rsi
movq 0x8(%rsp), %rax
leaq (%rsi,%rax), %rdx
leaq 0xb8(%rsp), %rdi
callq 0x8028
leaq 0xb8(%rsp), %rsi
movq %r14, %rdi
callq 0x59fe
movq %r14, 0x5f675a0(%rip)   # 0x5f6c368
movq 0xb8(%rsp), %rdi
cmpq %r15, %rdi
je 0x4de5
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x21f0
movq 0x38(%rsp), %rax
movq 0x40(%rsp), %rcx
testq %rcx, %rcx
setne %dl
addq %rax, %rcx
decq %rcx
cmpq %rax, %rcx
seta %sil
andb %dl, %sil
cmpb $0x1, %sil
jne 0x4e29
incq %rax
movb -0x1(%rax), %dl
movb (%rcx), %sil
movb %sil, -0x1(%rax)
movb %dl, (%rcx)
decq %rcx
leaq 0x1(%rax), %rdx
cmpq %rcx, %rax
movq %rdx, %rax
jb 0x4e0e
movl $0x38, %edi
callq 0x21e0
movq %rax, %r14
leaq 0xa8(%rsp), %r15
movq %r15, -0x10(%r15)
movq 0x38(%rsp), %rsi
movq 0x40(%rsp), %rdx
addq %rsi, %rdx
leaq 0x98(%rsp), %rdi
callq 0x8028
leaq 0x98(%rsp), %rsi
movq %r14, %rdi
callq 0x59fe
movq %r14, 0x5f674fd(%rip)   # 0x5f6c370
movq 0x98(%rsp), %rdi
cmpq %r15, %rdi
je 0x4e90
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x21f0
movq 0x38(%rsp), %rax
movq 0x40(%rsp), %rsi
testq %rsi, %rsi
setne %dl
leaq (%rax,%rsi), %rcx
decq %rcx
cmpq %rax, %rcx
seta %dil
andb %dl, %dil
cmpb $0x1, %dil
jne 0x4eda
incq %rax
movb -0x1(%rax), %dl
movb (%rcx), %sil
movb %sil, -0x1(%rax)
movb %dl, (%rcx)
decq %rcx
leaq 0x1(%rax), %rdx
cmpq %rcx, %rax
movq %rdx, %rax
jb 0x4eba
movq 0x40(%rsp), %rsi
movq 0x5f6746f(%rip), %rbx   # 0x5f6c350
incq %rsi
leaq 0x58(%rsp), %rdx
movl $0x0, (%rdx)
leaq 0x18(%rsp), %rdi
leaq 0x17(%rsp), %rcx
callq 0x5682
leaq 0x5f67473(%rip), %rdi   # 0x5f6c378
leaq 0x18(%rsp), %rdx
movq %rbx, %rsi
callq 0x5cf8
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x4f29
movq 0x28(%rsp), %rsi
subq %rdi, %rsi
callq 0x21f0
cmpq $0x0, 0x40(%rsp)
je 0x4f97
xorl %r14d, %r14d
leaq 0x5f6740d(%rip), %rbx   # 0x5f6c348
movq 0x5f6740e(%rip), %rax   # 0x5f6c350
testq %rax, %rax
je 0x4f63
movq 0x5f6742a(%rip), %rcx   # 0x5f6c378
movq (%rcx), %rdx
movl (%rdx,%r14,4), %esi
movl %esi, 0x4(%rdx,%r14,4)
addq $0x18, %rcx
decq %rax
jne 0x4f4e
movq 0x38(%rsp), %rax
movsbl (%rax,%r14), %esi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x2250
cltq
movq 0x5f673f8(%rip), %rcx   # 0x5f6c378
leaq (%rax,%rax,2), %rax
movq (%rcx,%rax,8), %rax
incl 0x4(%rax,%r14,4)
incq %r14
cmpq %r14, 0x40(%rsp)
ja 0x4f3b
movq 0x9052(%rip), %rbx      # 0xdff0
leaq 0x51f9(%rip), %rsi      # 0xa19e
movl $0x13, %edx
movq %rbx, %rdi
callq 0x2210
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x21b0
movsbl %al, %esi
movq 0x9020(%rip), %rdi      # 0xdff0
callq 0x2040
movq %rax, %rdi
callq 0x2140
movq %r12, 0x70(%rsp)
leaq 0x88(%rsp), %r15
movq %r15, -0x10(%r15)
movq 0x5f67333(%rip), %rsi   # 0x5f6c328
movq 0x5f67334(%rip), %rdx   # 0x5f6c330
addq %rsi, %rdx
leaq 0x78(%rsp), %rdi
callq 0x8028
leaq 0xe8(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x5195(%rip), %rsi      # 0xa1b2
leaq 0x518f(%rip), %rdx      # 0xa1b3
leaq 0xd8(%rsp), %rdi
callq 0x87ec
leaq 0x78(%rsp), %rdi
leaq 0xd8(%rsp), %rbx
movq %rbx, %rsi
callq 0x2ab2
movq %rax, %r14
movq (%rbx), %rdi
cmpq %r12, %rdi
je 0x5061
movq 0xe8(%rsp), %rsi
incq %rsi
callq 0x21f0
movq 0x78(%rsp), %rdi
cmpq %r15, %rdi
je 0x507b
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x21f0
movl 0x9153(%rip), %eax      # 0xe1d4
decl %eax
movslq %eax, %rcx
movl $0x0, 0x10(%rsp)
cmpq %rcx, 0x8(%rsp)
jbe 0x52a5
movl $0xffffffff, 0x34(%rsp) # imm = 0xFFFFFFFF
leaq 0x58(%rsp), %rbx
xorl %r15d, %r15d
movl $0x0, 0x10(%rsp)
xorl %r12d, %r12d
movl %r12d, %ecx
cmpl %eax, %r12d
movl %eax, %r12d
cmovgl %ecx, %r12d
leaq 0x5f672c8(%rip), %rdi   # 0x5f6c390
callq 0x5e6a
leaq 0x18(%rsp), %rdi
movl %r15d, %esi
movl %r12d, %edx
callq 0x42a4
movl %r12d, %eax
cmpq %rax, 0x8(%rsp)
jbe 0x516c
movq 0x20(%rsp), %rax
subq 0x18(%rsp), %rax
sarq $0x3, %rax
movslq 0x90cc(%rip), %rcx      # 0xe1cc
cmpq %rcx, %rax
jb 0x516c
leaq 0x5f672bc(%rip), %rdi   # 0x5f6c3c8
callq 0x5e6a
movq %rbx, %rdi
movl %r15d, %esi
movl %r12d, %edx
callq 0x42a4
movq 0x58(%rsp), %rdi
movq 0x60(%rsp), %rbp
subq %rdi, %rbp
sarq $0x3, %rbp
movslq 0x9095(%rip), %r13      # 0xe1cc
cmpq %r13, %rbp
jb 0x5151
leaq 0x18(%rsp), %rdi
movq %rbx, %rsi
callq 0x5d3a
incl %r12d
movq 0x58(%rsp), %rdi
testq %rdi, %rdi
je 0x5163
movq 0x68(%rsp), %rsi
subq %rdi, %rsi
callq 0x21f0
cmpq %r13, %rbp
jae 0x50dd
movq 0x18(%rsp), %rbp
cmpl 0x34(%rsp), %r12d
jle 0x5276
movq 0x20(%rsp), %rax
subq %rbp, %rax
sarq $0x3, %rax
movslq 0x903d(%rip), %rcx      # 0xe1cc
cmpq %rcx, %rax
jb 0x5276
leal -0x1(%r12), %ecx
movq %r14, %rdi
leaq 0x501c(%rip), %rsi      # 0xa1c3
movl %r15d, %edx
xorl %eax, %eax
callq 0x2270
cmpl %r15d, %r12d
jle 0x51d5
movl %r12d, %r13d
movq %r15, %rbp
movq 0x38(%rsp), %rax
movsbl (%rax,%rbp), %edi
movq %r14, %rsi
callq 0x2240
incq %rbp
cmpq %rbp, %r13
jne 0x51bc
movl $0xa, %edi
movq %r14, %rsi
callq 0x2240
movq 0x20(%rsp), %rdx
subq 0x18(%rsp), %rdx
sarq $0x3, %rdx
movq %r14, %rdi
leaq 0x4fba(%rip), %rsi      # 0xa1b4
xorl %eax, %eax
callq 0x2270
movq 0x18(%rsp), %rbp
cmpq 0x20(%rsp), %rbp
je 0x526d
movl (%rbp), %edx
movl 0x4(%rbp), %ecx
movq %r14, %rdi
leaq 0x4fa5(%rip), %rsi      # 0xa1c2
xorl %eax, %eax
callq 0x2270
movslq (%rbp), %r13
cmpl 0x4(%rbp), %r13d
jg 0x5250
decq %r13
movq 0x38(%rsp), %rax
movsbl 0x1(%rax,%r13), %edi
movq %r14, %rsi
callq 0x2240
movslq 0x4(%rbp), %rax
incq %r13
cmpq %rax, %r13
jl 0x5231
movl $0xa, %edi
movq %r14, %rsi
callq 0x2240
addq $0x8, %rbp
cmpq 0x20(%rsp), %rbp
jne 0x520d
movq 0x18(%rsp), %rbp
incl 0x10(%rsp)
movl %r12d, 0x34(%rsp)
testq %rbp, %rbp
je 0x528b
movq 0x28(%rsp), %rsi
subq %rbp, %rsi
movq %rbp, %rdi
callq 0x21f0
movl 0x8f43(%rip), %eax      # 0xe1d4
addl %r15d, %eax
incq %r15
movslq %eax, %rcx
cmpq %rcx, 0x8(%rsp)
ja 0x50b4
movq 0x8d44(%rip), %rdi      # 0xdff0
leaq 0x4f17(%rip), %rsi      # 0xa1ca
movl $0x19, %edx
callq 0x2210
movl 0x10(%rsp), %ebp
movq 0x8d28(%rip), %rdi      # 0xdff0
movl %ebp, %esi
callq 0x2320
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21b0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2140
movq 0x8cf0(%rip), %rdi      # 0xdff0
leaq 0x4edd(%rip), %rsi      # 0xa1e4
movl $0xa, %edx
callq 0x2210
movl 0x5f670e9(%rip), %esi   # 0x5f6c400
movq 0x8cd2(%rip), %rdi      # 0xdff0
callq 0x2320
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21b0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2140
movq %r14, %rdi
callq 0x21d0
movq 0x8c6c(%rip), %rdi      # 0xdfc8
leaq 0x4e8c(%rip), %rsi      # 0xa1ef
movl $0xe, %edx
callq 0x2210
cvtsi2sdq 0x70(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
callq 0x2120
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
subsd 0x8(%rsp), %xmm0
divsd 0x4cab(%rip), %xmm0     # 0xa040
movq 0x8c2c(%rip), %rdi      # 0xdfc8
callq 0x22f0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21b0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2140
movq 0x8bf6(%rip), %rdi      # 0xdfc8
leaq 0x4e25(%rip), %rsi      # 0xa1fe
movl $0xf, %edx
callq 0x2210
movq 0x8bde(%rip), %rdi      # 0xdfc8
movl %ebp, %esi
callq 0x2320
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21b0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2140
leaq 0x48(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x5436
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x21f0
xorl %eax, %eax
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0x78(%rsp), %rdi
cmpq %r15, %rdi
je 0x54fd
movq 0x88(%rsp), %rsi
incq %rsi
jmp 0x54f8
jmp 0x54c2
jmp 0x54e3
jmp 0x54c2
movq %rax, %rbx
movq 0x98(%rsp), %rdi
cmpq %r15, %rdi
je 0x54b2
movq 0xa8(%rsp), %rsi
jmp 0x54a5
jmp 0x54af
movq %rax, %rbx
movq 0xb8(%rsp), %rdi
cmpq %r15, %rdi
je 0x54b2
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x21f0
jmp 0x54b2
movq %rax, %rbx
movl $0x38, %esi
movq %r14, %rdi
jmp 0x54f8
jmp 0x54c2
jmp 0x54c2
jmp 0x54c2
movq %rax, %rbx
jmp 0x54fd
movq %rax, %rbx
movq 0x58(%rsp), %rdi
testq %rdi, %rdi
je 0x54e6
movq 0x68(%rsp), %rsi
subq %rdi, %rsi
callq 0x21f0
jmp 0x54e6
movq %rax, %rbx
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x54fd
movq 0x28(%rsp), %rsi
subq %rdi, %rsi
callq 0x21f0
leaq 0x48(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x5518
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x21f0
movq %rbx, %rdi
callq 0x2330