// File: /workspace/github_cpp_makefile_star2_O3/shangjingbo1226[P]MACFP/src/methods/TDP.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();
    //dna = "acgtacgt";

    int n = dna.size();
    cerr << "length of DNA sequence = " << n << endl;

    //cerr << getSup(dna, n, 1958, 1970).size() << endl; return 0;
    /*cerr << "valid = " << valid(dna, n, 0, 0) << endl;
    cerr << "valid = " << valid(dna, n, 0, 1) << endl;
    return 0;*/

    FILE* out = tryOpen(OUTPUT_FILENAME, "w");
    int lastJ = -1;
    int cnt = 0;
    for (int i = 0, j = 0; i < n; ++ i) {
        j = max(j, i);
        while (j < n && getSup(dna, n, i, j).size() >= MIN_SUP) {
            ++ j;
        }
        if (j > lastJ) {
            lastJ = j;
            if (j - i < LEN_THRES) {
                continue;
            }
            vector< pair<int, int> > sups = getSup(dna, n, i, j - 1);
            //cerr << i << " " << j << endl;
            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", sups.size());
            FOR (pair, sups) {
                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;
    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 $0x98, %rsp
callq 0x29f4
movq 0x4d36(%rip), %rbx      # 0x7fc8
leaq 0x1e5a(%rip), %rsi      # 0x50f3
movl $0x9, %edx
movq %rbx, %rdi
callq 0x21b0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2160
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2100
leaq 0x1e29(%rip), %rsi      # 0x50fd
movl $0xc, %edx
movq %rbx, %rdi
callq 0x21b0
movq 0x5f62ff0(%rip), %rsi   # 0x5f662d8
movq 0x5f62ff1(%rip), %rdx   # 0x5f662e0
movq %rbx, %rdi
callq 0x21b0
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2160
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2100
leaq 0x1de2(%rip), %rsi      # 0x510a
movl $0xb, %edx
movq %rbx, %rdi
callq 0x21b0
movl 0x4e59(%rip), %esi      # 0x8194
movq %rbx, %rdi
callq 0x22b0
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2160
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2100
leaq 0x1da2(%rip), %rsi      # 0x5116
movl $0xd, %edx
movq %rbx, %rdi
callq 0x21b0
movl 0x4e15(%rip), %esi      # 0x819c
movq %rbx, %rdi
callq 0x22b0
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2160
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2100
leaq 0x1d64(%rip), %rsi      # 0x5124
movl $0xe, %edx
movq %rbx, %rdi
callq 0x21b0
movl 0x4dc5(%rip), %esi      # 0x8198
movq %rbx, %rdi
callq 0x22b0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2160
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2100
callq 0x20f0
movq %rax, %r14
leaq 0x28(%rsp), %rbx
movq %rbx, %rdi
callq 0x2c26
movq 0x8(%rbx), %r15
movq 0x4bcb(%rip), %rdi      # 0x7ff0
leaq 0x1d07(%rip), %rsi      # 0x5133
movl $0x19, %edx
callq 0x21b0
movq 0x4bb3(%rip), %rdi      # 0x7ff0
movl %r15d, %esi
callq 0x22b0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2160
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2100
movq %r15, 0x8(%rsp)
leaq 0x68(%rsp), %r12
movq %r12, -0x10(%r12)
movq 0x5f62e73(%rip), %rsi   # 0x5f662f8
movq 0x5f62e74(%rip), %rdx   # 0x5f66300
addq %rsi, %rdx
leaq 0x58(%rsp), %rdi
callq 0x3c4c
leaq 0x88(%rsp), %r13
movq %r13, -0x10(%r13)
leaq 0x1ca1(%rip), %rsi      # 0x514d
leaq 0x1c9b(%rip), %rdx      # 0x514e
leaq 0x78(%rsp), %rdi
callq 0x4410
leaq 0x58(%rsp), %rdi
leaq 0x78(%rsp), %rbx
movq %rbx, %rsi
callq 0x2892
movq %rax, %r15
movq (%rbx), %rdi
cmpq %r13, %rdi
je 0x34ea
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x21a0
movq 0x58(%rsp), %rdi
cmpq %r12, %rdi
movq 0x8(%rsp), %r13
je 0x3506
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x21a0
movq %r14, 0x48(%rsp)
testl %r13d, %r13d
jle 0x36d7
movl %r13d, %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movq %rax, 0x50(%rsp)
movl $0xffffffff, 0x4(%rsp)  # imm = 0xFFFFFFFF
xorl %ebp, %ebp
movl $0x0, (%rsp)
xorl %ebx, %ebx
cmpl %ebp, %ebx
cmovlel %ebp, %ebx
cmpl %r13d, %ebx
jge 0x3595
leaq 0x10(%rsp), %rdi
leaq 0x28(%rsp), %rsi
movl %r13d, %edx
movl %ebp, %ecx
movl %ebx, %r8d
callq 0x2e1d
movq 0x10(%rsp), %r12
movq 0x18(%rsp), %r13
movslq 0x4c2e(%rip), %r14      # 0x8194
testq %r12, %r12
je 0x357b
movq 0x20(%rsp), %rsi
subq %r12, %rsi
movq %r12, %rdi
callq 0x21a0
subq %r12, %r13
sarq $0x3, %r13
cmpq %r14, %r13
jb 0x3590
incl %ebx
movq 0x8(%rsp), %r13
jmp 0x3539
movq 0x8(%rsp), %r13
cmpl 0x4(%rsp), %ebx
jle 0x36c7
movl %ebx, %eax
subl %ebp, %eax
cmpl 0x4bf3(%rip), %eax      # 0x819c
jge 0x35b4
movl %ebx, 0x4(%rsp)
jmp 0x36c7
leal -0x1(%rbx), %r12d
leaq 0x10(%rsp), %rdi
leaq 0x28(%rsp), %rsi
movl %r13d, %edx
movl %ebp, %ecx
movl %r12d, %r8d
callq 0x2e1d
movq %r15, %rdi
leaq 0x1b85(%rip), %rsi      # 0x515e
movl %ebp, %edx
movl %r12d, %ecx
xorl %eax, %eax
callq 0x2200
cmpl %ebp, %ebx
jbe 0x3609
movl %ebx, %r12d
movq %rbp, %r14
movq 0x28(%rsp), %rax
movsbl (%rax,%r14), %edi
movq %r15, %rsi
callq 0x21e0
incq %r14
cmpq %r14, %r12
jne 0x35ef
movl $0xa, %edi
movq %r15, %rsi
callq 0x21e0
movq 0x18(%rsp), %rdx
subq 0x10(%rsp), %rdx
sarq $0x3, %rdx
movq %r15, %rdi
leaq 0x1b21(%rip), %rsi      # 0x514f
xorl %eax, %eax
callq 0x2200
movq 0x10(%rsp), %r12
cmpq 0x18(%rsp), %r12
je 0x36a6
movl (%r12), %edx
movl 0x4(%r12), %ecx
movq %r15, %rdi
leaq 0x1b09(%rip), %rsi      # 0x515d
xorl %eax, %eax
callq 0x2200
movslq (%r12), %r13
cmpl 0x4(%r12), %r13d
jg 0x3689
decq %r13
movq 0x28(%rsp), %rax
movsbl 0x1(%rax,%r13), %edi
movq %r15, %rsi
callq 0x21e0
movslq 0x4(%r12), %rax
incq %r13
cmpq %rax, %r13
jl 0x3669
movl $0xa, %edi
movq %r15, %rsi
callq 0x21e0
addq $0x8, %r12
cmpq 0x18(%rsp), %r12
jne 0x3641
movq 0x10(%rsp), %r12
testq %r12, %r12
je 0x36bb
movq 0x20(%rsp), %rsi
subq %r12, %rsi
movq %r12, %rdi
callq 0x21a0
incl (%rsp)
movl %ebx, 0x4(%rsp)
movq 0x8(%rsp), %r13
incq %rbp
cmpq 0x50(%rsp), %rbp
jne 0x3534
jmp 0x36de
movl $0x0, (%rsp)
movq 0x490b(%rip), %rdi      # 0x7ff0
leaq 0x1a79(%rip), %rsi      # 0x5165
movl $0x19, %edx
callq 0x21b0
movl (%rsp), %ebp
movq 0x48f0(%rip), %rdi      # 0x7ff0
movl %ebp, %esi
callq 0x22b0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2160
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2100
movq %r15, %rdi
callq 0x2180
movq 0x4888(%rip), %rdi      # 0x7fc8
leaq 0x1a38(%rip), %rsi      # 0x517f
movl $0xe, %edx
callq 0x21b0
cvtsi2sdq 0x48(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
callq 0x20f0
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
subsd 0x8(%rsp), %xmm0
divsd 0x18c7(%rip), %xmm0     # 0x5040
movq 0x4848(%rip), %rdi      # 0x7fc8
callq 0x2280
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2160
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2100
movq 0x4812(%rip), %rdi      # 0x7fc8
leaq 0x19d1(%rip), %rsi      # 0x518e
movl $0xf, %edx
callq 0x21b0
movq 0x47fa(%rip), %rdi      # 0x7fc8
movl %ebp, %esi
callq 0x22b0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2160
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2100
leaq 0x38(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x381a
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x21a0
xorl %eax, %eax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0x58(%rsp), %rdi
cmpq %r12, %rdi
je 0x3855
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x21a0
jmp 0x3855
jmp 0x3852
jmp 0x3852
jmp 0x3852
jmp 0x3852
movq %rax, %rbx
leaq 0x38(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3870
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x21a0
movq %rbx, %rdi
callq 0x22c0