// File: Mengjintao[P]SWAPCounter/src/kmerGraph.cpp
// Function: kmerGraph::printKmerCounting(parameter*, MPIEnviroment*)
void kmerGraph::printKmerCounting(parameter *parameters, MPIEnviroment *MPIcontrol)
{
        ofstream fs(parameters->kmerGraph);
        if(!fs.is_open())
        {
                cout<<"Error opening file"<<endl;
                exit(1);
        }

	int lineLen = parameters->hashLength+1+4*8+5;
	int totLen = kmolecules.size()*lineLen;
	
	char *buf = new char [totLen];
	int i=0;

	for(unordered_map<unsigned long long, unsigned long long>::iterator I=kmolecules.begin(); I!=kmolecules.end(); I++)
	{
		sprintf(buf+i*lineLen, "%s ", longLongToString(I->first, parameters).c_str());
		unsigned char *p = (unsigned char *) &I->second;
		int t=0;
		/*for(int j=0;j<8;j++)	
		{
			t += p[j];
			sprintf(buf+i*lineLen+parameters->hashLength+1+j*4, "%3d ", (int) p[j]);
		}*/
		sprintf(buf+i*lineLen+parameters->hashLength+1+4*8, "%4d\n", t);	
		i++;	
	}
	buf[totLen] = 0;
	MPIcontrol->File_write(parameters->kmerGraph, buf, totLen);
}

// Assembly:
subq $0x2b8, %rsp            # imm = 0x2B8
movq %rdi, 0x2b0(%rsp)
movq %rsi, 0x2a8(%rsp)
movq %rdx, 0x2a0(%rsp)
movq 0x2b0(%rsp), %rax
movq %rax, 0x18(%rsp)
movq 0x2a8(%rsp), %rsi
addq $0x8f7, %rsi            # imm = 0x8F7
leaq 0xa0(%rsp), %rdi
movq %rdi, 0x20(%rsp)
movl $0x10, %edx
callq 0x8730
movq 0x20(%rsp), %rdi
callq 0x84b0
movb %al, 0x2f(%rsp)
jmp 0xc4b2
movb 0x2f(%rsp), %al
testb $0x1, %al
jne 0xc519
jmp 0xc4bc
movq 0x10af5(%rip), %rdi     # 0x1cfb8
leaq 0xa18f(%rip), %rsi      # 0x16659
callq 0x8680
movq %rax, 0x10(%rsp)
jmp 0xc4d6
movq 0x10(%rsp), %rdi
movq 0x10aa6(%rip), %rsi     # 0x1cf88
callq 0x86c0
jmp 0xc4e9
movl $0x1, %edi
callq 0x8800
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x98(%rsp)
movl %eax, 0x94(%rsp)
leaq 0xa0(%rsp), %rdi
callq 0x8a40
jmp 0xc6fb
movq 0x18(%rsp), %rdi
movq 0x2a8(%rsp), %rax
movl 0xaf8(%rax), %eax
addl $0x26, %eax
movl %eax, 0x90(%rsp)
callq 0xd500
movl 0x90(%rsp), %ecx
imull %ecx, %eax
movl %eax, 0x8c(%rsp)
movslq 0x8c(%rsp), %rdi
testq %rdi, %rdi
movq $-0x1, %rax
cmovsq %rax, %rdi
callq 0x8030
movq %rax, 0x8(%rsp)
jmp 0xc56e
movq 0x18(%rsp), %rdi
movq 0x8(%rsp), %rax
movq %rax, 0x80(%rsp)
movl $0x0, 0x7c(%rsp)
callq 0xd550
movq %rax, 0x70(%rsp)
movq 0x18(%rsp), %rdi
callq 0xd2d0
movq %rax, 0x68(%rsp)
leaq 0x70(%rsp), %rdi
leaq 0x68(%rsp), %rsi
callq 0xd280
testb $0x1, %al
jne 0xc5b9
jmp 0xc6a4
movq 0x80(%rsp), %rax
movl 0x7c(%rsp), %ecx
movl 0x90(%rsp), %edx
imull %edx, %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, (%rsp)
leaq 0x70(%rsp), %rdi
callq 0xd580
movq (%rax), %rsi
movq 0x2a8(%rsp), %rdx
leaq 0x48(%rsp), %rdi
callq 0x90c0
jmp 0xc5fa
leaq 0x48(%rsp), %rdi
callq 0x81f0
movq (%rsp), %rdi
movq %rax, %rdx
leaq 0xa05a(%rip), %rsi      # 0x1666c
movb $0x0, %al
callq 0x80e0
leaq 0x48(%rsp), %rdi
callq 0x8390
leaq 0x70(%rsp), %rdi
callq 0xd580
addq $0x8, %rax
movq %rax, 0x40(%rsp)
movl $0x0, 0x3c(%rsp)
movq 0x80(%rsp), %rdi
movl 0x7c(%rsp), %eax
imull 0x90(%rsp), %eax
cltq
addq %rax, %rdi
movq 0x2a8(%rsp), %rax
movslq 0xaf8(%rax), %rax
addq %rax, %rdi
addq $0x1, %rdi
addq $0x20, %rdi
movl 0x3c(%rsp), %edx
leaq 0x9ff4(%rip), %rsi      # 0x16670
movb $0x0, %al
callq 0x80e0
movl 0x7c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x7c(%rsp)
leaq 0x70(%rsp), %rdi
xorl %esi, %esi
callq 0xd5c0
movq %rax, 0x30(%rsp)
jmp 0xc592
movq 0x80(%rsp), %rax
movslq 0x8c(%rsp), %rcx
movb $0x0, (%rax,%rcx)
movq 0x2a0(%rsp), %rdi
movq 0x2a8(%rsp), %rsi
addq $0x8f7, %rsi            # imm = 0x8F7
movq 0x80(%rsp), %rdx
movslq 0x8c(%rsp), %rcx
callq 0x15af0
jmp 0xc6e6
leaq 0xa0(%rsp), %rdi
callq 0x8a40
addq $0x2b8, %rsp            # imm = 0x2B8
retq
movq 0x98(%rsp), %rdi
callq 0x8c20
nopl (%rax,%rax)