// File: 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:
subq $0x17f8, %rsp           # imm = 0x17F8
movl $0x0, 0x17f4(%rsp)
movl %edi, 0x17f0(%rsp)
movq %rsi, 0x17e8(%rsp)
movl 0x17f0(%rsp), %esi
movq 0x17e8(%rsp), %rdx
leaq 0x1568(%rsp), %rdi
callq 0x15200
movl 0x17f0(%rsp), %esi
movq 0x17e8(%rsp), %rdx
leaq 0x928(%rsp), %rdi
leaq 0x1568(%rsp), %rcx
callq 0x14e50
movq $0x0, 0x920(%rsp)
leaq 0x928(%rsp), %rdi
addq $0x2fd, %rdi            # imm = 0x2FD
leaq 0xa529(%rip), %rsi      # 0x16cbc
callq 0x87c0
movq %rax, 0x920(%rsp)
movq $0x0, 0x918(%rsp)
movq $0x0, 0x910(%rsp)
cmpl $0x0, 0x1568(%rsp)
jne 0xc7cf
callq 0x83e0
movq %rax, 0x918(%rsp)
leaq 0x868(%rsp), %rdi
callq 0xd5f0
movsd 0x1450(%rsp), %xmm0
movsd 0x982b(%rip), %xmm2     # 0x16018
movaps %xmm0, %xmm1
subsd %xmm2, %xmm1
cvttsd2si %xmm1, %rcx
cvttsd2si %xmm0, %rax
movq %rax, %rdx
sarq $0x3f, %rdx
andq %rdx, %rcx
orq %rcx, %rax
shlq $0x2, %rax
movslq 0x156c(%rsp), %rcx
xorl %edx, %edx
divq %rcx
movq %rax, %rsi
leaq 0x838(%rsp), %rdi
movl $0x3, %edx
callq 0xd6d0
jmp 0xc833
leaq 0x868(%rsp), %rdi
leaq 0x928(%rsp), %rsi
leaq 0x1568(%rsp), %rdx
leaq 0x838(%rsp), %rcx
callq 0xb350
jmp 0xc85a
leaq 0x868(%rsp), %rdi
leaq 0x928(%rsp), %rsi
leaq 0x1568(%rsp), %rdx
callq 0xbd30
jmp 0xc879
cmpl $0x0, 0x1568(%rsp)
jne 0xc9bb
cvtsi2ssq 0x17b0(%rsp), %xmm0
movss 0x976b(%rip), %xmm1     # 0x16004
divss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x9dcd(%rip), %rsi      # 0x16675
leaq 0x420(%rsp), %rdi
movq %rdi, 0x18(%rsp)
movb $0x1, %al
callq 0x80e0
movq 0x18(%rsp), %rsi
movq 0x920(%rsp), %rdx
leaq 0x1568(%rsp), %rdi
callq 0x15340
jmp 0xc8d8
cvtsi2ssq 0x17b8(%rsp), %xmm0
movss 0x971a(%rip), %xmm1     # 0x16004
divss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x9da7(%rip), %rsi      # 0x166a0
leaq 0x420(%rsp), %rdi
movq %rdi, 0x10(%rsp)
movb $0x1, %al
callq 0x80e0
movq 0x10(%rsp), %rsi
movq 0x920(%rsp), %rdx
leaq 0x1568(%rsp), %rdi
callq 0x15340
jmp 0xc929
cvtsi2ssq 0x17c0(%rsp), %xmm0
movss 0x96c9(%rip), %xmm1     # 0x16004
divss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x9d7a(%rip), %rsi      # 0x166c4
leaq 0x420(%rsp), %rdi
movq %rdi, 0x8(%rsp)
movb $0x1, %al
callq 0x80e0
movq 0x8(%rsp), %rsi
movq 0x920(%rsp), %rdx
leaq 0x1568(%rsp), %rdi
callq 0x15340
jmp 0xc97a
jmp 0xc9bb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x830(%rsp)
movl %eax, 0x82c(%rsp)
jmp 0xcabc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x830(%rsp)
movl %eax, 0x82c(%rsp)
leaq 0x838(%rsp), %rdi
callq 0xd9f0
jmp 0xcabc
cmpl $0x0, 0x1568(%rsp)
jne 0xca79
callq 0x83e0
movq %rax, 0x910(%rsp)
movq 0x910(%rsp), %rax
movq 0x918(%rsp), %rcx
subq %rcx, %rax
cvtsi2ss %rax, %xmm0
movss 0x960e(%rip), %xmm1     # 0x16004
divss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x9c70(%rip), %rsi      # 0x16675
leaq 0x20(%rsp), %rdi
movq %rdi, (%rsp)
movb $0x1, %al
callq 0x80e0
movq (%rsp), %rsi
movq 0x920(%rsp), %rdx
leaq 0x1568(%rsp), %rdi
callq 0x15340
jmp 0xca30
movq 0x910(%rsp), %rax
movq 0x918(%rsp), %rcx
subq %rcx, %rax
cvtsi2ss %rax, %xmm0
movss 0x95b4(%rip), %xmm1     # 0x16004
divss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x9c16(%rip), %rdi      # 0x16675
movb $0x1, %al
callq 0x8040
jmp 0xca68
movq 0x920(%rsp), %rdi
callq 0x8690
jmp 0xca77
jmp 0xca79
leaq 0x1568(%rsp), %rdi
callq 0x153f0
jmp 0xca88
movl $0x0, 0x17f4(%rsp)
leaq 0x838(%rsp), %rdi
callq 0xd9f0
leaq 0x868(%rsp), %rdi
callq 0xda30
movl 0x17f4(%rsp), %eax
addq $0x17f8, %rsp           # imm = 0x17F8
retq
leaq 0x868(%rsp), %rdi
callq 0xda30
movq 0x830(%rsp), %rdi
callq 0x8c20
nopw %cs:(%rax,%rax)