// File: giovannarosone[P]BCR_LCP_GSA/BCRexternalBWT.cpp
// Function: BCRexternalBWT::storeEntireBWTFilePartial(char const*)
void BCRexternalBWT::storeEntireBWTFilePartial( const char* fn ) {

	static FILE *OutFileBWT, *InFileBWT;                  // output and input file BWT;
	char *filenameIn = new char[strlen(fn)+100];
	char *filename = new char[strlen(fn)+100];
	
	#if USE_QS == 1
		static FILE *OutFileBWTQS, *InFileBWTQS;                  // output and input file BWT;
		char *filenameInQS = new char[120];
		char *filenameQS = new char[120];
		char *fnQS = new char[strlen(fn)+100];
		sprintf (fnQS,"%s%s",fn,".ebwt.qs");
	#endif
	
	dataTypeNChar numchar=0;
	dataTypeNChar numcharWrite=0;

	uchar *buffer = new uchar[SIZEBUFFER];
	std::cerr << "storeEntireBWTFilePartial:SIZEBUFFER is " << SIZEBUFFER << std::endl;

	dataTypeNChar *freqOut = new dataTypeNChar [SIZE_ALPHA];
	for (dataTypedimAlpha i = 0; i < SIZE_ALPHA-1; ++i)
        freqOut[i] = 0;
	freqOut[SIZE_ALPHA-1] = 0;

	char *fnBWT = new char[strlen(fn)+100];
	numchar=sprintf (fnBWT,"%s%s",fn,".ebwt");		
	OutFileBWT = fopen(fnBWT, "wb");
	if (OutFileBWT==NULL) {
		std::cerr << "storeEntireBWTFilePartial: Entire BWT file: Error opening " << std::endl;
		exit (EXIT_FAILURE);
	}
	
	#if USE_QS == 1
		OutFileBWTQS = fopen(fnQS, "wb");
		if (OutFileBWTQS==NULL) {
			std::cerr << "storeEntireBWTFilePartial: Entire BWT QS file: Error opening " << std::endl;
			exit (EXIT_FAILURE);
		}
	#endif

	std::cerr << "storeEntireBWTFilePartial: Build the entire BWT file and compute the distribution of chars.\n";

	for (dataTypedimAlpha g = 0 ; g < sizeAlpha; g++) {
		numchar=sprintf (filename, "bwt_%d", g);
		numchar=sprintf (filenameIn,"%s%s",filename,ext);
		InFileBWT = fopen(filenameIn, "rb");
		if (InFileBWT==NULL) {
			std::cerr << "storeEntireBWTFilePartial: BWT file " << (unsigned int)g <<": Error opening " << std::endl;
			exit (EXIT_FAILURE);
		}

		#if USE_QS == 1
			numchar=sprintf (filenameQS, "bwt.qs_%d", g);
			numchar=sprintf (filenameInQS,"%s%s",filenameQS,ext);
			InFileBWTQS = fopen(filenameInQS, "rb");
			if (InFileBWTQS==NULL) {
				std::cerr << "storeEntireBWTFilePartial: BWT QS file " << (unsigned int)g <<": Error opening " << std::endl;
				exit (EXIT_FAILURE);
			}
		#endif

		//std::cerr << "BWT file " << (unsigned int)g << "= ";
		numchar = fread(buffer,sizeof(uchar),SIZEBUFFER,InFileBWT);
		numcharWrite = fwrite (buffer, sizeof(uchar), numchar , OutFileBWT);
		//std::cerr << "numchar= " << numchar << std::endl;
		//std::cerr << "numcharWrite= " << numcharWrite << std::endl;
		assert(numchar == numcharWrite); // we should always read/write the same number of characters

		for (dataTypeNChar j = 0 ; j < numchar; j++)
	        freqOut[(unsigned int)(buffer[j])]++;

		#if USE_QS == 1
			numchar = fread(buffer,sizeof(uchar),SIZEBUFFER,InFileBWTQS);
			numcharWrite = fwrite (buffer, sizeof(uchar), numchar , OutFileBWTQS);
			assert(numchar == numcharWrite);
		#endif

		while (numchar!=0) {
			numchar = fread(buffer,sizeof(uchar),SIZEBUFFER,InFileBWT);
			numcharWrite = fwrite (buffer, sizeof(uchar), numchar , OutFileBWT);
			assert(numchar == numcharWrite); // we should always read/write the same number of characters

			for (dataTypeNChar j = 0 ; j < numchar; j++)
				freqOut[(unsigned int)(buffer[j])]++;
			
			#if USE_QS == 1
				numchar = fread(buffer,sizeof(uchar),SIZEBUFFER,InFileBWTQS);
				numcharWrite = fwrite (buffer, sizeof(uchar), numchar , OutFileBWTQS);
				assert(numchar == numcharWrite);
			#endif

		}

		fclose(InFileBWT);		
		#if USE_QS==1
			fclose(InFileBWTQS);
		#endif
			
	}
	fclose(OutFileBWT);

	#if verboseEncode==1
		std::cerr << "\nThe Entire BWT:"<< std::endl;
		fnBWT = new char[strlen(fn) + 7];
		sprintf (fnBWT,"%s%s",fn,".ebwt");
		OutFileBWT = fopen(fnBWT, "rb");
		if (OutFileBWT==NULL) {
			std::cerr << "storeEntireBWTFilePartial: Entire BWT file: Error opening " << std::endl;
			exit (EXIT_FAILURE);
		}

		numchar = 1;
		for (dataTypeNSeq g = 0 ; g < SIZEBUFFER; g++)
			buffer[g] = '\0';
		numchar = fread(buffer,sizeof(uchar),SIZEBUFFER,OutFileBWT);
   		if (numchar==0)
			   std::cerr  << "empty\n";
		else
			    std::cerr  << buffer;
       	while (numchar!=0) {
	     		for (dataTypeNChar g = 0 ; g < SIZEBUFFER; g++)
		     		buffer[g] = '\0';
			   numchar = fread(buffer,sizeof(uchar),SIZEBUFFER,OutFileBWT);
			   if (numchar!=0)
			      std::cerr  << buffer;
        }
		std::cerr << std::endl;
		fclose(OutFileBWT);
	#endif

	delete [] buffer;

	
	
	int check=0;
	std::cerr << "Distribution in BWT\n";
	for (dataTypedimAlpha g = 0 ; g < SIZE_ALPHA-1; g++) {
		if (freqOut[g] > 0){
			InFileBWT = openFilePartialIn(alpha[(unsigned int)g]);
			fseek(InFileBWT,0,SEEK_END);
			dataTypeNChar lengthBWTPartial=ftell(InFileBWT);
			if (freqOut[g] == lengthBWTPartial)
				std::cerr << (unsigned int)g << " freq: " << freqOut[g] << "\n";
			else {
				std::cerr << (unsigned int)g << " freq: " << freqOut[g] << " freq in BWT: " << lengthBWTPartial << "***********************\n";
				check = 1;
			}
			closeFilePartial(InFileBWT);
			
			#if deletePartialBWT == 1
				sprintf (filename, "bwt_%d", alpha[(unsigned int)g]);
				sprintf (filenameIn,"%s%s",filename,ext);
				if (remove(filenameIn)!=0)
					std::cerr << "storeEntireBWTFilePartial: Error deleting (bwt aux): " << filenameIn << std::endl;
			#endif
			
			#if ((deletePartialQS == 1) && (USE_QS==1))
				sprintf (filename, "bwt.qs_%d", alpha[(unsigned int)g]);
				sprintf (filenameInQS,"%s%s",filename,ext);
				if (remove(filenameInQS)!=0)
					std::cerr << "storeEntireBWTFilePartial: Error deleting (qs aux): " << filenameInQS << std::endl;
			#endif
			
		}
	}
	if (freqOut[(SIZE_ALPHA-1)] > 0){
		InFileBWT = openFilePartialIn(alpha[(unsigned int)(SIZE_ALPHA-1)]);
		fseek(InFileBWT,0,SEEK_END);
		dataTypeNChar lengthBWTPartial=ftell(InFileBWT);
		if (freqOut[(SIZE_ALPHA-1)] == lengthBWTPartial)
			std::cerr << (unsigned int)(SIZE_ALPHA-1) << " freq: " << freqOut[(SIZE_ALPHA-1)] << "\n";
		else {
			std::cerr << (unsigned int)(SIZE_ALPHA-1) << " freq: " << freqOut[(SIZE_ALPHA-1)] << " freq in BWT: " << lengthBWTPartial << "***********************\n";
			check = 1;
		}
		closeFilePartial(InFileBWT);
		#if deletePartialBWT == 1
			sprintf (filename, "bwt_%d", alpha[(unsigned int)(SIZE_ALPHA-1)] );
			sprintf (filenameIn,"%s%s",filename,ext);
			if (remove(filenameIn)!=0)
				std::cerr << "storeEntireBWTFilePartial: Error deleting (bwt aux): " << filenameIn << std::endl;
		#endif
		
		#if ((deletePartialQS == 1) && (USE_QS==1))
			sprintf (filename, "bwt.qs_%d", alpha[(unsigned int)SIZE_ALPHA-1]);
			sprintf (filenameInQS,"%s%s",filename,ext);
			if (remove(filenameInQS)!=0)
				std::cerr << "storeEntireBWTFilePartial: Error deleting (qs aux): " << filenameInQS << std::endl;
		#endif
		
	}

	if (check == 1) {
		std::cerr << "storeEntireBWTFilePartial: WARNING! Some length partial BWT != the number of occorrences! " << std::endl;
		exit (EXIT_FAILURE);
	}
	else
		std::cerr << "storeEntireBWTFilePartial: test ok! " << std::endl;

	delete [] freqOut;
	delete [] filenameIn;
	delete [] filename;

	#if USE_QS == 1
		delete [] filenameInQS;
		delete [] filenameQS;
		delete [] fnQS;
	#endif
}

