// File: /workspace/github_cpp_makefile_star2_O1/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %r8, %r15
movq %rcx, 0x70(%rsp)
movq %rdi, %r13
testq %r8, %r8
sete %al
testq %r9, %r9
setle %cl
orb %al, %cl
jne 0x2ad9
movl $0x1, %r10d
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %eax, %eax
movb -0x1(%r15,%r10), %dil
cmpb $0x3e, %dil
jne 0x2a9c
movslq 0xaf8(%rsi), %r8
leaq 0x1(%r8), %rdi
cmpq %rdi, %rcx
jle 0x2ac3
addq %rax, %rcx
subq %r8, %rcx
movq %rcx, %rax
xorl %r8d, %r8d
jmp 0x2aad
testq %r8, %r8
jne 0x2ab1
cmpb $0xa, %dil
jne 0x2ab1
movl $0x1, %r8d
xorl %ecx, %ecx
jmp 0x2ac6
xorl %edi, %edi
cmpq $0x1, %r8
sete %dil
addq %rdi, %rcx
movq %rdi, %r8
jmp 0x2ac6
xorl %r8d, %r8d
testq %r15, %r15
je 0x2add
leaq 0x1(%r10), %rdi
cmpq %r9, %r10
movq %rdi, %r10
jl 0x2a73
jmp 0x2add
xorl %eax, %eax
xorl %ecx, %ecx
movq %rdx, 0x48(%rsp)
testq %r15, %r15
sete %bl
movslq 0xaf8(%rsi), %rdx
movq %rcx, %r14
subq %rdx, %r14
incq %rdx
xorl %edi, %edi
cmpq %rdx, %rcx
cmovleq %rdi, %r14
addq %rax, %r14
movq %r14, 0x70(%r13)
movq %r14, %rax
shrq $0x3d, %rax
leaq (,%r14,8), %rcx
negq %rax
movl $0x0, %edi
sbbq %rdi, %rdi
orq %rcx, %rdi
movq %rsi, 0x18(%rsp)
movq %r9, 0x8(%rsp)
callq 0x2030
movq %rax, (%rsp)
testq %r14, %r14
movq $-0x1, %rdi
cmovnsq %r14, %rdi
callq 0x2030
movq %rax, 0x20(%rsp)
callq 0x2180
xorl %r8d, %r8d
movq 0x8(%rsp), %rdi
movq 0x18(%rsp), %r9
movq %rax, 0x28(%rsp)
testq %rdi, %rdi
setle %al
orb %bl, %al
movl $0x0, %ebp
movq %r13, 0x50(%rsp)
jne 0x2cb8
xorl %r12d, %r12d
xorl %ebp, %ebp
xorl %ecx, %ecx
xorl %r8d, %r8d
leaq (%r15,%r12), %r14
movzbl (%r15,%r12), %edx
cmpl $0x3e, %edx
jne 0x2c69
movslq 0xaf8(%r9), %rax
incq %rax
cmpq %rax, %rbp
jle 0x2ca2
movq %r14, %rbx
subq %rbp, %rbx
leaq -0x1(%r14), %rdx
movq (%rsp), %rax
leaq (%rax,%r8,8), %rcx
movq 0x20(%rsp), %rax
movq %r8, 0x10(%rsp)
addq %rax, %r8
movq %rbx, %rsi
movq 0x18(%rsp), %r9
callq 0x2812
movq 0x18(%rsp), %r9
movq %rax, %r13
movslq 0xaf8(%r9), %rax
movq %rbp, %rcx
subq %rax, %rcx
cmpq %rcx, %r13
je 0x2c3e
leaq 0x359c(%rip), %rdi      # 0x6197
movq %r13, %rsi
movq %rbp, %rdx
movq %r12, %r8
xorl %eax, %eax
callq 0x2050
testq %rbp, %rbp
js 0x2c20
movsbl (%rbx), %edi
callq 0x2370
incq %rbx
cmpq %r14, %rbx
jbe 0x2c10
movl $0xa, %edi
callq 0x2370
movq 0x6347(%rip), %rax      # 0x8f78
movq (%rax), %rdi
callq 0x22e0
movq 0x18(%rsp), %r9
movslq 0xaf8(%r9), %rax
subq %rax, %rbp
cmpq %rbp, %r13
movq 0x8(%rsp), %rdi
jne 0x3299
movq 0x10(%rsp), %r8
addq %r13, %r8
xorl %eax, %eax
xorl %ebp, %ebp
movq 0x50(%rsp), %r13
jmp 0x2ca4
movl $0x1, %eax
testq %rcx, %rcx
jne 0x2c7c
cmpb $0xa, %dl
jne 0x2c7c
xorl %ebp, %ebp
jmp 0x2ca4
cmpq $0x1, %rcx
jne 0x2ca2
leal -0x41(%rdx), %ecx
cmpl $0x13, %ecx
ja 0x2c94
movl $0x80045, %esi          # imm = 0x80045
btl %ecx, %esi
jb 0x2c9d
cmpl $0xa, %edx
je 0x2c9d
movb $0x41, (%r14)
incq %rbp
jmp 0x2ca4
xorl %eax, %eax
testq %r15, %r15
je 0x2cb8
incq %r12
movq %rax, %rcx
cmpq %rdi, %r12
jl 0x2b89
testq %r15, %r15
je 0x2cfa
movslq 0xaf8(%r9), %rax
incq %rax
cmpq %rax, %rbp
movq 0x20(%rsp), %rax
jle 0x2cfa
leaq (%r15,%rdi), %rsi
subq %rbp, %rsi
leaq (%r15,%rdi), %rdx
decq %rdx
movq (%rsp), %r15
leaq (%r15,%r8,8), %rcx
movq %r8, %rbx
addq %rax, %r8
callq 0x2812
movq %rbx, %r8
addq %rax, %r8
jmp 0x2cfe
movq (%rsp), %r15
cmpq %r8, 0x70(%r13)
movq 0x48(%rsp), %rbp
jne 0x32b8
movabsq $0x1fffffffffffffff, %rbx # imm = 0x1FFFFFFFFFFFFFFF
movq %r8, 0x70(%r13)
callq 0x2180
movq %rax, 0x30(%rsp)
movq 0x70(%r13), %r12
leaq (,%r12,8), %rdi
cmpq %rbx, %r12
movq $-0x1, %r13
movq %rdi, 0x10(%rsp)
cmovaq %r13, %rdi
callq 0x2030
movq %rax, %r14
testq %r12, %r12
movq $-0x1, %rdi
cmovnsq %r12, %rdi
callq 0x2030
movq %rax, %rbx
testq %r12, %r12
jle 0x2d83
movq %rbx, %rdi
xorl %esi, %esi
movq %r12, %rdx
callq 0x2140
movq %r14, %rdi
xorl %esi, %esi
movq 0x10(%rsp), %rdx
callq 0x2140
movq %rbx, 0x60(%rsp)
movq %r14, 0x40(%rsp)
movslq 0x4(%rbp), %r14
leaq (,%r14,4), %rax
testq %r14, %r14
movq %rax, 0x8(%rsp)
cmovnsq %rax, %r13
movq %r13, %rdi
callq 0x2030
movq %rax, %rbx
movq %r13, %rdi
callq 0x2030
movq %rax, 0x38(%rsp)
movq %r13, %rdi
callq 0x2030
movq %rax, 0x10(%rsp)
movq %r13, %rdi
movq %rbx, %r13
callq 0x2030
movq %rax, 0x58(%rsp)
testq %r14, %r14
jle 0x2e00
movq 0x38(%rsp), %rdi
xorl %esi, %esi
movq 0x8(%rsp), %rbx
movq %rbx, %rdx
callq 0x2140
movq %r13, %rdi
xorl %esi, %esi
movq %rbx, %rdx
callq 0x2140
movq %r13, 0x8(%rsp)
testq %r12, %r12
jle 0x2e3f
movq 0x18(%rsp), %rax
movl 0xaf8(%rax), %ebx
xorl %r13d, %r13d
movq (%r15,%r13,8), %rsi
movl %ebx, %edx
movq %rbp, %rcx
callq 0x27a8
cmpq %r14, %rax
jae 0x327a
movq 0x8(%rsp), %rcx
incl (%rcx,%rax,4)
incq %r13
cmpq %r13, %r12
jne 0x2e18
movq 0xd0(%rsp), %rax
movq 0xc8(%rsp), %r14
movq 0x30(%rsp), %rcx
subq 0x28(%rsp), %rcx
addq %rcx, (%rax)
callq 0x2180
movq %rax, %rbx
subq $0x8, %rsp
movq 0x6151(%rip), %rdx      # 0x8fc0
movq 0x10(%rsp), %r15
movq %r15, %rdi
movl $0x1, %esi
movq 0x40(%rsp), %r12
movq %r12, %rcx
movl $0x1, %r8d
movq %rdx, %r9
pushq 0x60fd(%rip)            # 0x8f90
callq 0x2130
addq $0x10, %rsp
callq 0x2180
subq %rbx, %rax
addq %rax, (%r14)
callq 0x2180
movslq 0x4(%rbp), %r8
testq %r8, %r8
jle 0x2ecf
xorl %ecx, %ecx
xorl %eax, %eax
movq 0x10(%rsp), %rdi
movslq (%r15,%rcx,4), %rdx
addq %rdx, %rax
incq %rcx
cmpq %rcx, %r8
jne 0x2ebe
jmp 0x2ed6
xorl %eax, %eax
movq 0x10(%rsp), %rdi
testl %r8d, %r8d
jle 0x2ef0
xorl %ecx, %ecx
xorl %esi, %esi
movslq (%r12,%rcx,4), %rdx
addq %rdx, %rsi
incq %rcx
cmpq %rcx, %r8
jne 0x2edf
jmp 0x2ef2
xorl %esi, %esi
movq 0x50(%rsp), %rcx
movq 0x70(%rcx), %r14
cmpq %r14, %rax
jne 0x32d7
movl $0x0, (%rdi)
cmpl $0x2, %r8d
jl 0x2f28
movl (%rdi), %eax
leaq -0x1(%r8), %rcx
xorl %edx, %edx
addl (%r15,%rdx,4), %eax
movl %eax, 0x4(%rdi,%rdx,4)
incq %rdx
cmpq %rdx, %rcx
jne 0x2f18
movq %rsi, 0x68(%rsp)
movq 0x58(%rsp), %rsi
movl $0x0, (%rsi)
cmpl $0x2, %r8d
jl 0x2f56
movl (%rsi), %eax
leaq -0x1(%r8), %rcx
xorl %edx, %edx
addl (%r12,%rdx,4), %eax
movl %eax, 0x4(%rsi,%rdx,4)
incq %rdx
cmpq %rdx, %rcx
jne 0x2f46
movq %r8, 0x30(%rsp)
testq %r14, %r14
movq 0x48(%rsp), %r15
movq (%rsp), %rcx
movq 0x40(%rsp), %rbx
movq 0x60(%rsp), %r13
jle 0x2fc4
movq 0x18(%rsp), %rax
movl 0xaf8(%rax), %eax
movl %eax, 0x28(%rsp)
xorl %ebp, %ebp
movq (%rcx,%rbp,8), %r12
movq %r12, %rsi
movl 0x28(%rsp), %edx
movq %r15, %rcx
callq 0x27a8
movq 0x20(%rsp), %r8
movq 0x10(%rsp), %rdi
movslq (%rdi,%rax,4), %rcx
movq %r12, (%rbx,%rcx,8)
movb (%r8,%rbp), %dl
leal 0x1(%rcx), %esi
movl %esi, (%rdi,%rax,4)
movb %dl, (%r13,%rcx)
movq (%rsp), %rcx
incq %rbp
cmpq %rbp, %r14
jne 0x2f84
movl $0x0, (%rdi)
movq 0x30(%rsp), %rdx
cmpl $0x2, %edx
movq 0x8(%rsp), %r12
jl 0x2ff0
movl (%rdi), %eax
decq %rdx
xorl %ecx, %ecx
addl (%r12,%rcx,4), %eax
movl %eax, 0x4(%rdi,%rcx,4)
incq %rcx
cmpq %rcx, %rdx
jne 0x2fe0
movq (%rsp), %rdi
callq 0x2330
movq 0x20(%rsp), %rdi
callq 0x2330
movq 0x68(%rsp), %r13
testq %r13, %r13
movq 0x48(%rsp), %rax
movq 0x40(%rsp), %rbp
movq 0x60(%rsp), %r15
jne 0x302e
movl (%rax), %esi
leaq 0x3232(%rip), %rdi      # 0x6257
xorl %edx, %edx
xorl %eax, %eax
callq 0x2050
movq 0x5f43(%rip), %rax      # 0x8f78
movq (%rax), %rdi
callq 0x22e0
leaq 0x1(%r13), %rbx
movabsq $0x1fffffffffffffff, %rax # imm = 0x1FFFFFFFFFFFFFFF
cmpq %rax, %rbx
leaq 0x8(,%r13,8), %rax
movq $-0x1, %rdi
cmovbeq %rax, %rdi
callq 0x2030
movq %rax, %r14
movq %rbx, %rdi
callq 0x2030
movq %rax, (%rsp)
callq 0x2180
callq 0x2180
movq %rax, 0x28(%rsp)
subq $0x8, %rsp
movq 0x5f19(%rip), %rcx      # 0x8fa8
movq %rbp, %rdi
movq %r12, %rsi
movq 0x18(%rsp), %rbx
movq %rbx, %rdx
movq %r14, 0x28(%rsp)
movq %r14, %r8
movq 0x40(%rsp), %rbp
movq %rbp, %r9
movq 0x5edc(%rip), %rax      # 0x8f90
pushq %rax
pushq %rcx
movq 0x70(%rsp), %r14
pushq %r14
callq 0x2420
addq $0x18, %rsp
movq 0x5eb3(%rip), %rcx      # 0x8f80
movq %r15, %rdi
movq %r12, %rsi
movq %rbx, %rdx
movq 0x8(%rsp), %r8
movq %rbp, %r9
pushq 0x5eac(%rip)            # 0x8f90
pushq %rcx
pushq %r14
callq 0x2420
addq $0x20, %rsp
callq 0x2180
subq 0x28(%rsp), %rax
movq 0xc8(%rsp), %rcx
addq %rax, (%rcx)
movq 0x40(%rsp), %rdi
callq 0x2330
movq %r15, %rdi
callq 0x2330
movq 0x50(%rsp), %rax
movq %r13, 0x70(%rax)
movq %rax, %r13
movq %r12, %rdi
callq 0x2330
movq %rbp, %rdi
callq 0x2330
movq %rbx, %rdi
callq 0x2330
movq %r14, %rdi
callq 0x2330
callq 0x2180
movq %rax, %r14
cmpq $0x0, 0x70(%r13)
jle 0x31e7
leaq 0x38(%r13), %r15
xorl %ebx, %ebx
movq 0x20(%rsp), %rbp
movq %r15, %rdi
movq %rbp, %rsi
callq 0x4a56
incq (%rax)
movq (%rbp), %rcx
movq %rcx, %rax
xorl %edx, %edx
divq 0x8(%r13)
movq %r13, %rdi
movq %rdx, %rsi
movq %rbp, %rdx
callq 0x4b68
testq %rax, %rax
je 0x3195
cmpq $0x0, (%rax)
jne 0x31c8
movq (%rbp), %rsi
movq 0x70(%rsp), %rdi
callq 0x4308
testl %eax, %eax
je 0x31c8
movq 0x18(%rsp), %rcx
movslq 0xb0c(%rcx), %r12
cmpl %r12d, %eax
jl 0x31d6
movq %r13, %rdi
movq %rbp, %rsi
callq 0x4a56
movq %r12, (%rax)
jmp 0x31d6
movq %r13, %rdi
movq %rbp, %rsi
callq 0x4a56
incq (%rax)
incq %rbx
addq $0x8, %rbp
cmpq 0x70(%r13), %rbx
jl 0x3161
callq 0x2180
subq %r14, %rax
movq 0xd0(%rsp), %rcx
addq %rax, (%rcx)
leaq 0x80(%rsp), %rbx
movq $0x0, (%rbx)
movq 0x18(%r13), %rax
leaq 0x78(%rsp), %r14
movq %rax, (%r14)
callq 0x2180
movq %rax, %r15
movq 0x5d84(%rip), %rcx      # 0x8fa8
movq 0x5d45(%rip), %r8       # 0x8f70
movq 0x5d5e(%rip), %r9       # 0x8f90
movq %r14, %rdi
movq %rbx, %rsi
movl $0x1, %edx
callq 0x2310
callq 0x2180
subq %r15, %rax
movq 0xc8(%rsp), %rcx
addq %rax, (%rcx)
movq 0x20(%rsp), %rdi
callq 0x2330
movq (%rsp), %rdi
callq 0x2330
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2f72(%rip), %rdi      # 0x61f3
leaq 0x2dbb(%rip), %rsi      # 0x6043
leaq 0x2e86(%rip), %rcx      # 0x6115
movl $0x12b, %edx            # imm = 0x12B
callq 0x2170
leaq 0x2f1d(%rip), %rdi      # 0x61bd
leaq 0x2d9c(%rip), %rsi      # 0x6043
leaq 0x2e67(%rip), %rcx      # 0x6115
movl $0xf4, %edx
callq 0x2170
leaq 0x2f21(%rip), %rdi      # 0x61e0
leaq 0x2d7d(%rip), %rsi      # 0x6043
leaq 0x2e48(%rip), %rcx      # 0x6115
movl $0x107, %edx            # imm = 0x107
callq 0x2170
leaq 0x2f53(%rip), %rdi      # 0x6231
leaq 0x2d5e(%rip), %rsi      # 0x6043
leaq 0x2e29(%rip), %rcx      # 0x6115
movl $0x138, %edx            # imm = 0x138
callq 0x2170