// File: CK7[P]abawaca/src/ClusterWriter.cpp
// Function: ClusterWriter::write_scaffold_stats(ClusterData const&, std::set<unsigned long, std::less<unsigned long>, std::allocator<unsigned long>> const&, std::unordered_set<unsigned long, std::hash<unsigned long>, std::equal_to<unsigned long>, std::allocator<unsigned long>> const&, char const*) const
void ClusterWriter::write_scaffold_stats(const ClusterData& clustering_db, const set<size_t>& scafs, const unordered_set<size_t>& raw_dps, const char* out_file) const
{
	map<size_t, size_t>	scafs_in2ndps, scafs_out2ndps;

	for(auto vit=scafs.begin(); vit != scafs.end(); vit++)
		scafs_in2ndps.insert(pair<size_t, size_t>(*vit, 0));

	for(auto vit=raw_dps.begin(); vit != raw_dps.end(); vit++) {
		size_t scaf = scaf_db.dp2scaf(*vit);
		if(scafs_in2ndps.find(scaf) != scafs_in2ndps.end())
			scafs_in2ndps[scaf]++;
		else if(scafs_out2ndps.find(scaf) != scafs_out2ndps.end())
			scafs_out2ndps[scaf]++;
		else
			scafs_out2ndps.insert(pair<size_t, size_t>(scaf, 1));
	}

        FILE* fp = fopen(out_file, "w");
	if(fp == NULL) {
		cerr << "Fatal error, " << __FILE__ << " (" << __LINE__ << "): could write to file " << out_file << endl << endl;
		exit(-1);
	}

	fprintf(fp, "SCAF      \tRAW\tTOTAL\tIN/OUT_CLUSTER\n\n");

	for(map<size_t, size_t>::const_iterator mit = scafs_in2ndps.begin(); mit != scafs_in2ndps.end(); mit++)
		fprintf(fp, "%s\t%lu\t%lu\tin\n", scaf_db.scaf_id2name(mit->first).c_str(), mit->second, scaf_db.ndps(mit->first));
	for(map<size_t, size_t>::const_iterator mit = scafs_out2ndps.begin(); mit != scafs_out2ndps.end(); mit++)
		fprintf(fp, "%s\t%lu\t%lu\tout\n", scaf_db.scaf_id2name(mit->first).c_str(), mit->second, scaf_db.ndps(mit->first));
	fclose(fp);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2e0, %rsp            # imm = 0x2E0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x1e0(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x9e40
leaq -0x88(%rbp), %rdi
callq 0x9e40
movq -0x18(%rbp), %rdi
callq 0xa8e0
movq %rax, -0x90(%rbp)
movq -0x18(%rbp), %rdi
callq 0xa910
movq %rax, -0x98(%rbp)
leaq -0x90(%rbp), %rdi
leaq -0x98(%rbp), %rsi
callq 0xa3a0
testb $0x1, %al
jne 0x238ab
jmp 0x23943
leaq -0x90(%rbp), %rdi
callq 0xa400
movq %rax, %rsi
movl $0x0, -0xac(%rbp)
leaq -0xa8(%rbp), %rdi
leaq -0xac(%rbp), %rdx
callq 0x24590
jmp 0x238d9
leaq -0x58(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
callq 0x14690
movb %dl, -0x1e9(%rbp)
movq %rax, -0x1e8(%rbp)
jmp 0x238f8
movb -0x1e9(%rbp), %al
movq -0x1e8(%rbp), %rcx
movq %rcx, -0xd0(%rbp)
movb %al, -0xc8(%rbp)
leaq -0x90(%rbp), %rdi
xorl %esi, %esi
callq 0xa420
movq %rax, -0xd8(%rbp)
jmp 0x2387f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb8(%rbp)
movl %eax, -0xbc(%rbp)
jmp 0x23fa4
movq -0x20(%rbp), %rdi
callq 0xbfd0
movq %rax, -0xe0(%rbp)
movq -0x20(%rbp), %rdi
callq 0xc0b0
movq %rax, -0xe8(%rbp)
leaq -0xe0(%rbp), %rdi
leaq -0xe8(%rbp), %rsi
callq 0xa1d0
testb $0x1, %al
jne 0x2397f
jmp 0x23b47
movq -0x1e0(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x200(%rbp)
leaq -0xe0(%rbp), %rdi
callq 0xa310
movq -0x200(%rbp), %rdi
movq (%rax), %rsi
callq 0x13a40
movq %rax, -0x1f8(%rbp)
jmp 0x239b5
movq -0x1f8(%rbp), %rax
movq %rax, -0xf0(%rbp)
leaq -0x58(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
callq 0xa6e0
movq %rax, -0x208(%rbp)
jmp 0x239dc
movq -0x208(%rbp), %rax
movq %rax, -0xf8(%rbp)
leaq -0x58(%rbp), %rdi
callq 0xa710
movq %rax, -0x100(%rbp)
leaq -0xf8(%rbp), %rdi
leaq -0x100(%rbp), %rsi
callq 0x245c0
testb $0x1, %al
jne 0x23a13
jmp 0x23a42
leaq -0x58(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
callq 0xa230
movq %rax, -0x210(%rbp)
jmp 0x23a2c
movq -0x210(%rbp), %rax
movq (%rax), %rcx
addq $0x1, %rcx
movq %rcx, (%rax)
jmp 0x23b2b
leaq -0x88(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
callq 0xa6e0
movq %rax, -0x218(%rbp)
jmp 0x23a5e
movq -0x218(%rbp), %rax
movq %rax, -0x108(%rbp)
leaq -0x88(%rbp), %rdi
callq 0xa710
movq %rax, -0x110(%rbp)
leaq -0x108(%rbp), %rdi
leaq -0x110(%rbp), %rsi
callq 0x245c0
testb $0x1, %al
jne 0x23a98
jmp 0x23ac7
leaq -0x88(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
callq 0xa230
movq %rax, -0x220(%rbp)
jmp 0x23ab4
movq -0x220(%rbp), %rax
movq (%rax), %rcx
addq $0x1, %rcx
movq %rcx, (%rax)
jmp 0x23b29
movl $0x1, -0x124(%rbp)
leaq -0x120(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
leaq -0x124(%rbp), %rdx
callq 0x245f0
jmp 0x23aed
leaq -0x88(%rbp), %rdi
leaq -0x120(%rbp), %rsi
callq 0x14690
movb %dl, -0x229(%rbp)
movq %rax, -0x228(%rbp)
jmp 0x23b0f
movb -0x229(%rbp), %al
movq -0x228(%rbp), %rcx
movq %rcx, -0x138(%rbp)
movb %al, -0x130(%rbp)
jmp 0x23b2b
jmp 0x23b2d
leaq -0xe0(%rbp), %rdi
xorl %esi, %esi
callq 0xa340
movq %rax, -0x140(%rbp)
jmp 0x23953
movq -0x28(%rbp), %rdi
leaq 0x12562(%rip), %rsi     # 0x360b4
callq 0x54b0
movq %rax, -0x238(%rbp)
jmp 0x23b60
movq -0x238(%rbp), %rax
movq %rax, -0x148(%rbp)
cmpq $0x0, -0x148(%rbp)
jne 0x23c5a
movq 0x29465(%rip), %rdi     # 0x4cfe8
leaq 0x1252c(%rip), %rsi     # 0x360b6
callq 0x53f0
movq %rax, -0x240(%rbp)
jmp 0x23b98
movq -0x240(%rbp), %rdi
leaq 0x1251e(%rip), %rsi     # 0x360c4
callq 0x53f0
movq %rax, -0x248(%rbp)
jmp 0x23bb4
movq -0x248(%rbp), %rdi
leaq 0x12363(%rip), %rsi     # 0x35f25
callq 0x53f0
movq %rax, -0x250(%rbp)
jmp 0x23bd0
movq -0x250(%rbp), %rdi
movl $0x37, %esi
callq 0x5710
movq %rax, -0x258(%rbp)
jmp 0x23bea
movq -0x258(%rbp), %rdi
leaq 0x124e2(%rip), %rsi     # 0x360da
callq 0x53f0
movq %rax, -0x260(%rbp)
jmp 0x23c06
movq -0x260(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x53f0
movq %rax, -0x268(%rbp)
jmp 0x23c1f
movq -0x268(%rbp), %rdi
movq 0x29363(%rip), %rsi     # 0x4cf90
callq 0x5440
movq %rax, -0x270(%rbp)
jmp 0x23c3b
movq -0x270(%rbp), %rdi
movq 0x29347(%rip), %rsi     # 0x4cf90
callq 0x5440
jmp 0x23c50
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x54f0
movq -0x148(%rbp), %rdi
leaq 0x12491(%rip), %rsi     # 0x360f9
movb $0x0, %al
callq 0x5610
leaq -0x58(%rbp), %rdi
callq 0x24620
movq %rax, -0x158(%rbp)
leaq -0x150(%rbp), %rdi
leaq -0x158(%rbp), %rsi
callq 0x10a80
leaq -0x58(%rbp), %rdi
callq 0xa710
movq %rax, -0x168(%rbp)
leaq -0x160(%rbp), %rdi
leaq -0x168(%rbp), %rsi
callq 0x10a80
leaq -0x150(%rbp), %rdi
leaq -0x160(%rbp), %rsi
callq 0x218d0
testb $0x1, %al
jne 0x23cd1
jmp 0x23df2
movq -0x1e0(%rbp), %rax
movq -0x148(%rbp), %rcx
movq %rcx, -0x280(%rbp)
movq 0x28(%rax), %rax
movq %rax, -0x278(%rbp)
leaq -0x150(%rbp), %rdi
callq 0x1d0c0
movq -0x278(%rbp), %rsi
movq (%rax), %rdx
leaq -0x188(%rbp), %rdi
callq 0x13c70
jmp 0x23d15
leaq -0x188(%rbp), %rdi
callq 0x5190
movq %rax, -0x2a8(%rbp)
leaq -0x150(%rbp), %rdi
movq %rdi, -0x2a0(%rbp)
callq 0x1d0c0
movq -0x2a0(%rbp), %rdi
movq %rax, %rcx
movq -0x1e0(%rbp), %rax
movq 0x8(%rcx), %rcx
movq %rcx, -0x298(%rbp)
movq 0x28(%rax), %rax
movq %rax, -0x290(%rbp)
callq 0x1d0c0
movq -0x290(%rbp), %rdi
movq (%rax), %rsi
callq 0x13b50
movq %rax, -0x288(%rbp)
jmp 0x23d7f
movq -0x288(%rbp), %r8
movq -0x298(%rbp), %rcx
movq -0x2a8(%rbp), %rdx
movq -0x280(%rbp), %rdi
leaq 0x1237d(%rip), %rsi     # 0x3611f
movb $0x0, %al
callq 0x5610
leaq -0x188(%rbp), %rdi
callq 0x5250
leaq -0x150(%rbp), %rdi
xorl %esi, %esi
callq 0x24650
movq %rax, -0x190(%rbp)
jmp 0x23c92
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb8(%rbp)
movl %eax, -0xbc(%rbp)
leaq -0x188(%rbp), %rdi
callq 0x5250
jmp 0x23fa4
leaq -0x88(%rbp), %rdi
callq 0x24620
movq %rax, -0x1a0(%rbp)
leaq -0x198(%rbp), %rdi
leaq -0x1a0(%rbp), %rsi
callq 0x10a80
leaq -0x88(%rbp), %rdi
callq 0xa710
movq %rax, -0x1b0(%rbp)
leaq -0x1a8(%rbp), %rdi
leaq -0x1b0(%rbp), %rsi
callq 0x10a80
leaq -0x198(%rbp), %rdi
leaq -0x1a8(%rbp), %rsi
callq 0x218d0
testb $0x1, %al
jne 0x23e5a
jmp 0x23f78
movq -0x1e0(%rbp), %rax
movq -0x148(%rbp), %rcx
movq %rcx, -0x2b8(%rbp)
movq 0x28(%rax), %rax
movq %rax, -0x2b0(%rbp)
leaq -0x198(%rbp), %rdi
callq 0x1d0c0
movq -0x2b0(%rbp), %rsi
movq (%rax), %rdx
leaq -0x1d0(%rbp), %rdi
callq 0x13c70
jmp 0x23e9e
leaq -0x1d0(%rbp), %rdi
callq 0x5190
movq %rax, -0x2e0(%rbp)
leaq -0x198(%rbp), %rdi
movq %rdi, -0x2d8(%rbp)
callq 0x1d0c0
movq -0x2d8(%rbp), %rdi
movq %rax, %rcx
movq -0x1e0(%rbp), %rax
movq 0x8(%rcx), %rcx
movq %rcx, -0x2d0(%rbp)
movq 0x28(%rax), %rax
movq %rax, -0x2c8(%rbp)
callq 0x1d0c0
movq -0x2c8(%rbp), %rdi
movq (%rax), %rsi
callq 0x13b50
movq %rax, -0x2c0(%rbp)
jmp 0x23f08
movq -0x2c0(%rbp), %r8
movq -0x2d0(%rbp), %rcx
movq -0x2e0(%rbp), %rdx
movq -0x2b8(%rbp), %rdi
leaq 0x12203(%rip), %rsi     # 0x3612e
movb $0x0, %al
callq 0x5610
leaq -0x1d0(%rbp), %rdi
callq 0x5250
leaq -0x198(%rbp), %rdi
xorl %esi, %esi
callq 0x24650
movq %rax, -0x1d8(%rbp)
jmp 0x23e18
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb8(%rbp)
movl %eax, -0xbc(%rbp)
leaq -0x1d0(%rbp), %rdi
callq 0x5250
jmp 0x23fa4
movq -0x148(%rbp), %rdi
callq 0x5400
jmp 0x23f86
leaq -0x88(%rbp), %rdi
callq 0xa770
leaq -0x58(%rbp), %rdi
callq 0xa770
addq $0x2e0, %rsp            # imm = 0x2E0
popq %rbp
retq
leaq -0x88(%rbp), %rdi
callq 0xa770
leaq -0x58(%rbp), %rdi
callq 0xa770
movq -0xb8(%rbp), %rdi
callq 0x5750
nopw %cs:(%rax,%rax)