// File: readmapping[P]alfalfa/src/mapper.cpp
// Function: alignment_t::constructCIGAR(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, unsigned char const*, int, int, signed char const*, int, int, int, int)
void alignment_t::constructCIGAR(const string& S, const uint8_t * readP, 
        int Plen, int fixedBand, const int8_t *mat, int match, int openGap, int extendGap, int print){
    //use chain to recreate succesfull alignment, but now use other method that recovers alignment
    stringstream sNM;
    editDist = 0;
    int costEx = 0; //performanceCounter
    //start with beginGap:
    if(qB){
        if(print >= 4) cerr << "clipping before start alignment: " << qB << endl;
        sNM << qB << "S";
    }
    assert(chain.size()>0);
    int qLen = qE - qB + 1;
    int refLen = (int)(refE - refB + 1L);
    int band;
    uint8_t *target;
    target = (uint8_t *)malloc(refLen);
    for (int i = 0; i < refLen; ++i) // convert to the nt4 encoding
        target[i] = Utils::ORDVALUE[(size_t)S[refB+i]];
    //before first element of chain
    if(chain[0].query > qB){
        qLen = chain[0].query - qB;
        refLen = (int)(chain[0].ref - refB);
        int n_cigar;
        uint32_t * cigar;
        band = bandSizeEstimate(fixedBand, qLen, refLen, match, openGap, extendGap, alignmentScore);
        costEx += refLen*band;
        if(print >=7 ) cerr << "dp called with dimension " << (qLen) << "x" << (refLen) << " and band " << band << endl;
        ksw_global(qLen, readP+qB, refLen, target, 5, mat, -1*openGap, -1*extendGap, band, &n_cigar, &cigar);
        editDist += recoverCIGAR4(n_cigar, cigar, readP+qB, target, sNM);
        if(print >=4 ) cerr << "current cigar " << sNM.str() << endl;
        free(cigar);        
    }
    sNM << chain[0].len << '=';
    //traverse chain
    for(size_t i = 1; i < chain.size(); i++){
        int qDist = chain[i].query - (chain[i-1].query + chain[i-1].len - 1);
        int refDist = (int) (chain[i].ref - (chain[i-1].ref + chain[i-1].len - 1L));
        if (qDist < 0 || refDist < 0) {
            if (qDist >= refDist)
                qDist -= refDist; //qDist insertions
            else
                refDist -= qDist;
        }
        if (qDist <= 0) {//minRefDist deletions //1+|qDist| matches lost of next mem
            sNM << refDist << 'D' << (chain[i].len - 1 + qDist) << '=';
            editDist += refDist;
        } else if (refDist <= 0) {
            sNM << qDist << 'I' << (chain[i].len - 1 + refDist) << '=';
            editDist += qDist;
        } else if (qDist == 1) {
            sNM << (refDist-1) << 'D' << chain[i].len << '=';
            editDist += refDist-1;
        } else if (refDist == 1) {
            sNM << (qDist-1) << 'I' << chain[i].len << '=';
            editDist += qDist-1;
        } else if (refDist == 2 && qDist==2) {
            sNM << 1 << 'X' << chain[i].len << '=';
            editDist += 1;
        } else {//both distances are positive and not equal to (1,1), otherwise seeds would not be maximal!
            qLen = chain[i].query - 1 - (chain[i-1].query + chain[i-1].len) + 1;
            refLen = (int)(chain[i].ref - 1 - (chain[i-1].ref + chain[i-1].len) + 1);
            int n_cigar;
            uint32_t * cigar;
            band = bandSizeEstimate(fixedBand, qLen, refLen, match, openGap, extendGap, alignmentScore);
            costEx += refLen*band;
            if(print >= 7) cerr << "dp called with dimension " << (qLen) << "x" << (refLen) << " and band " << band << endl;
            ksw_global(qLen, readP+chain[i-1].query + chain[i-1].len, refLen, target+(chain[i-1].ref + chain[i-1].len-refB), 5, mat, -1*openGap, -1*extendGap, band, &n_cigar, &cigar);
            editDist += recoverCIGAR4(n_cigar, cigar, readP+chain[i-1].query + chain[i-1].len, target + (chain[i-1].ref + chain[i-1].len-refB), sNM);
            sNM << chain[i].len << '=';
            free(cigar);
        }
        if(print>= 4) cerr << "current cigar " << sNM.str() << endl;
    }
    //after last element of chain
    int lastIndex = chain.size()-1;
    if(chain[lastIndex].query+chain[lastIndex].len-1 < qE){
        qLen = qE - (chain[lastIndex].query + chain[lastIndex].len) + 1;
        refLen = (int)(refE - (chain[lastIndex].ref + chain[lastIndex].len) + 1);
        int n_cigar;
        uint32_t * cigar;
        band = bandSizeEstimate(fixedBand, qLen, refLen, match, openGap, extendGap, alignmentScore);
        if(print>=7) cerr << "dp called with dimension " << (qLen) << "x" << (refLen) << " and band " << band << endl;
        costEx += refLen*band;
        ksw_global(qLen, readP+chain[lastIndex].query + chain[lastIndex].len, refLen, target+(chain[lastIndex].ref + chain[lastIndex].len-refB), 5, mat, -1*openGap, -1*extendGap, band, &n_cigar, &cigar);
        editDist += recoverCIGAR4(n_cigar, cigar, readP+chain[lastIndex].query + chain[lastIndex].len, target+(chain[lastIndex].ref + chain[lastIndex].len-refB), sNM);
        if(print>=4) cerr << "current cigar " << sNM.str() << endl;
        free(cigar);        
    }    
    //end with possible endGap
    if(Plen-1-qE){
        if(print>=4) cerr << "clipping after end alignment: " << (Plen-1-qE) << endl;
        sNM << (Plen-1-qE) << "S";
    }
    //final results:
    free(target);    
    NMtag = sNM.str();
    cigar = recoverCIGAR3from4(NMtag);
    if(print>=2) cerr << "#COSTPOSTPROC " << costEx << endl;
}

