// File: /workspace/github_cpp_makefile_star2_O2/WeichenZhou[P]PALMER/./scp/3_read_masker.cpp
// Function: ReadMasker(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 ReadMasker(string WD_dir, string mode){
    
    //std::ios::sync_with_stdio(false);
    //std::cin.tie(0);
    
    ifstream file1;
    //ifstream file2;
    ifstream file3;
    ofstream file5;
    ofstream file6;
    ofstream file7;
    
    string sys_regionsam = WD_dir+"region.sam";
    char *syst_regionsam = new char[sys_regionsam.length()+1];
    strcpy(syst_regionsam, sys_regionsam.c_str());
    
    file1.open(syst_regionsam);
    
    /*
    string sys_RMselec = WD_dir+"RM.selected";
    char *syst_RMselec = new char[sys_RMselec.length()+1];
    strcpy(syst_RMselec, sys_RMselec.c_str());
    
    file2.open(syst_RMselec);
    */
    
    string sys_cigar2 = WD_dir+"cigar.2";
    char *syst_cigar2 = new char[sys_cigar2.length()+1];
    strcpy(syst_cigar2, sys_cigar2.c_str());
    
    file5.open(syst_cigar2);
    
    string sys_SEQ = WD_dir+"SEQ.masked";
    char *syst_SEQ = new char[sys_SEQ.length()+1];
    strcpy(syst_SEQ, sys_SEQ.c_str());
    
    file6.open(syst_SEQ);
    
    string sys_selecinfo = WD_dir+"selected.reads.info";
    char *syst_selecinfo = new char[sys_selecinfo.length()+1];
    strcpy(syst_selecinfo, sys_selecinfo.c_str());
    
    file7.open(syst_selecinfo);
    
    if (!file1.is_open())
    {
        cout <<"CANNOT OPEN FILE, 'region.sam'"<< endl;
        //exit(1);
        return 0;
    }
    
    string input;
    int input_int;
    
    int line=0;
    
    for(int i=0;!file1.eof();++i){
        getline(file1,input);
        line=i;
    }
    file1.close();
    file1.clear();
    file1.open(syst_regionsam);

    string **sam_info;
    sam_info=new string*[line];
    for(int i=0;i!=line;++i) sam_info[i]=new string[6];
    
    int **sam_loc;
    sam_loc=new int*[line];
    for(int i=0;i!=line;++i) sam_loc[i]=new int[5];
    
    for(int i=0;i!=line;++i){
        file1>>sam_info[i][0];        //QNAME
        //getline(file1,sam_info[i][0],'\t'); //QNAME
        file1>>sam_loc[i][0];         //FLAG
        file1>>sam_info[i][1];        //RNAME
        file1>>sam_loc[i][1];         //POS
        file1>>sam_loc[i][2];         //MAPQ
        file1>>sam_info[i][2];        //CIGAR
        file1>>sam_info[i][3];        //RNEXT
        file1>>sam_loc[i][3];         //PNEXT
        file1>>sam_loc[i][4];         //TLEN
        file1>>sam_info[i][4];        //SEQ
        getline(file1,sam_info[i][5]);//QUAL
        
    }
    
    /*
    int line_rm;
    int **rm_loc;
    string **rm_info;
    
    if (!file2.is_open()){
        line_rm=1;
        
        rm_loc=new int*[line_rm];
        for(int i=0;i!=line_rm;++i) rm_loc[i]=new int[2];
        
        rm_info=new string*[line_rm];
        for(int i=0;i!=line_rm;++i) rm_info[i]=new string[4];
        
        rm_info[0][0]="null";           //chr
        rm_loc[0][0]=0;            //start
        rm_loc[0][1]=0;            //end
        rm_info[0][1]="null";           //class
        rm_info[0][2]="null";           //family
        rm_info[0][3]="null";          //name
        
    }
    else {
        line_rm=0;
        for(int i=0;!file2.eof();++i){
            getline(file2,input);
            line_rm=i;
        }
        file2.close();
        file2.clear();
        file2.open(syst_RMselec);
        
        rm_loc=new int*[line_rm];
        for(int i=0;i!=line_rm;++i) rm_loc[i]=new int[2];
        
        rm_info=new string*[line_rm];
        for(int i=0;i!=line_rm;++i) rm_info[i]=new string[4];
        
        for(int i=0;i!=line_rm;++i){
            file2>>rm_info[i][0];           //chr
            file2>>rm_loc[i][0];            //start
            file2>>rm_loc[i][1];            //end
            file2>>rm_info[i][1];           //class
            file2>>rm_info[i][2];           //family
            file2>>rm_info[i][3];           //name
        }
    }
     */
    
