// File: /workspace/github_cpp_makefile_star2_O1/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 0x1e22d
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 0x36b7c
movb $0x2c, (%r12)
leaq 0xe0(%rsp), %rdi
leaq 0xf8(%rsp), %rdx
movq %r15, %rsi
callq 0x36b7c
leaq 0xf8(%rsp), %rdx
movb $0x2c, (%rdx)
leaq 0xa0(%rsp), %rdi
movq %rbx, %rsi
callq 0x36b7c
movq 0x128(%rsp), %r15
movq 0x130(%rsp), %rax
movq %rax, 0x38(%rsp)
subq %r15, %rax
movq 0xe8(%rsp), %rcx
subq 0xe0(%rsp), %rcx
cmpq %rcx, %rax
jne 0x1e266
movq 0xa8(%rsp), %rcx
subq 0xa0(%rsp), %rcx
cmpq %rcx, %rax
jne 0x1e285
leaq 0x80(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x213f9(%rip), %rdx     # 0x3eb22
leaq 0x70(%rsp), %rdi
movq %rdx, %rsi
callq 0x5384
leaq 0x60(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x213dc(%rip), %rdx     # 0x3eb22
leaq 0x50(%rsp), %rdi
movq %rdx, %rsi
callq 0x5384
leaq 0x170(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x213bc(%rip), %rdx     # 0x3eb22
leaq 0x160(%rsp), %rdi
movq %rdx, %rsi
callq 0x5384
leaq 0x150(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x21399(%rip), %rdx     # 0x3eb22
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 0x38(%rsp), %r15
je 0x1dad5
movq %r14, 0x180(%rsp)
xorl %r13d, %r13d
leaq 0xb8(%rsp), %r12
leaq 0x10(%rsp), %rbx
movl $0x0, 0x40(%rsp)
movq $0x0, 0xd8(%rsp)
movq $0x0, (%rsp)
movq $0x0, 0x8(%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 0x36b7c
movq 0xb8(%rsp), %rax
movq (%rax), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x4130
movq %rax, %rbp
movq 0xb8(%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 0x1d8eb
movq 0xa0(%rsp), %rsi
addq %r13, %rsi
leaq 0xf8(%rsp), %rdi
callq 0xe368
leaq 0x100(%rsp), %rcx
cmpq %rcx, %rax
movq %r12, %rbx
jne 0x1da88
movq 0xa0(%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 0xda32
movq %r14, %r12
movl $0x1, 0x30(%rsp)
leaq 0xf8(%rsp), %rdi
movq %rbx, %rsi
callq 0xe3f2
jmp 0x1da67
cmpq %rax, %rbp
ja 0x1d928
movq 0xe0(%rsp), %rsi
addq %r13, %rsi
leaq 0x160(%rsp), %rdi
callq 0x41c0
movq 0xa0(%rsp), %rsi
addq %r13, %rsi
leaq 0x70(%rsp), %rdi
callq 0x41c0
movq %rbp, %rax
movq %rbp, 0xd8(%rsp)
cmpq $0x0, (%rsp)
jne 0x1d982
movq 0x48(%rsp), %rcx
cmpq %rcx, %rbp
seta %al
cmpq %rcx, %rbx
setb %cl
orb %al, %cl
je 0x1d94e
movq $0x0, (%rsp)
jmp 0x1d982
movq 0xe0(%rsp), %rsi
addq %r13, %rsi
leaq 0x140(%rsp), %rdi
callq 0x41c0
movq 0xa0(%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 0x1d9b5
movq 0x8(%rsp), %rdx
jmp 0x1d9e5
movq 0x8(%rsp), %rsi
testq %rsi, %rsi
je 0x1d9e2
movq %rbp, %rdx
subq %rsi, %rdx
jb 0x1e247
movq 0x90(%rsp), %rsi
cmpq %rsi, %rdx
cmovaq %rdx, %rsi
movq %rsi, 0x90(%rsp)
movq %rbp, %rdx
movq %rdx, 0x8(%rsp)
andb %al, %cl
movzbl %cl, %eax
addl %eax, 0x40(%rsp)
cmpq 0x48(%rsp), %rbp
jbe 0x1da85
movq 0xa0(%rsp), %rsi
addq %r13, %rsi
leaq 0x190(%rsp), %rdi
callq 0xe368
movq %r12, %rbx
leaq 0x198(%rsp), %rcx
cmpq %rcx, %rax
movq %r14, %r12
jne 0x1da8b
movq 0xa0(%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 0xda32
movl $0x1, 0x30(%rsp)
leaq 0x190(%rsp), %rdi
movq %rbx, %rsi
callq 0xe3f2
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x1da8b
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x4340
jmp 0x1da8b
movq %r12, %rbx
movq %r14, %r12
movq %r12, %rdi
callq 0x6aa2
leaq (%r15,%r13), %rax
addq $0x20, %rax
addq $0x20, %r13
cmpq 0x38(%rsp), %rax
jne 0x1d823
movl 0x40(%rsp), %eax
incl %eax
movslq %eax, %rbx
movq 0x210(%rsp), %r13
movq 0x180(%rsp), %r14
movq 0xd8(%rsp), %r15
movq 0x90(%rsp), %rcx
jmp 0x1dae5
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 0xe368
leaq 0x100(%rsp), %rcx
cmpq %rcx, %rax
je 0x1db30
leaq 0xf8(%rsp), %rdi
leaq 0x70(%rsp), %rsi
callq 0x21d2a
leaq 0xf8(%rsp), %rdi
movq %rax, %rsi
callq 0x21dd2
movq 0x228(%rsp), %rax
movl 0x120(%rsp), %ecx
movl %ecx, (%rax)
leaq 0x190(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0xe368
leaq 0x198(%rsp), %rcx
cmpq %rcx, %rax
je 0x1db82
leaq 0x190(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x21d2a
leaq 0x190(%rsp), %rdi
movq %rax, %rsi
callq 0x21dd2
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 0x1eaed(%rip), %rsi     # 0x3c6a0
leaq 0x1eaf1(%rip), %rdx     # 0x3c6ab
leaq 0x10(%rsp), %rdi
callq 0x5384
movq 0x58(%rsp), %rbx
movq 0x78(%rsp), %r14
cmpq %rbx, %r14
movq %rbx, %rdx
cmovbq %r14, %rdx
testq %rdx, %rdx
je 0x1dbf3
movq 0x70(%rsp), %rsi
movq 0x50(%rsp), %rdi
callq 0x4350
testl %eax, %eax
sete %al
jmp 0x1dbf5
movb $0x1, %al
cmpq %r14, %rbx
setne %cl
xorb $0x1, %al
orb %cl, %al
leaq 0xc8(%rsp), %rbp
jne 0x1dc59
movb $0x1, (%r13)
leaq 0xb8(%rsp), %rdi
movq %rbp, (%rdi)
leaq 0x1ea8c(%rip), %rsi     # 0x3c6ac
leaq 0x1ea8b(%rip), %rdx     # 0x3c6b2
callq 0x5384
leaq 0x10(%rsp), %rdi
leaq 0xb8(%rsp), %rbx
movq %rbx, %rsi
callq 0x43e0
movq (%rbx), %rdi
cmpq %rbp, %rdi
je 0x1dc59
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x4340
movq 0x78(%rsp), %rax
testq %rax, %rax
je 0x1dd68
cmpq $0x0, 0x58(%rsp)
je 0x1dd68
movq 0x2e34e(%rip), %rdi     # 0x4bfc8
leaq 0x1ea32(%rip), %rsi     # 0x3c6b3
movl $0x24, %edx
callq 0x43a0
movq 0x2e336(%rip), %rdi     # 0x4bfc8
movq %r15, %rsi
callq 0x4210
movq %rax, %rbx
leaq 0x209ba(%rip), %rsi     # 0x3e65e
movl $0x2, %edx
movq %rax, %rdi
callq 0x43a0
movq %rbx, %rdi
movq (%rsp), %rsi
callq 0x4210
movq %rax, %rbx
leaq 0x201d4(%rip), %rsi     # 0x3de9b
movl $0x1, %edx
movq %rax, %rdi
callq 0x43a0
leaq 0x1e9fd(%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 0x1e9e4(%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 0x20931(%rip), %rsi     # 0x3e65e
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 0x1df7d
testq %rax, %rax
je 0x1de4e
cmpq $0x0, 0x58(%rsp)
jne 0x1de4e
movq 0x2e244(%rip), %rdi     # 0x4bfc8
leaq 0x1e969(%rip), %rsi     # 0x3c6f4
movl $0x1e, %edx
callq 0x43a0
movq 0x2e22c(%rip), %rdi     # 0x4bfc8
movq %r15, %rsi
callq 0x4210
movq %rax, %rbx
leaq 0x1e965(%rip), %rsi     # 0x3c713
movl $0x2f, %edx
movq %rax, %rdi
callq 0x43a0
leaq 0x200d9(%rip), %rsi     # 0x3de9b
movl $0x1, %edx
movq %rbx, %rdi
callq 0x43a0
leaq 0x1e902(%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 0x1e944(%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 0x1d090(%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 0x1df7d
testq %rax, %rax
jne 0x1df4e
cmpq $0x0, 0x58(%rsp)
je 0x1df4e
movq 0x2e15e(%rip), %rdi     # 0x4bfc8
leaq 0x1e8dd(%rip), %rsi     # 0x3c74e
movl $0x1c, %edx
callq 0x43a0
movq 0x2e146(%rip), %rdi     # 0x4bfc8
leaq 0x1e8e2(%rip), %rsi     # 0x3c76b
movl $0x2d, %edx
callq 0x43a0
movq 0x2e12e(%rip), %rdi     # 0x4bfc8
leaq 0x207bd(%rip), %rsi     # 0x3e65e
movl $0x2, %edx
callq 0x43a0
movq 0x2e116(%rip), %rdi     # 0x4bfc8
movq (%rsp), %rsi
callq 0x4210
movq %rax, %rbx
leaq 0x1ffd6(%rip), %rsi     # 0x3de9b
movl $0x1, %edx
movq %rax, %rdi
callq 0x43a0
leaq 0x1e7ff(%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 0x1e841(%rip), %rsi     # 0x3c743
movl $0xa, %edx
movq %rax, %rdi
callq 0x43a0
leaq 0x20748(%rip), %rsi     # 0x3e65e
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 0x1df7d
movq 0x2e073(%rip), %r15     # 0x4bfc8
leaq 0x1e83d(%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, 0x40(%rsp)
cmpq %rax, %rcx
je 0x1e140
xorl %r13d, %r13d
leaq 0x1c0(%rsp), %rdi
leaq 0xb8(%rsp), %r12
movq $0x0, 0x38(%rsp)
movq $0x0, 0x8(%rsp)
movq $0x0, (%rsp)
movq %rbp, %r14
movq %rcx, %r15
leaq (%rcx,%r13), %rsi
movb $0x2c, 0xb8(%rsp)
movq %rdi, %rbx
movq %r12, %rdx
callq 0x36b7c
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
movq %r14, 0xb8(%rsp)
movq (%rax,%r13), %rsi
movq 0x8(%rax,%r13), %rdx
addq %rsi, %rdx
movq %r12, %rdi
callq 0xda32
movq %r12, %rdi
leaq 0x1c5ef(%rip), %rsi     # 0x3a641
callq 0x4100
movq 0x38(%rsp), %rcx
subq $0x1, %rcx
movq %rcx, 0x38(%rsp)
jae 0x1e085
testl %eax, %eax
movq (%rsp), %rax
cmoveq %rbp, %rax
movq %rax, (%rsp)
movq 0x8(%rsp), %rax
cmovneq %rbp, %rax
movq %rax, 0x8(%rsp)
jmp 0x1e0f3
testl %eax, %eax
movq (%rsp), %rdx
movq 0x8(%rsp), %rsi
je 0x1e0c4
testq %rsi, %rsi
je 0x1e0bd
movl %ebp, %eax
subl %esi, %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)
jmp 0x1e0f3
testq %rdx, %rdx
je 0x1e0ef
movl %ebp, %eax
subl %edx, %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, (%rsp)
movq 0xb8(%rsp), %rdi
movq %r14, %rbp
cmpq %r14, %rdi
je 0x1e113
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x4340
movq %rbx, %rdi
callq 0x6aa2
movq %rbx, %rdi
movq %r15, %rcx
leaq (%r15,%r13), %rax
addq $0x20, %rax
addq $0x20, %r13
cmpq 0x40(%rsp), %rax
leaq 0xb8(%rsp), %r12
jne 0x1dfdb
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x1e15c
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x4340
leaq 0x190(%rsp), %rdi
callq 0xd8e0
leaq 0xf8(%rsp), %rdi
callq 0xd8e0
movq 0x140(%rsp), %rdi
leaq 0x150(%rsp), %rax
cmpq %rax, %rdi
je 0x1e19b
movq 0x150(%rsp), %rsi
incq %rsi
callq 0x4340
movq 0x160(%rsp), %rdi
leaq 0x170(%rsp), %rax
cmpq %rax, %rdi
je 0x1e1c0
movq 0x170(%rsp), %rsi
incq %rsi
callq 0x4340
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x1e1dc
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x4340
movq 0x70(%rsp), %rdi
leaq 0x80(%rsp), %rax
cmpq %rax, %rdi
je 0x1e1fe
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x4340
leaq 0xa0(%rsp), %rdi
callq 0x6aa2
leaq 0xe0(%rsp), %rdi
callq 0x6aa2
leaq 0x128(%rsp), %rdi
callq 0x6aa2
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 0x1e43c(%rip), %rdi     # 0x3c68a
leaq 0x1dccc(%rip), %rsi     # 0x3bf21
leaq 0x1e38e(%rip), %rcx     # 0x3c5ea
movl $0x50b, %edx            # imm = 0x50B
callq 0x41f0
leaq 0x1e35d(%rip), %rdi     # 0x3c5ca
leaq 0x1dcad(%rip), %rsi     # 0x3bf21
leaq 0x1e36f(%rip), %rcx     # 0x3c5ea
movl $0x4cb, %edx            # imm = 0x4CB
callq 0x41f0
leaq 0x1e3e1(%rip), %rdi     # 0x3c66d
leaq 0x1dc8e(%rip), %rsi     # 0x3bf21
leaq 0x1e350(%rip), %rcx     # 0x3c5ea
movl $0x4cc, %edx            # imm = 0x4CC
callq 0x41f0
jmp 0x1e329
jmp 0x1e35c
jmp 0x1e35c
jmp 0x1e35c
movq %rax, %rbx
jmp 0x1e39e
movq %rax, %rbx
jmp 0x1e3c3
movq %rax, %rbx
jmp 0x1e3df
movq %rax, %rbx
jmp 0x1e401
movq %rax, %rbx
jmp 0x1e40e
movq %rax, %rbx
jmp 0x1e41b
jmp 0x1e2ee
jmp 0x1e317
jmp 0x1e35c
movq %rax, %rbx
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x1e31a
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x4340
jmp 0x1e31a
jmp 0x1e317
jmp 0x1e317
jmp 0x1e317
jmp 0x1e329
movq %rax, %rbx
leaq 0xb8(%rsp), %rdi
callq 0x6aa2
jmp 0x1e35f
movq %rax, %rbx
jmp 0x1e33e
movq %rax, %rbx
leaq 0x1c0(%rsp), %rdi
callq 0x6aa2
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x1e35f
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x4340
jmp 0x1e35f
movq %rax, %rbx
leaq 0x190(%rsp), %rdi
callq 0xd8e0
leaq 0xf8(%rsp), %rdi
callq 0xd8e0
movq 0x140(%rsp), %rdi
leaq 0x150(%rsp), %rax
cmpq %rax, %rdi
je 0x1e39e
movq 0x150(%rsp), %rsi
incq %rsi
callq 0x4340
movq 0x160(%rsp), %rdi
leaq 0x170(%rsp), %rax
cmpq %rax, %rdi
je 0x1e3c3
movq 0x170(%rsp), %rsi
incq %rsi
callq 0x4340
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x1e3df
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x4340
movq 0x70(%rsp), %rdi
leaq 0x80(%rsp), %rax
cmpq %rax, %rdi
je 0x1e401
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x4340
leaq 0xa0(%rsp), %rdi
callq 0x6aa2
leaq 0xe0(%rsp), %rdi
callq 0x6aa2
leaq 0x128(%rsp), %rdi
callq 0x6aa2
movq %rbx, %rdi
callq 0x45a0