// File: Mengjintao[P]SWAPCounter/src/kmerGraph.cpp
// Function: kmerGraph::extractKmerGraph(parameter*, MPIEnviroment*, bloomFilter*, char*, long long, long long, long&, long&)
void kmerGraph::extractKmerGraph(parameter *parameters, MPIEnviroment *MPIcontrol, bloomFilter *bFilter, char *readBuf, long long int localEnd, long long int readRound, clock_t & commTime, clock_t & checkTime)
{
		clock_t t0, t1;
		clock_t tt0, tt1;

		long long int tot_kmer_num = 0, localTag=0, localLen=0;
		for(long long int i=0; i<localEnd&&readBuf; i++)
		{
			if(readBuf[i]=='>')	
			{	
				localTag=0;	
				if(localLen <= parameters->hashLength+1)	continue;
				tot_kmer_num += localLen-parameters->hashLength;
				localLen = 0;
			}
			else if(localTag==0&&readBuf[i]=='\n')	localTag=1, localLen=0;
			else if(localTag==1)			localLen++;
		}	
		if(localLen>parameters->hashLength+1)	tot_kmer_num += localLen-parameters->hashLength;
		size  = tot_kmer_num;

		unsigned long long *kmers = new unsigned long long [size];
		unsigned char      *arcs  = new unsigned char      [size];
		assert(kmers && arcs);	
	
		tt0 = clock();		
		tot_kmer_num=0, localTag=0, localLen=0;
		for(long long int i=0; i<localEnd&&readBuf; i++)
		{
			if(readBuf[i]=='>')	
			{	
				localTag=0;	
				if(localLen <= parameters->hashLength+1)	continue;
				long long r = addKmers(readBuf+i-localLen, readBuf+i-1, kmers+tot_kmer_num, arcs+tot_kmer_num, parameters); 
			
				if(r!=localLen-parameters->hashLength)
				{
					printf("------r = %ld %ld %ld %ld-----------\n", r, localLen, localLen-parameters->hashLength, i);
					for(char *p=readBuf+i-localLen; p<=readBuf+i;p++)	printf("%c", *p);
					printf("\n");
					fflush(stdout);
				}
				assert(r==localLen-parameters->hashLength);
				localLen = 0;
				tot_kmer_num += r;
			}
			else if(localTag==0&&readBuf[i]=='\n')	localTag=1, localLen=0;
			else if(localTag==1)			
			{
				if(readBuf[i]=='A'||readBuf[i]=='T'||readBuf[i]=='C'||readBuf[i]=='G'|| readBuf[i]=='\n');
				else	readBuf[i]='A';				
				localLen++;
			}
		}	
	
		if(localLen>parameters->hashLength+1&&readBuf)	{
//			if(readBuf[localEnd]!='>')	localLen--;
			long long r = addKmers(readBuf+localEnd-localLen, readBuf+localEnd-1, kmers+tot_kmer_num, arcs+tot_kmer_num, parameters); 
			tot_kmer_num += r;
		//	assert(r==localLen-parameters->hashLength);
		}
		assert(size==tot_kmer_num);
		size  = tot_kmer_num;
//		readRound++;

		tt1 = clock();
//		MPI_Barrier(MPI_COMM_WORLD);
//		if(MPIcontrol->rank==0)	printf("Proc %d: OK in Barrier 2, size=%lld\n", MPIcontrol->rank, size);

		//arrange kmers and arcs before the communication step
		unsigned long long *kmers_send = new unsigned long long [size];
		assert(kmers_send != NULL);
		unsigned char      *arcs_send  = new unsigned char      [size];
		assert(arcs_send != NULL);
		for(long long i=0; i < size; i++)	kmers_send[i] = arcs_send[i] = 0;

		int  *send_size = new int [MPIcontrol->nprocs];
		assert(send_size!=NULL);
		int  *recv_size = new int [MPIcontrol->nprocs];
		assert(recv_size!=NULL);
		int  *send_pos  = new int [MPIcontrol->nprocs];
		assert(send_pos!=NULL);
		int  *recv_pos  = new int [MPIcontrol->nprocs];
		assert(recv_pos!=NULL);

		for(int i=0; i<MPIcontrol->nprocs; i++)	send_size[i] = recv_size[i] = 0;

//		if(MPIcontrol->rank==0)	printf("Proc %d: OK in Barrier 2 size=%llu\n", MPIcontrol->rank, size);
//		fflush(stdout);
//		MPI_Barrier(MPI_COMM_WORLD);

		unsigned long long send_sum=0,  recv_sum=0;
		unsigned long long ProcsID;	

		for(long long i=0; i<size; i++)
		{
			ProcsID = getProcsID(kmers[i], parameters->hashLength, MPIcontrol);
			assert(ProcsID>=0 && ProcsID<(unsigned long long) MPIcontrol->nprocs);
			send_size[ProcsID]++;
		}

		checkTime += tt1-tt0;
		t0 = clock();
//		MPI_Barrier(MPI_COMM_WORLD);
		MPI_Alltoall(send_size, 1, MPI_INT, recv_size, 1, MPI_INT, MPI_COMM_WORLD);
		t1 = clock();
		commTime += (t1-t0);
		tt0 = clock();
		for(int i=0; i<MPIcontrol->nprocs; i++)	send_sum += send_size[i];
		for(int i=0; i<MPIcontrol->nprocs; i++)	recv_sum += recv_size[i];
		assert(send_sum == (unsigned long long) size);
	
//		MPI_Barrier(MPI_COMM_WORLD);
//		if(MPIcontrol->rank==0)	printf("Proc %d: OK in Barrier 3\n", MPIcontrol->rank);
//		printf("Proc %d: send_sum=%llu recv_sum=%llu\n", MPIcontrol->rank, send_sum, recv_sum);

		send_pos[0] = 0;
		for(int i=1; i<MPIcontrol->nprocs; i++)	send_pos[i] = send_pos[i-1] + send_size[i-1];
		recv_pos[0] = 0;
		for(int i=1; i<MPIcontrol->nprocs; i++)	recv_pos[i] = recv_pos[i-1] + recv_size[i-1];
//	        printf("proc%d: ", MPIcontrol->rank);
//        	for(int i=0;i<size;i++) printf("send_size[%d]=%d ", i, send_size[i]);
//        	printf("\t");
//		printf("proc%d: ", MPIcontrol->rank);
//       	for(int i=0;i<size;i++) printf("recv_size[%d]=%d ", i, recv_size[i]);

		for(long long i=0; i<size; i++)
		{
			ProcsID = getProcsID(kmers[i], parameters->hashLength, MPIcontrol);
			kmers_send[send_pos[ProcsID]]  = kmers[i]; 
			arcs_send[send_pos[ProcsID]++] = arcs[i];	
		}

		send_pos[0] = 0;
		for(int i=1; i<MPIcontrol->nprocs; i++)	send_pos[i] = send_pos[i-1] + send_size[i-1];

		delete [] kmers;
		delete [] arcs;
		kmers = NULL;  arcs=NULL;	
		if(recv_sum==0)	printf("Proc %d: recv_sum = %lld \n", MPIcontrol->rank, recv_sum);
		fflush(stdout);

//		MPI_Barrier(MPI_COMM_WORLD);
		kmers = new unsigned long long [recv_sum+1];
		assert(kmers!=NULL);
		arcs  = new unsigned char      [recv_sum+1];
		assert(arcs!=NULL);
		
//		MPI_Barrier(MPI_COMM_WORLD);
//		if(MPIcontrol->rank==0)	printf("Proc %d: OK in Barrier 4\n", MPIcontrol->rank);

		tt1 = clock();
//		checkTime += tt1-tt0;
		t0 = clock();
		MPI_Alltoallv(kmers_send,send_size,send_pos, MPI_LONG_LONG_INT, kmers,recv_size,recv_pos, MPI_LONG_LONG_INT, MPI_COMM_WORLD);	
		MPI_Alltoallv(arcs_send, send_size,send_pos, MPI_CHAR,          arcs, recv_size,recv_pos, MPI_CHAR,          MPI_COMM_WORLD);
	//	printf("Proc %d: AlltoAll Finished\n", MPIcontrol->rank);
		t1 = clock();
		commTime += (t1-t0);

		delete [] kmers_send;
		delete [] arcs_send;
		kmers_send = NULL;	arcs_send = NULL;
		size  = recv_sum;
	
		delete [] send_size;
		delete [] recv_size;
		delete [] send_pos;
		delete [] recv_pos;
		send_size = recv_size = send_pos = recv_pos = NULL;

		tt0 = clock();
		for(long long i=0;i<size;i++)
		{
			tmp[kmers[i]]++;

			if(kmolecules.find(kmers[i])!=kmolecules.end())	 kmolecules[kmers[i]]++;
			else 
			{
				int retFilter = bFilter->bloomAdd(kmers[i]);
				if( retFilter==0 )		kmolecules[kmers[i]]++;
				else if( retFilter < parameters->cutoffThreshold)	continue;	
	//			int ProcsID = getProcsID(kmers[i], parameters->hashLength, MPIcontrol);
	//			assert(ProcsID == MPIcontrol->rank);
	//			unsigned char *p = (unsigned char *) &kmolecules[kmers[i]];
	//			for(int j=0; j<8; j++) 	if(p[j]<250)	p[j] += ((arcs[i]&(1<<j))?1:0);
				else				kmolecules[kmers[i]]=parameters->cutoffThreshold;
			}
		}
	
		tt1 = clock();
		checkTime += tt1-tt0;
	
		long long int tot_kmol=0, cur_kmol=kmolecules.size();
		t0 = clock();
		MPI_Allreduce(&cur_kmol, &tot_kmol, 1, MPI_LONG_LONG_INT, MPI_SUM, MPI_COMM_WORLD);
//		if(MPIcontrol->rank==0)	printf("Proc %d: %llu Num of kmolecules is %llu(totNum is %llu)\n", MPIcontrol->rank, readRound, cur_kmol, tot_kmol);
		t1 = clock();
		commTime += (t1-t0);

		delete [] kmers;
		delete [] arcs;
		kmers=NULL;	arcs=NULL;
}