//cout<<"region reading complete"<<endl;
    for(int i=0;i!=line;++i){
        //cout<<i<<endl;
        int number=0;
        int sc1, sc2, I, M, D, F, h1, h2, eq;
        sc1=sc2=I=M=D=F=h1=h2=eq=0;
        char cig;
        int read_s, read_e;
        read_s=sam_loc[i][1];
       
        string cigar1;
        cigar1=sam_info[i][2]+"0E";
        stringstream ss_cigar1;
        ss_cigar1.clear();
        ss_cigar1.str(cigar1);
        
//reads cigar&seq
        int le=sam_info[i][4].length();
        char *seq =new char[sam_info[i][4].length()+1];
        strcpy(seq,sam_info[i][4].c_str());
        
        /*
        int le=sam_info[i][4].length();
        char seq[le];
        char *cseq=sam_info[i][4].c_str();
        strcpy(seq,cseq);
        */
        ss_cigar1>>number;
        ss_cigar1>>cig;
        
        for(;!(cig=='E'&&number==0);){
            if(cig=='S'&&F==0) {sc1=sc1+number;F=1;}
            else if(cig=='H'&&F==0) h1=h1+number;
            else if (cig=='M') {M=M+number;F=1;}
            else if (cig=='='||cig=='X') {eq=eq+number;F=1;}
            else if (cig=='I') {I=I+number;F=1;}
            else if (cig=='D'||cig=='N') {D=D+number;F=1;}
            else if (cig=='S'&&F==1) sc2=sc2+number;
            else if (cig=='H'&&F==1) h2=h2+number;
            ss_cigar1>>number;
            ss_cigar1>>cig;
        }
        read_e=sam_loc[i][1]+M+D+eq-1;
        
        
        //if(sc1>=50||sc2>=50||I>=50){
            
//mask
            int start=0;
            int end=0;
            
            /*
            for(int j=0;j!=line_rm;++j){
                if(!((read_s>rm_loc[j][1])||(read_e<rm_loc[j][0]))){
                    
                    stringstream ss_cigar1;
                    ss_cigar1.clear();
                    ss_cigar1.str(cigar1);
                    
                    //file3.open(syst_cigar1);
                    if(read_s>rm_loc[j][0]) start=read_s;
                    else start= rm_loc[j][0];
                    if(read_e>rm_loc[j][1]) end=rm_loc[j][1];
                    else end=read_e;
                    
                    ss_cigar1>>number;
                    ss_cigar1>>cig;
                    int bit=read_s; //bit = reference location
                    int k=0;        //k = read seq location
                    
                    
                    for(;!(cig=='E'&&number==0);){
                        if(cig=='M'||cig=='='||cig=='X') {
                            bit=bit+number;
                            
                            if(bit>=start&&bit<=end&&(bit-number)>=start){
                                for(int x=0;x!=number;++x){
                                    seq[k+x]='N';
                                }
                            }
                            else if(bit>=start&&bit<=end&&(bit-number)<start){
                                for(int x=start-bit+number;x!=number;++x){
                                    seq[k+x]='N';
                                }
                            }
                            else if((bit-number)>=start&&(bit-number)<=end&&bit>end){
                                for(int x=0;x!=end-bit+number+1;++x){
                                    seq[k+x]='N';
                                }
                            }
                            else if((bit-number)<start&&bit>end){
                                for(int x=start-bit+number;x!=end-bit+number+1;++x){
                                    seq[k+x]='N';
                                }
                            }
                            k=k+number;
                        }
                        else if(cig=='D'||cig=='N') {bit=bit+number;
                        }
                        else if(cig=='S'||cig=='I') {k=k+number;
                        }
                        ss_cigar1>>number;
                        ss_cigar1>>cig;
                    }
                }
            }
            */
            
            stringstream ss_cigar2;
            ss_cigar2.clear();
            ss_cigar2.str(cigar1);
            
            //file3.open(syst_cigar1);
            start=read_s;
            end=read_e;
            
            ss_cigar2>>number;
            ss_cigar2>>cig;
            
            int bit_s=0;
            int k_s=0;
            for(;!(cig=='E'&&number==0);){
                /*if(cig=='S') {
                   
                    for(int x=0;x!=number;++x){
                        seq[k_s+x]='N';
                    }
                    
                    k_s=k_s+number;
                }
                
                ss_cigar1>>number;
                ss_cigar1>>cig;
                */
                
                if(cig=='M'||cig=='=') {
                    
                    for(int x=0;x!=number;++x){
                        seq[k_s+x]='N';
                    }
                    
                    bit_s=bit_s+number;
                    k_s=k_s+number;
                }
                else if(cig=='X') {
                    bit_s=bit_s+number;
                    k_s=k_s+number;
                }
                else if(cig=='D'||cig=='N') {bit_s=bit_s+number;
                }
                
                else if(cig=='I') {k_s=k_s+number;
                }
                
                else if(cig=='S'&&mode=="asm") {
                   
                    for(int x=0;x!=number;++x){
                        seq[k_s+x]='N';
                    }
                    
                    k_s=k_s+number;
                }
                
                else if(cig=='S'){
                    k_s=k_s+number;
                }
                
                ss_cigar2>>number;
                ss_cigar2>>cig;
                
            }
            
            
            
            
//output
            file5<<sam_info[i][2]<<"0E"<<'\t'<<i<<endl;
            file6<<">"<<sam_info[i][0]<<"_"<<sam_loc[i][1]<<"_"<<i<<endl;
            for(int x=0;x!=le;++x) file6<<seq[x];
            file6<<endl;
            file7<<sam_info[i][0]<<'\t'<<sam_info[i][1]<<'\t'<<sam_loc[i][1]<<'\t'<<le<<'\t'<<i<<endl;
        //}
        delete [] seq;
    }
    
    for(int i=0;i!=line;++i){
        delete [] sam_info[i];
        delete [] sam_loc[i];
    }
    delete [] sam_info;
    delete [] sam_loc;
    
    /*
    for(int i=0;i!=line_rm;++i){
        delete [] rm_info[i];
        delete [] rm_loc[i];
    }
    delete [] rm_info;
    delete [] rm_loc;
    */
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xe28, %rsp            # imm = 0xE28
movq %rsi, 0x60(%rsp)
movq %rdi, %r14
leaq 0x108(%rsp), %rdi
callq 0x2250
leaq 0xc20(%rsp), %rdi
callq 0x2250
leaq 0xa20(%rsp), %rdi
callq 0x23a0
leaq 0x310(%rsp), %rdi
callq 0x23a0
leaq 0x820(%rsp), %rdi
callq 0x23a0
leaq 0x227ed(%rip), %rdx     # 0x25083
leaq 0xc8(%rsp), %rdi
movq %r14, %rsi
callq 0x23b6b
movq 0xd0(%rsp), %rdi
incq %rdi
callq 0x2030
movq %rax, %rbx
movq 0xc8(%rsp), %rsi
movq %rax, %rdi
callq 0x2210
leaq 0x108(%rsp), %rdi
pushq $0x8
popq %rdx
movq %rbx, %rsi
callq 0x21a0
leaq 0x227ab(%rip), %rdx     # 0x2508e
leaq 0xa8(%rsp), %rdi
movq %r14, %rsi
callq 0x23b6b
movq 0xb0(%rsp), %rdi
incq %rdi
callq 0x2030
movq %rax, %r15
movq 0xa8(%rsp), %rsi
movq %rax, %rdi
callq 0x2210
leaq 0xa20(%rsp), %rdi
pushq $0x10
popq %rdx
movq %r15, %rsi
callq 0x2050
leaq 0x22766(%rip), %rdx     # 0x25096
leaq 0x88(%rsp), %rdi
movq %r14, %rsi
callq 0x23b6b
movq 0x90(%rsp), %rdi
incq %rdi
callq 0x2030
movq %rax, %r15
movq 0x88(%rsp), %rsi
movq %rax, %rdi
callq 0x2210
leaq 0x310(%rsp), %rdi
pushq $0x10
popq %rdx
movq %r15, %rsi
callq 0x2050
leaq 0x22724(%rip), %rdx     # 0x250a1
leaq 0x68(%rsp), %rdi
movq %r14, %rsi
callq 0x23b6b
movq 0x70(%rsp), %rdi
incq %rdi
callq 0x2030
movq %rax, %r14
movq 0x68(%rsp), %rsi
movq %rax, %rdi
callq 0x2210
leaq 0x820(%rsp), %rdi
pushq $0x10
popq %rdx
movq %r14, %rsi
callq 0x2050
leaq 0x180(%rsp), %rdi
callq 0x2090
testb %al, %al
je 0x2a21
leaq 0xf8(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
xorl %eax, %eax
leaq 0x108(%rsp), %r14
leaq 0xe8(%rsp), %r15
xorl %ebp, %ebp
movl %eax, %r12d
movq 0x108(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x2, 0x128(%rsp,%rax)
jne 0x2a41
movq %r14, %rdi
movq %r15, %rsi
callq 0x2070
leal 0x1(%r12), %eax
movl %r12d, %ebp
jmp 0x29f3
movq 0x2a5a8(%rip), %rdi     # 0x2cfd0
leaq 0x22686(%rip), %rsi     # 0x250b5
callq 0x2230
movq %rax, %rdi
callq 0x2150
jmp 0x302d
leaq 0x108(%rsp), %r14
movq %r14, %rdi
callq 0x2080
movq 0x108(%rsp), %rax
addq -0x18(%rax), %r14
movq %r14, %rdi
xorl %esi, %esi
callq 0x2390
leaq 0x108(%rsp), %rdi
pushq $0x8
popq %rdx
movq %rbx, %rsi
callq 0x21a0
movl %ebp, %ebp
leaq (,%rbp,8), %rbx
movq %rbx, %rdi
callq 0x2030
movq %rax, %r13
xorl %r14d, %r14d
pushq $0x18
popq %r15
cmpq %rbp, %r14
je 0x2add
movl $0xc8, %edi
callq 0x2030
movq $0x6, (%rax)
movq %r15, %rcx
leaq (%rax,%rcx), %rdx
movq %rdx, -0x10(%rax,%rcx)
andq $0x0, -0x8(%rax,%rcx)
movb $0x0, (%rax,%rcx)
addq $0x20, %rcx
cmpq $0xd8, %rcx
jne 0x2aaf
addq $0x8, %rax
movq %rax, (%r13,%r14,8)
incq %r14
jmp 0x2a96
movq %rbx, %rdi
callq 0x2030
movq %rax, 0x8(%rsp)
xorl %r14d, %r14d
pushq $0x14
popq %rbx
cmpq %r14, %rbp
je 0x2b0b
movq %rbx, %rdi
callq 0x2030
movq 0x8(%rsp), %rcx
movq %rax, (%rcx,%r14,8)
incq %r14
jmp 0x2af0
xorl %r12d, %r12d
leaq 0x108(%rsp), %rbx
cmpq %r12, %rbp
je 0x2bc3
movq (%r13,%r12,8), %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x22a0
movq 0x8(%rsp), %rax
movq (%rax,%r12,8), %r15
movq %rbx, %rdi
movq %r15, %rsi
callq 0x2190
leaq 0x20(%r14), %rsi
movq %rbx, %rdi
callq 0x22a0
leaq 0x4(%r15), %rsi
movq %rbx, %rdi
callq 0x2190
leaq 0x8(%r15), %rsi
movq %rbx, %rdi
callq 0x2190
leaq 0x40(%r14), %rsi
movq %rbx, %rdi
callq 0x22a0
leaq 0x60(%r14), %rsi
movq %rbx, %rdi
callq 0x22a0
leaq 0xc(%r15), %rsi
movq %rbx, %rdi
callq 0x2190
addq $0x10, %r15
movq %rbx, %rdi
movq %r15, %rsi
callq 0x2190
leaq 0x80(%r14), %rsi
movq %rbx, %rdi
callq 0x22a0
addq $0xa0, %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2070
incq %r12
jmp 0x2b16
movq %r13, 0x28(%rsp)
xorl %ecx, %ecx
leaq 0x698(%rsp), %r13
leaq 0x4(%rsp), %r12
leaq 0x3(%rsp), %r14
leaq 0x510(%rsp), %rbx
movq %rbp, 0x58(%rsp)
cmpq %rbp, %rcx
je 0x2fb3
andl $0x0, 0x4(%rsp)
leaq 0x48(%rsp), %rax
movq %rax, 0x38(%rsp)
andq $0x0, 0x40(%rsp)
movb $0x0, 0x48(%rsp)
movq 0x28(%rsp), %rax
movq %rcx, 0x10(%rsp)
movq (%rax,%rcx,8), %rax
movq %rax, 0x18(%rsp)
leaq 0x40(%rax), %rsi
movq %r13, %rdi
movq %rsi, 0x20(%rsp)
leaq 0x224a2(%rip), %rdx     # 0x250d4
callq 0x23b6b
leaq 0x38(%rsp), %rdi
movq %r13, %rsi
callq 0x2290
movq %r13, %rdi
callq 0x2130
movq %r13, %rdi
callq 0x21b0
movq 0x698(%rsp), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
xorl %esi, %esi
callq 0x2390
leaq 0x6b0(%rsp), %rdi
leaq 0x38(%rsp), %rsi
callq 0x2330
movq 0x18(%rsp), %rax
movq 0x88(%rax), %rcx
movq %rcx, 0x30(%rsp)
leaq 0x1(%rcx), %rdi
callq 0x2030
movq %rax, %rbp
movq 0x18(%rsp), %rax
movq 0x80(%rax), %rsi
movq %rbp, %rdi
callq 0x2210
movq %r13, %rdi
movq %r12, %rsi
callq 0x2190
movq %r13, %rdi
movq %r14, %rsi
callq 0x22d0
xorl %eax, %eax
movzbl 0x3(%rsp), %ecx
cmpl $0x45, %ecx
jne 0x2cd6
cmpl $0x0, 0x4(%rsp)
je 0x2d25
movl %ecx, %edx
xorl $0x53, %edx
orl %eax, %edx
pushq $0x1
popq %r15
je 0x2d05
movl %ecx, %edx
xorl $0x48, %edx
xorl %r15d, %r15d
orl %eax, %edx
je 0x2d05
addl $-0x3d, %ecx
cmpl $0x1b, %ecx
ja 0x2d20
movl $0x8031081, %edx        # imm = 0x8031081
btl %ecx, %edx
pushq $0x1
popq %r15
jae 0x2d20
movq %r13, %rdi
movq %r12, %rsi
callq 0x2190
movq %r13, %rdi
movq %r14, %rsi
callq 0x22d0
movl %r15d, %eax
jmp 0x2cc5
movl %eax, %r15d
jmp 0x2d05
movq %rbx, %rdi
callq 0x21b0
movq 0x510(%rsp), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
xorl %esi, %esi
callq 0x2390
leaq 0x528(%rsp), %rdi
leaq 0x38(%rsp), %rsi
callq 0x2330
movq %rbx, %rdi
movq %r12, %rsi
callq 0x2190
movq %rbx, %rdi
movq %r14, %rsi
callq 0x22d0
xorl %r15d, %r15d
movzbl 0x3(%rsp), %ecx
movl %ecx, %edx
xorl $0x45, %edx
movl 0x4(%rsp), %eax
orl %eax, %edx
je 0x2e14
movl %eax, %eax
movslq %r15d, %r12
cmpl $0x3d, %ecx
je 0x2da2
cmpl $0x49, %ecx
je 0x2de3
cmpl $0x58, %ecx
je 0x2de3
cmpl $0x53, %ecx
je 0x2db6
cmpl $0x4d, %ecx
jne 0x2de9
addq %rbp, %r12
xorl %ecx, %ecx
cmpq %rcx, %rax
je 0x2de3
movb $0x4e, (%r12,%rcx)
incq %rcx
jmp 0x2da7
movq 0x60(%rsp), %rdi
leaq 0x22315(%rip), %rsi     # 0x250d7
callq 0x23ba3
testb %al, %al
je 0x2e06
movl 0x4(%rsp), %eax
addq %rbp, %r12
xorl %ecx, %ecx
cmpq %rcx, %rax
je 0x2de3
movb $0x4e, (%r12,%rcx)
incq %rcx
jmp 0x2dd4
addl %r15d, %eax
movl %eax, %r15d
leaq 0x4(%rsp), %rsi
movq %rbx, %rdi
callq 0x2190
movq %rbx, %rdi
movq %r14, %rsi
callq 0x22d0
jmp 0x2d6e
cmpb $0x53, 0x3(%rsp)
jne 0x2de9
addl 0x4(%rsp), %r15d
jmp 0x2de9
leaq 0xa20(%rsp), %rdi
movq 0x20(%rsp), %rsi
callq 0x2200
movq %rax, %rdi
leaq 0x222a4(%rip), %rsi     # 0x250d4
callq 0x2230
movq %rax, %rdi
pushq $0x9
popq %rsi
callq 0x2270
movq %rax, %rdi
movq 0x10(%rsp), %rsi
callq 0x23b0
movq %rax, %rdi
callq 0x2150
leaq 0x310(%rsp), %rdi
leaq 0x2399b(%rip), %rsi     # 0x267ff
callq 0x2230
movq %rax, %rdi
movq 0x18(%rsp), %rsi
callq 0x2200
movq %rax, %rdi
leaq 0x2225b(%rip), %rsi     # 0x250db
callq 0x2230
movq 0x8(%rsp), %rcx
movq 0x10(%rsp), %rdx
movq (%rcx,%rdx,8), %rcx
movq %rcx, 0x20(%rsp)
movl 0x4(%rcx), %esi
movq %rax, %rdi
callq 0x23b0
movq %rax, %rdi
leaq 0x2222e(%rip), %rsi     # 0x250db
callq 0x2230
movq %rax, %rdi
movq 0x10(%rsp), %rsi
callq 0x23b0
movq %rax, %rdi
callq 0x2150
movl 0x30(%rsp), %r12d
xorl %r15d, %r15d
cmpq %r15, %r12
je 0x2eec
movsbl (%rbp,%r15), %esi
leaq 0x310(%rsp), %rdi
callq 0x2270
incq %r15
jmp 0x2ecf
leaq 0x310(%rsp), %rdi
callq 0x2150
leaq 0x820(%rsp), %rdi
movq 0x18(%rsp), %rsi
callq 0x2200
movq %rax, %rdi
pushq $0x9
popq %rsi
callq 0x2270
movq 0x18(%rsp), %rsi
addq $0x20, %rsi
movq %rax, %rdi
callq 0x2200
movq %rax, %rdi
pushq $0x9
popq %rsi
callq 0x2270
movq 0x20(%rsp), %rcx
movl 0x4(%rcx), %esi
movq %rax, %rdi
callq 0x23b0
movq %rax, %rdi
pushq $0x9
popq %rsi
callq 0x2270
movq %rax, %rdi
movq 0x30(%rsp), %rsi
callq 0x23b0
movq %rax, %rdi
pushq $0x9
popq %rsi
callq 0x2270
movq %rax, %rdi
movq 0x10(%rsp), %rsi
callq 0x23b0
movq %rax, %rdi
callq 0x2150
movq %rbp, %rdi
callq 0x22b0
movq %rbx, %rdi
callq 0x21c0
movq %r13, %rdi
callq 0x21c0
leaq 0x38(%rsp), %rdi
callq 0x2130
movq 0x10(%rsp), %rcx
incq %rcx
movq 0x58(%rsp), %rbp
leaq 0x4(%rsp), %r12
jmp 0x2be9
xorl %r14d, %r14d
movq 0x28(%rsp), %r13
cmpq %rbp, %r14
je 0x300e
movq (%r13,%r14,8), %rbx
testq %rbx, %rbx
je 0x2ff6
movq -0x8(%rbx), %r15
testq %r15, %r15
je 0x2fea
leaq -0x20(%rbx), %r12
shlq $0x5, %r15
leaq (%r12,%r15), %rdi
callq 0x2130
addq $-0x20, %r15
jne 0x2fdb
addq $-0x8, %rbx
movq %rbx, %rdi
callq 0x22b0
movq 0x8(%rsp), %rax
movq (%rax,%r14,8), %rdi
testq %rdi, %rdi
je 0x3009
callq 0x22b0
incq %r14
jmp 0x2fbb
movq %r13, %rdi
callq 0x22b0
movq 0x8(%rsp), %rdi
callq 0x22b0
leaq 0xe8(%rsp), %rdi
callq 0x2130
leaq 0x68(%rsp), %rdi
callq 0x2130
leaq 0x88(%rsp), %rdi
callq 0x2130
leaq 0xa8(%rsp), %rdi
callq 0x2130
leaq 0xc8(%rsp), %rdi
callq 0x2130
leaq 0x820(%rsp), %rdi
callq 0x2320
leaq 0x310(%rsp), %rdi
callq 0x2320
leaq 0xa20(%rsp), %rdi
callq 0x2320
leaq 0xc20(%rsp), %rdi
callq 0x20a0
leaq 0x108(%rsp), %rdi
callq 0x20a0
xorl %eax, %eax
addq $0xe28, %rsp            # imm = 0xE28
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x3113
jmp 0x3113
jmp 0x30e7
jmp 0x30ec
jmp 0x30f1
movq %rax, %rbx
jmp 0x3186
movq %rax, %rbx
jmp 0x3193
movq %rax, %rbx
jmp 0x31a0
movq %rax, %rbx
jmp 0x31ad
movq %rax, %rbx
jmp 0x31ba
jmp 0x3113
movq %rax, %rbx
jmp 0x315f
movq %rax, %rbx
jmp 0x316c
movq %rax, %rbx
jmp 0x3179
movq %rax, %rbx
jmp 0x3155
jmp 0x312e
jmp 0x3102
movq %rax, %rbx
jmp 0x313e
jmp 0x3113
jmp 0x3113
jmp 0x3113
jmp 0x312e
jmp 0x312e
jmp 0x311c
movq %rax, %rbx
jmp 0x3148
jmp 0x311c
jmp 0x311c
movq %rax, %rbx
leaq 0x510(%rsp), %rdi
callq 0x21c0
jmp 0x3131
movq %rax, %rbx
leaq 0x698(%rsp), %rdi
callq 0x21c0
leaq 0x38(%rsp), %rdi
callq 0x2130
leaq 0xe8(%rsp), %rdi
callq 0x2130
leaq 0x68(%rsp), %rdi
callq 0x2130
leaq 0x88(%rsp), %rdi
callq 0x2130
leaq 0xa8(%rsp), %rdi
callq 0x2130
leaq 0xc8(%rsp), %rdi
callq 0x2130
leaq 0x820(%rsp), %rdi
callq 0x2320
leaq 0x310(%rsp), %rdi
callq 0x2320
leaq 0xa20(%rsp), %rdi
callq 0x2320
leaq 0xc20(%rsp), %rdi
callq 0x20a0
leaq 0x108(%rsp), %rdi
callq 0x20a0
movq %rbx, %rdi
callq 0x23c0