// File: giovannarosone[P]BCR_LCP_GSA/BCR_BWTCollection.cpp
// Function: main
int main(int argc, char *argv[])
{

    string inputPrevBCR="";
    #if BUILD_BCR_FROM_BCRpartials==0
        if( argc != 3 )  {
            std::cerr << "usage: " << argv[0] << " input output" << std::endl;
            exit(1);
        }
    #elif BUILD_BCR_FROM_BCRpartials==1
        if( argc != 4 )  {
            std::cerr << "usage: " << argv[0] << " input output inputPrevBCR" << std::endl;
            std::cerr << "where: " << std::endl;
            std::cerr << "\tinputPrevBCR --> prefix filename BCR partial files" << std::endl;
            exit(1);
        }
        inputPrevBCR = argv[3];
        std::cerr << "WARNING!: BUILD_BCR_FROM_BCRpartials==1 - The types must be equal to previous BCR partial files (see BUILD_BCR_FROM_BCRpartials in Parameters.h)" << endl;
    #endif
    
	
	std::cout << "BWTCollection: The input is " << argv[1] << std::endl;
	ifstream f(argv[1]);
    	if (f.good() == 0) {
		std::cerr  << argv[1] << " does not exist." << std::endl;
        	exit(1);
	} 
	std::cout << "BWTCollection: The output is " << argv[2] << std::endl;
	#if BUILD_BCR_FROM_BCRpartials==1
		std::cout << "BWTCollection: inputPrevBCR is set to " << inputPrevBCR << std::endl;
		ifstream f2(argv[2]);
		if (f2.good() == 0) {
			std::cerr  << argv[2] << " does not exist." << std::endl;
			exit(1);
		} 
	#endif

	#if ( FASTQ==1) 
        if (USE_QS==0) {
            std::cerr << "Error: if FASTQ==1 then USE_QS==1 (see USE_QS in Tools.h)" << endl;
            exit (EXIT_FAILURE);
        }
    #endif

    #if ( (USE_QS==1) &&  (FASTQ==0) )
        std::cout << "The title of the quality score file must start with '{'. Please use the script.\n";
    #endif

    #if BCR_SET == 0        //Build BCR for 1 sequence
        std::cout << "BCR of 1 sequence" << endl;

        if ( (BUILD_DA_bit == 1) || (BUILD_DA == 1)  )  {
            std::cout << "Error! Since BCR_SET == 0, then BUILD_DA or BUILD_DA_bit must be set to 0 (see Parameters.h).\n";
            exit (EXIT_FAILURE);
        }
        
        #if BCR_FROMCYC==1
            std::cerr << "Error: BCR_FROMCYC==1 (cyc files in input) is not implemented! (see BCR_FROMCYC in Parameters.h)" << endl;
            exit (EXIT_FAILURE);
        #endif
        
        #if USE_QS==1
            std::cerr << "Error: USE_QS==1 (quality score is not implemented! (see USE_QS in Tools.h)" << endl;
            exit (EXIT_FAILURE);
        #endif
            

        #if BUILD_BCR_FROM_BCRpartials==1
            std::cerr << "Error: BUILD_BCR_FROM_BCRpartials==1 is not implemented! (see BUILD_BCR_FROM_BCRpartials in Parameters.h)" << endl;
            exit (EXIT_FAILURE);
        #endif

        #if BCR_FROMCYC==1
            std::cerr << "Error: BCR_FROMCYC==1 is not implemented! (see BCR_FROMCYC in Parameters.h)" << endl;
            exit (EXIT_FAILURE);
        #endif

        #if BCR_INPUT_IN_MEMORY==1      // BCR reads from string
            std::cout << "loads the input file in a string and compute the BWT of the string." << std::endl;
        #else                           // BCR reads from file
            std::cout << "reads from file and computes the BWT of the reverse string." << std::endl;
        #endif
    #else
        std::cout << "BCR of multi-sequences" << endl;
        #if BCR_INPUT_IN_MEMORY==1      // BCR reads from string
            std::cerr << "Error BCR_SET == 0, so that BCR_INPUT_IN_MEMORY must be 0." << std::endl;
            exit (EXIT_FAILURE);
        #endif
        #if BCR_FROMCYC==1 && KSEQ_PARSER==1
            std::cerr << "Error: BCR_FROMCYC==1 (cyc files in input) is not implemented! (Please, set KSEQ_PARSER == 0)" << endl;
            exit (EXIT_FAILURE);
        #endif 
    #endif
    
    
    #if OUTPUT_linear_SuffixArray ==  1
        std::cout << "dataTypeNChar: sizeof(type of #characters): " << sizeof(dataTypeNChar) << "\n";
    #endif


        if ( (BCR_SET!=1) && (BCR_SET_ALN_RH) && (BUILD_BCR_FROM_BCRpartials!=0) && (BUILD_BCR_ALTERNATE!=0) && (BUILD_LCP!=1) )
        {
            std::cerr << "Error! The input is a set. BCR_SET must be set to 1, BUILD_BCR_FROM_BCRpartials must be set to 0, BUILD_BCR_ALTERNATE must be set to 1  (see Parameters.h).\n";
            exit (EXIT_FAILURE);
        }
        
        if(BCR_SET_ALN_RH==1 && STORE_ENDMARKER_POS==1)
        {
            std::cerr << "Error! EOFpos file is computed only if BCR_SET_ALN_RH is set to 0 (see Parameters.h).\n";
            exit (EXIT_FAILURE);
        }
	
	if(BCR_SET_ALN_RH!=1 && (BUILD_SAP || BUILD_RED_SAP))
        {
            std::cerr << "Error! SAP array is computed only if BCR_SET_ALN_RH is set to 1 (see Parameters.h).\n";
            exit (EXIT_FAILURE);
        }
		
		if(BUILD_SAP && BUILD_RED_SAP)
        {
            std::cerr << "Warning! To compute the reduced SAP array BUILD_SAP must be set to 0 (see Parameters.h).\n";
        }
         
        if (OUTPUT_FORMAT==0) {
            std::cout << "The output format of BCR is at most 5 files (ebwt, lcp, da, posSA, ebwt.qs) - built one after the other.\n";
        }
        
        if (OUTPUT_FORMAT==1) {
            if ((BUILD_LCP==1) && (BUILD_DA==1) && (BUILD_SA==1) )
                std::cout << "The output format of BCR is as the output of eGSA.\n";
            else {
                std::cerr << "Error! The output format of BCR is as the output of EGSA. BUILD_LCP and BUILD_SA and BUILD_DA must be set to 1 (see Parameters.h).\n";
                exit (EXIT_FAILURE);
            }
        }

        if (OUTPUT_FORMAT==2) {
            if ((BUILD_LCP==1) )
                std::cout << "The output format of BCR is a unique file .egsa. Order: bwt, lcp, da, sa.\n";
            else {
                std::cerr << "Error! The output format of BCR is a unique file .egsa (we do not use a struct). BUILD_LCP must be set to 1  (see Parameters.h), BUILD_DA and BUILD_SA could be set to a either 0 or 1.  Order: bwt, lcp, da, sa.\n";
                exit (EXIT_FAILURE);
            }
        }

        if (OUTPUT_FORMAT==3) {
            if ( ((BUILD_LCP == 1) || (BUILD_DA==1) || (BUILD_SA==1) || (BUILD_SAP==1) || (BUILD_RED_SAP==1) || KEEP_eBWT_IN_EXT_MEMORY==1) )
                std::cout << "The output format of BCR is at most 5 files (ebwt, lcp, da, posSA, SAP-array) at the same time.\n";
            else {
                std::cerr << "Error! The output format of BCR is at most 4 files (ebwt, lcp, da, posSA) at the same time\n";
                std::cerr << " BUILD_LCP or BUILD_DA==1 or BUILD_SA==1 or KEEP_eBWT_IN_EXT_MEMORY must be 1 (see Parameters.h).\n";
                exit (EXIT_FAILURE);
            }
        }
        
        if (OUTPUT_FORMAT==4) {
            if (BUILD_DA==1) 
                std::cout << "The output format of BCR is at most 3 files (ebwt, da), lcp, sa.\n";
            else {
                std::cerr << "Error! The output format of BCR is at most 3 files (ebwt, da), lcp, sa. BUILD_DA must be set to 1 (see Parameters.h).\n";
                exit (EXIT_FAILURE);
            }
        }
        
        if (OUTPUT_FORMAT==5) {
            if ( (BUILD_DA==1) && (BUILD_LCP==1) )
                std::cout << "The output format of BCR is at most 3 files ebwt, (lcp, da), sa.\n";
            else {
                std::cerr << "Error! The output format of BCR is at most 3 files ebwt, (lcp, da), sa. BUILD_DA and BUILD_LCP must be set to 1 (see Parameters.h).\n";
                exit (EXIT_FAILURE);
            }
        }
        
        if (OUTPUT_FORMAT==6) {
            if ( (BUILD_DA==1) && (BUILD_SA==1) )
                std::cout << "The output format of BCR is at most 3 files ebwt), lcp, (sa, da).\n";
            else {
                std::cerr << "Error! The output format of BCR is at most 3 files ebwt, lcp, (sa, da). BUILD_DA and BUILD_SA must be set to 1 (see Parameters.h).\n";
                exit (EXIT_FAILURE);
            }
        }

    std::cout << "********************" << endl;
    std::cout << "Setting:\n";
    std::cout << "\tSpecial symbols: " << std::endl;
    std::cout << "\t\tTERMINATE_CHAR: " << TERMINATE_CHAR << " Ascii: " << (int)TERMINATE_CHAR << std::endl;
    std::cout << "\t\tTERMINATE_CHAR_LEN: " << TERMINATE_CHAR_LEN << " Ascii: " << (int)TERMINATE_CHAR_LEN <<  std::endl;

    std::cout << "\tTypes:\n";
    std::cout << "\t\tdataTypedimAlpha: sizeof(type size of alpha): " << sizeof(dataTypedimAlpha) << " bytes \n";
    std::cout << "\t\tdataTypelenSeq: sizeof(type of seq length): " << sizeof(dataTypelenSeq) << " bytes \n";
    std::cout << "\t\tdataTypeNSeq: sizeof(type of #sequences): " << sizeof(dataTypeNSeq) << " bytes\n";
    std::cout << "\t\tdataTypeNChar: sizeof(type of #sequences): " << sizeof(dataTypeNChar) << " bytes\n";
    #if OUTPUT_FORMAT == 1
        std::cerr << "EGSA: sizeof(type of t_GSA): " << sizeof(t_GSA) << "\n";
        std::cerr << "file EGSA: " << lengthTot_plus_eof * sizeof(t_GSA) << "\n";
    #endif


    std::cout << "\tAlphabet order:\n";
    #if BUILD_BCR_ALTERNATE == 0
        std::cout << "\t\tLexicographic order" << endl;
    #else
        std::cout << "\t\tAlternate lexicographic order" << endl;
    #endif

    std::cout << "\tStrings order:\n";
    #if RLO == 0
        std::cout << "\t\tInput order" << endl;
    #else
        std::cout << "\t\tReverse lexicographic order" << endl;
    #endif
	
    std::cout << "\tEBWT computation (.ebwt file)" << endl;

    #if (BUILD_LCP==1)
        std::cout << "\t\ttogether LCP array (.lcp file)" << endl;
    #endif

    #if (BUILD_SA==1)
        std::cout << "\t\ttogether SA array, i.e. positions in the sequence, so they go from 0 to sequence length (.posSA file)" << endl;
    #endif

    #if (BUILD_DA==1)
        std::cout << "\t\ttogether DA array, i.e. ID/Colour of the sequence (.DA file)" << endl;
    #endif

    #if (BUILD_DA_bit==1) 
        std::cout << "\t\ttogether DA (bit vector) of the sets, i.e. ID/Colour of two sets (.bitDA file)" << endl;
    #endif

    #if USE_QS == 1
        std::cout << "\t\ttogether QS permutation" << endl;
    #endif

    #if BUILD_SAP == 1
        std::cout << "\t\ttogether SAP array" << endl;	
    #elif BUILD_RED_SAP == 1
		std::cout << "\t\ttogether reduced SAP array" << endl;
	#endif
	
    std::cout << "\tBWT partial:\n";
    #if  KEEP_eBWT_IN_EXT_MEMORY == 1    //BCR uses the internal memory for the BWT partial
        std::cout << "\t\tin external memory" << endl;
    #else
        std::cout << "\t\tin internal memory" << endl;
    #endif

    std::cout << "\tInput file:\n";
    #if  BCR_INPUT_IN_MEMORY == 0    //BCR reads cyc files
        std::cout << "\t\tin external memory, uses .cyc files by using ";
        if(BCR_SET_ALN_RH==0 )
            std::cout << "LEFT alignment" ;
        else
            std::cout << "RIGHT alignment" ;
        if(BCR_FROMCYC==0 )
            std::cout << " and builds the cyc files" << endl;
        else
            std::cout << " and using pre-computed cyc files" << endl;
    #else
        std::cout << "\t\tin internal memory (no cyc files)" << endl;
    #endif

    std::cout << "End Setting" << endl;
    std::cout << "********************" << endl;

	BWTCollection *BCRexternalBWT = BWTCollection::InitBWTCollection(argv[1], argv[2], inputPrevBCR );
	
	//cout << "finished iteration, usage: " << timer << endl;
	delete BCRexternalBWT;

	std::cerr << "\nThe BWT et al. is ready! " << std::endl;


	std::cerr << "The End!\n";
}

