// File: /workspace/github_cpp_makefile_star2_O1/giovannarosone[P]BCR_LCP_GSA/TransposeFasta.cpp
// Function: TransposeFasta::convertQS(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, unsigned long)
bool TransposeFasta::convertQS( const string& input, const string& output, dataTypeNChar ram )
{
	FILE* ifile;
	cerr << "\nTrasposeFasta convertQS: file " << input << " !" << endl;
	
	ifile = fopen(input.c_str(), "rb");

    if( ifile == NULL ) { 
		cerr << "TrasposeFasta convertQS: could not open file " << input << " !" << endl; 
	}


	vector <FILE*> outputFiles_;
	outputFiles_.resize(lengthRead);    //One for each symbol of the read.
    // create output files   (cyc qs files)
    for(dataTypelenSeq i=0;i<lengthRead;i++ )
    {
        std::stringstream fn;
        fn << output << "qs." << (int)i << ".txt";
        outputFiles_[i] = fopen( fn.str().c_str(),"w" );
        if (outputFiles_[i] == NULL) {
                std::cerr << "TrasposeFasta: could not open file "  <<  fn.str().c_str() << std::endl;
				exit (EXIT_FAILURE);
		}
        fclose(outputFiles_[i]);
    }

	//TO DO: CHECK THE CASE OF charsBuffered >= SIZEBUFFERcycFiles
	//if (nSeq > SIZEBUFFERcycFiles) {
	//	cerr << "Warning: Number of sequences is: " << (unsigned long)nSeq << " and SIZEBUFFERcycFiles (in TransposeFasta.h) is " << SIZEBUFFERcycFiles << endl;
	//}
	
	ram = ram * nSeq;   //ram used in BCR for vector 
	
	SIZEBUFFERcycFiles = ram / lengthRead;
	
	if ( SIZEBUFFERcycFiles > nSeq )   //number of columns
		SIZEBUFFERcycFiles = nSeq;
	else if ( SIZEBUFFERcycFiles < 1048576 )
		SIZEBUFFERcycFiles = 1048576;
	
	
	std::cerr << "TrasposeFasta.convertQS: init buf_ of size " << (unsigned long) lengthRead << " * " << SIZEBUFFERcycFiles << std::endl;
	
	vector<vector<uchar> > buf_;
	buf_.resize(lengthRead);    //For each symbol/column of the read
	for (dataTypelenSeq x = 0 ; x < lengthRead; x++)         //For each symbol/column of the read
		buf_[x].resize(SIZEBUFFERcycFiles);
	for (dataTypelenSeq x = 0 ; x < lengthRead; x++)         //For each symbol/column of the read
		for (dataTypeNChar y = 0 ; y < SIZEBUFFERcycFiles; y++)         //For each buffered symbol of the read
			buf_[x][y]=TERMINATE_CHAR_LEN;

	//char buf[SIZEBUFFERcycFiles];
    //for(dataTypeNChar i=0;i<SIZEBUFFERcycFiles;i++ )
//		buf[i] = '\0';	
	//fgets ( buf, SIZEBUFFERcycFiles, ifile );			//it starts with '>', we can ignore it
	
	std::ifstream infile(input.c_str());
	string bufChar;
	
	dataTypeNChar charsBuffered = 0;
    // looping through the input file, add the characters to the buffer, print buffer when it's full
//    unsigned int num_read = 0;
    dataTypeNChar num_write = 0;
	dataTypelenSeq tmpLen = 0;
    nSeq = 0;
	dataTypelenSeq sumLenCum = 0;

    /*while( !feof(ifile) )
    {
        if( charsBuffered-1 == SIZEBUFFERcycFiles)   //it is linked to the number of sequences
        {
            // write buffers to the files, clear buffers
            for(dataTypelenSeq i=0;i<lengthRead;i++ )  {       //For each symbol/column of the read   (for each string)
                std::stringstream fn;
                fn << output << "qs." << (int)i << ".txt";
				outputFiles_[i] = fopen( fn.str().c_str(),"a" );
				num_write = fwrite ( &buf_[i][0],sizeof(char),charsBuffered-1,outputFiles_[i] );
				assert( num_write == charsBuffered-1 );
				for(dataTypeNChar x=0; x<charsBuffered-1; x++ ) {
					//For each buffered symbol of the read (a symbol for each string)
					if (buf_[i][x] != TERMINATE_CHAR_LEN) {
						//freq[(unsigned int)(buf_[i][x])]=1;
						buf_[i][x] = TERMINATE_CHAR_LEN;
					}
				}
				fclose(outputFiles_[i]);
            }
			
	        //for (dataTypelenSeq x = 0 ; x < lengthRead; x++)         //For each symbol/column of the read
		    //    for (dataTypeNChar y = 0 ; y < BUFFERSIZE; y++)         //For each buffered symbol of the read
			//        buf_[x][y]=TERMINATE_CHAR_LEN;
			
            charsBuffered=1;
        }

        // process the input
        if( buf[0] != '>' )
        {
			dataTypelenSeq posit = 0 + sumLenCum;
			for(dataTypelenSeq i=posit; i < posit + tmpLen;i++) {
				buf_[i][charsBuffered-1] = buf[i-posit];
			}

            sumLenCum += tmpLen;

			#if verboseEncode==1
				cerr << "Partial Buf_ " << endl;
				for(dataTypelenSeq i=0;i<lengthRead;i++ ) {
					cerr << (int)i << " " ;
					for(dataTypeNChar x=0; x<charsBuffered; x++ )
						cerr << buf_[i][x] ;
					cerr << endl;
				}
			#endif
        }
		else  {
			if (nSeq % SIZEBUFFERcycFiles == 0)
				cerr << "New QS sequence - " << "Sequence N. " << (int)nSeq << std::endl;

			sumLenCum = 0;
		    // increase the number of sequences
			nSeq++;
			// increase the counter of chars buffered
			charsBuffered++;
		}
		for(dataTypelenSeq i=0;i<lengthRead;i++ )
			buf[i] = '\0';
		fgets ( buf, SIZEBUFFERcycFiles, ifile );
        if ((buf[strlen(buf)-2] == '\r') || (buf[strlen(buf)-2] == '\n'))
            buf[strlen(buf)-2] = '\0';
        else if ((buf[strlen(buf)-1] == '\r') || (buf[strlen(buf)-1] == '\n'))
            buf[strlen(buf)-1] = '\0';

		tmpLen = strlen(buf);          //tmpLen = strlen(buf)-1;
    }
	*/
	
	while (getline(infile, bufChar))  {
		if ((bufChar[bufChar.length()-2] == '\r') || (bufChar[bufChar.length()-2] == '\n'))
            bufChar[bufChar.length()-2] = '\0';
        else if ((bufChar[bufChar.length()-1] == '\r') || (bufChar[bufChar.length()-1] == '\n'))
            bufChar[bufChar.length()-1] = '\0';		
		
		tmpLen = bufChar.length();          //tmpLen = strlen(buf)-1;
		
		if ( (charsBuffered > 0) && ( charsBuffered-1 == SIZEBUFFERcycFiles))   //it is linked to the number of sequences
        {
			// write buffers to the files, clear buffers
            for(dataTypelenSeq i=0;i<lengthRead;i++ )  {       //For each symbol/column of the read   (for each string)
                std::stringstream fn;
                fn << output << "qs." << (int)i << ".txt";
				outputFiles_[i] = fopen( fn.str().c_str(),"a" );
				num_write = fwrite ( &buf_[i][0],sizeof(char),charsBuffered-1,outputFiles_[i] );
				assert( num_write == charsBuffered-1 );
				for(dataTypeNChar x=0; x<charsBuffered-1; x++ ) {
					//For each buffered symbol of the read (a symbol for each string)
					if (buf_[i][x] != TERMINATE_CHAR_LEN) {
						//freq[(unsigned int)(buf_[i][x])]++;   //=1
						buf_[i][x] = TERMINATE_CHAR_LEN;
					}
				}
				fclose(outputFiles_[i]);
            }
            charsBuffered=1;
        }

        // process the input
        if( bufChar[0] != '{' )   //no title
        {
			
			dataTypelenSeq posit = 0 + sumLenCum;
			for(dataTypelenSeq i=posit; i < posit + tmpLen;i++) {
				buf_[i][charsBuffered-1] = bufChar[i-posit];
			}

            sumLenCum += tmpLen;
			//cerr << "it is not title"<< " tmpLen " << (int)tmpLen << " sumLenCum " << (unsigned int)sumLenCum << endl;
			
 			/*#if verboseEncode==1
				cerr << "Partial Buf_ " << endl;
				for(dataTypelenSeq i=0;i<lengthRead;i++ ) {
					cerr << (int)i << " " ;
					for(dataTypeNChar x=0; x<charsBuffered; x++ )
						cerr << buf_[i][x] ;
					cerr << endl;
				}
			#endif */
        }
		else  {        //it is a title
            sumLenCum = 0;
		    // increase the number of sequences
			nSeq++;
			//cerr << "it is a title"<< nSeq << endl;
			// increase the counter of chars buffered
			charsBuffered++;
		}
		//for(dataTypelenSeq i=0;i<lengthRead;i++ )
		//	buf[i] = '\0';
		//fgets ( buf, BUFFER_SIZELEN, ifile );
        //if ((buf[strlen(buf)-2] == '\r') || (buf[strlen(buf)-2] == '\n'))
         //   buf[strlen(buf)-2] = '\0';
        //else if ((buf[strlen(buf)-1] == '\r') || (buf[strlen(buf)-1] == '\n'))
        //    buf[strlen(buf)-1] = '\0';

//        cerr << "buf: " << buf << "." << endl;
		
    }  //end-while
	
	

	/* 	#if verboseEncode==1
		cerr << "The last Buf_ " << endl;
		cerr << "Buf_ " << endl;
		for(dataTypelenSeq i=0;i<lengthRead;i++ ) {
			for(dataTypeNChar x=0; x<charsBuffered; x++ )
				cerr << buf_[i][x] ;
			cerr << endl;
		}
	#endif */

    // write the rest
    for(dataTypelenSeq i=0;i<lengthRead;i++ )
    {
        std::stringstream fn;
        fn << output << "qs." << (int)i << ".txt";
        outputFiles_[i] = fopen( fn.str().c_str(),"a" );
		num_write = fwrite ( &buf_[i][0],sizeof(char),charsBuffered,outputFiles_[i] );
		assert( num_write == charsBuffered );
		for(dataTypeNChar x=0; x<charsBuffered; x++ ) {
			if (buf_[i][x] != TERMINATE_CHAR_LEN) {
				//freq[(unsigned int)(buf_[i][x])]=1;
				buf_[i][x] = TERMINATE_CHAR_LEN;
			}
		}
        fclose( outputFiles_[i]);
    }

	cerr << "Number of quality score sequences reading/writing: " << nSeq << "\n";
	//cerr << "Number of characters reading/writing: " << lengthTexts << "\n";

    return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x428, %rsp            # imm = 0x428
movq %rcx, 0x70(%rsp)
movq %rdx, 0x8(%rsp)
movq %rsi, %r15
movq %rdi, %rbx
movq 0x7750(%rip), %r14      # 0x10ff0
leaq 0x3b7c(%rip), %rsi      # 0xd423
movl $0x1f, %edx
movq %r14, %rdi
callq 0x32d0
movq (%r15), %rsi
movq 0x8(%r15), %rdx
movq %r14, %rdi
callq 0x32d0
movq %rax, %r14
leaq 0x3b76(%rip), %rsi      # 0xd443
movl $0x2, %edx
movq %rax, %rdi
callq 0x32d0
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x3280
movsbl %al, %esi
movq %r14, %rdi
callq 0x3050
movq %rax, %rdi
callq 0x31e0
movq %r15, (%rsp)
movq (%r15), %rdi
leaq 0x3044(%rip), %rsi      # 0xc953
callq 0x32e0
testq %rax, %rax
jne 0x9985
movq 0x76d0(%rip), %r14      # 0x10ff0
leaq 0x3b1f(%rip), %rsi      # 0xd446
movl $0x2d, %edx
movq %r14, %rdi
callq 0x32d0
movq (%rsp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
movq %r14, %rdi
callq 0x32d0
movq %rax, %r14
leaq 0x3af2(%rip), %rsi      # 0xd443
movl $0x2, %edx
movq %rax, %rdi
callq 0x32d0
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x3280
movsbl %al, %esi
movq %r14, %rdi
callq 0x3050
movq %rax, %rdi
callq 0x31e0
xorps %xmm0, %xmm0
leaq 0x10(%rsp), %rdi
movaps %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
movzbl (%rbx), %esi
callq 0xa49c
movb (%rbx), %dl
testb %dl, %dl
je 0x9aa6
xorl %r15d, %r15d
leaq 0x220(%rsp), %r13
leaq 0x358a(%rip), %r12      # 0xcf46
movq 0x75f5(%rip), %rbp      # 0x10fb8
movq %r13, %rdi
callq 0x31f0
movq 0x8(%rsp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
leaq 0x230(%rsp), %rdi
callq 0x32d0
movq %rax, %r14
movl $0x3, %edx
movq %rax, %rdi
leaq 0x3a7e(%rip), %rsi      # 0xd474
callq 0x32d0
movq %r14, %rdi
movl %r15d, %esi
callq 0x3440
movl $0x4, %edx
movq %rax, %rdi
leaq 0x2f39(%rip), %rsi      # 0xc94e
callq 0x32d0
leaq 0x98(%rsp), %rdi
leaq 0x238(%rsp), %rsi
callq 0x33c0
movq 0x98(%rsp), %rdi
movq %r12, %rsi
callq 0x32e0
movl %r15d, %r14d
movq 0x10(%rsp), %rcx
movq %rax, (%rcx,%r14,8)
movq 0x98(%rsp), %rdi
leaq 0xa8(%rsp), %rax
cmpq %rax, %rdi
je 0x9a65
callq 0x3260
movq 0x10(%rsp), %rax
movq (%rax,%r14,8), %rdi
testq %rdi, %rdi
je 0xa051
callq 0x32a0
movq %r13, %rdi
movq %rbp, %rsi
callq 0x3210
leaq 0x2a0(%rsp), %rdi
callq 0x30d0
incb %r15b
movzbl %r15b, %r15d
movb (%rbx), %dl
cmpb %dl, %r15b
jb 0x99c3
movl 0x10(%rbx), %ecx
movq 0x70(%rsp), %rax
imulq %rcx, %rax
movzbl %dl, %esi
xorl %edx, %edx
divq %rsi
movq %rax, 0x820(%rbx)
cmpq %rcx, %rax
ja 0x9ad3
movl $0x100000, %ecx         # imm = 0x100000
cmpq $0xfffff, %rax          # imm = 0xFFFFF
ja 0x9ada
movq %rcx, 0x820(%rbx)
movq 0x750f(%rip), %rdi      # 0x10ff0
leaq 0x3990(%rip), %rsi      # 0xd478
movl $0x2b, %edx
callq 0x32d0
movzbl (%rbx), %esi
movq 0x74f4(%rip), %rdi      # 0x10ff0
callq 0x31d0
movq %rax, %r15
leaq 0x2d57(%rip), %rsi      # 0xc862
movl $0x3, %edx
movq %rax, %rdi
callq 0x32d0
movq 0x820(%rbx), %rsi
movq %r15, %rdi
callq 0x31d0
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x3280
movsbl %al, %esi
movq %r15, %rdi
callq 0x3050
movq %rax, %rdi
callq 0x31e0
xorps %xmm0, %xmm0
leaq 0x30(%rsp), %rdi
movaps %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
movzbl (%rbx), %esi
callq 0xa4ce
cmpb $0x0, (%rbx)
je 0x9b9a
xorl %r14d, %r14d
xorl %r15d, %r15d
movq 0x30(%rsp), %rdi
addq %r14, %rdi
movq 0x820(%rbx), %rsi
callq 0xa550
incq %r15
movzbl (%rbx), %eax
addq $0x18, %r14
cmpq %rax, %r15
jb 0x9b77
cmpb $0x0, (%rbx)
je 0x9bd5
xorl %eax, %eax
cmpq $0x0, 0x820(%rbx)
je 0x9bca
leaq (%rax,%rax,2), %rcx
xorl %edx, %edx
movq 0x30(%rsp), %rsi
movq (%rsi,%rcx,8), %rsi
movb $-0x1, (%rsi,%rdx)
incq %rdx
cmpq 0x820(%rbx), %rdx
jb 0x9bb1
incq %rax
movzbl (%rbx), %ecx
cmpq %rcx, %rax
jb 0x9ba1
movq (%rsp), %rax
movq (%rax), %rsi
leaq 0x220(%rsp), %r14
movq %r14, %rdi
movl $0x8, %edx
callq 0x3490
leaq 0x60(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movl $0x0, 0x10(%rbx)
xorl %r15d, %r15d
xorl %r13d, %r13d
movq %rbx, 0x48(%rsp)
movq 0x220(%rsp), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x3280
movsbl %al, %edx
movq %r14, %rdi
leaq 0x50(%rsp), %rsi
callq 0x34a0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x9e71
movq 0x50(%rsp), %rcx
movq 0x58(%rsp), %rdx
leaq (%rcx,%rdx), %rax
addq $-0x2, %rax
movzbl (%rax), %esi
cmpl $0xa, %esi
je 0x9c85
cmpl $0xd, %esi
je 0x9c85
leaq (%rcx,%rdx), %rax
decq %rax
movzbl (%rax), %ecx
cmpl $0xd, %ecx
je 0x9c85
cmpl $0xa, %ecx
jne 0x9c88
movb $0x0, (%rax)
movl 0x58(%rsp), %eax
movl %eax, (%rsp)
testq %r15, %r15
je 0x9e09
leaq -0x1(%r15), %r12
cmpq 0x820(%rbx), %r12
jne 0x9e0c
movl $0x1, %r15d
cmpb $0x0, (%rbx)
je 0x9e0c
xorl %ebp, %ebp
leaq 0x98(%rsp), %r15
movq %r15, %rdi
callq 0x31f0
movq %r14, %rbx
movq 0x8(%rsp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
leaq 0xa8(%rsp), %rdi
callq 0x32d0
movq %rax, %r14
movl $0x3, %edx
movq %rax, %rdi
leaq 0x377c(%rip), %rsi      # 0xd474
callq 0x32d0
movq %r14, %rdi
movl %ebp, %esi
callq 0x3440
movl $0x4, %edx
movq %rax, %rdi
leaq 0x2c38(%rip), %rsi      # 0xc94e
callq 0x32d0
leaq 0x78(%rsp), %rdi
leaq 0xb0(%rsp), %rsi
callq 0x33c0
movq 0x78(%rsp), %rdi
leaq 0x3543(%rip), %rsi      # 0xd27c
callq 0x32e0
movq 0x10(%rsp), %rcx
movq %rax, (%rcx,%rbp,8)
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0x9d5e
callq 0x3260
movq 0x30(%rsp), %rax
leaq (,%rbp,2), %r14
addq %rbp, %r14
movq (%rax,%r14,8), %rdi
movq 0x10(%rsp), %rax
movq (%rax,%rbp,8), %rcx
movl $0x1, %esi
movq %r12, %rdx
callq 0x34c0
cmpq %r12, %rax
jne 0xa032
testq %r12, %r12
je 0x9db3
xorl %eax, %eax
movq 0x30(%rsp), %rcx
movq (%rcx,%r14,8), %rcx
cmpb $-0x1, (%rcx,%rax)
je 0x9dab
movb $-0x1, (%rcx,%rax)
incq %rax
cmpq %rax, %r12
jne 0x9d98
movq 0x10(%rsp), %rax
movq (%rax,%rbp,8), %rdi
callq 0x32a0
leaq 0x98(%rsp), %r15
movq %r15, %rdi
movq 0x71e5(%rip), %rsi      # 0x10fb8
callq 0x3210
leaq 0x118(%rsp), %rdi
callq 0x30d0
incq %rbp
movq 0x48(%rsp), %rax
movzbl (%rax), %eax
cmpq %rax, %rbp
movq %rbx, %r14
jb 0x9cc2
movq 0x48(%rsp), %rbx
movl $0x1, %r15d
jmp 0x9e0c
xorl %r15d, %r15d
movq 0x50(%rsp), %rax
cmpb $0x7b, (%rax)
jne 0x9e24
incl 0x10(%rbx)
incq %r15
xorl %r13d, %r13d
jmp 0x9c17
movzbl %r13b, %ecx
movzbl (%rsp), %eax
addl %ecx, %eax
movl %ecx, %edx
cmpl %ecx, %eax
jbe 0x9e69
subl %ecx, %edx
movslq %edx, %rdx
movq 0x50(%rsp), %rsi
movb (%rsi,%rdx), %dl
movzbl %r13b, %r13d
movq 0x30(%rsp), %rsi
leaq (,%r13,2), %rdi
addq %r13, %rdi
movq (%rsi,%rdi,8), %rsi
movb %dl, -0x1(%rsi,%r15)
incb %r13b
movzbl %r13b, %edx
cmpl %edx, %eax
ja 0x9e34
movl %eax, %r13d
jmp 0x9c17
cmpb $0x0, (%rbx)
je 0x9fa9
xorl %r12d, %r12d
leaq 0x98(%rsp), %r13
movq 0x712c(%rip), %rbp      # 0x10fb8
movq %r13, %rdi
callq 0x31f0
movq 0x8(%rsp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
leaq 0xa8(%rsp), %rdi
callq 0x32d0
movq %rax, %r14
movl $0x3, %edx
movq %rax, %rdi
leaq 0x35b5(%rip), %rsi      # 0xd474
callq 0x32d0
movq %r14, %rdi
movl %r12d, %esi
callq 0x3440
movl $0x4, %edx
movq %rax, %rdi
leaq 0x2a70(%rip), %rsi      # 0xc94e
callq 0x32d0
leaq 0x78(%rsp), %rdi
leaq 0xb0(%rsp), %rsi
callq 0x33c0
movq 0x78(%rsp), %rdi
leaq 0x337b(%rip), %rsi      # 0xd27c
callq 0x32e0
movq 0x10(%rsp), %rcx
movq %rax, (%rcx,%r12,8)
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0x9f26
callq 0x3260
movq 0x30(%rsp), %rax
leaq (%r12,%r12,2), %r14
movq (%rax,%r14,8), %rdi
movq 0x10(%rsp), %rax
movq (%rax,%r12,8), %rcx
movl $0x1, %esi
movq %r15, %rdx
callq 0x34c0
cmpq %r15, %rax
jne 0xa0b1
testq %r15, %r15
je 0x9f74
xorl %eax, %eax
movq 0x30(%rsp), %rcx
movq (%rcx,%r14,8), %rcx
cmpb $-0x1, (%rcx,%rax)
je 0x9f6c
movb $-0x1, (%rcx,%rax)
incq %rax
cmpq %rax, %r15
jne 0x9f59
movq 0x10(%rsp), %rax
movq (%rax,%r12,8), %rdi
callq 0x32a0
movq %r13, %rdi
movq %rbp, %rsi
callq 0x3210
leaq 0x118(%rsp), %rdi
callq 0x30d0
incq %r12
movzbl (%rbx), %eax
cmpq %rax, %r12
jb 0x9e8c
movq 0x7040(%rip), %rdi      # 0x10ff0
leaq 0x3533(%rip), %rsi      # 0xd4ea
movl $0x33, %edx
callq 0x32d0
movl 0x10(%rbx), %esi
movq 0x7025(%rip), %rdi      # 0x10ff0
callq 0x31d0
leaq 0x2a5f(%rip), %rsi      # 0xca36
movl $0x1, %edx
movq %rax, %rdi
callq 0x32d0
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x9ff8
callq 0x3260
leaq 0x220(%rsp), %rdi
callq 0x30a0
leaq 0x30(%rsp), %rdi
callq 0xa57c
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0xa01e
callq 0x3260
movb $0x1, %al
addq $0x428, %rsp            # imm = 0x428
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3245(%rip), %rdi      # 0xd27e
leaq 0x3100(%rip), %rsi      # 0xd140
leaq 0x345d(%rip), %rcx      # 0xd4a4
movl $0x3b7, %edx            # imm = 0x3B7
callq 0x31a0
movq 0x6f98(%rip), %rdi      # 0x10ff0
leaq 0x31cd(%rip), %rsi      # 0xd22c
movl $0x23, %edx
callq 0x32d0
leaq 0x98(%rsp), %rdi
leaq 0x238(%rsp), %rsi
callq 0x33c0
movq 0x98(%rsp), %rsi
movq 0x6f63(%rip), %rdi      # 0x10ff0
callq 0x3290
movq %rax, %rdi
callq 0x3140
leaq 0x98(%rsp), %rdi
callq 0x3130
movl $0x1, %edi
callq 0x3300
leaq 0x323d(%rip), %rdi      # 0xd2f5
leaq 0x3081(%rip), %rsi      # 0xd140
leaq 0x33de(%rip), %rcx      # 0xd4a4
movl $0x401, %edx            # imm = 0x401
callq 0x31a0
jmp 0xa109
jmp 0xa109
jmp 0xa13a
movq %rax, %rbx
movq 0x98(%rsp), %rdi
leaq 0xa8(%rsp), %rax
cmpq %rax, %rdi
je 0xa115
callq 0x3260
jmp 0xa115
jmp 0xa112
jmp 0xa0ff
jmp 0xa112
jmp 0xa13a
jmp 0xa13f
movq %rax, %rbx
jmp 0xa18e
jmp 0xa112
movq %rax, %rbx
jmp 0xa184
jmp 0xa13a
jmp 0xa13f
movq %rax, %rbx
movq 0x6e9c(%rip), %rsi      # 0x10fb8
leaq 0x220(%rsp), %rdi
callq 0x3210
leaq 0x2a0(%rsp), %rdi
callq 0x30d0
jmp 0xa18e
jmp 0xa13f
movq %rax, %rbx
jmp 0xa163
movq %rax, %rbx
movq 0x6e6f(%rip), %rsi      # 0x10fb8
leaq 0x98(%rsp), %rdi
callq 0x3210
leaq 0x118(%rsp), %rdi
callq 0x30d0
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0xa177
callq 0x3260
leaq 0x220(%rsp), %rdi
callq 0x30a0
leaq 0x30(%rsp), %rdi
callq 0xa57c
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0xa19d
callq 0x3260
movq %rbx, %rdi
callq 0x3460
nop