// File: tedsharpe[P]ORFCall/ORFCall.cc
// Function: main
int main( int argc, char** argv )
{
    bool dumpNonAligners = false;
    unsigned K = 25;
    double maxMismatchFrac = .1;
    std::string outputFilename = "orfcall";
    bool pairedMode = false;
    unsigned minQ = 20;
    unsigned maxSeqErrs = 2;
    std::string codonTranslation =
            "KNKNTTTTRSRSIIMIQHQHPPPPRRRRLLLLEDEDAAAAGGGGVVVVZYZYSSSSZCWCLFLF";

    int opt;
    while ( (opt = getopt(argc, argv, "dE:K:M:O:pQ:T:")) != -1 )
    {
        switch ( opt )
        {
        case 'd':
            dumpNonAligners = true;
            break;
        case 'E':
        { std::istringstream iss(optarg);
          if ( !(iss >> maxSeqErrs) )
              FatalErr("Can't interpret E='" << optarg
                      << "'. Expecting an integer maximum for sequencing errors per read."); }
          break;
        case 'K':
          { std::istringstream iss(optarg);
            if ( !(iss >> K) || K < 14 || K > 64 )
                FatalErr("Can't interpret K='" << optarg
                        << "'. Expecting an integer between 14 and 64"
                           " for kmer size."); }
            // note to self:  we don't have to worry about palindromes because
            // we're adding the rc of the ref to the dictionary, too, and that
            // will cause palindromes to be discarded as dups.
            break;
        case 'M':
          { std::istringstream iss(optarg);
            if ( !(iss >> maxMismatchFrac) ||
                    maxMismatchFrac < 0. || maxMismatchFrac > 1. )
                FatalErr("Can't interpret M='" << optarg
                        << "'. Expecting a fraction between "
                           "0. and 1. for max mismatch rate."); }
            break;
        case 'O':
            outputFilename = optarg;
            break;
        case 'p':
            pairedMode = true;
            break;
        case 'Q':
          { std::istringstream iss(optarg);
            if ( !(iss >> minQ) || minQ > 60 )
                FatalErr("Can't interpret Q='" << optarg
                        << "'. Expecting an integer min quality score."); }
            break;
        case 'T':
            codonTranslation = optarg;
            if ( codonTranslation.size() != NCODONS )
                FatalErr("Can't interpret T='" << optarg <<
                        " as a table of codon calls.  Expected 64 characters.");
            break;
        case '?':
            if ( optopt == 'E' )
                FatalErr("Need value for E (max seq errs) option.");
            else if ( optopt == 'K' )
                FatalErr("Need value for K (kmer size) option.");
            else if ( optopt == 'M' )
                FatalErr("Need value for M (max mismatch fraction) option.");
            else if ( optopt == 'O' )
                FatalErr("Need value for O (output filename) option.");
            else if ( optopt == 'Q' )
                FatalErr("Need value for Q (min quality score) option.");
            else if ( optopt == 'T' )
                FatalErr("Need value for T (table of codon calls) option.");
            else
                FatalErr("Unknown option character " << optopt);
            break;
        }
    }

    if ( optind+2 > argc )
        FatalErr("Usage: ORFCall [-d] [-E MAX_SEQ_ERRS] [-K KMER_SIZE] "
                      " [-M MAX_MISMATCH_FRACTION]"
                      " [-O OUTPUT_FILENAME] [-p] [-Q MIN_QUAL] [-T CODON_TABLE] "
                      "ref.fasta codons_used.dat reads1.fastq [reads2.fastq...]\n"
                      "The -p flag signals paired mode.\n");

    Reference ref(argv[optind],argv[optind+1],K);
    ref.report();
    optind += 2;

    std::ofstream* pJunkOS = nullptr;
    if ( dumpNonAligners )
        pJunkOS = new std::ofstream(outputFilename+".unaligned.fasta");
    AminoAcidNamer aaNamer(codonTranslation);
    ORFCaller caller(ref,minQ,maxSeqErrs,aaNamer,pJunkOS);
    char** beg = argv+optind;
    char** end = argv+argc;
    if ( !pairedMode )
        caller.processFastqs(beg,end);
    else
        caller.processPairedFastqs(beg,end);
    std::cerr << "Aligned reads: " << 100.*caller.getFractionAligned() << "%\n";

    if ( pJunkOS )
        delete pJunkOS;

    caller.writeCodonCounts(outputFilename+".cdn");
    caller.writeAminoAcidCounts(outputFilename+".aa");
    caller.writeIndelCounts(outputFilename+".indels");
    caller.report(std::cout);
}

