// File: /workspace/github_cpp_makefile_star2_O2/Mengjintao[P]SWAPCounter/src/kmerGraph.cpp
// Function: main
int main(int argc, char *argv[])
{
	MPIEnviroment MPIcontrol;
	MPIcontrol.init(argc, argv);
	
	parameter parameters;
	parameters.getParameters(argc, argv, &MPIcontrol);	

	FILE *FP=NULL;
    	FP = fopen(parameters.LogPath, "a");
    	clock_t t0=0, t1=0;
    	if(MPIcontrol.rank==0)
	{
		t0 = clock();
    //		FP = fopen(parameters.LogPath, "w");
	}

	kmerGraph mygraph;
	bloomFilter bFilter((unsigned long long) parameters.refSize*4/MPIcontrol.nprocs, 3);
	if(DEBUG)   printf("Proc %d: MPIcontrol->groupProc %d\n", MPIcontrol.rank, MPIcontrol.groupProc);
	
	mygraph.constructKmerGraph(&parameters, &MPIcontrol, &bFilter);
	mygraph.printKmerFreq(&parameters, &MPIcontrol);
//	fflush(stdout);	
//	mygraph.printKmerCounting(&parameters, &MPIcontrol);	
    
    	if(MPIcontrol.rank==0)
   	{
		char message[1024];
		sprintf(message,"Time spend in I/O part in MPIcontrol %.5f\n", MPIcontrol.elapsedTime/(float)CLOCKS_PER_SEC);
 		MPIcontrol.print(message, FP);	
		sprintf(message, "Time spend in locate function %.5f\n", MPIcontrol.locateTime/(float)CLOCKS_PER_SEC);
		MPIcontrol.print(message,FP);
		sprintf(message,"Time spend in read function %.5f\n", MPIcontrol.readTime/(float)CLOCKS_PER_SEC);
		MPIcontrol.print(message,FP);
    	}

	if(MPIcontrol.rank==0)
	{
		t1 = clock();
		char message[1024];
		sprintf(message,"Time spend in I/O part in MPIcontrol %.5f\n", (t1-t0)/(float)CLOCKS_PER_SEC);
 		MPIcontrol.print(message, FP);	
		printf("Time spend in I/O part in MPIcontrol %.5f\n", (t1-t0)/(float)CLOCKS_PER_SEC);
		fclose(FP);
	}

	MPIcontrol.finalize();
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x13a0, %rsp           # imm = 0x13A0
movq %rsi, %rbx
movl %edi, %ebp
leaq 0xe0(%rsp), %r14
movq %r14, %rdi
movl %ebp, %esi
movq %rbx, %rdx
callq 0x5160
leaq 0x760(%rsp), %rdi
movl %ebp, %esi
movq %rbx, %rdx
movq %r14, %rcx
callq 0x4e34
leaq 0xa5d(%rsp), %rdi
leaq 0x2ace(%rip), %rsi      # 0x69ca
callq 0x22b0
movq %rax, %rbx
cmpl $0x0, (%r14)
je 0x3f0f
xorl %r14d, %r14d
jmp 0x3f17
callq 0x2170
movq %rax, %r14
leaq 0x38(%rsp), %rdi
callq 0x422c
movsd 0x1288(%rsp), %xmm0
cvttsd2si %xmm0, %rcx
movq %rcx, %rdx
sarq $0x3f, %rdx
subsd 0x20ca(%rip), %xmm0     # 0x6008
cvttsd2si %xmm0, %rax
andq %rdx, %rax
orq %rcx, %rax
shlq $0x2, %rax
movslq 0xe4(%rsp), %rcx
xorl %edx, %edx
divq %rcx
leaq 0x8(%rsp), %rdi
pushq $0x3
popq %rdx
movq %rax, %rsi
callq 0x42c4
leaq 0x38(%rsp), %rdi
leaq 0x760(%rsp), %rsi
leaq 0xe0(%rsp), %rdx
leaq 0x8(%rsp), %rcx
callq 0x33ca
leaq 0x38(%rsp), %rdi
leaq 0x760(%rsp), %rsi
leaq 0xe0(%rsp), %rdx
callq 0x391e
cmpl $0x0, 0xe0(%rsp)
jne 0x40ec
leaq 0xe0(%rsp), %r15
cvtsi2ssq 0x248(%r15), %xmm0
divss 0x203a(%rip), %xmm0     # 0x6004
cvtss2sd %xmm0, %xmm0
leaq 0x255f(%rip), %rsi      # 0x6534
leaq 0x360(%rsp), %r12
movq %r12, %rdi
movb $0x1, %al
callq 0x2060
movq %r15, %rdi
movq %r12, %rsi
movq %rbx, %rdx
callq 0x523a
leaq 0xe0(%rsp), %r15
cvtsi2ssq 0x250(%r15), %xmm0
divss 0x1ff6(%rip), %xmm0     # 0x6004
cvtss2sd %xmm0, %xmm0
leaq 0x2546(%rip), %rsi      # 0x655f
leaq 0x360(%rsp), %r12
movq %r12, %rdi
movb $0x1, %al
callq 0x2060
movq %r15, %rdi
movq %r12, %rsi
movq %rbx, %rdx
callq 0x523a
leaq 0xe0(%rsp), %r15
cvtsi2ssq 0x258(%r15), %xmm0
divss 0x1fb2(%rip), %xmm0     # 0x6004
cvtss2sd %xmm0, %xmm0
leaq 0x2526(%rip), %rsi      # 0x6583
leaq 0x360(%rsp), %r12
movq %r12, %rdi
movb $0x1, %al
callq 0x2060
movq %r15, %rdi
movq %r12, %rsi
movq %rbx, %rdx
callq 0x523a
cmpl $0x0, 0xe0(%rsp)
jne 0x40ec
callq 0x2170
subq %r14, %rax
cvtsi2ss %rax, %xmm0
divss 0x1f68(%rip), %xmm0     # 0x6004
cvtss2sd %xmm0, %xmm0
leaq 0x248d(%rip), %rsi      # 0x6534
leaq 0x360(%rsp), %r14
movq %r14, %rdi
movsd %xmm0, (%rsp)
movb $0x1, %al
callq 0x2060
leaq 0xe0(%rsp), %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x523a
leaq 0x245c(%rip), %rdi      # 0x6534
movsd (%rsp), %xmm0
movb $0x1, %al
callq 0x2040
movq %rbx, %rdi
callq 0x2240
leaq 0xe0(%rsp), %rdi
callq 0x52a2
leaq 0x8(%rsp), %rdi
callq 0x44aa
leaq 0x38(%rsp), %rdi
callq 0x44c8
xorl %eax, %eax
addq $0x13a0, %rsp           # imm = 0x13A0
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
jmp 0x4128
movq %rax, %rbx
jmp 0x4135
jmp 0x4128
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x44aa
leaq 0x38(%rsp), %rdi
callq 0x44c8
movq %rbx, %rdi
callq 0x2420
nop