// Assembly:
subq $0x1d8, %rsp            # imm = 0x1D8
movq 0x1f0(%rsp), %rax
movq 0x1e8(%rsp), %rax
movq 0x1e0(%rsp), %rax
movq %rdi, 0x1d0(%rsp)
movq %rsi, 0x1c8(%rsp)
movq %rdx, 0x1c0(%rsp)
movq %rcx, 0x1b8(%rsp)
movq %r8, 0x1b0(%rsp)
movq %r9, 0x1a8(%rsp)
movq 0x1d0(%rsp), %rax
movq %rax, 0x80(%rsp)
movq $0x0, 0x180(%rsp)
movq $0x0, 0x178(%rsp)
movq $0x0, 0x170(%rsp)
movq $0x0, 0x168(%rsp)
movq 0x168(%rsp), %rcx
xorl %eax, %eax
cmpq 0x1a8(%rsp), %rcx
movb %al, 0x7f(%rsp)
jge 0x9b07
cmpq $0x0, 0x1b0(%rsp)
setne %al
movb %al, 0x7f(%rsp)
movb 0x7f(%rsp), %al
testb $0x1, %al
jne 0x9b14
jmp 0x9c13
movq 0x1b0(%rsp), %rax
movq 0x168(%rsp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x3e, %eax
jne 0x9b97
movq $0x0, 0x178(%rsp)
movq 0x170(%rsp), %rax
movq 0x1c8(%rsp), %rcx
movl 0xaf8(%rcx), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
cmpq %rcx, %rax
jg 0x9b5f
jmp 0x9bfa
movq 0x170(%rsp), %rax
movq 0x1c8(%rsp), %rcx
movslq 0xaf8(%rcx), %rcx
subq %rcx, %rax
addq 0x180(%rsp), %rax
movq %rax, 0x180(%rsp)
movq $0x0, 0x170(%rsp)
jmp 0x9bf8
cmpq $0x0, 0x178(%rsp)
jne 0x9bd5
movq 0x1b0(%rsp), %rax
movq 0x168(%rsp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0xa, %eax
jne 0x9bd5
movq $0x1, 0x178(%rsp)
movq $0x0, 0x170(%rsp)
jmp 0x9bf6
cmpq $0x1, 0x178(%rsp)
jne 0x9bf4
movq 0x170(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x170(%rsp)
jmp 0x9bf6
jmp 0x9bf8
jmp 0x9bfa
movq 0x168(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x168(%rsp)
jmp 0x9adf
movq 0x170(%rsp), %rax
movq 0x1c8(%rsp), %rcx
movl 0xaf8(%rcx), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
cmpq %rcx, %rax
jle 0x9c5e
movq 0x170(%rsp), %rax
movq 0x1c8(%rsp), %rcx
movslq 0xaf8(%rcx), %rcx
subq %rcx, %rax
addq 0x180(%rsp), %rax
movq %rax, 0x180(%rsp)
movq 0x80(%rsp), %rax
movq 0x180(%rsp), %rcx
movq %rcx, 0x70(%rax)
movq 0x70(%rax), %rax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x8030
movq %rax, %rcx
movq 0x80(%rsp), %rax
movq %rcx, 0x160(%rsp)
movq 0x70(%rax), %rdi
movq $-0x1, %rax
cmpq $0x0, %rdi
cmovlq %rax, %rdi
callq 0x8030
movq %rax, 0x158(%rsp)
xorl %eax, %eax
cmpq $0x0, 0x160(%rsp)
movb %al, 0x7e(%rsp)
je 0x9ceb
cmpq $0x0, 0x158(%rsp)
setne %al
movb %al, 0x7e(%rsp)
movb 0x7e(%rsp), %al
testb $0x1, %al
jne 0x9cf5
jmp 0x9cf7
jmp 0x9d16
leaq 0xc4d0(%rip), %rdi      # 0x161ce
leaq 0xc34e(%rip), %rsi      # 0x16053
movl $0xe1, %edx
leaq 0xc4cb(%rip), %rcx      # 0x161dc
callq 0x83d0
callq 0x83e0
movq %rax, 0x190(%rsp)
movq $0x0, 0x180(%rsp)
movq $0x0, 0x178(%rsp)
movq $0x0, 0x170(%rsp)
movq $0x0, 0x150(%rsp)
movq 0x150(%rsp), %rcx
xorl %eax, %eax
cmpq 0x1a8(%rsp), %rcx
movb %al, 0x7d(%rsp)
jge 0x9d7b
cmpq $0x0, 0x1b0(%rsp)
setne %al
movb %al, 0x7d(%rsp)
movb 0x7d(%rsp), %al
testb $0x1, %al
jne 0x9d88
jmp 0xa0cc
movq 0x1b0(%rsp), %rax
movq 0x150(%rsp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x3e, %eax
jne 0x9fb6
movq $0x0, 0x178(%rsp)
movq 0x170(%rsp), %rax
movq 0x1c8(%rsp), %rcx
movl 0xaf8(%rcx), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
cmpq %rcx, %rax
jg 0x9dd7
jmp 0xa0b3
movq 0x80(%rsp), %rdi
movq 0x1b0(%rsp), %rsi
addq 0x150(%rsp), %rsi
xorl %eax, %eax
subq 0x170(%rsp), %rax
addq %rax, %rsi
movq 0x1b0(%rsp), %rdx
addq 0x150(%rsp), %rdx
addq $-0x1, %rdx
movq 0x160(%rsp), %rcx
movq 0x180(%rsp), %rax
shlq $0x3, %rax
addq %rax, %rcx
movq 0x158(%rsp), %r8
addq 0x180(%rsp), %r8
movq 0x1c8(%rsp), %r9
callq 0x93b0
movq %rax, 0x148(%rsp)
movq 0x148(%rsp), %rax
movq 0x170(%rsp), %rcx
movq 0x1c8(%rsp), %rdx
movslq 0xaf8(%rdx), %rdx
subq %rdx, %rcx
cmpq %rcx, %rax
je 0x9f45
movq 0x148(%rsp), %rsi
movq 0x170(%rsp), %rdx
movq 0x170(%rsp), %rcx
movq 0x1c8(%rsp), %rax
movslq 0xaf8(%rax), %rax
subq %rax, %rcx
movq 0x150(%rsp), %r8
leaq 0xc3ae(%rip), %rdi      # 0x1625e
movb $0x0, %al
callq 0x8040
movq 0x1b0(%rsp), %rax
addq 0x150(%rsp), %rax
xorl %ecx, %ecx
subq 0x170(%rsp), %rcx
addq %rcx, %rax
movq %rax, 0x140(%rsp)
movq 0x140(%rsp), %rax
movq 0x1b0(%rsp), %rcx
addq 0x150(%rsp), %rcx
cmpq %rcx, %rax
ja 0x9f28
movq 0x140(%rsp), %rax
movsbl (%rax), %esi
leaq 0xcc2c(%rip), %rdi      # 0x16b37
movb $0x0, %al
callq 0x8040
movq 0x140(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x140(%rsp)
jmp 0x9edc
leaq 0xc46b(%rip), %rdi      # 0x1639a
movb $0x0, %al
callq 0x8040
movq 0x13033(%rip), %rax     # 0x1cf70
movq (%rax), %rdi
callq 0x87b0
movq 0x148(%rsp), %rax
movq 0x170(%rsp), %rcx
movq 0x1c8(%rsp), %rdx
movslq 0xaf8(%rdx), %rdx
subq %rdx, %rcx
cmpq %rcx, %rax
jne 0x9f6e
jmp 0x9f8d
leaq 0xc30f(%rip), %rdi      # 0x16284
leaq 0xc0d7(%rip), %rsi      # 0x16053
movl $0xf4, %edx
leaq 0xc254(%rip), %rcx      # 0x161dc
callq 0x83d0
movq $0x0, 0x170(%rsp)
movq 0x148(%rsp), %rax
addq 0x180(%rsp), %rax
movq %rax, 0x180(%rsp)
jmp 0xa0b1
cmpq $0x0, 0x178(%rsp)
jne 0x9ff7
movq 0x1b0(%rsp), %rax
movq 0x150(%rsp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0xa, %eax
jne 0x9ff7
movq $0x1, 0x178(%rsp)
movq $0x0, 0x170(%rsp)
jmp 0xa0af
cmpq $0x1, 0x178(%rsp)
jne 0xa0ad
movq 0x1b0(%rsp), %rax
movq 0x150(%rsp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x41, %eax
je 0xa083
movq 0x1b0(%rsp), %rax
movq 0x150(%rsp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x54, %eax
je 0xa083
movq 0x1b0(%rsp), %rax
movq 0x150(%rsp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x43, %eax
je 0xa083
movq 0x1b0(%rsp), %rax
movq 0x150(%rsp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x47, %eax
je 0xa083
movq 0x1b0(%rsp), %rax
movq 0x150(%rsp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0xa, %eax
jne 0xa085
jmp 0xa099
movq 0x1b0(%rsp), %rax
movq 0x150(%rsp), %rcx
movb $0x41, (%rax,%rcx)
movq 0x170(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x170(%rsp)
jmp 0xa0af
jmp 0xa0b1
jmp 0xa0b3
movq 0x150(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x150(%rsp)
jmp 0x9d53
movq 0x170(%rsp), %rax
movq 0x1c8(%rsp), %rcx
movl 0xaf8(%rcx), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
cmpq %rcx, %rax
jle 0xa18d
cmpq $0x0, 0x1b0(%rsp)
je 0xa18d
movq 0x80(%rsp), %rdi
movq 0x1b0(%rsp), %rsi
addq 0x1a8(%rsp), %rsi
xorl %eax, %eax
subq 0x170(%rsp), %rax
addq %rax, %rsi
movq 0x1b0(%rsp), %rdx
addq 0x1a8(%rsp), %rdx
addq $-0x1, %rdx
movq 0x160(%rsp), %rcx
movq 0x180(%rsp), %rax
shlq $0x3, %rax
addq %rax, %rcx
movq 0x158(%rsp), %r8
addq 0x180(%rsp), %r8
movq 0x1c8(%rsp), %r9
callq 0x93b0
movq %rax, 0x138(%rsp)
movq 0x138(%rsp), %rax
addq 0x180(%rsp), %rax
movq %rax, 0x180(%rsp)
movq 0x80(%rsp), %rax
movq 0x70(%rax), %rax
cmpq 0x180(%rsp), %rax
jne 0xa1a5
jmp 0xa1c4
leaq 0xc0fb(%rip), %rdi      # 0x162a7
leaq 0xbea0(%rip), %rsi      # 0x16053
movl $0x107, %edx            # imm = 0x107
leaq 0xc01d(%rip), %rcx      # 0x161dc
callq 0x83d0
movq 0x80(%rsp), %rax
movq 0x180(%rsp), %rcx
movq %rcx, 0x70(%rax)
callq 0x83e0
movq %rax, %rcx
movq 0x80(%rsp), %rax
movq %rcx, 0x188(%rsp)
movq 0x70(%rax), %rax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x8030
movq %rax, 0x130(%rsp)
cmpq $0x0, 0x130(%rsp)
je 0xa22a
jmp 0xa249
leaq 0xc089(%rip), %rdi      # 0x162ba
leaq 0xbe1b(%rip), %rsi      # 0x16053
movl $0x111, %edx            # imm = 0x111
leaq 0xbf98(%rip), %rcx      # 0x161dc
callq 0x83d0
movq 0x80(%rsp), %rax
movq 0x70(%rax), %rdi
movq $-0x1, %rax
cmpq $0x0, %rdi
cmovlq %rax, %rdi
callq 0x8030
movq %rax, 0x128(%rsp)
cmpq $0x0, 0x128(%rsp)
je 0xa27e
jmp 0xa29d
leaq 0xc048(%rip), %rdi      # 0x162cd
leaq 0xbdc7(%rip), %rsi      # 0x16053
movl $0x113, %edx            # imm = 0x113
leaq 0xbf44(%rip), %rcx      # 0x161dc
callq 0x83d0
movq $0x0, 0x120(%rsp)
movq 0x80(%rsp), %rcx
movq 0x120(%rsp), %rax
cmpq 0x70(%rcx), %rax
jge 0xa301
movq 0x128(%rsp), %rax
movq 0x120(%rsp), %rcx
movb $0x0, (%rax,%rcx)
movq 0x130(%rsp), %rax
movq 0x120(%rsp), %rcx
movq $0x0, (%rax,%rcx,8)
movq 0x120(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x120(%rsp)
jmp 0xa2a9
movq 0x1c0(%rsp), %rax
movslq 0x4(%rax), %rax
movl $0x4, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x8030
movq %rax, 0x118(%rsp)
cmpq $0x0, 0x118(%rsp)
je 0xa343
jmp 0xa362
leaq 0xbf95(%rip), %rdi      # 0x162df
leaq 0xbd02(%rip), %rsi      # 0x16053
movl $0x117, %edx            # imm = 0x117
leaq 0xbe7f(%rip), %rcx      # 0x161dc
callq 0x83d0
movq 0x1c0(%rsp), %rax
movslq 0x4(%rax), %rax
movl $0x4, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x8030
movq %rax, 0x110(%rsp)
cmpq $0x0, 0x110(%rsp)
je 0xa3a4
jmp 0xa3c3
leaq 0xbf44(%rip), %rdi      # 0x162ef
leaq 0xbca1(%rip), %rsi      # 0x16053
movl $0x119, %edx            # imm = 0x119
leaq 0xbe1e(%rip), %rcx      # 0x161dc
callq 0x83d0
movq 0x1c0(%rsp), %rax
movslq 0x4(%rax), %rax
movl $0x4, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x8030
movq %rax, 0x108(%rsp)
cmpq $0x0, 0x108(%rsp)
je 0xa405
jmp 0xa424
leaq 0xbef3(%rip), %rdi      # 0x162ff
leaq 0xbc40(%rip), %rsi      # 0x16053
movl $0x11b, %edx            # imm = 0x11B
leaq 0xbdbd(%rip), %rcx      # 0x161dc
callq 0x83d0
movq 0x1c0(%rsp), %rax
movslq 0x4(%rax), %rax
movl $0x4, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x8030
movq %rax, 0x100(%rsp)
cmpq $0x0, 0x100(%rsp)
je 0xa466
jmp 0xa485
leaq 0xbea1(%rip), %rdi      # 0x1630e
leaq 0xbbdf(%rip), %rsi      # 0x16053
movl $0x11d, %edx            # imm = 0x11D
leaq 0xbd5c(%rip), %rcx      # 0x161dc
callq 0x83d0
movl $0x0, 0xfc(%rsp)
movl 0xfc(%rsp), %eax
movq 0x1c0(%rsp), %rcx
cmpl 0x4(%rcx), %eax
jge 0xa4e5
movq 0x110(%rsp), %rax
movslq 0xfc(%rsp), %rcx
movl $0x0, (%rax,%rcx,4)
movq 0x118(%rsp), %rax
movslq 0xfc(%rsp), %rcx
movl $0x0, (%rax,%rcx,4)
movl 0xfc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xfc(%rsp)
jmp 0xa490
movq $0x0, 0xf0(%rsp)
movq $0x0, 0xe8(%rsp)
movq $0x0, 0xd8(%rsp)
movq 0x80(%rsp), %rcx
movq 0xd8(%rsp), %rax
cmpq 0x70(%rcx), %rax
jge 0xa5ee
movq 0x80(%rsp), %rdi
movq 0x160(%rsp), %rax
movq 0xd8(%rsp), %rcx
movq (%rax,%rcx,8), %rsi
movq 0x1c8(%rsp), %rax
movl 0xaf8(%rax), %edx
movq 0x1c0(%rsp), %rcx
callq 0x9290
movq %rax, 0xe0(%rsp)
xorl %eax, %eax
cmpq $0x0, 0xe0(%rsp)
movb %al, 0x7c(%rsp)
jb 0xa591
movq 0xe0(%rsp), %rax
movq 0x1c0(%rsp), %rcx
movslq 0x4(%rcx), %rcx
cmpq %rcx, %rax
setb %al
movb %al, 0x7c(%rsp)
movb 0x7c(%rsp), %al
testb $0x1, %al
jne 0xa59b
jmp 0xa59d
jmp 0xa5bc
leaq 0xbd79(%rip), %rdi      # 0x1631d
leaq 0xbaa8(%rip), %rsi      # 0x16053
movl $0x12b, %edx            # imm = 0x12B
leaq 0xbc25(%rip), %rcx      # 0x161dc
callq 0x83d0
movq 0x118(%rsp), %rax
movq 0xe0(%rsp), %rcx
movl (%rax,%rcx,4), %edx
addl $0x1, %edx
movl %edx, (%rax,%rcx,4)
movq 0xd8(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xd8(%rsp)
jmp 0xa509
movq 0x188(%rsp), %rcx
subq 0x190(%rsp), %rcx
movq 0x1f0(%rsp), %rax
addq (%rax), %rcx
movq %rcx, (%rax)
callq 0x83e0
movq %rax, 0x1a0(%rsp)
movq 0x118(%rsp), %rdi
movq 0x110(%rsp), %rcx
movl $0x1, %r8d
movq 0x1298a(%rip), %r9      # 0x1cfc0
movq 0x12953(%rip), %rax     # 0x1cf90
movl %r8d, %esi
movq %r9, %rdx
movq %rax, (%rsp)
callq 0x82b0
callq 0x83e0
movq %rax, 0x198(%rsp)
movq 0x198(%rsp), %rcx
subq 0x1a0(%rsp), %rcx
movq 0x1e8(%rsp), %rax
addq (%rax), %rcx
movq %rcx, (%rax)
callq 0x83e0
movq %rax, 0x190(%rsp)
movl $0x0, 0xd4(%rsp)
movl 0xd4(%rsp), %eax
movq 0x1c0(%rsp), %rcx
cmpl 0x4(%rcx), %eax
jge 0xa6da
movq 0x118(%rsp), %rax
movslq 0xd4(%rsp), %rcx
movslq (%rax,%rcx,4), %rax
addq 0xf0(%rsp), %rax
movq %rax, 0xf0(%rsp)
movl 0xd4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xd4(%rsp)
jmp 0xa68f
movl $0x0, 0xd0(%rsp)
movl 0xd0(%rsp), %eax
movq 0x1c0(%rsp), %rcx
cmpl 0x4(%rcx), %eax
jge 0xa730
movq 0x110(%rsp), %rax
movslq 0xd0(%rsp), %rcx
movslq (%rax,%rcx,4), %rax
addq 0xe8(%rsp), %rax
movq %rax, 0xe8(%rsp)
movl 0xd0(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xd0(%rsp)
jmp 0xa6e5
movq 0x80(%rsp), %rcx
movq 0xf0(%rsp), %rax
cmpq 0x70(%rcx), %rax
jne 0xa748
jmp 0xa767
leaq 0xbc0c(%rip), %rdi      # 0x1635b
leaq 0xb8fd(%rip), %rsi      # 0x16053
movl $0x138, %edx            # imm = 0x138
leaq 0xba7a(%rip), %rcx      # 0x161dc
callq 0x83d0
movq 0x108(%rsp), %rax
movl $0x0, (%rax)
movl $0x1, 0xcc(%rsp)
movl 0xcc(%rsp), %eax
movq 0x1c0(%rsp), %rcx
cmpl 0x4(%rcx), %eax
jge 0xa7ea
movq 0x108(%rsp), %rax
movl 0xcc(%rsp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %edx
movq 0x118(%rsp), %rax
movl 0xcc(%rsp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
addl (%rax,%rcx,4), %edx
movq 0x108(%rsp), %rax
movslq 0xcc(%rsp), %rcx
movl %edx, (%rax,%rcx,4)
movl 0xcc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xcc(%rsp)
jmp 0xa780
movq 0x100(%rsp), %rax
movl $0x0, (%rax)
movl $0x1, 0xc8(%rsp)
movl 0xc8(%rsp), %eax
movq 0x1c0(%rsp), %rcx
cmpl 0x4(%rcx), %eax
jge 0xa86d
movq 0x100(%rsp), %rax
movl 0xc8(%rsp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %edx
movq 0x110(%rsp), %rax
movl 0xc8(%rsp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
addl (%rax,%rcx,4), %edx
movq 0x100(%rsp), %rax
movslq 0xc8(%rsp), %rcx
movl %edx, (%rax,%rcx,4)
movl 0xc8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xc8(%rsp)
jmp 0xa803
movq $0x0, 0xc0(%rsp)
movq 0x80(%rsp), %rcx
movq 0xc0(%rsp), %rax
cmpq 0x70(%rcx), %rax
jge 0xa95e
movq 0x80(%rsp), %rdi
movq 0x160(%rsp), %rax
movq 0xc0(%rsp), %rcx
movq (%rax,%rcx,8), %rsi
movq 0x1c8(%rsp), %rax
movl 0xaf8(%rax), %edx
movq 0x1c0(%rsp), %rcx
callq 0x9290
movq %rax, 0xe0(%rsp)
movq 0x160(%rsp), %rax
movq 0xc0(%rsp), %rcx
movq (%rax,%rcx,8), %rdx
movq 0x130(%rsp), %rax
movq 0x108(%rsp), %rcx
movq 0xe0(%rsp), %rsi
movslq (%rcx,%rsi,4), %rcx
movq %rdx, (%rax,%rcx,8)
movq 0x158(%rsp), %rax
movq 0xc0(%rsp), %rcx
movb (%rax,%rcx), %dl
movq 0x128(%rsp), %rax
movq 0x108(%rsp), %rsi
movq 0xe0(%rsp), %rdi
movl (%rsi,%rdi,4), %ecx
movl %ecx, %r8d
addl $0x1, %r8d
movl %r8d, (%rsi,%rdi,4)
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
movq 0xc0(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xc0(%rsp)
jmp 0xa879
movq 0x108(%rsp), %rax
movl $0x0, (%rax)
movl $0x1, 0xbc(%rsp)
movl 0xbc(%rsp), %eax
movq 0x1c0(%rsp), %rcx
cmpl 0x4(%rcx), %eax
jge 0xa9e1
movq 0x108(%rsp), %rax
movl 0xbc(%rsp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %edx
movq 0x118(%rsp), %rax
movl 0xbc(%rsp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
addl (%rax,%rcx,4), %edx
movq 0x108(%rsp), %rax
movslq 0xbc(%rsp), %rcx
movl %edx, (%rax,%rcx,4)
movl 0xbc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xbc(%rsp)
jmp 0xa977
movq 0x160(%rsp), %rax
movq %rax, 0x70(%rsp)
cmpq $0x0, %rax
je 0xa9fe
movq 0x70(%rsp), %rdi
callq 0x8870
movq 0x158(%rsp), %rax
movq %rax, 0x68(%rsp)
cmpq $0x0, %rax
je 0xaa1b
movq 0x68(%rsp), %rdi
callq 0x8870
movq $0x0, 0x160(%rsp)
movq $0x0, 0x158(%rsp)
cmpq $0x0, 0xe8(%rsp)
jne 0xaa5e
movq 0x1c0(%rsp), %rax
movl (%rax), %esi
movq 0xe8(%rsp), %rdx
leaq 0xb92a(%rip), %rdi      # 0x16381
movb $0x0, %al
callq 0x8040
movq 0x1250b(%rip), %rax     # 0x1cf70
movq (%rax), %rdi
callq 0x87b0
movq 0xe8(%rsp), %rax
addq $0x1, %rax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x8030
movq %rax, 0x160(%rsp)
cmpq $0x0, 0x160(%rsp)
je 0xaaaf
jmp 0xaace
leaq 0xb8e6(%rip), %rdi      # 0x1639c
leaq 0xb596(%rip), %rsi      # 0x16053
movl $0x15a, %edx            # imm = 0x15A
leaq 0xb713(%rip), %rcx      # 0x161dc
callq 0x83d0
movq 0xe8(%rsp), %rdi
addq $0x1, %rdi
callq 0x8030
movq %rax, 0x158(%rsp)
cmpq $0x0, 0x158(%rsp)
je 0xaaf4
jmp 0xab13
leaq 0xb8ad(%rip), %rdi      # 0x163a8
leaq 0xb551(%rip), %rsi      # 0x16053
movl $0x15c, %edx            # imm = 0x15C
leaq 0xb6ce(%rip), %rcx      # 0x161dc
callq 0x83d0
callq 0x83e0
movq %rax, 0x188(%rsp)
callq 0x83e0
movq %rax, 0x1a0(%rsp)
movq 0x130(%rsp), %rdi
movq 0x118(%rsp), %rsi
movq 0x108(%rsp), %rdx
movq 0x160(%rsp), %r8
movq 0x110(%rsp), %r9
movq 0x100(%rsp), %r11
movq 0x1243c(%rip), %r10     # 0x1cfa0
movq 0x12425(%rip), %rax     # 0x1cf90
movq %r10, %rcx
movq %r11, (%rsp)
movq %r10, 0x8(%rsp)
movq %rax, 0x10(%rsp)
callq 0x8ac0
movq 0x128(%rsp), %rdi
movq 0x118(%rsp), %rsi
movq 0x108(%rsp), %rdx
movq 0x158(%rsp), %r8
movq 0x110(%rsp), %r9
movq 0x100(%rsp), %r11
movq 0x123c0(%rip), %r10     # 0x1cf78
movq 0x123d1(%rip), %rax     # 0x1cf90
movq %r10, %rcx
movq %r11, (%rsp)
movq %r10, 0x8(%rsp)
movq %rax, 0x10(%rsp)
callq 0x8ac0
callq 0x83e0
movq %rax, 0x198(%rsp)
movq 0x198(%rsp), %rcx
subq 0x1a0(%rsp), %rcx
movq 0x1e8(%rsp), %rax
addq (%rax), %rcx
movq %rcx, (%rax)
movq 0x130(%rsp), %rax
movq %rax, 0x60(%rsp)
cmpq $0x0, %rax
je 0xac1d
movq 0x60(%rsp), %rdi
callq 0x8870
movq 0x128(%rsp), %rax
movq %rax, 0x58(%rsp)
cmpq $0x0, %rax
je 0xac3a
movq 0x58(%rsp), %rdi
callq 0x8870
movq 0x80(%rsp), %rax
movq $0x0, 0x130(%rsp)
movq $0x0, 0x128(%rsp)
movq 0xe8(%rsp), %rcx
movq %rcx, 0x70(%rax)
movq 0x118(%rsp), %rax
movq %rax, 0x50(%rsp)
cmpq $0x0, %rax
je 0xac83
movq 0x50(%rsp), %rdi
callq 0x8870
movq 0x110(%rsp), %rax
movq %rax, 0x48(%rsp)
cmpq $0x0, %rax
je 0xaca0
movq 0x48(%rsp), %rdi
callq 0x8870
movq 0x108(%rsp), %rax
movq %rax, 0x40(%rsp)
cmpq $0x0, %rax
je 0xacbd
movq 0x40(%rsp), %rdi
callq 0x8870
movq 0x100(%rsp), %rax
movq %rax, 0x38(%rsp)
cmpq $0x0, %rax
je 0xacda
movq 0x38(%rsp), %rdi
callq 0x8870
movq $0x0, 0x100(%rsp)
movq $0x0, 0x108(%rsp)
movq $0x0, 0x110(%rsp)
movq $0x0, 0x118(%rsp)
callq 0x83e0
movq %rax, 0x190(%rsp)
movq $0x0, 0xb0(%rsp)
movq 0x80(%rsp), %rcx
movq 0xb0(%rsp), %rax
cmpq 0x70(%rcx), %rax
jge 0xaed8
movq 0x80(%rsp), %rdi
addq $0x38, %rdi
movq 0x160(%rsp), %rsi
movq 0xb0(%rsp), %rax
shlq $0x3, %rax
addq %rax, %rsi
callq 0xd250
movq 0x80(%rsp), %rdi
movq (%rax), %rcx
addq $0x1, %rcx
movq %rcx, (%rax)
movq 0x160(%rsp), %rsi
movq 0xb0(%rsp), %rax
shlq $0x3, %rax
addq %rax, %rsi
callq 0xd2a0
movq 0x80(%rsp), %rdi
movq %rax, 0xa8(%rsp)
callq 0xd2d0
movq %rax, 0xa0(%rsp)
leaq 0xa8(%rsp), %rdi
leaq 0xa0(%rsp), %rsi
callq 0xd280
testb $0x1, %al
jne 0xadcb
jmp 0xadfe
movq 0x80(%rsp), %rdi
movq 0x160(%rsp), %rsi
movq 0xb0(%rsp), %rax
shlq $0x3, %rax
addq %rax, %rsi
callq 0xd250
movq (%rax), %rcx
addq $0x1, %rcx
movq %rcx, (%rax)
jmp 0xaebd
movq 0x1b8(%rsp), %rdi
movq 0x160(%rsp), %rax
movq 0xb0(%rsp), %rcx
movq (%rax,%rcx,8), %rsi
callq 0xd300
movl %eax, 0x9c(%rsp)
cmpl $0x0, 0x9c(%rsp)
jne 0xae60
movq 0x80(%rsp), %rdi
movq 0x160(%rsp), %rsi
movq 0xb0(%rsp), %rax
shlq $0x3, %rax
addq %rax, %rsi
callq 0xd250
movq (%rax), %rcx
addq $0x1, %rcx
movq %rcx, (%rax)
jmp 0xaebb
movl 0x9c(%rsp), %eax
movq 0x1c8(%rsp), %rcx
cmpl 0xb0c(%rcx), %eax
jge 0xae79
jmp 0xaebf
movq 0x80(%rsp), %rdi
movq 0x1c8(%rsp), %rax
movslq 0xb0c(%rax), %rax
movq %rax, 0x30(%rsp)
movq 0x160(%rsp), %rsi
movq 0xb0(%rsp), %rax
shlq $0x3, %rax
addq %rax, %rsi
callq 0xd250
movq 0x30(%rsp), %rcx
movq %rcx, (%rax)
jmp 0xaebb
jmp 0xaebd
jmp 0xaebf
movq 0xb0(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xb0(%rsp)
jmp 0xad23
callq 0x83e0
movq 0x80(%rsp), %rdi
movq %rax, 0x188(%rsp)
movq 0x188(%rsp), %rcx
subq 0x190(%rsp), %rcx
movq 0x1f0(%rsp), %rax
addq (%rax), %rcx
movq %rcx, (%rax)
movq $0x0, 0x90(%rsp)
callq 0xd500
movq %rax, 0x88(%rsp)
callq 0x83e0
movq %rax, 0x1a0(%rsp)
leaq 0x88(%rsp), %rdi
leaq 0x90(%rsp), %rsi
movl $0x1, %edx
movq 0x12053(%rip), %rcx     # 0x1cfa0
movq 0x12014(%rip), %r8      # 0x1cf68
movq 0x12035(%rip), %r9      # 0x1cf90
callq 0x8820
callq 0x83e0
movq %rax, 0x198(%rsp)
movq 0x198(%rsp), %rcx
subq 0x1a0(%rsp), %rcx
movq 0x1e8(%rsp), %rax
addq (%rax), %rcx
movq %rcx, (%rax)
movq 0x160(%rsp), %rax
movq %rax, 0x28(%rsp)
cmpq $0x0, %rax
je 0xafa8
movq 0x28(%rsp), %rdi
callq 0x8870
movq 0x158(%rsp), %rax
movq %rax, 0x20(%rsp)
cmpq $0x0, %rax
je 0xafc5
movq 0x20(%rsp), %rdi
callq 0x8870
movq $0x0, 0x160(%rsp)
movq $0x0, 0x158(%rsp)
addq $0x1d8, %rsp            # imm = 0x1D8
retq
nopw %cs:(%rax,%rax)