// Assembly:
subq $0xa8, %rsp
movq %rdi, 0xa0(%rsp)
movq %rsi, 0x98(%rsp)
movq 0xa0(%rsp), %rax
movq %rax, 0x20(%rsp)
movq 0x98(%rsp), %rdi
callq 0x3120
movq %rax, %rdi
addq $0x64, %rdi
callq 0x3040
movq %rax, 0x90(%rsp)
movq 0x98(%rsp), %rdi
callq 0x3120
movq %rax, %rdi
addq $0x64, %rdi
callq 0x3040
movq %rax, 0x88(%rsp)
movq $0x0, 0x80(%rsp)
movq $0x0, 0x78(%rsp)
movl $0x400, %edi            # imm = 0x400
callq 0x3040
movq %rax, 0x70(%rsp)
movq 0x1825f(%rip), %rdi     # 0x1fff0
leaq 0x10fee(%rip), %rsi     # 0x18d86
callq 0x3260
movq %rax, %rdi
movl $0x400, %esi            # imm = 0x400
callq 0x3480
movq %rax, %rdi
movq 0x1820c(%rip), %rsi     # 0x1ffc0
callq 0x32a0
movl $0x800, %edi            # imm = 0x800
callq 0x3040
movq %rax, 0x68(%rsp)
movb $0x0, 0x67(%rsp)
movzbl 0x67(%rsp), %eax
cmpl $0xff, %eax
jge 0x7df7
movq 0x68(%rsp), %rax
movzbl 0x67(%rsp), %ecx
movq $0x0, (%rax,%rcx,8)
movb 0x67(%rsp), %al
addb $0x1, %al
movb %al, 0x67(%rsp)
jmp 0x7dcd
movq 0x68(%rsp), %rax
movq $0x0, 0x7f8(%rax)
movq 0x98(%rsp), %rdi
callq 0x3120
movq %rax, %rdi
addq $0x64, %rdi
callq 0x3040
movq %rax, 0x58(%rsp)
movq 0x58(%rsp), %rdi
movq 0x98(%rsp), %rdx
leaq 0x10de5(%rip), %rsi     # 0x18c1e
leaq 0x10ee4(%rip), %rcx     # 0x18d24
movb $0x0, %al
callq 0x3060
cltq
movq %rax, 0x80(%rsp)
movq 0x58(%rsp), %rdi
leaq 0x10c84(%rip), %rsi     # 0x18ae1
callq 0x32e0
movq %rax, 0x18497(%rip)     # 0x20300
cmpq $0x0, 0x1848f(%rip)     # 0x20300
jne 0x7e9f
movq 0x18176(%rip), %rdi     # 0x1fff0
leaq 0x10f2e(%rip), %rsi     # 0x18daf
callq 0x3260
movq %rax, %rdi
movq 0x18130(%rip), %rsi     # 0x1ffc0
callq 0x32a0
movl $0x1, %edi
callq 0x3300
movq 0x1814a(%rip), %rdi     # 0x1fff0
leaq 0x10f3d(%rip), %rsi     # 0x18dea
callq 0x3260
movb $0x0, 0x57(%rsp)
movq 0x20(%rsp), %rcx
movzbl 0x57(%rsp), %eax
movzbl 0x148(%rcx), %ecx
cmpl %ecx, %eax
jge 0x8140
movq 0x88(%rsp), %rdi
movzbl 0x57(%rsp), %edx
leaq 0x11212(%rip), %rsi     # 0x190f6
movb $0x0, %al
callq 0x3060
cltq
movq %rax, 0x80(%rsp)
movq 0x90(%rsp), %rdi
movq 0x88(%rsp), %rdx
leaq 0x10d12(%rip), %rsi     # 0x18c1e
leaq 0x10c5e(%rip), %rcx     # 0x18b71
movb $0x0, %al
callq 0x3060
cltq
movq %rax, 0x80(%rsp)
movq 0x90(%rsp), %rdi
leaq 0x10a2b(%rip), %rsi     # 0x1895e
callq 0x32e0
movq %rax, 0x183c9(%rip)     # 0x20308
cmpq $0x0, 0x183c1(%rip)     # 0x20308
jne 0x7f91
movq 0x180a0(%rip), %rdi     # 0x1fff0
leaq 0x10ef0(%rip), %rsi     # 0x18e47
callq 0x3260
movq %rax, %rdi
movzbl 0x57(%rsp), %esi
callq 0x3350
movq %rax, %rdi
leaq 0x109f7(%rip), %rsi     # 0x1896a
callq 0x3260
movq %rax, %rdi
movq 0x1803e(%rip), %rsi     # 0x1ffc0
callq 0x32a0
movl $0x1, %edi
callq 0x3300
movq 0x70(%rsp), %rdi
movq 0x1836b(%rip), %rcx     # 0x20308
movl $0x1, %esi
movl $0x400, %edx            # imm = 0x400
callq 0x33c0
movq %rax, 0x80(%rsp)
movq 0x70(%rsp), %rdi
movq 0x80(%rsp), %rdx
movq 0x18338(%rip), %rcx     # 0x20300
movl $0x1, %esi
callq 0x3510
movq %rax, 0x78(%rsp)
movq 0x80(%rsp), %rax
cmpq 0x78(%rsp), %rax
jne 0x7fe8
jmp 0x8007
leaq 0x10ca2(%rip), %rdi     # 0x18c91
leaq 0x10373(%rip), %rsi     # 0x18369
movl $0x1384, %edx           # imm = 0x1384
leaq 0x10e6a(%rip), %rcx     # 0x18e6c
callq 0x3190
movq $0x0, 0x48(%rsp)
movq 0x48(%rsp), %rax
cmpq 0x80(%rsp), %rax
jae 0x8050
movq 0x68(%rsp), %rax
movq 0x70(%rsp), %rcx
movq 0x48(%rsp), %rdx
movzbl (%rcx,%rdx), %ecx
movl %ecx, %ecx
movq (%rax,%rcx,8), %rdx
addq $0x1, %rdx
movq %rdx, (%rax,%rcx,8)
movq 0x48(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x48(%rsp)
jmp 0x8010
jmp 0x8052
cmpq $0x0, 0x80(%rsp)
je 0x8125
movq 0x70(%rsp), %rdi
movq 0x1829b(%rip), %rcx     # 0x20308
movl $0x1, %esi
movl $0x400, %edx            # imm = 0x400
callq 0x33c0
movq %rax, 0x80(%rsp)
movq 0x70(%rsp), %rdi
movq 0x80(%rsp), %rdx
movq 0x18268(%rip), %rcx     # 0x20300
movl $0x1, %esi
callq 0x3510
movq %rax, 0x78(%rsp)
movq 0x80(%rsp), %rax
cmpq 0x78(%rsp), %rax
jne 0x80b8
jmp 0x80d7
leaq 0x10bd2(%rip), %rdi     # 0x18c91
leaq 0x102a3(%rip), %rsi     # 0x18369
movl $0x1392, %edx           # imm = 0x1392
leaq 0x10d9a(%rip), %rcx     # 0x18e6c
callq 0x3190
movq $0x0, 0x40(%rsp)
movq 0x40(%rsp), %rax
cmpq 0x80(%rsp), %rax
jae 0x8120
movq 0x68(%rsp), %rax
movq 0x70(%rsp), %rcx
movq 0x40(%rsp), %rdx
movzbl (%rcx,%rdx), %ecx
movl %ecx, %ecx
movq (%rax,%rcx,8), %rdx
addq $0x1, %rdx
movq %rdx, (%rax,%rcx,8)
movq 0x40(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x40(%rsp)
jmp 0x80e0
jmp 0x8052
movq 0x181dc(%rip), %rdi     # 0x20308
callq 0x3270
movb 0x57(%rsp), %al
addb $0x1, %al
movb %al, 0x57(%rsp)
jmp 0x7eb7
movq 0x181b9(%rip), %rdi     # 0x20300
callq 0x3270
movq 0x70(%rsp), %rax
movq %rax, 0x18(%rsp)
cmpq $0x0, %rax
je 0x8166
movq 0x18(%rsp), %rdi
callq 0x3330
movl $0x0, 0x3c(%rsp)
movq 0x17e7b(%rip), %rdi     # 0x1fff0
leaq 0x10d35(%rip), %rsi     # 0x18eb1
callq 0x3260
movb $0x0, 0x3b(%rsp)
movzbl 0x3b(%rsp), %eax
cmpl $0xff, %eax
jge 0x836e
movq 0x68(%rsp), %rax
movzbl 0x3b(%rsp), %ecx
cmpq $0x0, (%rax,%rcx,8)
jbe 0x835d
movq 0x20(%rsp), %rdi
movzbl 0x3b(%rsp), %eax
movl %eax, %eax
movb 0x48(%rdi,%rax), %cl
movq (%rdi), %rax
movzbl %cl, %esi
callq *0x70(%rax)
movq %rax, 0x1813d(%rip)     # 0x20308
movq 0x18136(%rip), %rdi     # 0x20308
xorl %eax, %eax
movl %eax, %esi
movl $0x2, %edx
callq 0x32c0
movq 0x18121(%rip), %rdi     # 0x20308
callq 0x3030
movq %rax, 0x30(%rsp)
movq 0x68(%rsp), %rax
movzbl 0x3b(%rsp), %ecx
movq (%rax,%rcx,8), %rax
cmpq 0x30(%rsp), %rax
jne 0x824d
movzbl 0x3b(%rsp), %esi
movq 0x17dde(%rip), %rdi     # 0x1fff0
callq 0x3350
movq %rax, %rdi
leaq 0x10ca5(%rip), %rsi     # 0x18ec6
callq 0x3260
movq %rax, %rdi
movq 0x68(%rsp), %rax
movzbl 0x3b(%rsp), %ecx
movq (%rax,%rcx,8), %rsi
callq 0x3090
movq %rax, %rdi
leaq 0x1090a(%rip), %rsi     # 0x18b50
callq 0x3260
jmp 0x82b6
movzbl 0x3b(%rsp), %esi
movq 0x17d97(%rip), %rdi     # 0x1fff0
callq 0x3350
movq %rax, %rdi
leaq 0x10c5e(%rip), %rsi     # 0x18ec6
callq 0x3260
movq %rax, %rdi
movq 0x68(%rsp), %rax
movzbl 0x3b(%rsp), %ecx
movq (%rax,%rcx,8), %rsi
callq 0x3090
movq %rax, %rdi
leaq 0x10c41(%rip), %rsi     # 0x18ece
callq 0x3260
movq %rax, %rdi
movq 0x30(%rsp), %rsi
callq 0x3090
movq %rax, %rdi
leaq 0x10c34(%rip), %rsi     # 0x18edd
callq 0x3260
movl $0x1, 0x3c(%rsp)
movq 0x20(%rsp), %rdi
movq 0x18046(%rip), %rsi     # 0x20308
movq (%rdi), %rax
callq *0x80(%rax)
movq 0x20(%rsp), %rax
movq 0x88(%rsp), %rdi
movzbl 0x3b(%rsp), %ecx
movl %ecx, %ecx
movzbl 0x48(%rax,%rcx), %edx
leaq 0x10e0b(%rip), %rsi     # 0x190f6
movb $0x0, %al
callq 0x3060
movq 0x90(%rsp), %rdi
movq 0x88(%rsp), %rdx
leaq 0x10915(%rip), %rsi     # 0x18c1e
leaq 0x10861(%rip), %rcx     # 0x18b71
movb $0x0, %al
callq 0x3060
movq 0x90(%rsp), %rdi
callq 0x34c0
cmpl $0x0, %eax
je 0x835b
movq 0x17cc0(%rip), %rdi     # 0x1fff0
leaq 0x10bbf(%rip), %rsi     # 0x18ef6
callq 0x3260
movq %rax, %rdi
movq 0x90(%rsp), %rsi
callq 0x3260
movq %rax, %rdi
movq 0x17c6a(%rip), %rsi     # 0x1ffc0
callq 0x32a0
jmp 0x835d
jmp 0x835f
movb 0x3b(%rsp), %al
addb $0x1, %al
movb %al, 0x3b(%rsp)
jmp 0x8186
movq 0x68(%rsp), %rax
cmpq $0x0, 0x7f8(%rax)
jbe 0x8523
movq 0x20(%rsp), %rdi
movb 0x147(%rdi), %cl
movq (%rdi), %rax
movzbl %cl, %esi
callq *0x70(%rax)
movq %rax, 0x17f6c(%rip)     # 0x20308
movq 0x17f65(%rip), %rdi     # 0x20308
xorl %eax, %eax
movl %eax, %esi
movl $0x2, %edx
callq 0x32c0
movq 0x17f50(%rip), %rdi     # 0x20308
callq 0x3030
movq %rax, 0x28(%rsp)
movq 0x68(%rsp), %rax
movq 0x7f8(%rax), %rax
cmpq 0x28(%rsp), %rax
jne 0x841a
movq 0x17c14(%rip), %rdi     # 0x1fff0
movl $0xff, %esi
callq 0x3350
movq %rax, %rdi
leaq 0x10ad6(%rip), %rsi     # 0x18ec6
callq 0x3260
movq %rax, %rdi
movq 0x68(%rsp), %rax
movq 0x7f8(%rax), %rsi
callq 0x3090
movq %rax, %rdi
leaq 0x1073d(%rip), %rsi     # 0x18b50
callq 0x3260
jmp 0x8481
movq 0x17bcf(%rip), %rdi     # 0x1fff0
movl $0xff, %esi
callq 0x3350
movq %rax, %rdi
leaq 0x10a91(%rip), %rsi     # 0x18ec6
callq 0x3260
movq %rax, %rdi
movq 0x68(%rsp), %rax
movq 0x7f8(%rax), %rsi
callq 0x3090
movq %rax, %rdi
leaq 0x10a76(%rip), %rsi     # 0x18ece
callq 0x3260
movq %rax, %rdi
movq 0x28(%rsp), %rsi
callq 0x3090
movq %rax, %rdi
leaq 0x10a69(%rip), %rsi     # 0x18edd
callq 0x3260
movl $0x1, 0x3c(%rsp)
movq 0x20(%rsp), %rdi
movq 0x17e7b(%rip), %rsi     # 0x20308
movq (%rdi), %rax
callq *0x80(%rax)
movq 0x20(%rsp), %rax
movq 0x88(%rsp), %rdi
movzbl 0x147(%rax), %edx
leaq 0x10c45(%rip), %rsi     # 0x190f6
movb $0x0, %al
callq 0x3060
movq 0x90(%rsp), %rdi
movq 0x88(%rsp), %rdx
leaq 0x1074f(%rip), %rsi     # 0x18c1e
leaq 0x1069b(%rip), %rcx     # 0x18b71
movb $0x0, %al
callq 0x3060
movq 0x90(%rsp), %rdi
callq 0x34c0
cmpl $0x0, %eax
je 0x8521
movq 0x17afa(%rip), %rdi     # 0x1fff0
leaq 0x109f9(%rip), %rsi     # 0x18ef6
callq 0x3260
movq %rax, %rdi
movq 0x90(%rsp), %rsi
callq 0x3260
movq %rax, %rdi
movq 0x17aa4(%rip), %rsi     # 0x1ffc0
callq 0x32a0
jmp 0x8523
cmpl $0x1, 0x3c(%rsp)
jne 0x8556
movq 0x17abf(%rip), %rdi     # 0x1fff0
leaq 0x109f4(%rip), %rsi     # 0x18f2c
callq 0x3260
movq %rax, %rdi
movq 0x17a79(%rip), %rsi     # 0x1ffc0
callq 0x32a0
movl $0x1, %edi
callq 0x3300
movq 0x17a93(%rip), %rdi     # 0x1fff0
leaq 0x10a23(%rip), %rsi     # 0x18f87
callq 0x3260
movq %rax, %rdi
movq 0x17a4d(%rip), %rsi     # 0x1ffc0
callq 0x32a0
movq 0x68(%rsp), %rax
movq %rax, 0x10(%rsp)
cmpq $0x0, %rax
je 0x8592
movq 0x10(%rsp), %rdi
callq 0x3330
movq 0x90(%rsp), %rax
movq %rax, 0x8(%rsp)
cmpq $0x0, %rax
je 0x85af
movq 0x8(%rsp), %rdi
callq 0x3330
movq 0x88(%rsp), %rax
movq %rax, (%rsp)
cmpq $0x0, %rax
je 0x85ca
movq (%rsp), %rdi
callq 0x3330
addq $0xa8, %rsp
retq
nopw %cs:(%rax,%rax)