// Assembly:
subq $0x3c8, %rsp            # imm = 0x3C8
movl $0x0, 0x3c4(%rsp)
movl %edi, 0x3c0(%rsp)
movq %rsi, 0x3b8(%rsp)
leaq 0x397(%rsp), %rdi
movq %rdi, 0x148(%rsp)
callq 0x34b0
movq 0x148(%rsp), %rdx
leaq 0x157d5(%rip), %rsi     # 0x18fca
leaq 0x398(%rsp), %rdi
callq 0x3370
jmp 0x3804
leaq 0x397(%rsp), %rdi
callq 0x32b0
cmpl $0x3, 0x3c0(%rsp)
je 0x38db
movq 0x1c7ca(%rip), %rdi     # 0x1fff0
leaq 0x147d7(%rip), %rsi     # 0x18004
callq 0x3260
movq %rax, 0x140(%rsp)
jmp 0x383c
movq 0x140(%rsp), %rdi
movq 0x3b8(%rsp), %rax
movq (%rax), %rsi
callq 0x3260
movq %rax, 0x138(%rsp)
jmp 0x385e
movq 0x138(%rsp), %rdi
leaq 0x1479f(%rip), %rsi     # 0x1800c
callq 0x3260
movq %rax, 0x130(%rsp)
jmp 0x387c
movq 0x130(%rsp), %rdi
movq 0x1c735(%rip), %rsi     # 0x1ffc0
callq 0x32a0
jmp 0x3892
movl $0x1, %edi
callq 0x3300
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x388(%rsp)
movl %eax, 0x384(%rsp)
leaq 0x397(%rsp), %rdi
callq 0x32b0
jmp 0x4045
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x388(%rsp)
movl %eax, 0x384(%rsp)
jmp 0x4038
movq 0x1c6ee(%rip), %rdi     # 0x1ffd0
leaq 0x14731(%rip), %rsi     # 0x1801a
callq 0x3260
movq %rax, 0x128(%rsp)
jmp 0x38f8
movq 0x128(%rsp), %rdi
movq 0x3b8(%rsp), %rax
movq 0x8(%rax), %rsi
callq 0x3260
movq %rax, 0x120(%rsp)
jmp 0x391b
movq 0x120(%rsp), %rdi
movq 0x1c696(%rip), %rsi     # 0x1ffc0
callq 0x32a0
jmp 0x3931
movq 0x3b8(%rsp), %rax
movq 0x8(%rax), %rsi
leaq 0x178(%rsp), %rdi
movl $0x8, %edx
callq 0x34e0
jmp 0x3951
movq 0x178(%rsp), %rax
movq -0x18(%rax), %rax
leaq 0x178(%rsp,%rax), %rdi
callq 0x3470
movb %al, 0x11f(%rsp)
jmp 0x3973
movb 0x11f(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x39fd
movq 0x3b8(%rsp), %rax
movq 0x8(%rax), %rsi
movq 0x1c659(%rip), %rdi     # 0x1fff0
callq 0x3260
movq %rax, 0x110(%rsp)
jmp 0x39a6
movq 0x110(%rsp), %rdi
leaq 0x14682(%rip), %rsi     # 0x18037
callq 0x3260
movq %rax, 0x108(%rsp)
jmp 0x39c4
movq 0x108(%rsp), %rdi
movq 0x1c5ed(%rip), %rsi     # 0x1ffc0
callq 0x32a0
jmp 0x39da
movl $0x1, %edi
callq 0x3300
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x388(%rsp)
movl %eax, 0x384(%rsp)
jmp 0x402b
movq 0x1c5cc(%rip), %rdi     # 0x1ffd0
leaq 0x1463d(%rip), %rsi     # 0x18048
callq 0x3260
movq %rax, 0x100(%rsp)
jmp 0x3a1a
movq 0x100(%rsp), %rdi
movq 0x3b8(%rsp), %rax
movq 0x10(%rax), %rsi
callq 0x3260
movq %rax, 0xf8(%rsp)
jmp 0x3a3d
movq 0xf8(%rsp), %rdi
movq 0x1c574(%rip), %rsi     # 0x1ffc0
callq 0x32a0
jmp 0x3a53
movq 0x1c576(%rip), %rdi     # 0x1ffd0
leaq 0x14605(%rip), %rsi     # 0x18066
callq 0x3260
movq %rax, 0xf0(%rsp)
jmp 0x3a70
movq 0xf0(%rsp), %rdi
movq 0x1c541(%rip), %rsi     # 0x1ffc0
callq 0x32a0
jmp 0x3a86
movq 0x1c543(%rip), %rdi     # 0x1ffd0
leaq 0x145e9(%rip), %rsi     # 0x1807d
callq 0x3260
jmp 0x3a9b
movq 0x1c52e(%rip), %rdi     # 0x1ffd0
leaq 0x14635(%rip), %rsi     # 0x180de
callq 0x3260
movq %rax, 0xe8(%rsp)
jmp 0x3ab8
movq 0xe8(%rsp), %rdi
movq 0x1c4f9(%rip), %rsi     # 0x1ffc0
callq 0x32a0
jmp 0x3ace
movq 0x1c4fb(%rip), %rdi     # 0x1ffd0
leaq 0x14617(%rip), %rsi     # 0x180f3
callq 0x3260
jmp 0x3ae3
movq 0x1c4e6(%rip), %rdi     # 0x1ffd0
leaq 0x1460c(%rip), %rsi     # 0x180fd
callq 0x3260
movq %rax, 0xe0(%rsp)
jmp 0x3b00
movq 0xe0(%rsp), %rdi
movq 0x1c4b1(%rip), %rsi     # 0x1ffc0
callq 0x32a0
jmp 0x3b16
movq 0x1c4b3(%rip), %rdi     # 0x1ffd0
leaq 0x145ec(%rip), %rsi     # 0x18110
callq 0x3260
movq %rax, 0xd8(%rsp)
jmp 0x3b33
movq 0xd8(%rsp), %rdi
movl $0x24, %esi
callq 0x32d0
movq %rax, 0xd0(%rsp)
jmp 0x3b4f
movq 0xd0(%rsp), %rdi
leaq 0x145c5(%rip), %rsi     # 0x18123
callq 0x3260
movq %rax, 0xc8(%rsp)
jmp 0x3b6d
movq 0xc8(%rsp), %rdi
movl $0x24, %esi
callq 0x3480
movq %rax, 0xc0(%rsp)
jmp 0x3b89
movq 0xc0(%rsp), %rdi
movq 0x1c428(%rip), %rsi     # 0x1ffc0
callq 0x32a0
jmp 0x3b9f
movq 0x1c42a(%rip), %rdi     # 0x1ffd0
leaq 0x1457f(%rip), %rsi     # 0x1812c
callq 0x3260
movq %rax, 0xb8(%rsp)
jmp 0x3bbc
movq 0xb8(%rsp), %rdi
movl $0xff, %esi
callq 0x33e0
movq %rax, 0xb0(%rsp)
jmp 0x3bd8
movq 0xb0(%rsp), %rdi
leaq 0x1453c(%rip), %rsi     # 0x18123
callq 0x3260
movq %rax, 0xa8(%rsp)
jmp 0x3bf6
movq 0xa8(%rsp), %rdi
movl $0xff, %esi
callq 0x3480
movq %rax, 0xa0(%rsp)
jmp 0x3c12
movq 0xa0(%rsp), %rdi
movq 0x1c39f(%rip), %rsi     # 0x1ffc0
callq 0x32a0
jmp 0x3c28
movq 0x1c3a1(%rip), %rdi     # 0x1ffd0
leaq 0x1450d(%rip), %rsi     # 0x18143
callq 0x3260
jmp 0x3c3d
movq 0x1c38c(%rip), %rdi     # 0x1ffd0
leaq 0x14501(%rip), %rsi     # 0x1814c
callq 0x3260
movq %rax, 0x98(%rsp)
jmp 0x3c5a
movq 0x98(%rsp), %rdi
movl $0x1, %esi
callq 0x3090
movq %rax, 0x90(%rsp)
jmp 0x3c76
movq 0x90(%rsp), %rdi
leaq 0x144f8(%rip), %rsi     # 0x1817d
callq 0x3260
jmp 0x3c8c
movq 0x1c33d(%rip), %rdi     # 0x1ffd0
leaq 0x144ec(%rip), %rsi     # 0x18186
callq 0x3260
movq %rax, 0x88(%rsp)
jmp 0x3ca9
movq 0x88(%rsp), %rdi
movl $0x1, %esi
callq 0x3090
movq %rax, 0x80(%rsp)
jmp 0x3cc5
movq 0x80(%rsp), %rdi
leaq 0x144a9(%rip), %rsi     # 0x1817d
callq 0x3260
jmp 0x3cdb
movq 0x1c2ee(%rip), %rdi     # 0x1ffd0
leaq 0x144cc(%rip), %rsi     # 0x181b5
callq 0x3260
movq %rax, 0x78(%rsp)
jmp 0x3cf5
movq 0x78(%rsp), %rdi
movl $0x4, %esi
callq 0x3090
movq %rax, 0x70(%rsp)
jmp 0x3d0b
movq 0x70(%rsp), %rdi
leaq 0x144cb(%rip), %rsi     # 0x181e2
callq 0x3260
jmp 0x3d1e
movq 0x1c2ab(%rip), %rdi     # 0x1ffd0
leaq 0x144be(%rip), %rsi     # 0x181ea
callq 0x3260
movq %rax, 0x68(%rsp)
jmp 0x3d38
movq 0x68(%rsp), %rdi
movl $0x8, %esi
callq 0x3090
movq %rax, 0x60(%rsp)
jmp 0x3d4e
movq 0x60(%rsp), %rdi
leaq 0x14488(%rip), %rsi     # 0x181e2
callq 0x3260
jmp 0x3d61
movq 0x1c268(%rip), %rdi     # 0x1ffd0
leaq 0x144a9(%rip), %rsi     # 0x18218
callq 0x3260
jmp 0x3d76
movq 0x1c253(%rip), %rdi     # 0x1ffd0
leaq 0x144a6(%rip), %rsi     # 0x1822a
callq 0x3260
movq %rax, 0x58(%rsp)
jmp 0x3d90
movq 0x58(%rsp), %rdi
movq 0x1c224(%rip), %rsi     # 0x1ffc0
callq 0x32a0
jmp 0x3da3
movq 0x1c226(%rip), %rdi     # 0x1ffd0
leaq 0x1448f(%rip), %rsi     # 0x18240
callq 0x3260
jmp 0x3db8
movq 0x1c211(%rip), %rdi     # 0x1ffd0
leaq 0x1448b(%rip), %rsi     # 0x18251
callq 0x3260
movq %rax, 0x50(%rsp)
jmp 0x3dd2
movq 0x50(%rsp), %rdi
movq 0x1c1e2(%rip), %rsi     # 0x1ffc0
callq 0x32a0
jmp 0x3de5
movq 0x1c1e4(%rip), %rdi     # 0x1ffd0
leaq 0x1446c(%rip), %rsi     # 0x1825f
callq 0x3260
movq %rax, 0x48(%rsp)
jmp 0x3dff
movq 0x48(%rsp), %rdi
movq 0x1c1b5(%rip), %rsi     # 0x1ffc0
callq 0x32a0
jmp 0x3e12
movq 0x1c1b7(%rip), %rdi     # 0x1ffd0
leaq 0x1445e(%rip), %rsi     # 0x1827e
callq 0x3260
jmp 0x3e27
movq 0x1c1a2(%rip), %rdi     # 0x1ffd0
leaq 0x14458(%rip), %rsi     # 0x1828d
callq 0x3260
movq %rax, 0x40(%rsp)
jmp 0x3e41
movq 0x40(%rsp), %rdi
movq 0x1c173(%rip), %rsi     # 0x1ffc0
callq 0x32a0
jmp 0x3e54
movq 0x1c175(%rip), %rdi     # 0x1ffd0
leaq 0x14440(%rip), %rsi     # 0x182a2
callq 0x3260
jmp 0x3e69
movq 0x1c160(%rip), %rdi     # 0x1ffd0
leaq 0x14439(%rip), %rsi     # 0x182b0
callq 0x3260
jmp 0x3e7e
movq 0x1c14b(%rip), %rdi     # 0x1ffd0
leaq 0x14454(%rip), %rsi     # 0x182e0
callq 0x3260
jmp 0x3e93
movq 0x1c136(%rip), %rdi     # 0x1ffd0
leaq 0x1444e(%rip), %rsi     # 0x182ef
callq 0x3260
movq %rax, 0x38(%rsp)
jmp 0x3ead
movq 0x38(%rsp), %rdi
movq 0x1c107(%rip), %rsi     # 0x1ffc0
callq 0x32a0
jmp 0x3ec0
movq 0x1c109(%rip), %rdi     # 0x1ffd0
leaq 0x1443b(%rip), %rsi     # 0x18309
callq 0x3260
movq %rax, 0x30(%rsp)
jmp 0x3eda
movq 0x30(%rsp), %rdi
movq 0x1c0da(%rip), %rsi     # 0x1ffc0
callq 0x32a0
jmp 0x3eed
movq 0x1c0dc(%rip), %rdi     # 0x1ffd0
leaq 0x141e3(%rip), %rsi     # 0x180de
callq 0x3260
movq %rax, 0x28(%rsp)
jmp 0x3f07
movq 0x28(%rsp), %rdi
movq 0x1c0ad(%rip), %rsi     # 0x1ffc0
callq 0x32a0
jmp 0x3f1a
movq 0x3b8(%rsp), %rax
movq 0x8(%rax), %rcx
movq %rcx, 0x18(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x20(%rsp)
leaq 0x150(%rsp), %rdi
leaq 0x398(%rsp), %rsi
callq 0x3110
jmp 0x3f4b
movq 0x20(%rsp), %rsi
movq 0x18(%rsp), %rdi
leaq 0x150(%rsp), %rdx
callq 0x4060
movq %rax, 0x10(%rsp)
jmp 0x3f69
leaq 0x150(%rsp), %rdi
callq 0x3180
movq 0x10(%rsp), %rax
movq %rax, 0x170(%rsp)
movq 0x170(%rsp), %rax
movq %rax, 0x8(%rsp)
cmpq $0x0, %rax
je 0x3fa1
movq 0x8(%rsp), %rdi
movq (%rdi), %rax
callq *0x8(%rax)
movq 0x1c048(%rip), %rdi     # 0x1fff0
leaq 0x14366(%rip), %rsi     # 0x18315
callq 0x3260
movq %rax, (%rsp)
jmp 0x3fba
movq (%rsp), %rdi
movq 0x1bffb(%rip), %rsi     # 0x1ffc0
callq 0x32a0
jmp 0x3fcc
movq 0x1c01d(%rip), %rdi     # 0x1fff0
leaq 0x14356(%rip), %rsi     # 0x18330
callq 0x3260
jmp 0x3fe1
leaq 0x178(%rsp), %rdi
callq 0x30a0
leaq 0x398(%rsp), %rdi
callq 0x3180
movl 0x3c4(%rsp), %eax
addq $0x3c8, %rsp            # imm = 0x3C8
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x388(%rsp)
movl %eax, 0x384(%rsp)
leaq 0x150(%rsp), %rdi
callq 0x3180
leaq 0x178(%rsp), %rdi
callq 0x30a0
leaq 0x398(%rsp), %rdi
callq 0x3180
movq 0x388(%rsp), %rdi
callq 0x34a0
nopw %cs:(%rax,%rax)
nopl (%rax)