// Assembly:
subq $0xd78, %rsp            # imm = 0xD78
movl $0x0, 0xd74(%rsp)
movl %edi, 0xd70(%rsp)
movq %rsi, 0xd68(%rsp)
movb $0x0, 0xd67(%rsp)
movl $0x19, 0xd60(%rsp)
movabsq $0x3fb999999999999a, %rax # imm = 0x3FB999999999999A
movq %rax, 0xd58(%rsp)
leaq 0xd37(%rsp), %rdi
movq %rdi, 0x178(%rsp)
callq 0x4520
movq 0x178(%rsp), %rdx
leaq 0x1cb32(%rip), %rsi     # 0x212ac
leaq 0xd38(%rsp), %rdi
callq 0x4380
jmp 0x4789
leaq 0xd37(%rsp), %rdi
callq 0x42c0
movb $0x0, 0xd23(%rsp)
movl $0x14, 0xd1c(%rsp)
movl $0x2, 0xd18(%rsp)
leaq 0xcf7(%rsp), %rdi
movq %rdi, 0x170(%rsp)
callq 0x4520
movq 0x170(%rsp), %rdx
leaq 0x1cadc(%rip), %rsi     # 0x212b4
leaq 0xcf8(%rsp), %rdi
callq 0x4380
jmp 0x47e7
leaq 0xcf7(%rsp), %rdi
callq 0x42c0
movl 0xd70(%rsp), %edi
movq 0xd68(%rsp), %rsi
leaq 0x1caeb(%rip), %rdx     # 0x212f5
callq 0x4060
movl %eax, 0xcf0(%rsp)
cmpl $-0x1, %eax
je 0x52e1
movl 0xcf0(%rsp), %eax
addl $-0x3f, %eax
movl %eax, %ecx
movq %rcx, 0x168(%rsp)
subl $0x31, %eax
ja 0x52dc
movq 0x168(%rsp), %rax
leaq 0x1c7cd(%rip), %rcx     # 0x21018
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd28(%rsp)
movl %eax, 0xd24(%rsp)
leaq 0xd37(%rsp), %rdi
callq 0x42c0
jmp 0x57e8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd28(%rsp)
movl %eax, 0xd24(%rsp)
leaq 0xcf7(%rsp), %rdi
callq 0x42c0
jmp 0x57db
movb $0x1, 0xd67(%rsp)
jmp 0x52dc
movq 0x286fc(%rip), %rax     # 0x2cfb0
movq (%rax), %rax
movq %rax, 0x158(%rsp)
leaq 0xb4f(%rsp), %rdi
movq %rdi, 0x160(%rsp)
callq 0x4520
movq 0x158(%rsp), %rsi
movq 0x160(%rsp), %rdx
leaq 0xb50(%rsp), %rdi
callq 0x4380
jmp 0x48f3
leaq 0xb70(%rsp), %rdi
leaq 0xb50(%rsp), %rsi
movl $0x8, %edx
callq 0x44b0
jmp 0x490f
leaq 0xb50(%rsp), %rdi
callq 0x41b0
leaq 0xb4f(%rsp), %rdi
callq 0x42c0
leaq 0xb70(%rsp), %rdi
leaq 0xd18(%rsp), %rsi
callq 0x4040
movq %rax, 0x150(%rsp)
jmp 0x4948
movq 0x150(%rsp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x4150
movb %al, 0x14f(%rsp)
jmp 0x4968
movb 0x14f(%rsp), %al
testb $0x1, %al
jne 0x4978
jmp 0x4a63
movq 0x28671(%rip), %rdi     # 0x2cff0
leaq 0x1c97e(%rip), %rsi     # 0x21304
callq 0x4290
movq %rax, 0x140(%rsp)
jmp 0x4995
movq 0x140(%rsp), %rdi
movq 0x2860c(%rip), %rax     # 0x2cfb0
movq (%rax), %rsi
callq 0x4290
movq %rax, 0x138(%rsp)
jmp 0x49b6
movq 0x138(%rsp), %rdi
leaq 0x1c953(%rip), %rsi     # 0x21318
callq 0x4290
movq %rax, 0x130(%rsp)
jmp 0x49d4
movq 0x130(%rsp), %rdi
movq 0x285c5(%rip), %rsi     # 0x2cfa8
callq 0x42b0
jmp 0x49ea
movl $0x1, %edi
callq 0x42f0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd28(%rsp)
movl %eax, 0xd24(%rsp)
jmp 0x4a2b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd28(%rsp)
movl %eax, 0xd24(%rsp)
leaq 0xb50(%rsp), %rdi
callq 0x41b0
leaq 0xb4f(%rsp), %rdi
callq 0x42c0
jmp 0x57ce
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd28(%rsp)
movl %eax, 0xd24(%rsp)
leaq 0xb70(%rsp), %rdi
callq 0x4160
jmp 0x57ce
leaq 0xb70(%rsp), %rdi
callq 0x4160
jmp 0x52dc
movq 0x28534(%rip), %rax     # 0x2cfb0
movq (%rax), %rax
movq %rax, 0x120(%rsp)
leaq 0x9a7(%rsp), %rdi
movq %rdi, 0x128(%rsp)
callq 0x4520
movq 0x120(%rsp), %rsi
movq 0x128(%rsp), %rdx
leaq 0x9a8(%rsp), %rdi
callq 0x4380
jmp 0x4abb
leaq 0x9c8(%rsp), %rdi
leaq 0x9a8(%rsp), %rsi
movl $0x8, %edx
callq 0x44b0
jmp 0x4ad7
leaq 0x9a8(%rsp), %rdi
callq 0x41b0
leaq 0x9a7(%rsp), %rdi
callq 0x42c0
leaq 0x9c8(%rsp), %rdi
leaq 0xd60(%rsp), %rsi
callq 0x4040
movq %rax, 0x118(%rsp)
jmp 0x4b10
movq 0x118(%rsp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x4150
movb %al, 0x117(%rsp)
jmp 0x4b30
movb 0x117(%rsp), %al
testb $0x1, %al
jne 0x4b55
jmp 0x4b3d
cmpl $0xe, 0xd60(%rsp)
jb 0x4b55
cmpl $0x40, 0xd60(%rsp)
jbe 0x4c40
movq 0x28494(%rip), %rdi     # 0x2cff0
leaq 0x1c7f5(%rip), %rsi     # 0x21358
callq 0x4290
movq %rax, 0x108(%rsp)
jmp 0x4b72
movq 0x108(%rsp), %rdi
movq 0x2842f(%rip), %rax     # 0x2cfb0
movq (%rax), %rsi
callq 0x4290
movq %rax, 0x100(%rsp)
jmp 0x4b93
movq 0x100(%rsp), %rdi
leaq 0x1c7ca(%rip), %rsi     # 0x2136c
callq 0x4290
movq %rax, 0xf8(%rsp)
jmp 0x4bb1
movq 0xf8(%rsp), %rdi
movq 0x283e8(%rip), %rsi     # 0x2cfa8
callq 0x42b0
jmp 0x4bc7
movl $0x1, %edi
callq 0x42f0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd28(%rsp)
movl %eax, 0xd24(%rsp)
jmp 0x4c08
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd28(%rsp)
movl %eax, 0xd24(%rsp)
leaq 0x9a8(%rsp), %rdi
callq 0x41b0
leaq 0x9a7(%rsp), %rdi
callq 0x42c0
jmp 0x57ce
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd28(%rsp)
movl %eax, 0xd24(%rsp)
leaq 0x9c8(%rsp), %rdi
callq 0x4160
jmp 0x57ce
leaq 0x9c8(%rsp), %rdi
callq 0x4160
jmp 0x52dc
movq 0x28357(%rip), %rax     # 0x2cfb0
movq (%rax), %rax
movq %rax, 0xe8(%rsp)
leaq 0x7ff(%rsp), %rdi
movq %rdi, 0xf0(%rsp)
callq 0x4520
movq 0xe8(%rsp), %rsi
movq 0xf0(%rsp), %rdx
leaq 0x800(%rsp), %rdi
callq 0x4380
jmp 0x4c98
leaq 0x820(%rsp), %rdi
leaq 0x800(%rsp), %rsi
movl $0x8, %edx
callq 0x44b0
jmp 0x4cb4
leaq 0x800(%rsp), %rdi
callq 0x41b0
leaq 0x7ff(%rsp), %rdi
callq 0x42c0
leaq 0x820(%rsp), %rdi
leaq 0xd58(%rsp), %rsi
callq 0x4200
movq %rax, 0xe0(%rsp)
jmp 0x4ced
movq 0xe0(%rsp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x4150
movb %al, 0xdf(%rsp)
jmp 0x4d0d
movb 0xdf(%rsp), %al
testb $0x1, %al
jne 0x4d44
jmp 0x4d1a
vpxor %xmm0, %xmm0, %xmm0
vucomisd 0xd58(%rsp), %xmm0
ja 0x4d44
vmovsd 0xd58(%rsp), %xmm0
vmovsd 0x1c2d6(%rip), %xmm1    # 0x21010
vucomisd %xmm1, %xmm0
jbe 0x4e2f
movq 0x282a5(%rip), %rdi     # 0x2cff0
leaq 0x1c653(%rip), %rsi     # 0x213a5
callq 0x4290
movq %rax, 0xd0(%rsp)
jmp 0x4d61
movq 0xd0(%rsp), %rdi
movq 0x28240(%rip), %rax     # 0x2cfb0
movq (%rax), %rsi
callq 0x4290
movq %rax, 0xc8(%rsp)
jmp 0x4d82
movq 0xc8(%rsp), %rdi
leaq 0x1c628(%rip), %rsi     # 0x213b9
callq 0x4290
movq %rax, 0xc0(%rsp)
jmp 0x4da0
movq 0xc0(%rsp), %rdi
movq 0x281f9(%rip), %rsi     # 0x2cfa8
callq 0x42b0
jmp 0x4db6
movl $0x1, %edi
callq 0x42f0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd28(%rsp)
movl %eax, 0xd24(%rsp)
jmp 0x4df7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd28(%rsp)
movl %eax, 0xd24(%rsp)
leaq 0x800(%rsp), %rdi
callq 0x41b0
leaq 0x7ff(%rsp), %rdi
callq 0x42c0
jmp 0x57ce
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd28(%rsp)
movl %eax, 0xd24(%rsp)
leaq 0x820(%rsp), %rdi
callq 0x4160
jmp 0x57ce
leaq 0x820(%rsp), %rdi
callq 0x4160
jmp 0x52dc
movq 0x28168(%rip), %rax     # 0x2cfb0
movq (%rax), %rsi
leaq 0xd38(%rsp), %rdi
callq 0x4370
jmp 0x4e5a
jmp 0x52dc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd28(%rsp)
movl %eax, 0xd24(%rsp)
jmp 0x57ce
movb $0x1, 0xd23(%rsp)
jmp 0x52dc
movq 0x28124(%rip), %rax     # 0x2cfb0
movq (%rax), %rax
movq %rax, 0xb0(%rsp)
leaq 0x657(%rsp), %rdi
movq %rdi, 0xb8(%rsp)
callq 0x4520
movq 0xb0(%rsp), %rsi
movq 0xb8(%rsp), %rdx
leaq 0x658(%rsp), %rdi
callq 0x4380
jmp 0x4ecb
leaq 0x678(%rsp), %rdi
leaq 0x658(%rsp), %rsi
movl $0x8, %edx
callq 0x44b0
jmp 0x4ee7
leaq 0x658(%rsp), %rdi
callq 0x41b0
leaq 0x657(%rsp), %rdi
callq 0x42c0
leaq 0x678(%rsp), %rdi
leaq 0xd1c(%rsp), %rsi
callq 0x4040
movq %rax, 0xa8(%rsp)
jmp 0x4f20
movq 0xa8(%rsp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x4150
movb %al, 0xa7(%rsp)
jmp 0x4f40
movb 0xa7(%rsp), %al
testb $0x1, %al
jne 0x4f5b
jmp 0x4f4d
cmpl $0x3c, 0xd1c(%rsp)
jbe 0x5046
movq 0x2808e(%rip), %rdi     # 0x2cff0
leaq 0x1c491(%rip), %rsi     # 0x213fa
callq 0x4290
movq %rax, 0x98(%rsp)
jmp 0x4f78
movq 0x98(%rsp), %rdi
movq 0x28029(%rip), %rax     # 0x2cfb0
movq (%rax), %rsi
callq 0x4290
movq %rax, 0x90(%rsp)
jmp 0x4f99
movq 0x90(%rsp), %rdi
leaq 0x1c466(%rip), %rsi     # 0x2140e
callq 0x4290
movq %rax, 0x88(%rsp)
jmp 0x4fb7
movq 0x88(%rsp), %rdi
movq 0x27fe2(%rip), %rsi     # 0x2cfa8
callq 0x42b0
jmp 0x4fcd
movl $0x1, %edi
callq 0x42f0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd28(%rsp)
movl %eax, 0xd24(%rsp)
jmp 0x500e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd28(%rsp)
movl %eax, 0xd24(%rsp)
leaq 0x658(%rsp), %rdi
callq 0x41b0
leaq 0x657(%rsp), %rdi
callq 0x42c0
jmp 0x57ce
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd28(%rsp)
movl %eax, 0xd24(%rsp)
leaq 0x678(%rsp), %rdi
callq 0x4160
jmp 0x57ce
leaq 0x678(%rsp), %rdi
callq 0x4160
jmp 0x52dc
movq 0x27f51(%rip), %rax     # 0x2cfb0
movq (%rax), %rsi
leaq 0xcf8(%rsp), %rdi
callq 0x4370
jmp 0x5071
leaq 0xcf8(%rsp), %rdi
callq 0x41c0
cmpq $0x40, %rax
je 0x50f4
movq 0x27f65(%rip), %rdi     # 0x2cff0
leaq 0x1c3a7(%rip), %rsi     # 0x21439
callq 0x4290
movq %rax, 0x80(%rsp)
jmp 0x50a1
movq 0x80(%rsp), %rdi
movq 0x27f00(%rip), %rax     # 0x2cfb0
movq (%rax), %rsi
callq 0x4290
movq %rax, 0x78(%rsp)
jmp 0x50bf
movq 0x78(%rsp), %rdi
leaq 0x1c382(%rip), %rsi     # 0x2144d
callq 0x4290
movq %rax, 0x70(%rsp)
jmp 0x50d7
movq 0x70(%rsp), %rdi
movq 0x27ec5(%rip), %rsi     # 0x2cfa8
callq 0x42b0
jmp 0x50ea
movl $0x1, %edi
callq 0x42f0
jmp 0x52dc
movq 0x27ec0(%rip), %rax     # 0x2cfc0
cmpl $0x45, (%rax)
jne 0x513c
movq 0x27ee4(%rip), %rdi     # 0x2cff0
leaq 0x1c36f(%rip), %rsi     # 0x21482
callq 0x4290
movq %rax, 0x68(%rsp)
jmp 0x511f
movq 0x68(%rsp), %rdi
movq 0x27e7d(%rip), %rsi     # 0x2cfa8
callq 0x42b0
jmp 0x5132
movl $0x1, %edi
callq 0x42f0
movq 0x27e7d(%rip), %rax     # 0x2cfc0
cmpl $0x4b, (%rax)
jne 0x517f
movq 0x27ea1(%rip), %rdi     # 0x2cff0
leaq 0x1c354(%rip), %rsi     # 0x214aa
callq 0x4290
movq %rax, 0x60(%rsp)
jmp 0x5162
movq 0x60(%rsp), %rdi
movq 0x27e3a(%rip), %rsi     # 0x2cfa8
callq 0x42b0
jmp 0x5175
movl $0x1, %edi
callq 0x42f0
movq 0x27e3a(%rip), %rax     # 0x2cfc0
cmpl $0x4d, (%rax)
jne 0x51c2
movq 0x27e5e(%rip), %rdi     # 0x2cff0
leaq 0x1c336(%rip), %rsi     # 0x214cf
callq 0x4290
movq %rax, 0x58(%rsp)
jmp 0x51a5
movq 0x58(%rsp), %rdi
movq 0x27df7(%rip), %rsi     # 0x2cfa8
callq 0x42b0
jmp 0x51b8
movl $0x1, %edi
callq 0x42f0
movq 0x27df7(%rip), %rax     # 0x2cfc0
cmpl $0x4f, (%rax)
jne 0x5205
movq 0x27e1b(%rip), %rdi     # 0x2cff0
leaq 0x1c324(%rip), %rsi     # 0x21500
callq 0x4290
movq %rax, 0x50(%rsp)
jmp 0x51e8
movq 0x50(%rsp), %rdi
movq 0x27db4(%rip), %rsi     # 0x2cfa8
callq 0x42b0
jmp 0x51fb
movl $0x1, %edi
callq 0x42f0
movq 0x27db4(%rip), %rax     # 0x2cfc0
cmpl $0x51, (%rax)
jne 0x5248
movq 0x27dd8(%rip), %rdi     # 0x2cff0
leaq 0x1c30c(%rip), %rsi     # 0x2152b
callq 0x4290
movq %rax, 0x48(%rsp)
jmp 0x522b
movq 0x48(%rsp), %rdi
movq 0x27d71(%rip), %rsi     # 0x2cfa8
callq 0x42b0
jmp 0x523e
movl $0x1, %edi
callq 0x42f0
movq 0x27d71(%rip), %rax     # 0x2cfc0
cmpl $0x54, (%rax)
jne 0x528b
movq 0x27d95(%rip), %rdi     # 0x2cff0
leaq 0x1c2f6(%rip), %rsi     # 0x21558
callq 0x4290
movq %rax, 0x40(%rsp)
jmp 0x526e
movq 0x40(%rsp), %rdi
movq 0x27d2e(%rip), %rsi     # 0x2cfa8
callq 0x42b0
jmp 0x5281
movl $0x1, %edi
callq 0x42f0
movq 0x27d5e(%rip), %rdi     # 0x2cff0
leaq 0x1c2ef(%rip), %rsi     # 0x21588
callq 0x4290
movq %rax, 0x38(%rsp)
jmp 0x52a5
movq 0x38(%rsp), %rdi
movq 0x27d0f(%rip), %rax     # 0x2cfc0
movl (%rax), %esi
callq 0x44e0
movq %rax, 0x30(%rsp)
jmp 0x52bf
movq 0x30(%rsp), %rdi
movq 0x27cdd(%rip), %rsi     # 0x2cfa8
callq 0x42b0
jmp 0x52d2
movl $0x1, %edi
callq 0x42f0
jmp 0x47f4
movq 0x27ce8(%rip), %rax     # 0x2cfd0
movl (%rax), %eax
addl $0x2, %eax
cmpl 0xd70(%rsp), %eax
jle 0x532d
movq 0x27cf3(%rip), %rdi     # 0x2cff0
leaq 0x1c29e(%rip), %rsi     # 0x215a2
callq 0x4290
movq %rax, 0x28(%rsp)
jmp 0x5310
movq 0x28(%rsp), %rdi
movq 0x27c8c(%rip), %rsi     # 0x2cfa8
callq 0x42b0
jmp 0x5323
movl $0x1, %edi
callq 0x42f0
movq 0xd68(%rsp), %rax
movq 0x27c94(%rip), %rcx     # 0x2cfd0
movslq (%rcx), %rcx
movq (%rax,%rcx,8), %rsi
movq 0x8(%rax,%rcx,8), %rdx
movl 0xd60(%rsp), %ecx
leaq 0x590(%rsp), %rdi
callq 0x5800
jmp 0x535e
leaq 0x590(%rsp), %rdi
callq 0x59a0
jmp 0x536d
movq 0x27c5c(%rip), %rax     # 0x2cfd0
movl (%rax), %ecx
addl $0x2, %ecx
movq 0x27c50(%rip), %rax     # 0x2cfd0
movl %ecx, (%rax)
movq $0x0, 0x588(%rsp)
testb $0x1, 0xd67(%rsp)
je 0x547b
movl $0x200, %edi            # imm = 0x200
callq 0x42a0
movq %rax, 0x20(%rsp)
jmp 0x53ad
movb $0x1, 0x567(%rsp)
leaq 0x1c2cb(%rip), %rdx     # 0x21687
leaq 0x568(%rsp), %rdi
leaq 0xd38(%rsp), %rsi
callq 0x16df0
jmp 0x53d3
movq 0x20(%rsp), %rdi
leaq 0x568(%rsp), %rsi
movl $0x10, %edx
callq 0x45a0
jmp 0x53ec
movq 0x20(%rsp), %rax
movb $0x0, 0x567(%rsp)
movq %rax, 0x588(%rsp)
leaq 0x568(%rsp), %rdi
callq 0x41b0
jmp 0x547b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd28(%rsp)
movl %eax, 0xd24(%rsp)
jmp 0x57c1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd28(%rsp)
movl %eax, 0xd24(%rsp)
jmp 0x5460
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd28(%rsp)
movl %eax, 0xd24(%rsp)
leaq 0x568(%rsp), %rdi
callq 0x41b0
testb $0x1, 0x567(%rsp)
jne 0x546c
jmp 0x5476
movq 0x20(%rsp), %rdi
callq 0x4270
jmp 0x57c1
leaq 0x340(%rsp), %rdi
leaq 0xcf8(%rsp), %rsi
callq 0x5bc0
jmp 0x5492
movzbl 0xd1c(%rsp), %edx
movl 0xd18(%rsp), %ecx
movq 0x588(%rsp), %r9
leaq 0x1f0(%rsp), %rdi
leaq 0x590(%rsp), %rsi
leaq 0x340(%rsp), %r8
callq 0x5e20
jmp 0x54c8
movq 0xd68(%rsp), %rax
movq 0x27af9(%rip), %rcx     # 0x2cfd0
movslq (%rcx), %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, 0x1e8(%rsp)
movq 0xd68(%rsp), %rax
movslq 0xd70(%rsp), %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, 0x1e0(%rsp)
testb $0x1, 0xd23(%rsp)
jne 0x5565
movq 0x1e8(%rsp), %rsi
movq 0x1e0(%rsp), %rdx
leaq 0x1f0(%rsp), %rdi
callq 0x5f40
jmp 0x5531
jmp 0x5586
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd28(%rsp)
movl %eax, 0xd24(%rsp)
jmp 0x57b4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd28(%rsp)
movl %eax, 0xd24(%rsp)
jmp 0x57a7
movq 0x1e8(%rsp), %rsi
movq 0x1e0(%rsp), %rdx
leaq 0x1f0(%rsp), %rdi
callq 0x6240
jmp 0x5584
jmp 0x5586
movq 0x27a63(%rip), %rdi     # 0x2cff0
leaq 0x1c104(%rip), %rsi     # 0x21698
callq 0x4290
movq %rax, 0x18(%rsp)
jmp 0x55a0
leaq 0x1f0(%rsp), %rdi
callq 0x6850
vmovsd %xmm0, 0x10(%rsp)
jmp 0x55b5
movq 0x18(%rsp), %rdi
vmovsd 0x10(%rsp), %xmm0
vmovsd 0x1ba40(%rip), %xmm1    # 0x21008
vmulsd %xmm1, %xmm0, %xmm0
callq 0x4580
movq %rax, 0x8(%rsp)
jmp 0x55d8
movq 0x8(%rsp), %rdi
leaq 0x1c835(%rip), %rsi     # 0x21e19
callq 0x4290
jmp 0x55eb
cmpq $0x0, 0x588(%rsp)
je 0x5614
movq 0x588(%rsp), %rax
movq %rax, (%rsp)
cmpq $0x0, %rax
je 0x5612
movq (%rsp), %rdi
movq (%rdi), %rax
callq *0x8(%rax)
jmp 0x5614
leaq 0x1c08d(%rip), %rdx     # 0x216a8
leaq 0x1c0(%rsp), %rdi
leaq 0xd38(%rsp), %rsi
callq 0x16df0
jmp 0x5632
leaq 0x1f0(%rsp), %rdi
leaq 0x1c0(%rsp), %rsi
callq 0x68b0
jmp 0x5649
leaq 0x1c0(%rsp), %rdi
callq 0x41b0
leaq 0x1c050(%rip), %rdx     # 0x216ad
leaq 0x1a0(%rsp), %rdi
leaq 0xd38(%rsp), %rsi
callq 0x16df0
jmp 0x5674
leaq 0x1f0(%rsp), %rdi
leaq 0x1a0(%rsp), %rsi
callq 0x6ad0
jmp 0x568b
leaq 0x1a0(%rsp), %rdi
callq 0x41b0
leaq 0x1c012(%rip), %rdx     # 0x216b1
leaq 0x180(%rsp), %rdi
leaq 0xd38(%rsp), %rsi
callq 0x16df0
jmp 0x56b6
leaq 0x1f0(%rsp), %rdi
leaq 0x180(%rsp), %rsi
callq 0x6e30
jmp 0x56cd
leaq 0x180(%rsp), %rdi
callq 0x41b0
movq 0x278e7(%rip), %rsi     # 0x2cfc8
leaq 0x1f0(%rsp), %rdi
callq 0x7050
jmp 0x56f0
leaq 0x1f0(%rsp), %rdi
callq 0x7880
leaq 0x340(%rsp), %rdi
callq 0x78d0
leaq 0x590(%rsp), %rdi
callq 0x78e0
leaq 0xcf8(%rsp), %rdi
callq 0x41b0
leaq 0xd38(%rsp), %rdi
callq 0x41b0
movl 0xd74(%rsp), %eax
addq $0xd78, %rsp            # imm = 0xD78
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd28(%rsp)
movl %eax, 0xd24(%rsp)
leaq 0x1c0(%rsp), %rdi
callq 0x41b0
jmp 0x57a7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd28(%rsp)
movl %eax, 0xd24(%rsp)
leaq 0x1a0(%rsp), %rdi
callq 0x41b0
jmp 0x57a7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd28(%rsp)
movl %eax, 0xd24(%rsp)
leaq 0x180(%rsp), %rdi
callq 0x41b0
leaq 0x1f0(%rsp), %rdi
callq 0x7880
leaq 0x340(%rsp), %rdi
callq 0x78d0
leaq 0x590(%rsp), %rdi
callq 0x78e0
leaq 0xcf8(%rsp), %rdi
callq 0x41b0
leaq 0xd38(%rsp), %rdi
callq 0x41b0
movq 0xd28(%rsp), %rdi
callq 0x4510
nopw %cs:(%rax,%rax)