// Assembly:
pushq %rbx
subq $0x640, %rsp            # imm = 0x640
movl 0x668(%rsp), %eax
movl 0x660(%rsp), %eax
movl 0x658(%rsp), %eax
movl 0x650(%rsp), %eax
movq %rdi, 0x638(%rsp)
movq %rsi, 0x630(%rsp)
movq %rdx, 0x628(%rsp)
movl %ecx, 0x624(%rsp)
movl %r8d, 0x620(%rsp)
movq %r9, 0x618(%rsp)
movq 0x638(%rsp), %rax
movq %rax, 0x360(%rsp)
leaq 0x490(%rsp), %rdi
callq 0x8260
movq 0x360(%rsp), %rax
movl $0x0, 0x6c(%rax)
movl $0x0, 0x48c(%rsp)
cmpl $0x0, 0x10(%rax)
je 0x3aa18
cmpl $0x4, 0x668(%rsp)
jl 0x3a9de
movq 0x5c67b(%rip), %rdi     # 0x96ff0
leaq 0x4321a(%rip), %rsi     # 0x7db96
callq 0x8360
movq %rax, 0x358(%rsp)
jmp 0x3a98b
movq 0x358(%rsp), %rdi
movq 0x360(%rsp), %rax
movl 0x10(%rax), %esi
callq 0x8710
movq %rax, 0x350(%rsp)
jmp 0x3a9ad
movq 0x350(%rsp), %rdi
movq 0x5c5f4(%rip), %rsi     # 0x96fb0
callq 0x83b0
jmp 0x3a9c3
jmp 0x3a9de
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x480(%rsp)
movl %eax, 0x47c(%rsp)
jmp 0x3c253
movq 0x360(%rsp), %rax
leaq 0x4a0(%rsp), %rdi
movl 0x10(%rax), %esi
callq 0x8710
movq %rax, 0x348(%rsp)
jmp 0x3aa00
movq 0x348(%rsp), %rdi
leaq 0x439f2(%rip), %rsi     # 0x7e401
callq 0x8360
jmp 0x3aa16
jmp 0x3aa18
movq 0x360(%rsp), %rcx
movl 0x14(%rcx), %eax
subl 0x10(%rcx), %eax
addl $0x1, %eax
movl %eax, 0x478(%rsp)
movq 0x8(%rcx), %rax
subq (%rcx), %rax
addq $0x1, %rax
movl %eax, 0x474(%rsp)
movslq 0x474(%rsp), %rdi
callq 0x8560
movq %rax, 0x468(%rsp)
movl $0x0, 0x464(%rsp)
movl 0x464(%rsp), %eax
cmpl 0x474(%rsp), %eax
jge 0x3aac9
movq 0x360(%rsp), %rax
movq 0x630(%rsp), %rdi
movq (%rax), %rsi
movslq 0x464(%rsp), %rax
addq %rax, %rsi
callq 0x8410
movsbq (%rax), %rcx
leaq 0x43d00(%rip), %rax     # 0x7e7a0
movb (%rax,%rcx), %dl
movq 0x468(%rsp), %rax
movslq 0x464(%rsp), %rcx
movb %dl, (%rax,%rcx)
movl 0x464(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x464(%rsp)
jmp 0x3aa62
movq 0x360(%rsp), %rdi
addq $0xe8, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x4c200
movq 0x360(%rsp), %rcx
movl 0x8(%rax), %eax
cmpl 0x10(%rcx), %eax
jle 0x3ae41
movq 0x360(%rsp), %rdi
addq $0xe8, %rdi
movq %rdi, 0x330(%rsp)
xorl %eax, %eax
movl %eax, %esi
movq %rsi, 0x338(%rsp)
callq 0x4c200
movq 0x330(%rsp), %rdi
movq 0x338(%rsp), %rsi
movq 0x360(%rsp), %rcx
movl 0x8(%rax), %eax
movl 0x10(%rcx), %ecx
subl %ecx, %eax
movl %eax, 0x478(%rsp)
callq 0x4c200
movq %rax, %rcx
movq 0x360(%rsp), %rax
movl (%rcx), %ecx
movl (%rax), %edx
subl %edx, %ecx
movl %ecx, 0x474(%rsp)
movl 0x620(%rsp), %edi
movl 0x478(%rsp), %esi
movl 0x474(%rsp), %edx
movl 0x650(%rsp), %ecx
movl 0x658(%rsp), %r8d
movl 0x660(%rsp), %r9d
movl 0x70(%rax), %r10d
movq %rsp, %rax
movl %r10d, (%rax)
callq 0x39dd0
movl %eax, 0x344(%rsp)
jmp 0x3aba5
movl 0x344(%rsp), %eax
movl %eax, 0x470(%rsp)
movl 0x474(%rsp), %eax
imull 0x470(%rsp), %eax
addl 0x48c(%rsp), %eax
movl %eax, 0x48c(%rsp)
cmpl $0x7, 0x668(%rsp)
jl 0x3aca9
movq 0x5c40b(%rip), %rdi     # 0x96ff0
leaq 0x42fcc(%rip), %rsi     # 0x7dbb8
callq 0x8360
movq %rax, 0x328(%rsp)
jmp 0x3abfb
movq 0x328(%rsp), %rdi
movl 0x478(%rsp), %esi
callq 0x8710
movq %rax, 0x320(%rsp)
jmp 0x3ac19
movq 0x320(%rsp), %rdi
leaq 0x3f253(%rip), %rsi     # 0x79e7b
callq 0x8360
movq %rax, 0x318(%rsp)
jmp 0x3ac37
movq 0x318(%rsp), %rdi
movl 0x474(%rsp), %esi
callq 0x8710
movq %rax, 0x310(%rsp)
jmp 0x3ac55
movq 0x310(%rsp), %rdi
leaq 0x42f6e(%rip), %rsi     # 0x7dbd2
callq 0x8360
movq %rax, 0x308(%rsp)
jmp 0x3ac73
movq 0x308(%rsp), %rdi
movl 0x470(%rsp), %esi
callq 0x8710
movq %rax, 0x300(%rsp)
jmp 0x3ac91
movq 0x300(%rsp), %rdi
movq 0x5c310(%rip), %rsi     # 0x96fb0
callq 0x83b0
jmp 0x3aca7
jmp 0x3aca9
movq 0x360(%rsp), %rax
movl 0x478(%rsp), %edi
movq 0x628(%rsp), %rsi
movslq 0x10(%rax), %rax
addq %rax, %rsi
movl 0x474(%rsp), %edx
movq 0x468(%rsp), %rcx
movq 0x618(%rsp), %r9
movl 0x658(%rsp), %r8d
negl %r8d
movl 0x660(%rsp), %r10d
negl %r10d
movl 0x470(%rsp), %r11d
movq %rsp, %rax
leaq 0x458(%rsp), %rbx
movq %rbx, 0x20(%rax)
leaq 0x460(%rsp), %rbx
movq %rbx, 0x18(%rax)
movl %r11d, 0x10(%rax)
movl %r10d, 0x8(%rax)
movl %r8d, (%rax)
movl $0x5, %r8d
callq 0x77080
jmp 0x3ad2f
movq 0x360(%rsp), %rax
movl 0x460(%rsp), %edi
movq 0x458(%rsp), %rsi
movq 0x628(%rsp), %rdx
movslq 0x10(%rax), %rax
addq %rax, %rdx
movq 0x468(%rsp), %rcx
leaq 0x490(%rsp), %r8
callq 0x3a0c0
movl %eax, 0x2fc(%rsp)
jmp 0x3ad73
movq 0x360(%rsp), %rax
movl 0x2fc(%rsp), %ecx
addl 0x6c(%rax), %ecx
movl %ecx, 0x6c(%rax)
cmpl $0x4, 0x668(%rsp)
jl 0x3ae34
movq 0x5c253(%rip), %rdi     # 0x96ff0
leaq 0x42e39(%rip), %rsi     # 0x7dbdd
callq 0x8360
movq %rax, 0x2f0(%rsp)
jmp 0x3adb3
leaq 0x438(%rsp), %rdi
leaq 0x490(%rsp), %rsi
callq 0x8350
jmp 0x3adca
movq 0x2f0(%rsp), %rdi
leaq 0x438(%rsp), %rsi
callq 0x8330
movq %rax, 0x2e8(%rsp)
jmp 0x3ade9
movq 0x2e8(%rsp), %rdi
movq 0x5c1b8(%rip), %rsi     # 0x96fb0
callq 0x83b0
jmp 0x3adff
leaq 0x438(%rsp), %rdi
callq 0x8858
jmp 0x3ae34
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x480(%rsp)
movl %eax, 0x47c(%rsp)
leaq 0x438(%rsp), %rdi
callq 0x8858
jmp 0x3c253
movq 0x458(%rsp), %rdi
callq 0x8470
movq 0x360(%rsp), %rdi
leaq 0x4a0(%rsp), %rax
movq %rax, 0x2d8(%rsp)
addq $0xe8, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x4c200
movq 0x2d8(%rsp), %rdi
movl 0xc(%rax), %esi
callq 0x8710
movq %rax, 0x2e0(%rsp)
jmp 0x3ae83
movq 0x2e0(%rsp), %rdi
movl $0x3d, %esi
callq 0x8440
jmp 0x3ae97
movq $0x1, 0x430(%rsp)
movq 0x360(%rsp), %rdi
movq 0x430(%rsp), %rax
movq %rax, 0x2d0(%rsp)
addq $0xe8, %rdi
callq 0x23440
movq %rax, %rcx
movq 0x2d0(%rsp), %rax
cmpq %rcx, %rax
jae 0x3ba41
movq 0x360(%rsp), %rdi
addq $0xe8, %rdi
movq 0x430(%rsp), %rsi
callq 0x4c200
movq 0x360(%rsp), %rdi
movl 0x8(%rax), %eax
movl %eax, 0x2bc(%rsp)
addq $0xe8, %rdi
movq 0x430(%rsp), %rsi
subq $0x1, %rsi
callq 0x4c200
movq 0x360(%rsp), %rdi
movl 0x8(%rax), %eax
movl %eax, 0x2b8(%rsp)
addq $0xe8, %rdi
movq 0x430(%rsp), %rsi
subq $0x1, %rsi
callq 0x4c200
movl 0x2b8(%rsp), %ecx
movq 0x360(%rsp), %rdi
movq %rax, %rdx
movl 0x2bc(%rsp), %eax
addl 0xc(%rdx), %ecx
subl $0x1, %ecx
subl %ecx, %eax
movl %eax, 0x42c(%rsp)
addq $0xe8, %rdi
movq 0x430(%rsp), %rsi
callq 0x4c200
movq 0x360(%rsp), %rdi
movq (%rax), %rax
movq %rax, 0x2c8(%rsp)
addq $0xe8, %rdi
movq 0x430(%rsp), %rsi
subq $0x1, %rsi
callq 0x4c200
movq 0x360(%rsp), %rdi
movq (%rax), %rax
movq %rax, 0x2c0(%rsp)
addq $0xe8, %rdi
movq 0x430(%rsp), %rsi
subq $0x1, %rsi
callq 0x4c200
movq 0x2c0(%rsp), %rcx
movq %rax, %rdx
movq 0x2c8(%rsp), %rax
movslq 0xc(%rdx), %rdx
addq %rdx, %rcx
subq $0x1, %rcx
subq %rcx, %rax
movl %eax, 0x428(%rsp)
cmpl $0x0, 0x42c(%rsp)
jl 0x3b019
cmpl $0x0, 0x428(%rsp)
jge 0x3b05b
movl 0x42c(%rsp), %eax
cmpl 0x428(%rsp), %eax
jl 0x3b042
movl 0x428(%rsp), %ecx
movl 0x42c(%rsp), %eax
subl %ecx, %eax
movl %eax, 0x42c(%rsp)
jmp 0x3b059
movl 0x42c(%rsp), %ecx
movl 0x428(%rsp), %eax
subl %ecx, %eax
movl %eax, 0x428(%rsp)
jmp 0x3b05b
cmpl $0x0, 0x42c(%rsp)
jg 0x3b116
leaq 0x4a0(%rsp), %rdi
movl 0x428(%rsp), %esi
callq 0x8710
movq %rax, 0x2b0(%rsp)
jmp 0x3b087
movq 0x2b0(%rsp), %rdi
movl $0x44, %esi
callq 0x8440
movq %rax, 0x2a8(%rsp)
jmp 0x3b0a3
movq 0x360(%rsp), %rdi
addq $0xe8, %rdi
movq 0x430(%rsp), %rsi
callq 0x4c200
movq 0x2a8(%rsp), %rdi
movl 0xc(%rax), %edx
movl 0x42c(%rsp), %eax
movl %eax, %ecx
movl %edx, %eax
leal -0x1(%rax,%rcx), %esi
callq 0x8710
movq %rax, 0x2a0(%rsp)
jmp 0x3b0e8
movq 0x2a0(%rsp), %rdi
movl $0x3d, %esi
callq 0x8440
jmp 0x3b0fc
movq 0x360(%rsp), %rax
movl 0x428(%rsp), %ecx
addl 0x6c(%rax), %ecx
movl %ecx, 0x6c(%rax)
jmp 0x3b97a
cmpl $0x0, 0x428(%rsp)
jg 0x3b1d1
leaq 0x4a0(%rsp), %rdi
movl 0x42c(%rsp), %esi
callq 0x8710
movq %rax, 0x298(%rsp)
jmp 0x3b142
movq 0x298(%rsp), %rdi
movl $0x49, %esi
callq 0x8440
movq %rax, 0x290(%rsp)
jmp 0x3b15e
movq 0x360(%rsp), %rdi
addq $0xe8, %rdi
movq 0x430(%rsp), %rsi
callq 0x4c200
movq 0x290(%rsp), %rdi
movl 0xc(%rax), %edx
movl 0x428(%rsp), %eax
movl %eax, %ecx
movl %edx, %eax
leal -0x1(%rax,%rcx), %esi
callq 0x8710
movq %rax, 0x288(%rsp)
jmp 0x3b1a3
movq 0x288(%rsp), %rdi
movl $0x3d, %esi
callq 0x8440
jmp 0x3b1b7
movq 0x360(%rsp), %rax
movl 0x42c(%rsp), %ecx
addl 0x6c(%rax), %ecx
movl %ecx, 0x6c(%rax)
jmp 0x3b978
cmpl $0x1, 0x42c(%rsp)
jne 0x3b282
leaq 0x4a0(%rsp), %rdi
movl 0x428(%rsp), %esi
decl %esi
callq 0x8710
movq %rax, 0x280(%rsp)
jmp 0x3b1ff
movq 0x280(%rsp), %rdi
movl $0x44, %esi
callq 0x8440
movq %rax, 0x278(%rsp)
jmp 0x3b21b
movq 0x360(%rsp), %rdi
addq $0xe8, %rdi
movq 0x430(%rsp), %rsi
callq 0x4c200
movq 0x278(%rsp), %rdi
movl 0xc(%rax), %esi
callq 0x8710
movq %rax, 0x270(%rsp)
jmp 0x3b251
movq 0x270(%rsp), %rdi
movl $0x3d, %esi
callq 0x8440
jmp 0x3b265
movq 0x360(%rsp), %rax
movl 0x428(%rsp), %ecx
subl $0x1, %ecx
addl 0x6c(%rax), %ecx
movl %ecx, 0x6c(%rax)
jmp 0x3b976
cmpl $0x1, 0x428(%rsp)
jne 0x3b333
leaq 0x4a0(%rsp), %rdi
movl 0x42c(%rsp), %esi
decl %esi
callq 0x8710
movq %rax, 0x268(%rsp)
jmp 0x3b2b0
movq 0x268(%rsp), %rdi
movl $0x49, %esi
callq 0x8440
movq %rax, 0x260(%rsp)
jmp 0x3b2cc
movq 0x360(%rsp), %rdi
addq $0xe8, %rdi
movq 0x430(%rsp), %rsi
callq 0x4c200
movq 0x260(%rsp), %rdi
movl 0xc(%rax), %esi
callq 0x8710
movq %rax, 0x258(%rsp)
jmp 0x3b302
movq 0x258(%rsp), %rdi
movl $0x3d, %esi
callq 0x8440
jmp 0x3b316
movq 0x360(%rsp), %rax
movl 0x42c(%rsp), %ecx
subl $0x1, %ecx
addl 0x6c(%rax), %ecx
movl %ecx, 0x6c(%rax)
jmp 0x3b974
cmpl $0x2, 0x428(%rsp)
jne 0x3b3e7
cmpl $0x2, 0x42c(%rsp)
jne 0x3b3e7
leaq 0x4a0(%rsp), %rdi
movl $0x1, %esi
callq 0x8710
movq %rax, 0x250(%rsp)
jmp 0x3b36b
movq 0x250(%rsp), %rdi
movl $0x58, %esi
callq 0x8440
movq %rax, 0x248(%rsp)
jmp 0x3b387
movq 0x360(%rsp), %rdi
addq $0xe8, %rdi
movq 0x430(%rsp), %rsi
callq 0x4c200
movq 0x248(%rsp), %rdi
movl 0xc(%rax), %esi
callq 0x8710
movq %rax, 0x240(%rsp)
jmp 0x3b3bd
movq 0x240(%rsp), %rdi
movl $0x3d, %esi
callq 0x8440
jmp 0x3b3d1
movq 0x360(%rsp), %rax
movl 0x6c(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x6c(%rax)
jmp 0x3b972
movq 0x360(%rsp), %rdi
addq $0xe8, %rdi
movq %rdi, 0x228(%rsp)
movq 0x430(%rsp), %rsi
callq 0x4c200
movq 0x228(%rsp), %rdi
movl 0x8(%rax), %eax
movl %eax, 0x224(%rsp)
movq 0x430(%rsp), %rsi
decq %rsi
callq 0x4c200
movq 0x228(%rsp), %rdi
movl 0x8(%rax), %eax
movl %eax, 0x220(%rsp)
movq 0x430(%rsp), %rsi
decq %rsi
callq 0x4c200
movl 0x220(%rsp), %ecx
movq 0x228(%rsp), %rdi
movq %rax, %rdx
movl 0x224(%rsp), %eax
movl 0xc(%rdx), %edx
addl %edx, %ecx
subl %ecx, %eax
movl %eax, 0x478(%rsp)
movq 0x430(%rsp), %rsi
callq 0x4c200
movq 0x228(%rsp), %rdi
movl (%rax), %eax
movl %eax, 0x238(%rsp)
movq 0x430(%rsp), %rsi
decq %rsi
callq 0x4c200
movq 0x228(%rsp), %rdi
movl (%rax), %eax
movl %eax, 0x234(%rsp)
movq 0x430(%rsp), %rsi
decq %rsi
callq 0x4c200
movl 0x234(%rsp), %edx
movl 0x238(%rsp), %ecx
movq %rax, %rsi
movq 0x360(%rsp), %rax
movl 0xc(%rsi), %esi
addl %esi, %edx
subl %edx, %ecx
movl %ecx, 0x474(%rsp)
movl 0x620(%rsp), %edi
movl 0x478(%rsp), %esi
movl 0x474(%rsp), %edx
movl 0x650(%rsp), %ecx
movl 0x658(%rsp), %r8d
movl 0x660(%rsp), %r9d
movl 0x70(%rax), %r10d
movq %rsp, %rax
movl %r10d, (%rax)
callq 0x39dd0
movl %eax, 0x23c(%rsp)
jmp 0x3b530
movl 0x23c(%rsp), %eax
movl %eax, 0x470(%rsp)
movl 0x474(%rsp), %eax
imull 0x470(%rsp), %eax
addl 0x48c(%rsp), %eax
movl %eax, 0x48c(%rsp)
cmpl $0x7, 0x668(%rsp)
jl 0x3b634
movq 0x5ba80(%rip), %rdi     # 0x96ff0
leaq 0x42641(%rip), %rsi     # 0x7dbb8
callq 0x8360
movq %rax, 0x218(%rsp)
jmp 0x3b586
movq 0x218(%rsp), %rdi
movl 0x478(%rsp), %esi
callq 0x8710
movq %rax, 0x210(%rsp)
jmp 0x3b5a4
movq 0x210(%rsp), %rdi
leaq 0x3e8c8(%rip), %rsi     # 0x79e7b
callq 0x8360
movq %rax, 0x208(%rsp)
jmp 0x3b5c2
movq 0x208(%rsp), %rdi
movl 0x474(%rsp), %esi
callq 0x8710
movq %rax, 0x200(%rsp)
jmp 0x3b5e0
movq 0x200(%rsp), %rdi
leaq 0x425e3(%rip), %rsi     # 0x7dbd2
callq 0x8360
movq %rax, 0x1f8(%rsp)
jmp 0x3b5fe
movq 0x1f8(%rsp), %rdi
movl 0x470(%rsp), %esi
callq 0x8710
movq %rax, 0x1f0(%rsp)
jmp 0x3b61c
movq 0x1f0(%rsp), %rdi
movq 0x5b985(%rip), %rsi     # 0x96fb0
callq 0x83b0
jmp 0x3b632
jmp 0x3b634
movq 0x360(%rsp), %rdi
movl 0x478(%rsp), %eax
movl %eax, 0x1d4(%rsp)
movq 0x628(%rsp), %rax
movq %rax, 0x1b0(%rsp)
addq $0xe8, %rdi
movq %rdi, 0x1c0(%rsp)
movq 0x430(%rsp), %rsi
decq %rsi
callq 0x4c200
movq 0x1c0(%rsp), %rdi
movq %rax, %rcx
movq 0x1b0(%rsp), %rax
movslq 0x8(%rcx), %rcx
addq %rcx, %rax
movq %rax, 0x1b8(%rsp)
movq 0x430(%rsp), %rsi
decq %rsi
callq 0x4c200
movq 0x1c0(%rsp), %rdi
movq %rax, %rcx
movq 0x1b8(%rsp), %rax
movslq 0xc(%rcx), %rcx
addq %rcx, %rax
movq %rax, 0x1d8(%rsp)
movl 0x474(%rsp), %eax
movl %eax, 0x1e4(%rsp)
movq 0x468(%rsp), %rax
movq %rax, 0x1c8(%rsp)
movq 0x430(%rsp), %rsi
decq %rsi
callq 0x4c200
movq 0x1c0(%rsp), %rdi
movq (%rax), %rax
movq %rax, 0x1e8(%rsp)
movq 0x430(%rsp), %rsi
decq %rsi
callq 0x4c200
movq 0x360(%rsp), %r8
movq 0x1c8(%rsp), %rcx
movl 0x1d4(%rsp), %edi
movq 0x1d8(%rsp), %rsi
movl 0x1e4(%rsp), %edx
movq %rax, %r9
movq 0x1e8(%rsp), %rax
movslq 0xc(%r9), %r9
addq %r9, %rax
movq (%r8), %r8
subq %r8, %rax
addq %rax, %rcx
movq 0x618(%rsp), %r9
movl 0x658(%rsp), %r8d
negl %r8d
movl 0x660(%rsp), %r10d
negl %r10d
movl 0x470(%rsp), %r11d
movq %rsp, %rax
leaq 0x418(%rsp), %rbx
movq %rbx, 0x20(%rax)
leaq 0x424(%rsp), %rbx
movq %rbx, 0x18(%rax)
movl %r11d, 0x10(%rax)
movl %r10d, 0x8(%rax)
movl %r8d, (%rax)
movl $0x5, %r8d
callq 0x77080
jmp 0x3b7b8
movq 0x360(%rsp), %rdi
movl 0x424(%rsp), %eax
movl %eax, 0x18c(%rsp)
movq 0x418(%rsp), %rax
movq %rax, 0x190(%rsp)
movq 0x628(%rsp), %rax
movq %rax, 0x168(%rsp)
addq $0xe8, %rdi
movq %rdi, 0x178(%rsp)
movq 0x430(%rsp), %rsi
decq %rsi
callq 0x4c200
movq 0x178(%rsp), %rdi
movq %rax, %rcx
movq 0x168(%rsp), %rax
movslq 0x8(%rcx), %rcx
addq %rcx, %rax
movq %rax, 0x170(%rsp)
movq 0x430(%rsp), %rsi
decq %rsi
callq 0x4c200
movq 0x178(%rsp), %rdi
movq %rax, %rcx
movq 0x170(%rsp), %rax
movslq 0xc(%rcx), %rcx
addq %rcx, %rax
movq %rax, 0x198(%rsp)
movq 0x468(%rsp), %rax
movq %rax, 0x180(%rsp)
movq 0x430(%rsp), %rsi
decq %rsi
callq 0x4c200
movq 0x178(%rsp), %rdi
movq (%rax), %rax
movq %rax, 0x1a0(%rsp)
movq 0x430(%rsp), %rsi
decq %rsi
callq 0x4c200
movq 0x360(%rsp), %r8
movq 0x180(%rsp), %rcx
movl 0x18c(%rsp), %edi
movq 0x190(%rsp), %rsi
movq 0x198(%rsp), %rdx
movq %rax, %r9
movq 0x1a0(%rsp), %rax
movslq 0xc(%r9), %r9
addq %r9, %rax
movq (%r8), %r8
subq %r8, %rax
addq %rax, %rcx
leaq 0x490(%rsp), %r8
callq 0x3a0c0
movl %eax, 0x1ac(%rsp)
jmp 0x3b8fc
movq 0x360(%rsp), %rdi
movl 0x1ac(%rsp), %ecx
movl 0x6c(%rdi), %eax
addl %ecx, %eax
movl %eax, 0x6c(%rdi)
leaq 0x4a0(%rsp), %rax
movq %rax, 0x158(%rsp)
addq $0xe8, %rdi
movq 0x430(%rsp), %rsi
callq 0x4c200
movq 0x158(%rsp), %rdi
movl 0xc(%rax), %esi
callq 0x8710
movq %rax, 0x160(%rsp)
jmp 0x3b951
movq 0x160(%rsp), %rdi
movl $0x3d, %esi
callq 0x8440
jmp 0x3b965
movq 0x418(%rsp), %rdi
callq 0x8470
jmp 0x3b974
jmp 0x3b976
jmp 0x3b978
jmp 0x3b97a
cmpl $0x4, 0x668(%rsp)
jl 0x3ba26
movq 0x5b661(%rip), %rdi     # 0x96ff0
leaq 0x42247(%rip), %rsi     # 0x7dbdd
callq 0x8360
movq %rax, 0x150(%rsp)
jmp 0x3b9a5
leaq 0x3f8(%rsp), %rdi
leaq 0x490(%rsp), %rsi
callq 0x8350
jmp 0x3b9bc
movq 0x150(%rsp), %rdi
leaq 0x3f8(%rsp), %rsi
callq 0x8330
movq %rax, 0x148(%rsp)
jmp 0x3b9db
movq 0x148(%rsp), %rdi
movq 0x5b5c6(%rip), %rsi     # 0x96fb0
callq 0x83b0
jmp 0x3b9f1
leaq 0x3f8(%rsp), %rdi
callq 0x8858
jmp 0x3ba26
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x480(%rsp)
movl %eax, 0x47c(%rsp)
leaq 0x3f8(%rsp), %rdi
callq 0x8858
jmp 0x3c253
jmp 0x3ba28
movq 0x430(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x430(%rsp)
jmp 0x3aea3
movq 0x360(%rsp), %rdi
addq $0xe8, %rdi
callq 0x23440
movq 0x360(%rsp), %rdi
subq $0x1, %rax
movl %eax, 0x3f4(%rsp)
addq $0xe8, %rdi
movslq 0x3f4(%rsp), %rsi
callq 0x4c200
movq 0x360(%rsp), %rdi
movl 0x8(%rax), %eax
movl %eax, 0x144(%rsp)
addq $0xe8, %rdi
movslq 0x3f4(%rsp), %rsi
callq 0x4c200
movq 0x360(%rsp), %rcx
movq %rax, %rdx
movl 0x144(%rsp), %eax
addl 0xc(%rdx), %eax
subl $0x1, %eax
cmpl 0x14(%rcx), %eax
jge 0x3c05d
movq 0x360(%rsp), %rdi
movl 0x14(%rdi), %eax
movl %eax, 0x12c(%rsp)
addq $0xe8, %rdi
movq %rdi, 0x130(%rsp)
movslq 0x3f4(%rsp), %rsi
callq 0x4c200
movq 0x130(%rsp), %rdi
movl 0x8(%rax), %eax
movl %eax, 0x128(%rsp)
movslq 0x3f4(%rsp), %rsi
callq 0x4c200
movl 0x128(%rsp), %ecx
movl 0x12c(%rsp), %esi
movq 0x130(%rsp), %rdi
movq %rax, %rdx
movq 0x360(%rsp), %rax
movl 0xc(%rdx), %edx
addl %edx, %ecx
negl %ecx
movl %ecx, %edx
movl %esi, %ecx
leal 0x1(%rcx,%rdx), %ecx
movl %ecx, 0x478(%rsp)
movl 0x8(%rax), %eax
movl %eax, 0x13c(%rsp)
movslq 0x3f4(%rsp), %rsi
callq 0x4c200
movq 0x130(%rsp), %rdi
movl (%rax), %eax
movl %eax, 0x138(%rsp)
movslq 0x3f4(%rsp), %rsi
callq 0x4c200
movl 0x138(%rsp), %ecx
movl 0x13c(%rsp), %esi
movq %rax, %rdx
movq 0x360(%rsp), %rax
movl 0xc(%rdx), %edx
addl %edx, %ecx
negl %ecx
movl %ecx, %edx
movl %esi, %ecx
leal 0x1(%rcx,%rdx), %ecx
movl %ecx, 0x474(%rsp)
movl 0x620(%rsp), %edi
movl 0x478(%rsp), %esi
movl 0x474(%rsp), %edx
movl 0x650(%rsp), %ecx
movl 0x658(%rsp), %r8d
movl 0x660(%rsp), %r9d
movl 0x70(%rax), %r10d
movq %rsp, %rax
movl %r10d, (%rax)
callq 0x39dd0
movl %eax, 0x140(%rsp)
jmp 0x3bbef
movl 0x140(%rsp), %eax
movl %eax, 0x470(%rsp)
cmpl $0x7, 0x668(%rsp)
jl 0x3bcd6
movq 0x5b3de(%rip), %rdi     # 0x96ff0
leaq 0x41f9f(%rip), %rsi     # 0x7dbb8
callq 0x8360
movq %rax, 0x120(%rsp)
jmp 0x3bc28
movq 0x120(%rsp), %rdi
movl 0x478(%rsp), %esi
callq 0x8710
movq %rax, 0x118(%rsp)
jmp 0x3bc46
movq 0x118(%rsp), %rdi
leaq 0x3e226(%rip), %rsi     # 0x79e7b
callq 0x8360
movq %rax, 0x110(%rsp)
jmp 0x3bc64
movq 0x110(%rsp), %rdi
movl 0x474(%rsp), %esi
callq 0x8710
movq %rax, 0x108(%rsp)
jmp 0x3bc82
movq 0x108(%rsp), %rdi
leaq 0x41f41(%rip), %rsi     # 0x7dbd2
callq 0x8360
movq %rax, 0x100(%rsp)
jmp 0x3bca0
movq 0x100(%rsp), %rdi
movl 0x470(%rsp), %esi
callq 0x8710
movq %rax, 0xf8(%rsp)
jmp 0x3bcbe
movq 0xf8(%rsp), %rdi
movq 0x5b2e3(%rip), %rsi     # 0x96fb0
callq 0x83b0
jmp 0x3bcd4
jmp 0x3bcd6
movq 0x360(%rsp), %rdi
movl 0x474(%rsp), %ecx
movl 0x470(%rsp), %eax
imull %eax, %ecx
movl 0x48c(%rsp), %eax
addl %ecx, %eax
movl %eax, 0x48c(%rsp)
movl 0x478(%rsp), %eax
movl %eax, 0xdc(%rsp)
movq 0x628(%rsp), %rax
movq %rax, 0xb8(%rsp)
addq $0xe8, %rdi
movq %rdi, 0xc8(%rsp)
movslq 0x3f4(%rsp), %rsi
callq 0x4c200
movq 0xc8(%rsp), %rdi
movq %rax, %rcx
movq 0xb8(%rsp), %rax
movslq 0x8(%rcx), %rcx
addq %rcx, %rax
movq %rax, 0xc0(%rsp)
movslq 0x3f4(%rsp), %rsi
callq 0x4c200
movq 0xc8(%rsp), %rdi
movq %rax, %rcx
movq 0xc0(%rsp), %rax
movslq 0xc(%rcx), %rcx
addq %rcx, %rax
movq %rax, 0xe0(%rsp)
movl 0x474(%rsp), %eax
movl %eax, 0xec(%rsp)
movq 0x468(%rsp), %rax
movq %rax, 0xd0(%rsp)
movslq 0x3f4(%rsp), %rsi
callq 0x4c200
movq 0xc8(%rsp), %rdi
movq (%rax), %rax
movq %rax, 0xf0(%rsp)
movslq 0x3f4(%rsp), %rsi
callq 0x4c200
movq 0x360(%rsp), %r8
movq 0xd0(%rsp), %rcx
movl 0xdc(%rsp), %edi
movq 0xe0(%rsp), %rsi
movl 0xec(%rsp), %edx
movq %rax, %r9
movq 0xf0(%rsp), %rax
movslq 0xc(%r9), %r9
addq %r9, %rax
movq (%r8), %r8
subq %r8, %rax
addq %rax, %rcx
movq 0x618(%rsp), %r9
movl 0x658(%rsp), %r8d
negl %r8d
movl 0x660(%rsp), %r10d
negl %r10d
movl 0x470(%rsp), %r11d
movq %rsp, %rax
leaq 0x3e8(%rsp), %rbx
movq %rbx, 0x20(%rax)
leaq 0x3f0(%rsp), %rbx
movq %rbx, 0x18(%rax)
movl %r11d, 0x10(%rax)
movl %r10d, 0x8(%rax)
movl %r8d, (%rax)
movl $0x5, %r8d
callq 0x77080
jmp 0x3be6f
movq 0x360(%rsp), %rdi
movl 0x3f0(%rsp), %eax
movl %eax, 0x94(%rsp)
movq 0x3e8(%rsp), %rax
movq %rax, 0x98(%rsp)
movq 0x628(%rsp), %rax
movq %rax, 0x70(%rsp)
addq $0xe8, %rdi
movq %rdi, 0x80(%rsp)
movslq 0x3f4(%rsp), %rsi
callq 0x4c200
movq 0x80(%rsp), %rdi
movq %rax, %rcx
movq 0x70(%rsp), %rax
movslq 0x8(%rcx), %rcx
addq %rcx, %rax
movq %rax, 0x78(%rsp)
movslq 0x3f4(%rsp), %rsi
callq 0x4c200
movq 0x80(%rsp), %rdi
movq %rax, %rcx
movq 0x78(%rsp), %rax
movslq 0xc(%rcx), %rcx
addq %rcx, %rax
movq %rax, 0xa0(%rsp)
movq 0x468(%rsp), %rax
movq %rax, 0x88(%rsp)
movslq 0x3f4(%rsp), %rsi
callq 0x4c200
movq 0x80(%rsp), %rdi
movq (%rax), %rax
movq %rax, 0xa8(%rsp)
movslq 0x3f4(%rsp), %rsi
callq 0x4c200
movq 0x360(%rsp), %r8
movq 0x88(%rsp), %rcx
movl 0x94(%rsp), %edi
movq 0x98(%rsp), %rsi
movq 0xa0(%rsp), %rdx
movq %rax, %r9
movq 0xa8(%rsp), %rax
movslq 0xc(%r9), %r9
addq %r9, %rax
movq (%r8), %r8
subq %r8, %rax
addq %rax, %rcx
leaq 0x490(%rsp), %r8
callq 0x3a0c0
movl %eax, 0xb4(%rsp)
jmp 0x3bf9b
movq 0x360(%rsp), %rax
movl 0xb4(%rsp), %ecx
addl 0x6c(%rax), %ecx
movl %ecx, 0x6c(%rax)
cmpl $0x4, 0x668(%rsp)
jl 0x3c050
movq 0x5b02b(%rip), %rdi     # 0x96ff0
leaq 0x41c11(%rip), %rsi     # 0x7dbdd
callq 0x8360
movq %rax, 0x68(%rsp)
jmp 0x3bfd8
leaq 0x3c8(%rsp), %rdi
leaq 0x490(%rsp), %rsi
callq 0x8350
jmp 0x3bfef
movq 0x68(%rsp), %rdi
leaq 0x3c8(%rsp), %rsi
callq 0x8330
movq %rax, 0x60(%rsp)
jmp 0x3c008
movq 0x60(%rsp), %rdi
movq 0x5af9c(%rip), %rsi     # 0x96fb0
callq 0x83b0
jmp 0x3c01b
leaq 0x3c8(%rsp), %rdi
callq 0x8858
jmp 0x3c050
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x480(%rsp)
movl %eax, 0x47c(%rsp)
leaq 0x3c8(%rsp), %rdi
callq 0x8858
jmp 0x3c253
movq 0x3e8(%rsp), %rdi
callq 0x8470
movq 0x360(%rsp), %rcx
movl 0x624(%rsp), %eax
subl $0x1, %eax
subl 0x14(%rcx), %eax
cmpl $0x0, %eax
je 0x3c11a
cmpl $0x4, 0x668(%rsp)
jl 0x3c0db
movq 0x5af64(%rip), %rdi     # 0x96ff0
leaq 0x41b59(%rip), %rsi     # 0x7dbec
callq 0x8360
movq %rax, 0x58(%rsp)
jmp 0x3c09f
movq 0x58(%rsp), %rdi
movq 0x360(%rsp), %rcx
movl 0x624(%rsp), %eax
movl 0x14(%rcx), %esi
notl %esi
addl %eax, %esi
callq 0x8710
movq %rax, 0x50(%rsp)
jmp 0x3c0c6
movq 0x50(%rsp), %rdi
movq 0x5aede(%rip), %rsi     # 0x96fb0
callq 0x83b0
jmp 0x3c0d9
jmp 0x3c0db
movq 0x360(%rsp), %rcx
leaq 0x4a0(%rsp), %rdi
movl 0x624(%rsp), %eax
movl 0x14(%rcx), %esi
notl %esi
addl %eax, %esi
callq 0x8710
movq %rax, 0x48(%rsp)
jmp 0x3c105
movq 0x48(%rsp), %rdi
leaq 0x422f0(%rip), %rsi     # 0x7e401
callq 0x8360
jmp 0x3c118
jmp 0x3c11a
movq 0x468(%rsp), %rdi
callq 0x8470
leaq 0x3a8(%rsp), %rdi
leaq 0x490(%rsp), %rsi
callq 0x8350
jmp 0x3c13e
movq 0x360(%rsp), %rdi
addq $0x78, %rdi
movq %rdi, 0x40(%rsp)
leaq 0x3a8(%rsp), %rsi
movq %rsi, 0x38(%rsp)
callq 0x84b0
movq 0x38(%rsp), %rdi
callq 0x8858
movq 0x40(%rsp), %rsi
leaq 0x368(%rsp), %rdi
callq 0x8180
jmp 0x3c17f
leaq 0x388(%rsp), %rdi
leaq 0x368(%rsp), %rsi
callq 0x39ed0
jmp 0x3c196
movq 0x360(%rsp), %rdi
addq $0x20, %rdi
leaq 0x388(%rsp), %rsi
callq 0x84b0
leaq 0x388(%rsp), %rdi
callq 0x8858
leaq 0x368(%rsp), %rdi
callq 0x8858
cmpl $0x2, 0x668(%rsp)
jl 0x3c23d
movq 0x5ae16(%rip), %rdi     # 0x96ff0
leaq 0x41a2a(%rip), %rsi     # 0x7dc0b
callq 0x8360
movq %rax, 0x30(%rsp)
jmp 0x3c1ed
movq 0x30(%rsp), %rdi
movl 0x48c(%rsp), %esi
callq 0x8710
movq %rax, 0x28(%rsp)
jmp 0x3c205
movq 0x28(%rsp), %rdi
movq 0x5ad9f(%rip), %rsi     # 0x96fb0
callq 0x83b0
jmp 0x3c218
jmp 0x3c23d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x480(%rsp)
movl %eax, 0x47c(%rsp)
leaq 0x368(%rsp), %rdi
callq 0x8858
jmp 0x3c253
leaq 0x490(%rsp), %rdi
callq 0x8290
addq $0x640, %rsp            # imm = 0x640
popq %rbx
retq
leaq 0x490(%rsp), %rdi
callq 0x8290
movq 0x480(%rsp), %rdi
callq 0x8730
nopl (%rax)