// File: /workspace/github_cpp_makefile_star2_O3/schneebergerlab[P]DrLink/detect_recombsite.cpp
// Function: check_co_read_density(unsigned long, unsigned long, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, int*, bool*, int*, int*, int*, int*, int*)
bool check_co_read_density(unsigned long       co_start,
                           unsigned long       co_end,
                           string              read_align_info,
                           string              read_order_info,
                           string              read_id_info,
                           int*                bp_per_read_in_co,
                           bool*               bp_boundary_same_fragment,
                           int*                min_RR_dist,
                           int*                max_RR_dist,
                           int*                n_readLeft,
                           int*                n_readRight,
                           int*                max_CORR_dist)
{
    /* this function checks read density in a potential CO interval
       how many bp per read within this interval
       -The larger/"smaller" the value, the higher chance that 
        this molecule is falsely merged from different molecules.
       
       Example molecule with info:
       
	1#ACGCGTGGTCCAGTAT  8229787 8277108 47422   0.08    30  R   8277208
 
 	# span of reads: read_align_info
	8229787,8229914;8229933,8230022;8234823,8234973;8235084,8235141;
	8235256,8235406;8235546,8235673;8237785,8237913;8238134,8238284;
	8245266,8245416;8245555,8245682;8250091,8250218;8250471,8250611;
	8252479,8252629;8252479,8252629;8252711,8252807;8252714,8252807;
	8256708,8256858;8257166,8257293;8262644,8262803;8262929,8263056;
	8264841,8264991;8265091,8265218;8266796,8266946;8266809,8266864;
	8267521,8267644;8267724,8267873;8272690,8272817;8273056,8273206;
	8276756,8276883;8277108,8277208 

	# order in read pairs: read_order_info
	1,2,2,1,2,1,1,2,2,1,1,2,2,2,1,1,2,1,2,1,2,1,2,1,1,2,1,2,1,2 

	# id of reads: read_id_info
	J00137:105:HNFWJBBXX:3:1213:4685:18616,J00137:105:HNFWJBBXX:3:1213:4685:18616,
	J00137:102:HMYVWBBXX:7:2102:6482:8400,J00137:102:HMYVWBBXX:7:2102:6482:8400,
	J00137:105:HNFWJBBXX:3:2225:2950:3266,J00137:105:HNFWJBBXX:3:2225:2950:3266,
	J00137:108:HNGC7BBXX:3:1211:16072:22133,J00137:108:HNGC7BBXX:3:1211:16072:22133,
	J00137:105:HNFWJBBXX:3:1109:7314:28973,J00137:105:HNFWJBBXX:3:1109:7314:28973,
	J00137:108:HNGC7BBXX:3:2103:14874:10247,J00137:108:HNGC7BBXX:3:2103:14874:10247,
	J00137:102:HMYVWBBXX:7:2127:1692:16559,J00137:102:HMYVWBBXX:7:2127:1895:16665,
	J00137:102:HMYVWBBXX:7:2127:1692:16559,J00137:102:HMYVWBBXX:7:2127:1895:16665,
	J00137:105:HNFWJBBXX:3:1114:28107:1525,J00137:105:HNFWJBBXX:3:1114:28107:1525,
	J00137:102:HMYVWBBXX:8:2124:19471:30274,J00137:102:HMYVWBBXX:8:2124:19471:30274,
	J00137:108:HNGC7BBXX:3:1210:19705:2897,J00137:108:HNGC7BBXX:3:1210:19705:2897,
	J00137:102:HMYVWBBXX:7:2106:30655:43251,J00137:102:HMYVWBBXX:7:2106:30655:43251,
	J00137:108:HNGC7BBXX:3:1212:11363:38029,J00137:108:HNGC7BBXX:3:1212:11363:38029,
	J00137:105:HNFWJBBXX:3:2204:5284:22854,J00137:105:HNFWJBBXX:3:2204:5284:22854,
	J00137:105:HNFWJBBXX:3:1104:14143:15451,J00137:105:HNFWJBBXX:3:1104:14143:15451
	
	bp predicted as: 8252716 -> 8262697, where CO start/end in reads at 8252714, 8262644
    */
    //
    if(co_end < co_start)
    {
        return false;
    }
    // return values
    *bp_per_read_in_co         = -1;     // read density within CO interval
    *bp_boundary_same_fragment = false;  // whether the read covering co start/end from the same fragment
    *min_RR_dist               = 999999; // minimum R1-R1 or R2-R2 distance within the molecule
    *max_RR_dist               = 0;      // maximum ...
    // task 1. check read density within the potential CO interval
    vector<string> respan  = split_string(read_align_info, ';'); // ; with ,    
    vector<string> reorder = split_string(read_order_info, ','); // ,
    vector<string> reid    = split_string(read_id_info,    ','); // ,
    assert( respan.size() == reorder.size() );
    assert( respan.size() == reid.size() ); 
    vector<string>::iterator ritr;
    vector<string>::iterator ritr_end;
    ritr     = respan.begin();
    ritr_end = respan.end();
    int n_read = 0;                    // number of reads in interval
    int i_read = -1;                   // to satisfy index start from 0 in vector
    unsigned long sta_aligned_pos = 0; // last  read covering start of interval
    unsigned long end_aligned_pos = 0; // first read covering end   of interval
    string        sta_read_name("");
    string        end_read_name("");
    string        sta_read_order("");
    string        end_read_order("");
    //
    map<string, int> readLeft;
    map<string, int> readRight;
    //
    unsigned long lastReadStaInCO     = 0; // <read_align_sta, read_align_end>
    unsigned long maxIntervalSizeInCo = 0;
    //
    while(ritr != ritr_end)
    {
        vector<string> ralign = split_string(*ritr, ',');
        
        unsigned long rsta = strtoul(ralign[0].c_str(), NULL, 0);
        unsigned long rend = strtoul(ralign[1].c_str(), NULL, 0);
        
        i_read ++; // first valid: i_read = 0
        
        // skip checking reads in front of the interval
        if(rend < co_start)
        {
            if(readLeft.find(reid[i_read]) == readLeft.end())
            {
                readLeft.insert(std::pair<string, int>(reid[i_read], 1));
            }
            ritr ++;
            continue;
        }
        //
        if(rsta<=co_start && co_start<=rend)
        {
            sta_aligned_pos = rsta; // take the last  read statisfying this
            sta_read_order  = reorder[i_read];            
            sta_read_name   = reid[i_read];
        }
        //
        if(end_aligned_pos==0 && rsta<=co_end && co_end<=rend)
        {
            end_aligned_pos = rsta; // take the first read satsifying this
            end_read_order  = reorder[i_read];            
            end_read_name   = reid[i_read];        
        }
        // number of reads within interval
        if(co_start<rsta && rend<co_end)
        {
            n_read ++;
        }
        // reads on/in CO interval
        if( (co_start<=rsta && rsta<=co_end) || (co_start<=rend && rend<=co_end) )
        {
            if(lastReadStaInCO != 0)
            {
                assert(rsta>=lastReadStaInCO);
                unsigned long this_dist = rsta - lastReadStaInCO;
                if(this_dist > maxIntervalSizeInCo) 
                {
                    maxIntervalSizeInCo = this_dist;
                }
            }
            lastReadStaInCO     = rsta;
        }        
        // reads after the interval
        if(rsta > co_end)
        {
            if(readRight.find(reid[i_read]) == readRight.end())
            {
                readRight.insert(std::pair<string, int>(reid[i_read], 1));
            }
        }
        ritr ++;
    }
    //
    *max_CORR_dist = maxIntervalSizeInCo;
    // exclude read ids at start and end of CO
    if(readLeft.find(sta_read_name) != readLeft.end())
    {
        readLeft.erase(sta_read_name);
    }
    *n_readLeft = readLeft.size();
    if(readRight.find(end_read_name) != readRight.end())
    {
        readRight.erase(end_read_name);
    }
    *n_readRight = readRight.size();
    // e.g., one read r2 within interval: co_sta_in_r1----r2------co_end_in_r3, that is, n_read = 1,
    //      => density = (co_end - co_sta) / (n_read+1)
    n_read += 1; 
    *bp_per_read_in_co = (co_end - co_start)/n_read; // check::TODO: use end_last_read - sta_first_read :: full span
    //
    string frag(" different ");
    if(end_read_name.compare(sta_read_name) == 0)
    {
        *bp_boundary_same_fragment = true;
        frag                       = (string)" same ";
    }
    //
    if(sta_read_name.size() != 0 && end_read_name.size() != 0)
    {
        cout << "         CO starts/ends in reads at " 
             << sta_aligned_pos   << ", " << end_aligned_pos << "\n"
             << "          with " << frag << " read ids: " 
             << sta_read_name     << ", " << end_read_name
             << endl;
    }
    else // reads in molecule missing compared to vcf, possibly due to secondary alignment etc.
    if(sta_read_name.size() != 0 && end_read_name.size() == 0)
    {
        cout << "         CO starts in read at " 
             << sta_aligned_pos   << ", CO-end read discarded during bam conversion. " << "\n"
             << "          with " << frag << " read id: " 
             << sta_read_name     << ","
             << endl;    
    }
    else
    if(sta_read_name.size() == 0 && end_read_name.size() != 0)
    {
        cout << "         CO ends in read at " 
             << "CO-start read discarded during bam conversion" << ", " << end_aligned_pos << "\n"
             << "          with " << frag << " read id: " 
             << ", "              << end_read_name
             << endl;    
    }
    else
    {
        cout << "         CO starts/ends in reads -- both discarded during bam conversion. " 
             << endl;
    }

    // task 2. check read density within the potential-CO related molecule
    unsigned long RR_dist_total  = 0;
    int           RR_dist_num    = 0;
    unsigned long lastR1AlignSta = 0; // for calculating R1 distance
    unsigned long lastR1AlignEnd = 0; // ..
    unsigned long lastR2AlignSta = 0; // for calculating R2 distance
    unsigned long lastR2AlignEnd = 0; // ..  
    ritr        = respan.begin();
    ritr_end    = respan.end();
    i_read      = -1;
    while(ritr != ritr_end)
    {
        vector<string> ralign = split_string(*ritr, ',');
        unsigned long rsta = strtoul(ralign[0].c_str(), NULL, 0);
        unsigned long rend = strtoul(ralign[1].c_str(), NULL, 0);
        // the i_read-th read: 0,1,...,n-1
        i_read ++;
        string iorder = reorder[i_read];
        
        if(i_read == 0)
        {
            if(iorder.compare("1") == 0)
            {
                lastR1AlignSta = rsta;
                lastR1AlignEnd = rend;
            }
            else
            {
                lastR2AlignSta = rsta;
                lastR2AlignEnd = rend;                
            }
        }
        else
        {
            if(iorder.compare("1") == 0) // current is R1
            {
                if(lastR1AlignSta > 0)   // there is last R1
                {
                    // the dist where a read takes within a molecule: always >= 0
                    int i_dist   = (rsta>lastR1AlignSta)?(rsta-lastR1AlignSta):((lastR1AlignSta-rsta)*(-1));
                    *min_RR_dist = (*min_RR_dist>i_dist)?i_dist:*min_RR_dist;
                    *max_RR_dist = (*max_RR_dist<i_dist)?i_dist:*max_RR_dist;
                    RR_dist_total+= i_dist>0?i_dist:(-1)*i_dist; // absolute dist total
                    RR_dist_num ++;
                }
                lastR1AlignSta  = rsta;
                lastR1AlignEnd  = rend;
            }
            else                         // current is R2
            {
                if(lastR2AlignSta > 0)   // there is last R2
                {
                    // minus exists: meaning overlapped RR reads
                    int i_dist  = (rsta>lastR2AlignSta)?(rsta-lastR2AlignSta):((lastR2AlignSta-rsta)*(-1));
                    *min_RR_dist = (*min_RR_dist>i_dist)?i_dist:*min_RR_dist;
                    *max_RR_dist = (*max_RR_dist<i_dist)?i_dist:*max_RR_dist;
                    RR_dist_total+= i_dist>0?i_dist:(-1)*i_dist; // absolute dist total
                    RR_dist_num ++;              
                }                
                lastR2AlignSta  = rsta;
                lastR2AlignEnd  = rend;                
            }          
        }
        
        ritr ++;
    }

    return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1d8, %rsp            # imm = 0x1D8
movq %rsi, 0x48(%rsp)
subq %rdi, %rsi
jb 0x1e18c
movq %r9, %r14
movq %r8, %rbx
movq %rcx, %r15
movq %rsi, 0x188(%rsp)
movq %rdi, 0x98(%rsp)
movq 0x220(%rsp), %rax
movq 0x218(%rsp), %rcx
movq 0x210(%rsp), %r13
movl $0xffffffff, (%r9)      # imm = 0xFFFFFFFF
movb $0x0, (%r13)
movl $0xf423f, (%rcx)        # imm = 0xF423F
movl $0x0, (%rax)
leaq 0xf8(%rsp), %r12
movb $0x3b, (%r12)
leaq 0x128(%rsp), %rdi
movq %rdx, %rsi
movq %r12, %rdx
callq 0x367c0
movb $0x2c, (%r12)
leaq 0xe0(%rsp), %rdi
leaq 0xf8(%rsp), %rdx
movq %r15, %rsi
callq 0x367c0
leaq 0xf8(%rsp), %rdx
movb $0x2c, (%rdx)
leaq 0xc0(%rsp), %rdi
movq %rbx, %rsi
callq 0x367c0
movq 0x128(%rsp), %r15
movq 0x130(%rsp), %rax
movq %rax, 0x8(%rsp)
subq %r15, %rax
movq 0xe8(%rsp), %rcx
subq 0xe0(%rsp), %rcx
cmpq %rcx, %rax
jne 0x1e1c5
movq 0xc8(%rsp), %rcx
subq 0xc0(%rsp), %rcx
cmpq %rcx, %rax
jne 0x1e1e4
leaq 0x80(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x21455(%rip), %rdx     # 0x3eb0a
leaq 0x70(%rsp), %rdi
movq %rdx, %rsi
callq 0x5384
leaq 0x60(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x21438(%rip), %rdx     # 0x3eb0a
leaq 0x50(%rsp), %rdi
movq %rdx, %rsi
callq 0x5384
leaq 0x170(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x21418(%rip), %rdx     # 0x3eb0a
leaq 0x160(%rsp), %rdi
movq %rdx, %rsi
callq 0x5384
leaq 0x150(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x213f5(%rip), %rdx     # 0x3eb0a
leaq 0x140(%rsp), %rdi
movq %rdx, %rsi
callq 0x5384
leaq 0x100(%rsp), %rax
xorl %ecx, %ecx
movl %ecx, (%rax)
movq %rcx, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
movq %rcx, 0x20(%rax)
leaq 0x198(%rsp), %rax
movl %ecx, (%rax)
movq %rcx, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
movq %rcx, 0x20(%rax)
cmpq 0x8(%rsp), %r15
je 0x1da61
movq %r14, 0x180(%rsp)
xorl %r13d, %r13d
leaq 0xa0(%rsp), %r12
leaq 0x10(%rsp), %rbx
movl $0x0, 0x44(%rsp)
movq $0x0, 0xd8(%rsp)
movq $0x0, (%rsp)
movq $0x0, 0x38(%rsp)
movq $0x0, 0x90(%rsp)
leaq (%r15,%r13), %rsi
movb $0x2c, 0x10(%rsp)
movq %r12, %r14
movq %r12, %rdi
movq %rbx, %r12
movq %rbx, %rdx
callq 0x367c0
movq 0xa0(%rsp), %rax
movq (%rax), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x4130
movq %rax, %rbp
movq 0xa0(%rsp), %rax
movq 0x20(%rax), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x4130
movq %rax, %rbx
movq 0x98(%rsp), %rax
cmpq %rax, %rbx
jae 0x1d877
movq 0xc0(%rsp), %rsi
addq %r13, %rsi
leaq 0xf8(%rsp), %rdi
callq 0xe288
leaq 0x100(%rsp), %rcx
cmpq %rcx, %rax
movq %r12, %rbx
jne 0x1da14
movq 0xc0(%rsp), %rax
leaq 0x20(%rsp), %rcx
movq %rcx, 0x10(%rsp)
movq (%rax,%r13), %rsi
movq 0x8(%rax,%r13), %rdx
addq %rsi, %rdx
movq %rbx, %rdi
callq 0xd940
movq %r14, %r12
movl $0x1, 0x30(%rsp)
leaq 0xf8(%rsp), %rdi
movq %rbx, %rsi
callq 0xe312
jmp 0x1d9f3
cmpq %rax, %rbp
ja 0x1d8b4
movq 0xe0(%rsp), %rsi
addq %r13, %rsi
leaq 0x160(%rsp), %rdi
callq 0x41c0
movq 0xc0(%rsp), %rsi
addq %r13, %rsi
leaq 0x70(%rsp), %rdi
callq 0x41c0
movq %rbp, %rax
movq %rbp, 0xd8(%rsp)
cmpq $0x0, (%rsp)
jne 0x1d90e
movq 0x48(%rsp), %rcx
cmpq %rcx, %rbp
seta %al
cmpq %rcx, %rbx
setb %cl
orb %al, %cl
je 0x1d8da
movq $0x0, (%rsp)
jmp 0x1d90e
movq 0xe0(%rsp), %rsi
addq %r13, %rsi
leaq 0x140(%rsp), %rdi
callq 0x41c0
movq 0xc0(%rsp), %rsi
addq %r13, %rsi
leaq 0x50(%rsp), %rdi
callq 0x41c0
movq %rbp, %rax
movq %rbp, (%rsp)
movq 0x48(%rsp), %rdi
cmpq %rdi, %rbx
setb %al
seta %dl
cmpq 0x98(%rsp), %rbp
seta %cl
setb %sil
cmpq %rdi, %rbp
seta %dil
orb %sil, %dil
testb %dl, %dil
je 0x1d941
movq 0x38(%rsp), %rdx
jmp 0x1d971
movq 0x38(%rsp), %rsi
testq %rsi, %rsi
je 0x1d96e
movq %rbp, %rdx
subq %rsi, %rdx
jb 0x1e1a6
movq 0x90(%rsp), %rsi
cmpq %rsi, %rdx
cmovaq %rdx, %rsi
movq %rsi, 0x90(%rsp)
movq %rbp, %rdx
movq %rdx, 0x38(%rsp)
andb %al, %cl
movzbl %cl, %eax
addl %eax, 0x44(%rsp)
cmpq 0x48(%rsp), %rbp
jbe 0x1da11
movq 0xc0(%rsp), %rsi
addq %r13, %rsi
leaq 0x190(%rsp), %rdi
callq 0xe288
movq %r12, %rbx
leaq 0x198(%rsp), %rcx
cmpq %rcx, %rax
movq %r14, %r12
jne 0x1da17
movq 0xc0(%rsp), %rax
leaq 0x20(%rsp), %rcx
movq %rcx, 0x10(%rsp)
movq (%rax,%r13), %rsi
movq 0x8(%rax,%r13), %rdx
addq %rsi, %rdx
movq %rbx, %rdi
callq 0xd940
movl $0x1, 0x30(%rsp)
leaq 0x190(%rsp), %rdi
movq %rbx, %rsi
callq 0xe312
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x1da17
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x4340
jmp 0x1da17
movq %r12, %rbx
movq %r14, %r12
movq %r12, %rdi
callq 0x6aac
leaq (%r15,%r13), %rax
addq $0x20, %rax
addq $0x20, %r13
cmpq 0x8(%rsp), %rax
jne 0x1d7af
movl 0x44(%rsp), %eax
incl %eax
movslq %eax, %rbx
movq 0x210(%rsp), %r13
movq 0x180(%rsp), %r14
movq 0xd8(%rsp), %r15
movq 0x90(%rsp), %rcx
jmp 0x1da71
movl $0x1, %ebx
movq $0x0, (%rsp)
xorl %r15d, %r15d
movq 0x238(%rsp), %rax
movl %ecx, (%rax)
leaq 0xf8(%rsp), %rdi
leaq 0x70(%rsp), %rsi
callq 0xe288
leaq 0x100(%rsp), %rcx
cmpq %rcx, %rax
je 0x1dabc
leaq 0xf8(%rsp), %rdi
leaq 0x70(%rsp), %rsi
callq 0x21bd0
leaq 0xf8(%rsp), %rdi
movq %rax, %rsi
callq 0x21c84
movq 0x228(%rsp), %rax
movl 0x120(%rsp), %ecx
movl %ecx, (%rax)
leaq 0x190(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0xe288
leaq 0x198(%rsp), %rcx
cmpq %rcx, %rax
je 0x1db0e
leaq 0x190(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x21bd0
leaq 0x190(%rsp), %rdi
movq %rax, %rsi
callq 0x21c84
movq 0x230(%rsp), %rax
movl 0x1b8(%rsp), %ecx
movl %ecx, (%rax)
movq 0x188(%rsp), %rax
xorl %edx, %edx
divq %rbx
movl %eax, (%r14)
leaq 0x20(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x1eb61(%rip), %rsi     # 0x3c6a0
leaq 0x1eb65(%rip), %rdx     # 0x3c6ab
leaq 0x10(%rsp), %rdi
callq 0x5384
movq 0x58(%rsp), %r14
movq 0x78(%rsp), %rbx
cmpq %r14, %rbx
movq %r14, %rdx
cmovbq %rbx, %rdx
testq %rdx, %rdx
je 0x1db83
movq 0x70(%rsp), %rsi
movq 0x50(%rsp), %rdi
callq 0x4350
cmpq %rbx, %r14
jne 0x1dbe6
testl %eax, %eax
je 0x1db88
jmp 0x1dbe6
cmpq %rbx, %r14
jne 0x1dbe6
movb $0x1, (%r13)
leaq 0xb0(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x1eb0c(%rip), %rsi     # 0x3c6ac
leaq 0x1eb0b(%rip), %rdx     # 0x3c6b2
leaq 0xa0(%rsp), %rdi
callq 0x5384
leaq 0x10(%rsp), %rdi
leaq 0xa0(%rsp), %rbx
movq %rbx, %rsi
callq 0x43e0
movq (%rbx), %rdi
cmpq %r14, %rdi
je 0x1dbe1
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x4340
movq 0x78(%rsp), %rbx
movq 0x58(%rsp), %rax
testq %rbx, %rbx
je 0x1dcf2
testq %rax, %rax
je 0x1dde9
movq 0x2e3c4(%rip), %rdi     # 0x4bfc8
leaq 0x1eaa8(%rip), %rsi     # 0x3c6b3
movl $0x24, %edx
callq 0x43a0
movq 0x2e3ac(%rip), %rdi     # 0x4bfc8
movq %r15, %rsi
callq 0x4210
movq %rax, %rbx
leaq 0x20a18(%rip), %rsi     # 0x3e646
movl $0x2, %edx
movq %rax, %rdi
callq 0x43a0
movq %rbx, %rdi
movq (%rsp), %rsi
callq 0x4210
movq %rax, %rbx
leaq 0x2024a(%rip), %rsi     # 0x3de9b
movl $0x1, %edx
movq %rax, %rdi
callq 0x43a0
leaq 0x1ea73(%rip), %rsi     # 0x3c6d8
movl $0xf, %edx
movq %rbx, %rdi
callq 0x43a0
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
movq %rbx, %rdi
callq 0x43a0
movq %rax, %rbx
leaq 0x1ea5a(%rip), %rsi     # 0x3c6e8
movl $0xb, %edx
movq %rax, %rdi
callq 0x43a0
movq 0x70(%rsp), %rsi
movq 0x78(%rsp), %rdx
movq %rbx, %rdi
callq 0x43a0
movq %rax, %rbx
leaq 0x2098f(%rip), %rsi     # 0x3e646
movl $0x2, %edx
movq %rax, %rdi
callq 0x43a0
movq 0x50(%rsp), %rsi
movq 0x58(%rsp), %rdx
movq %rbx, %rdi
callq 0x43a0
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x4310
jmp 0x1dee6
testq %rax, %rax
je 0x1deb7
movq 0x2e2c6(%rip), %rdi     # 0x4bfc8
leaq 0x1ea45(%rip), %rsi     # 0x3c74e
movl $0x1c, %edx
callq 0x43a0
movq 0x2e2ae(%rip), %rdi     # 0x4bfc8
leaq 0x1ea4a(%rip), %rsi     # 0x3c76b
movl $0x2d, %edx
callq 0x43a0
movq 0x2e296(%rip), %rdi     # 0x4bfc8
leaq 0x2090d(%rip), %rsi     # 0x3e646
movl $0x2, %edx
callq 0x43a0
movq 0x2e27e(%rip), %rdi     # 0x4bfc8
movq (%rsp), %rsi
callq 0x4210
movq %rax, %rbx
leaq 0x2013e(%rip), %rsi     # 0x3de9b
movl $0x1, %edx
movq %rax, %rdi
callq 0x43a0
leaq 0x1e967(%rip), %rsi     # 0x3c6d8
movl $0xf, %edx
movq %rbx, %rdi
callq 0x43a0
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
movq %rbx, %rdi
callq 0x43a0
movq %rax, %rbx
leaq 0x1e9a9(%rip), %rsi     # 0x3c743
movl $0xa, %edx
movq %rax, %rdi
callq 0x43a0
leaq 0x20898(%rip), %rsi     # 0x3e646
movl $0x2, %edx
movq %rbx, %rdi
callq 0x43a0
movq 0x50(%rsp), %rsi
movq 0x58(%rsp), %rdx
movq %rbx, %rdi
callq 0x43a0
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x4310
jmp 0x1dee6
movq 0x2e1d8(%rip), %rdi     # 0x4bfc8
leaq 0x1e8fd(%rip), %rsi     # 0x3c6f4
movl $0x1e, %edx
callq 0x43a0
movq 0x2e1c0(%rip), %rdi     # 0x4bfc8
movq %r15, %rsi
callq 0x4210
movq %rax, %rbx
leaq 0x1e8f9(%rip), %rsi     # 0x3c713
movl $0x2f, %edx
movq %rax, %rdi
callq 0x43a0
leaq 0x2006d(%rip), %rsi     # 0x3de9b
movl $0x1, %edx
movq %rbx, %rdi
callq 0x43a0
leaq 0x1e896(%rip), %rsi     # 0x3c6d8
movl $0xf, %edx
movq %rbx, %rdi
callq 0x43a0
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
movq %rbx, %rdi
callq 0x43a0
movq %rax, %rbx
leaq 0x1e8d8(%rip), %rsi     # 0x3c743
movl $0xa, %edx
movq %rax, %rdi
callq 0x43a0
movq 0x70(%rsp), %rsi
movq 0x78(%rsp), %rdx
movq %rbx, %rdi
callq 0x43a0
movq %rax, %r15
leaq 0x1d024(%rip), %rsi     # 0x3aeb8
movl $0x1, %edx
movq %rax, %rdi
callq 0x43a0
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x4310
jmp 0x1dee6
movq 0x2e10a(%rip), %r15     # 0x4bfc8
leaq 0x1e8d4(%rip), %rsi     # 0x3c799
movl $0x4a, %edx
movq %r15, %rdi
callq 0x43a0
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x4310
movsbl %al, %esi
movq %r15, %rdi
callq 0x4030
movq %rax, %rdi
callq 0x4220
movq 0x128(%rsp), %rcx
movq 0x130(%rsp), %rax
movq %rax, 0x38(%rsp)
cmpq %rax, %rcx
je 0x1e09f
xorl %r13d, %r13d
leaq 0x1c0(%rsp), %rbp
leaq 0xa0(%rsp), %r15
xorl %ebx, %ebx
xorl %r14d, %r14d
movq $0x0, 0x8(%rsp)
movq %rcx, (%rsp)
movq %rbx, %r12
leaq (%rcx,%r13), %rsi
movb $0x2c, 0xa0(%rsp)
movq %rbp, %rdi
movq %r15, %rbx
movq %r15, %rdx
callq 0x367c0
movq 0x1c0(%rsp), %rax
movq (%rax), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x4130
movq %rax, %rbp
movq 0x1c0(%rsp), %rax
movq 0x20(%rax), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x4130
movq 0xe0(%rsp), %rax
leaq 0xb0(%rsp), %rcx
movq %rcx, 0xa0(%rsp)
movq (%rax,%r13), %rsi
movq 0x8(%rax,%r13), %rdx
addq %rsi, %rdx
movq %rbx, %rdi
callq 0xd940
movq %rbx, %r15
movq %rbx, %rdi
leaq 0x1c683(%rip), %rsi     # 0x3a641
callq 0x4100
movq %r12, %rbx
subq $0x1, %rbx
jae 0x1dfe2
testl %eax, %eax
movq 0x8(%rsp), %rax
cmoveq %rbp, %rax
movq %rax, 0x8(%rsp)
cmovneq %rbp, %r14
jmp 0x1e04f
testl %eax, %eax
je 0x1e017
testq %r14, %r14
je 0x1e012
movl %ebp, %eax
subl %r14d, %eax
movq 0x218(%rsp), %rdx
movl (%rdx), %ecx
cmpl %eax, %ecx
cmovgel %eax, %ecx
movl %ecx, (%rdx)
movq 0x220(%rsp), %rdx
movl (%rdx), %ecx
cmpl %eax, %ecx
cmovgl %ecx, %eax
movl %eax, (%rdx)
movq %rbp, %r14
jmp 0x1e04f
movq 0x8(%rsp), %rax
testq %rax, %rax
je 0x1e04a
movq %rax, %rcx
movl %ebp, %eax
subl %ecx, %eax
movq 0x218(%rsp), %rdx
movl (%rdx), %ecx
cmpl %eax, %ecx
cmovgel %eax, %ecx
movl %ecx, (%rdx)
movq 0x220(%rsp), %rdx
movl (%rdx), %ecx
cmpl %eax, %ecx
cmovgl %ecx, %eax
movl %eax, (%rdx)
movq %rbp, 0x8(%rsp)
movq 0xa0(%rsp), %rdi
leaq 0xb0(%rsp), %rax
cmpq %rax, %rdi
leaq 0x1c0(%rsp), %rbp
je 0x1e07c
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x4340
movq %rbp, %rdi
callq 0x6aac
movq (%rsp), %rcx
leaq (%rcx,%r13), %rax
addq $0x20, %rax
addq $0x20, %r13
cmpq 0x38(%rsp), %rax
jne 0x1df3c
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x1e0bb
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x4340
leaq 0x190(%rsp), %rdi
callq 0xd7ee
leaq 0xf8(%rsp), %rdi
callq 0xd7ee
movq 0x140(%rsp), %rdi
leaq 0x150(%rsp), %rax
cmpq %rax, %rdi
je 0x1e0fa
movq 0x150(%rsp), %rsi
incq %rsi
callq 0x4340
movq 0x160(%rsp), %rdi
leaq 0x170(%rsp), %rax
cmpq %rax, %rdi
je 0x1e11f
movq 0x170(%rsp), %rsi
incq %rsi
callq 0x4340
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x1e13b
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x4340
movq 0x70(%rsp), %rdi
leaq 0x80(%rsp), %rax
cmpq %rax, %rdi
je 0x1e15d
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x4340
leaq 0xc0(%rsp), %rdi
callq 0x6aac
leaq 0xe0(%rsp), %rdi
callq 0x6aac
leaq 0x128(%rsp), %rdi
callq 0x6aac
movq 0x98(%rsp), %rdi
cmpq %rdi, 0x48(%rsp)
setae %al
addq $0x1d8, %rsp            # imm = 0x1D8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1e4dd(%rip), %rdi     # 0x3c68a
leaq 0x1dd6d(%rip), %rsi     # 0x3bf21
leaq 0x1e42f(%rip), %rcx     # 0x3c5ea
movl $0x50b, %edx            # imm = 0x50B
callq 0x41f0
leaq 0x1e3fe(%rip), %rdi     # 0x3c5ca
leaq 0x1dd4e(%rip), %rsi     # 0x3bf21
leaq 0x1e410(%rip), %rcx     # 0x3c5ea
movl $0x4cb, %edx            # imm = 0x4CB
callq 0x41f0
leaq 0x1e482(%rip), %rdi     # 0x3c66d
leaq 0x1dd2f(%rip), %rsi     # 0x3bf21
leaq 0x1e3f1(%rip), %rcx     # 0x3c5ea
movl $0x4cc, %edx            # imm = 0x4CC
callq 0x41f0
jmp 0x1e288
jmp 0x1e2bb
jmp 0x1e2bb
jmp 0x1e2bb
movq %rax, %rbx
jmp 0x1e2fd
movq %rax, %rbx
jmp 0x1e322
movq %rax, %rbx
jmp 0x1e33e
movq %rax, %rbx
jmp 0x1e360
movq %rax, %rbx
jmp 0x1e36d
movq %rax, %rbx
jmp 0x1e37a
jmp 0x1e24d
jmp 0x1e276
jmp 0x1e2bb
movq %rax, %rbx
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x1e279
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x4340
jmp 0x1e279
jmp 0x1e276
jmp 0x1e276
jmp 0x1e276
jmp 0x1e288
movq %rax, %rbx
leaq 0xa0(%rsp), %rdi
callq 0x6aac
jmp 0x1e2be
movq %rax, %rbx
jmp 0x1e29d
movq %rax, %rbx
leaq 0x1c0(%rsp), %rdi
callq 0x6aac
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x1e2be
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x4340
jmp 0x1e2be
movq %rax, %rbx
leaq 0x190(%rsp), %rdi
callq 0xd7ee
leaq 0xf8(%rsp), %rdi
callq 0xd7ee
movq 0x140(%rsp), %rdi
leaq 0x150(%rsp), %rax
cmpq %rax, %rdi
je 0x1e2fd
movq 0x150(%rsp), %rsi
incq %rsi
callq 0x4340
movq 0x160(%rsp), %rdi
leaq 0x170(%rsp), %rax
cmpq %rax, %rdi
je 0x1e322
movq 0x170(%rsp), %rsi
incq %rsi
callq 0x4340
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x1e33e
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x4340
movq 0x70(%rsp), %rdi
leaq 0x80(%rsp), %rax
cmpq %rax, %rdi
je 0x1e360
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x4340
leaq 0xc0(%rsp), %rdi
callq 0x6aac
leaq 0xe0(%rsp), %rdi
callq 0x6aac
leaq 0x128(%rsp), %rdi
callq 0x6aac
movq %rbx, %rdi
callq 0x45a0