// File: /workspace/github_cpp_makefile_star2_O3/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
setne %al
testq %r9, %r9
setg %bl
andb %al, %bl
cmpb $0x1, %bl
jne 0x2ab8
xorl %r10d, %r10d
xorl %ecx, %ecx
xorl %r11d, %r11d
xorl %eax, %eax
movb (%r15,%r10), %dil
cmpb $0x3e, %dil
jne 0x2a7b
movslq 0xaf8(%rsi), %r8
leaq 0x1(%r8), %rdi
cmpq %rdi, %rcx
jle 0x2a99
addq %rax, %rcx
subq %r8, %rcx
movq %rcx, %rax
xorl %r11d, %r11d
jmp 0x2a95
testq %r11, %r11
sete %r8b
cmpb $0xa, %dil
sete %dil
testb %dil, %r8b
je 0x2a9e
movl $0x1, %r11d
xorl %ecx, %ecx
jmp 0x2aae
xorl %r11d, %r11d
jmp 0x2aae
xorl %edi, %edi
cmpq $0x1, %r11
sete %dil
addq %rdi, %rcx
movq %rdi, %r11
incq %r10
cmpq %r9, %r10
jl 0x2a53
jmp 0x2abc
xorl %eax, %eax
xorl %ecx, %ecx
movq %rdx, 0x28(%rsp)
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, 0x10(%rsp)
movq %r9, 0x18(%rsp)
callq 0x2030
movq %rax, (%rsp)
testq %r14, %r14
movq $-0x1, %rdi
cmovnsq %r14, %rdi
callq 0x2030
movq %rax, 0x20(%rsp)
callq 0x2180
movq 0x18(%rsp), %rdi
movq 0x10(%rsp), %r9
movq %rax, 0x30(%rsp)
movl $0x0, %r12d
testb %bl, %bl
movl $0x0, %ebx
movq %r13, 0x50(%rsp)
je 0x2c90
xorl %ebp, %ebp
xorl %r12d, %r12d
xorl %ecx, %ecx
xorl %ebx, %ebx
leaq (%r15,%rbp), %r14
movzbl (%r15,%rbp), %edx
cmpl $0x3e, %edx
jne 0x2c45
movslq 0xaf8(%r9), %rax
incq %rax
cmpq %rax, %r12
jle 0x2c7f
movq %r14, %r13
subq %r12, %r13
leaq -0x1(%r14), %rdx
movq (%rsp), %rax
leaq (%rax,%rbx,8), %rcx
movq 0x20(%rsp), %rax
movq %rbx, 0x8(%rsp)
leaq (%rax,%rbx), %r8
movq %r13, %rsi
movq 0x10(%rsp), %r9
callq 0x280e
movq 0x10(%rsp), %r9
movq %rax, %rbx
movslq 0xaf8(%r9), %rax
movq %r12, %rcx
subq %rax, %rcx
cmpq %rcx, %rbx
je 0x2c23
leaq 0x35c6(%rip), %rdi      # 0x6197
movq %rbx, %rsi
movq %r12, %rdx
movq %rbp, %r8
xorl %eax, %eax
callq 0x2050
testq %r12, %r12
js 0x2bf8
movsbl (%r13), %edi
callq 0x2370
incq %r13
cmpq %r14, %r13
jbe 0x2be6
movl $0xa, %edi
callq 0x2370
movq 0x636f(%rip), %rax      # 0x8f78
movq (%rax), %rdi
callq 0x22e0
movq 0x10(%rsp), %r9
movslq 0xaf8(%r9), %rax
subq %rax, %r12
movq %r12, %rcx
cmpq %rcx, %rbx
movq 0x50(%rsp), %r13
movq 0x18(%rsp), %rdi
jne 0x3272
movq 0x8(%rsp), %rax
addq %rbx, %rax
movq %rax, %rbx
xorl %eax, %eax
jmp 0x2c54
movl $0x1, %eax
testq %rcx, %rcx
jne 0x2c59
cmpb $0xa, %dl
jne 0x2c59
xorl %r12d, %r12d
jmp 0x2c81
cmpq $0x1, %rcx
jne 0x2c7f
leal -0x41(%rdx), %ecx
cmpl $0x13, %ecx
ja 0x2c71
movl $0x80045, %esi          # imm = 0x80045
btl %ecx, %esi
jb 0x2c7a
cmpl $0xa, %edx
je 0x2c7a
movb $0x41, (%r14)
incq %r12
jmp 0x2c81
xorl %eax, %eax
incq %rbp
movq %rax, %rcx
cmpq %rdi, %rbp
jl 0x2b5e
testq %r15, %r15
je 0x2ccb
movslq 0xaf8(%r9), %rax
incq %rax
cmpq %rax, %r12
jle 0x2ccb
leaq (%r15,%rdi), %rsi
subq %r12, %rsi
leaq (%r15,%rdi), %rdx
decq %rdx
movq (%rsp), %rax
leaq (%rax,%rbx,8), %rcx
movq 0x20(%rsp), %rax
leaq (%rax,%rbx), %r8
callq 0x280e
addq %rax, %rbx
movq 0x28(%rsp), %rbp
cmpq %rbx, 0x70(%r13)
jne 0x3291
movabsq $0x1fffffffffffffff, %rbx # imm = 0x1FFFFFFFFFFFFFFF
callq 0x2180
movq %rax, 0x38(%rsp)
movq 0x70(%r13), %r12
leaq (,%r12,8), %r14
cmpq %rbx, %r12
movq $-0x1, %rbx
movq %r14, %rdi
cmovaq %rbx, %rdi
callq 0x2030
movq %rax, %r15
testq %r12, %r12
movq $-0x1, %rdi
cmovnsq %r12, %rdi
callq 0x2030
movq %rax, %r13
testq %r12, %r12
jle 0x2d48
movq %r13, %rdi
xorl %esi, %esi
movq %r12, %rdx
callq 0x2140
movq %r15, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x2140
movq %r13, 0x58(%rsp)
movq %r15, 0x48(%rsp)
movslq 0x4(%rbp), %r14
leaq (,%r14,4), %rax
testq %r14, %r14
movq %rax, 0x8(%rsp)
cmovnsq %rax, %rbx
movq %rbx, %rdi
callq 0x2030
movq %rax, %r13
movq %rbx, %rdi
callq 0x2030
movq %rax, %r15
movq %rbx, %rdi
callq 0x2030
movq %rax, 0x18(%rsp)
movq %rbx, %rdi
movq %r13, %rbx
callq 0x2030
movq %rax, 0x40(%rsp)
testq %r14, %r14
jle 0x2dc1
movq %r15, %rdi
xorl %esi, %esi
movq 0x8(%rsp), %r13
movq %r13, %rdx
callq 0x2140
movq %rbx, %rdi
xorl %esi, %esi
movq %r13, %rdx
callq 0x2140
movq %r15, 0x60(%rsp)
movq %rbx, 0x8(%rsp)
testq %r12, %r12
movq (%rsp), %r13
jle 0x2e0a
movq 0x10(%rsp), %rax
movl 0xaf8(%rax), %ebx
xorl %r15d, %r15d
movq (%r13,%r15,8), %rsi
movl %ebx, %edx
movq %rbp, %rcx
callq 0x27a4
cmpq %r14, %rax
jae 0x3253
movq 0x8(%rsp), %rcx
incl (%rcx,%rax,4)
incq %r15
cmpq %r15, %r12
jne 0x2de2
movq 0xd0(%rsp), %rax
movq 0xc8(%rsp), %r14
movq 0x38(%rsp), %rcx
subq 0x30(%rsp), %rcx
addq %rcx, (%rax)
callq 0x2180
movq %rax, %rbx
subq $0x8, %rsp
movq 0x6186(%rip), %rdx      # 0x8fc0
movq 0x10(%rsp), %r15
movq %r15, %rdi
movl $0x1, %esi
movq 0x68(%rsp), %r13
movq %r13, %rcx
movl $0x1, %r8d
movq %rdx, %r9
pushq 0x6132(%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 0x2eb9
xorl %eax, %eax
xorl %r9d, %r9d
movq 0x20(%rsp), %r12
movq 0x18(%rsp), %rdi
movslq (%r15,%rax,4), %rcx
addq %rcx, %r9
incq %rax
cmpq %rax, %r8
jne 0x2e8f
testl %r8d, %r8d
jle 0x2eca
xorl %eax, %eax
xorl %edx, %edx
movslq (%r13,%rax,4), %rcx
addq %rcx, %rdx
incq %rax
cmpq %rax, %r8
jne 0x2ea7
jmp 0x2ecc
xorl %r9d, %r9d
xorl %edx, %edx
movq 0x20(%rsp), %r12
movq 0x18(%rsp), %rdi
jmp 0x2ecc
xorl %edx, %edx
movq 0x50(%rsp), %rax
cmpq 0x70(%rax), %r9
jne 0x32b0
movl $0x0, (%rdi)
cmpl $0x1, %r8d
movq %rdx, 0x38(%rsp)
movq %r8, 0x68(%rsp)
jle 0x2f31
leaq -0x1(%r8), %rax
xorl %ecx, %ecx
xorl %edx, %edx
addl (%r15,%rcx,4), %edx
movl %edx, 0x4(%rdi,%rcx,4)
incq %rcx
cmpq %rcx, %rax
jne 0x2ef9
movq 0x40(%rsp), %rsi
movl $0x0, (%rsi)
cmpl $0x2, %r8d
jl 0x2f3c
xorl %ecx, %ecx
xorl %edx, %edx
addl (%r13,%rcx,4), %edx
movl %edx, 0x4(%rsi,%rcx,4)
incq %rcx
cmpq %rcx, %rax
jne 0x2f1e
jmp 0x2f3c
movq 0x40(%rsp), %rax
movl $0x0, (%rax)
testq %r9, %r9
movq 0x28(%rsp), %r14
movq (%rsp), %rcx
movq 0x48(%rsp), %rbx
movq 0x58(%rsp), %rbp
jle 0x2fab
movq 0x10(%rsp), %rax
movl 0xaf8(%rax), %eax
movl %eax, 0x30(%rsp)
xorl %r15d, %r15d
movq (%rcx,%r15,8), %r12
movq %r12, %rsi
movl 0x30(%rsp), %edx
movq %r14, %rcx
movq %r9, %r13
callq 0x27a4
movq %r13, %r9
movq 0x18(%rsp), %rdi
movslq (%rdi,%rax,4), %rcx
movq %r12, (%rbx,%rcx,8)
movq 0x20(%rsp), %r12
movb (%r12,%r15), %dl
leal 0x1(%rcx), %esi
movl %esi, (%rdi,%rax,4)
movb %dl, (%rbp,%rcx)
movq (%rsp), %rcx
incq %r15
cmpq %r15, %r13
jne 0x2f66
movl $0x0, (%rdi)
movq 0x68(%rsp), %rsi
cmpl $0x2, %esi
movq 0x8(%rsp), %rdx
jl 0x2fd6
decq %rsi
xorl %eax, %eax
xorl %ecx, %ecx
addl (%rdx,%rax,4), %ecx
movl %ecx, 0x4(%rdi,%rax,4)
incq %rax
cmpq %rax, %rsi
jne 0x2fc7
movq (%rsp), %rdi
callq 0x2330
movq %r12, %rdi
callq 0x2330
movq 0x38(%rsp), %r13
testq %r13, %r13
movq 0x28(%rsp), %rax
movq 0x48(%rsp), %r12
movq 0x60(%rsp), %r15
jne 0x3012
movl (%rax), %esi
leaq 0x324e(%rip), %rdi      # 0x6257
xorl %edx, %edx
xorl %eax, %eax
callq 0x2050
movq 0x5f5f(%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, %rbx
callq 0x2180
callq 0x2180
movq %rax, 0x30(%rsp)
subq $0x8, %rsp
movq 0x5f36(%rip), %rcx      # 0x8fa8
movq %r12, %rdi
movq 0x10(%rsp), %r12
movq %r12, %rsi
movq 0x20(%rsp), %rbp
movq %rbp, %rdx
movq %r14, 0x8(%rsp)
movq %r14, %r8
movq %r15, %r9
movq 0x5ef9(%rip), %rax      # 0x8f90
pushq %rax
pushq %rcx
movq %r15, %r13
movq 0x58(%rsp), %r15
pushq %r15
callq 0x2420
addq $0x18, %rsp
movq 0x5ecd(%rip), %rcx      # 0x8f80
movq 0x60(%rsp), %r14
movq %r14, %rdi
movq %r12, %rsi
movq %rbp, %rdx
movq %rbx, 0x28(%rsp)
movq %rbx, %r8
movq %r13, %r9
pushq 0x5ebe(%rip)            # 0x8f90
pushq %rcx
pushq %r15
callq 0x2420
addq $0x20, %rsp
callq 0x2180
subq 0x30(%rsp), %rax
movq 0xc8(%rsp), %rcx
addq %rax, (%rcx)
movq 0x48(%rsp), %rdi
callq 0x2330
movq %r14, %rdi
callq 0x2330
movq 0x50(%rsp), %rax
movq 0x38(%rsp), %rcx
movq %rcx, 0x70(%rax)
movq %r13, %rbx
movq %rax, %r13
movq %r12, %rdi
callq 0x2330
movq %rbx, %rdi
callq 0x2330
movq %rbp, %rdi
callq 0x2330
movq %r15, %rdi
callq 0x2330
callq 0x2180
movq %rax, %r14
cmpq $0x0, 0x70(%r13)
jle 0x31c0
leaq 0x38(%r13), %r15
xorl %ebx, %ebx
movq (%rsp), %rbp
movq %r15, %rdi
movq %rbp, %rsi
callq 0x4ae0
incq (%rax)
movq %r13, %rdi
movq %rbp, %rsi
callq 0x4d82
testq %rax, %rax
je 0x318d
movq %r13, %rdi
movq %rbp, %rsi
callq 0x4ae0
incq (%rax)
incq %rbx
addq $0x8, %rbp
cmpq 0x70(%r13), %rbx
jl 0x3152
jmp 0x31c0
movq (%rbp), %rsi
movq 0x70(%rsp), %rdi
callq 0x436a
testl %eax, %eax
je 0x3170
movq 0x10(%rsp), %rcx
movslq 0xb0c(%rcx), %r12
cmpl %r12d, %eax
jl 0x317e
movq %r13, %rdi
movq %rbp, %rsi
callq 0x4ae0
movq %r12, (%rax)
jmp 0x317e
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 0x5dab(%rip), %rcx      # 0x8fa8
movq 0x5d6c(%rip), %r8       # 0x8f70
movq 0x5d85(%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 (%rsp), %rdi
callq 0x2330
movq 0x20(%rsp), %rdi
callq 0x2330
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2f99(%rip), %rdi      # 0x61f3
leaq 0x2de2(%rip), %rsi      # 0x6043
leaq 0x2ead(%rip), %rcx      # 0x6115
movl $0x12b, %edx            # imm = 0x12B
callq 0x2170
leaq 0x2f44(%rip), %rdi      # 0x61bd
leaq 0x2dc3(%rip), %rsi      # 0x6043
leaq 0x2e8e(%rip), %rcx      # 0x6115
movl $0xf4, %edx
callq 0x2170
leaq 0x2f48(%rip), %rdi      # 0x61e0
leaq 0x2da4(%rip), %rsi      # 0x6043
leaq 0x2e6f(%rip), %rcx      # 0x6115
movl $0x107, %edx            # imm = 0x107
callq 0x2170
leaq 0x2f7a(%rip), %rdi      # 0x6231
leaq 0x2d85(%rip), %rsi      # 0x6043
leaq 0x2e50(%rip), %rcx      # 0x6115
movl $0x138, %edx            # imm = 0x138
callq 0x2170
nop