// File: /workspace/github_cpp_makefile_star2_O1/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, 0xe0(%rsp)
movq %rdi, %r14
leaq 0x108(%rsp), %rdi
callq 0x3270
leaq 0xc20(%rsp), %rdi
callq 0x3270
leaq 0x898(%rsp), %rdi
callq 0x33c0
leaq 0x498(%rsp), %rdi
callq 0x33c0
leaq 0x698(%rsp), %rdi
callq 0x33c0
leaq 0xc0(%rsp), %rax
movq %rax, -0x10(%rax)
movq (%r14), %rsi
movq 0x8(%r14), %rdx
addq %rsi, %rdx
leaq 0xb0(%rsp), %rdi
callq 0x40ce8
leaq 0x3e3ac(%rip), %rsi     # 0x42083
leaq 0xb0(%rsp), %rdi
callq 0x3410
movq 0xb8(%rsp), %rdi
incq %rdi
callq 0x3030
movq %rax, %rbx
movq 0xb0(%rsp), %rsi
movq %rax, %rdi
callq 0x3220
leaq 0x108(%rsp), %rdi
movq %rbx, %rsi
movl $0x8, %edx
callq 0x3180
leaq 0xa0(%rsp), %rax
movq %rax, -0x10(%rax)
movq (%r14), %rsi
movq 0x8(%r14), %rdx
addq %rsi, %rdx
leaq 0x90(%rsp), %rdi
callq 0x40ce8
leaq 0x3e348(%rip), %rsi     # 0x4208e
leaq 0x90(%rsp), %rdi
callq 0x3410
movq 0x98(%rsp), %rdi
incq %rdi
callq 0x3030
movq %rax, %r15
movq 0x90(%rsp), %rsi
movq %rax, %rdi
callq 0x3220
leaq 0x898(%rsp), %r13
movq %r13, %rdi
movq %r15, %rsi
movl $0x10, %edx
callq 0x3060
leaq 0x80(%rsp), %rax
movq %rax, -0x10(%rax)
movq (%r14), %rsi
movq 0x8(%r14), %rdx
addq %rsi, %rdx
leaq 0x70(%rsp), %rdi
callq 0x40ce8
leaq 0x3e2e1(%rip), %rsi     # 0x42096
leaq 0x70(%rsp), %rdi
callq 0x3410
movq 0x78(%rsp), %rdi
incq %rdi
callq 0x3030
movq %rax, %r15
movq 0x70(%rsp), %rsi
movq %rax, %rdi
callq 0x3220
leaq 0x498(%rsp), %rdi
movq %r15, %rsi
movl $0x10, %edx
callq 0x3060
leaq 0x60(%rsp), %rax
movq %rax, -0x10(%rax)
movq (%r14), %rsi
movq 0x8(%r14), %rdx
addq %rsi, %rdx
leaq 0x50(%rsp), %rdi
callq 0x40ce8
leaq 0x3e28c(%rip), %rsi     # 0x420a1
leaq 0x50(%rsp), %rdi
callq 0x3410
movq 0x58(%rsp), %rdi
incq %rdi
callq 0x3030
movq %rax, %r14
movq 0x50(%rsp), %rsi
movq %rax, %rdi
callq 0x3220
leaq 0x698(%rsp), %rdi
movq %r14, %rsi
movl $0x10, %edx
callq 0x3060
leaq 0x180(%rsp), %rdi
callq 0x3090
testb %al, %al
je 0x471c
leaq 0xf8(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq 0x108(%rsp), %rax
movq -0x18(%rax), %rax
xorl %ebp, %ebp
testb $0x2, 0x128(%rsp,%rax)
jne 0x3eec
leaq (%rsp,%rax), %rdi
addq $0x108, %rdi            # imm = 0x108
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
leaq 0x108(%rsp), %r14
leaq 0xe8(%rsp), %r15
movl $0xa, %esi
callq 0x3240
movsbl %al, %edx
movq %r14, %rdi
movq %r15, %rsi
callq 0x3400
movq 0x108(%rsp), %rax
movq -0x18(%rax), %rax
leaq (%rsp,%rax), %rdi
addq $0x108, %rdi            # imm = 0x108
incl %ebp
testb $0x2, 0x20(%rdi)
je 0x3eb5
leaq 0x108(%rsp), %r14
movq %r14, %rdi
callq 0x3080
movq 0x108(%rsp), %rax
addq -0x18(%rax), %r14
movq %r14, %rdi
xorl %esi, %esi
callq 0x33b0
leaq 0x108(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
movl $0x8, %edx
callq 0x3180
movl %ebp, %r12d
leaq (,%r12,8), %rbx
movq %rbx, %rdi
callq 0x3030
movq %rax, 0x8(%rsp)
testl %ebp, %ebp
je 0x3f97
xorl %r15d, %r15d
movl $0xc8, %edi
callq 0x3030
movq $0x6, (%rax)
movl $0x18, %ecx
leaq (%rax,%rcx), %rdx
movq %rdx, -0x10(%rax,%rcx)
movq $0x0, -0x8(%rax,%rcx)
movb $0x0, (%rax,%rcx)
addq $0x20, %rcx
cmpq $0xd8, %rcx
jne 0x3f5f
addq $0x8, %rax
movq 0x8(%rsp), %rcx
movq %rax, (%rcx,%r15,8)
incq %r15
cmpq %r12, %r15
jne 0x3f49
movq %rbx, %rdi
callq 0x3030
movq %rax, 0x18(%rsp)
testl %ebp, %ebp
je 0x46ec
xorl %ebx, %ebx
movq 0x18(%rsp), %r13
movl $0x14, %edi
callq 0x3030
movq %rax, (%r13,%rbx,8)
incq %rbx
cmpq %rbx, %r12
jne 0x3fb3
xorl %r15d, %r15d
movq 0x8(%rsp), %rax
movq (%rax,%r15,8), %rsi
movq %r14, %rdi
callq 0x32c0
movq (%r13,%r15,8), %rsi
movq %r14, %rdi
callq 0x3170
movq 0x8(%rsp), %rax
movq (%rax,%r15,8), %rsi
addq $0x20, %rsi
movq %r14, %rdi
callq 0x32c0
movq (%r13,%r15,8), %rsi
addq $0x4, %rsi
movq %r14, %rdi
callq 0x3170
movq (%r13,%r15,8), %rsi
addq $0x8, %rsi
movq %r14, %rdi
callq 0x3170
movq 0x8(%rsp), %rax
movq (%rax,%r15,8), %rsi
addq $0x40, %rsi
movq %r14, %rdi
callq 0x32c0
movq 0x8(%rsp), %rax
movq (%rax,%r15,8), %rsi
addq $0x60, %rsi
movq %r14, %rdi
callq 0x32c0
movq (%r13,%r15,8), %rsi
addq $0xc, %rsi
movq %r14, %rdi
callq 0x3170
movq (%r13,%r15,8), %rsi
addq $0x10, %rsi
movq %r14, %rdi
callq 0x3170
movq 0x8(%rsp), %rax
movq (%rax,%r15,8), %rsi
subq $-0x80, %rsi
movq %r14, %rdi
callq 0x32c0
movq 0x8(%rsp), %rax
movq (%rax,%r15,8), %rbx
movq 0x108(%rsp), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x3240
addq $0xa0, %rbx
movsbl %al, %edx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x3400
incq %r15
cmpq %r15, %r12
jne 0x3fcd
movq %r12, 0x20(%rsp)
leaq 0x320(%rsp), %r14
movl $0x80, %eax
leaq 0xa98(%rsp), %r12
leaq (%r12,%rax), %rcx
movq %rcx, 0xd0(%rsp)
leaq 0x310(%rsp), %rbx
addq %rbx, %rax
movq %rax, 0xd8(%rsp)
xorl %eax, %eax
leaq 0x3(%rsp), %r13
movl $0x0, 0x4(%rsp)
movq %rax, %rcx
leaq 0x40(%rsp), %rax
movq %rax, 0x30(%rsp)
movq $0x0, 0x38(%rsp)
movb $0x0, 0x40(%rsp)
movq 0x8(%rsp), %rax
movq %rcx, 0x10(%rsp)
movq (%rax,%rcx,8), %rax
movq %r14, 0x310(%rsp)
movq 0x40(%rax), %rsi
movq 0x48(%rax), %rdx
addq %rsi, %rdx
movq %rbx, %rdi
callq 0x40ce8
movq %rbx, %rdi
leaq 0x3df78(%rip), %rsi     # 0x420d4
callq 0x3410
leaq 0x30(%rsp), %rdi
movq %rbx, %rsi
callq 0x32b0
movq 0x310(%rsp), %rdi
cmpq %r14, %rdi
je 0x4180
callq 0x3230
movq %rbx, %rdi
callq 0x31a0
movq 0x310(%rsp), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
xorl %esi, %esi
callq 0x33b0
leaq 0x328(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x3340
movq 0x8(%rsp), %rax
movq 0x10(%rsp), %rcx
movq (%rax,%rcx,8), %r15
movq 0x88(%r15), %rcx
movq %rcx, 0x28(%rsp)
leaq 0x1(%rcx), %rdi
callq 0x3030
movq %rax, %r14
movq 0x80(%r15), %rsi
movq %rax, %rdi
callq 0x3220
movq %rbx, %rdi
leaq 0x4(%rsp), %rsi
callq 0x3170
movq %rbx, %rdi
movq %r13, %rsi
callq 0x32e0
xorl %eax, %eax
movzbl 0x3(%rsp), %ecx
cmpl $0x45, %ecx
jne 0x4210
cmpl $0x0, 0x4(%rsp)
je 0x4260
movl %ecx, %edx
xorl $0x53, %edx
movl $0x1, %ebp
orl %eax, %edx
je 0x4240
movl %ecx, %edx
xorl $0x48, %edx
xorl %ebp, %ebp
orl %eax, %edx
je 0x4240
addl $-0x3d, %ecx
cmpl $0x1b, %ecx
ja 0x425c
movl $0x8031081, %edx        # imm = 0x8031081
btl %ecx, %edx
movl $0x1, %ebp
jae 0x425c
movq %rbx, %rdi
leaq 0x4(%rsp), %rsi
callq 0x3170
movq %rbx, %rdi
movq %r13, %rsi
callq 0x32e0
movl %ebp, %eax
jmp 0x41ff
movl %eax, %ebp
jmp 0x4240
movq %r12, %rdi
callq 0x31a0
movq 0xa98(%rsp), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
xorl %esi, %esi
callq 0x33b0
leaq 0xab0(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x3340
movq %r12, %rdi
leaq 0x4(%rsp), %rsi
callq 0x3170
movq %r12, %rdi
movq %r13, %rsi
callq 0x32e0
xorl %ebp, %ebp
movzbl 0x3(%rsp), %eax
movl %eax, %edx
xorl $0x45, %edx
movl 0x4(%rsp), %ecx
orl %ecx, %edx
je 0x435b
movl %ecx, %r15d
cmpl $0x4c, %eax
jle 0x42d9
cmpl $0x52, %eax
jg 0x42ea
cmpl $0x4d, %eax
je 0x4320
cmpl $0x4e, %eax
je 0x433e
jmp 0x430e
cmpl $0x3d, %eax
je 0x4320
cmpl $0x44, %eax
je 0x433e
cmpl $0x49, %eax
je 0x4338
jmp 0x430e
cmpl $0x53, %eax
je 0x42f6
cmpl $0x58, %eax
je 0x4338
jmp 0x430e
movq 0xe0(%rsp), %rdi
leaq 0x3ddd2(%rip), %rsi     # 0x420d7
callq 0x30b0
testl %eax, %eax
je 0x431b
cmpb $0x53, 0x3(%rsp)
jne 0x433e
addl 0x4(%rsp), %ebp
jmp 0x433e
movl 0x4(%rsp), %r15d
testq %r15, %r15
je 0x4338
movslq %ebp, %rdi
addq %r14, %rdi
movl $0x4e, %esi
movq %r15, %rdx
callq 0x3150
addl %ebp, %r15d
movl %r15d, %ebp
movq %r12, %rdi
leaq 0x4(%rsp), %rsi
callq 0x3170
movq %r12, %rdi
movq %r13, %rsi
callq 0x32e0
jmp 0x42aa
movq 0x8(%rsp), %rax
movq 0x10(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x40(%rax), %rsi
movq 0x48(%rax), %rdx
leaq 0x898(%rsp), %rdi
callq 0x3280
movq %rax, %r15
movl $0x2, %edx
movq %rax, %rdi
leaq 0x3dd44(%rip), %rsi     # 0x420d4
callq 0x3280
movb $0x9, 0x2(%rsp)
movl $0x1, %edx
movq %r15, %rdi
leaq 0x2(%rsp), %rsi
callq 0x3280
movq %rax, %rdi
movq 0x10(%rsp), %rsi
callq 0x33d0
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x3240
movsbl %al, %esi
movq %r15, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x3190
movl $0x1, %edx
leaq 0x498(%rsp), %rdi
leaq 0x3f408(%rip), %rsi     # 0x437ff
callq 0x3280
movq 0x8(%rsp), %rax
movq 0x10(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
leaq 0x498(%rsp), %rdi
callq 0x3280
movq %rax, %r15
movl $0x1, %edx
movq %rax, %rdi
leaq 0x3dcab(%rip), %rsi     # 0x420db
callq 0x3280
movq 0x18(%rsp), %rax
movq 0x10(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movl 0x4(%rax), %esi
movq %r15, %rdi
callq 0x33d0
movq %rax, %r15
movl $0x1, %edx
movq %rax, %rdi
leaq 0x3dc7b(%rip), %rsi     # 0x420db
callq 0x3280
movq %r15, %rdi
movq 0x10(%rsp), %rsi
callq 0x33d0
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x3240
movsbl %al, %esi
movq %r15, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x3190
cmpl $0x0, 0x28(%rsp)
je 0x44d1
movl 0x28(%rsp), %r15d
xorl %ebp, %ebp
movb (%r14,%rbp), %al
movb %al, 0x2(%rsp)
movl $0x1, %edx
leaq 0x498(%rsp), %rdi
leaq 0x2(%rsp), %rsi
callq 0x3280
incq %rbp
cmpq %rbp, %r15
jne 0x44aa
movq 0x498(%rsp), %rax
movq -0x18(%rax), %rdi
leaq 0x498(%rsp), %rax
addq %rax, %rdi
movl $0xa, %esi
callq 0x3240
movsbl %al, %esi
leaq 0x498(%rsp), %rdi
callq 0x3040
movq %rax, %rdi
callq 0x3190
movq 0x8(%rsp), %rax
movq 0x10(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
leaq 0x698(%rsp), %rdi
callq 0x3280
movb $0x9, 0x2(%rsp)
movl $0x1, %edx
movq %rax, %rdi
leaq 0x2(%rsp), %rsi
callq 0x3280
movq 0x8(%rsp), %rcx
movq 0x10(%rsp), %rdx
movq (%rcx,%rdx,8), %rcx
movq 0x20(%rcx), %rsi
movq 0x28(%rcx), %rdx
movq %rax, %rdi
callq 0x3280
movb $0x9, 0x2(%rsp)
movl $0x1, %edx
movq %rax, %rdi
leaq 0x2(%rsp), %rsi
callq 0x3280
movq 0x18(%rsp), %rcx
movq 0x10(%rsp), %rdx
movq (%rcx,%rdx,8), %rcx
movl 0x4(%rcx), %esi
movq %rax, %rdi
callq 0x33d0
movb $0x9, 0x2(%rsp)
movl $0x1, %edx
movq %rax, %rdi
leaq 0x2(%rsp), %rsi
callq 0x3280
movq %rax, %rdi
movq 0x28(%rsp), %rsi
callq 0x33d0
movb $0x9, 0x2(%rsp)
movl $0x1, %edx
movq %rax, %rdi
leaq 0x2(%rsp), %rsi
callq 0x3280
movq %rax, %rdi
movq 0x10(%rsp), %rsi
callq 0x33d0
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x3240
movsbl %al, %esi
movq %r15, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x3190
movq %r14, %rdi
callq 0x32d0
movq %r12, %rdi
movq 0x449a3(%rip), %r14     # 0x48fb8
movq %r14, %rsi
callq 0x31c0
movq 0xd0(%rsp), %rdi
callq 0x30e0
movq %rbx, %rdi
movq %r14, %rsi
callq 0x31c0
movq 0xd8(%rsp), %rdi
callq 0x30e0
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x4656
callq 0x3230
movq 0x10(%rsp), %rax
incq %rax
cmpq 0x20(%rsp), %rax
leaq 0x320(%rsp), %r14
jne 0x4106
xorl %r14d, %r14d
leaq 0x898(%rsp), %r13
movq 0x20(%rsp), %r15
movq 0x8(%rsp), %rax
movq (%rax,%r14,8), %rbx
testq %rbx, %rbx
je 0x46d1
movq -0x8(%rbx), %r15
testq %r15, %r15
je 0x46c0
shlq $0x5, %r15
leaq (%rbx,%r15), %r12
addq $-0x10, %r12
negq %r15
movq -0x10(%r12), %rdi
cmpq %rdi, %r12
je 0x46b6
callq 0x3230
addq $-0x20, %r12
addq $0x20, %r15
jne 0x46a7
addq $-0x8, %rbx
movq %rbx, %rdi
callq 0x32d0
movq 0x20(%rsp), %r15
movq 0x18(%rsp), %rax
movq (%rax,%r14,8), %rdi
testq %rdi, %rdi
je 0x46e4
callq 0x32d0
incq %r14
cmpq %r15, %r14
jne 0x4681
movq 0x8(%rsp), %rdi
callq 0x32d0
movq 0x18(%rsp), %rdi
callq 0x32d0
movq 0xe8(%rsp), %rdi
leaq 0xf8(%rsp), %rax
cmpq %rax, %rdi
je 0x4762
callq 0x3230
jmp 0x4762
movq 0x448b5(%rip), %rbx     # 0x48fd8
leaq 0x3d98b(%rip), %rsi     # 0x420b5
movl $0x1e, %edx
movq %rbx, %rdi
callq 0x3280
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x3240
movsbl %al, %esi
movq 0x44883(%rip), %rdi     # 0x48fd8
callq 0x3040
movq %rax, %rdi
callq 0x3190
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x4776
callq 0x3230
movq 0x70(%rsp), %rdi
leaq 0x80(%rsp), %rax
cmpq %rax, %rdi
je 0x478d
callq 0x3230
movq 0x90(%rsp), %rdi
leaq 0xa0(%rsp), %rax
cmpq %rax, %rdi
je 0x47a7
callq 0x3230
movq 0xb0(%rsp), %rdi
leaq 0xc0(%rsp), %rax
cmpq %rax, %rdi
je 0x47c1
callq 0x3230
movq 0x44808(%rip), %rax     # 0x48fd0
movq (%rax), %rbx
movq 0x18(%rax), %r14
leaq 0x6a0(%rsp), %rdi
movq %rbx, -0x8(%rdi)
movq -0x18(%rbx), %rax
movq %r14, 0x698(%rsp,%rax)
callq 0x31f0
movl $0xf8, %r15d
leaq 0x698(%rsp), %rdi
addq %r15, %rdi
callq 0x30e0
leaq 0x4a0(%rsp), %rdi
movq %rbx, -0x8(%rdi)
movq -0x18(%rbx), %rax
movq %r14, 0x498(%rsp,%rax)
callq 0x31f0
leaq 0x498(%rsp), %rdi
addq %r15, %rdi
callq 0x30e0
leaq 0x8a0(%rsp), %rdi
movq %rbx, -0x8(%rdi)
movq -0x18(%rbx), %rax
movq %r14, 0x898(%rsp,%rax)
callq 0x31f0
addq %r15, %r13
movq %r13, %rdi
callq 0x30e0
leaq 0xc20(%rsp), %rdi
callq 0x30a0
leaq 0x108(%rsp), %rdi
callq 0x30a0
xorl %eax, %eax
addq $0xe28, %rsp            # imm = 0xE28
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x4913
jmp 0x4913
jmp 0x48df
jmp 0x48c7
jmp 0x48c7
jmp 0x48cf
jmp 0x48cf
jmp 0x48d7
jmp 0x48d7
movq %rax, %rbx
jmp 0x49f3
movq %rax, %rbx
jmp 0x4a00
movq %rax, %rbx
jmp 0x4a0d
movq %rax, %rbx
jmp 0x4a1a
movq %rax, %rbx
jmp 0x4a27
jmp 0x4913
movq %rax, %rbx
jmp 0x49a8
movq %rax, %rbx
jmp 0x49bf
movq %rax, %rbx
jmp 0x49d9
movq %rax, %rbx
jmp 0x4994
jmp 0x4942
jmp 0x4902
movq %rax, %rbx
movq 0x310(%rsp), %rdi
cmpq %r14, %rdi
je 0x4966
callq 0x3230
jmp 0x4966
movq %rax, %rbx
jmp 0x4966
jmp 0x4913
jmp 0x4913
jmp 0x4913
jmp 0x4942
jmp 0x4942
jmp 0x491c
movq %rax, %rbx
jmp 0x497a
jmp 0x491c
jmp 0x491c
movq %rax, %rbx
movq 0x44692(%rip), %rsi     # 0x48fb8
leaq 0xa98(%rsp), %rdi
callq 0x31c0
leaq 0xb18(%rsp), %rdi
callq 0x30e0
jmp 0x4945
movq %rax, %rbx
movq 0x4466c(%rip), %rsi     # 0x48fb8
leaq 0x310(%rsp), %rdi
callq 0x31c0
leaq 0x390(%rsp), %rdi
callq 0x30e0
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x497a
callq 0x3230
movq 0xe8(%rsp), %rdi
leaq 0xf8(%rsp), %rax
cmpq %rax, %rdi
je 0x4994
callq 0x3230
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x49a8
callq 0x3230
movq 0x70(%rsp), %rdi
leaq 0x80(%rsp), %rax
cmpq %rax, %rdi
je 0x49bf
callq 0x3230
movq 0x90(%rsp), %rdi
leaq 0xa0(%rsp), %rax
cmpq %rax, %rdi
je 0x49d9
callq 0x3230
movq 0xb0(%rsp), %rdi
leaq 0xc0(%rsp), %rax
cmpq %rax, %rdi
je 0x49f3
callq 0x3230
leaq 0x698(%rsp), %rdi
callq 0x3330
leaq 0x498(%rsp), %rdi
callq 0x3330
leaq 0x898(%rsp), %rdi
callq 0x3330
leaq 0xc20(%rsp), %rdi
callq 0x30a0
leaq 0x108(%rsp), %rdi
callq 0x30a0
movq %rbx, %rdi
callq 0x33e0