// File: /workspace/github_cpp_makefile_star2_O3/searsm8[P]FM_Partitioning/fmpart.cpp
// Function: printToFile()
void printToFile()
{
	FILE *out_file;
	char out_file_path[100];
	strcpy(out_file_path, file_path);	
	out_file = fopen(strcat(out_file_path, "fmpartition.nodes"), "w");		
			
	printf("\nPrinting results to file: %s\n", out_file_path);
	fprintf(out_file, "FM partition performed on: %s\n\n", file_path);
	fprintf(out_file, "Execution time: %.02f\t\t(%d passes performed)\n", (std::clock() - start_time) / (double) CLOCKS_PER_SEC, (std::clock() - timestamp) / (double) CLOCKS_PER_SEC, pass_count);
	fprintf(out_file, "Starting cut: %d\n", initial_partition_cut_size);
	fprintf(out_file, "Final cut: %d\n", cut_size);
	fprintf(out_file, "Percent change: %.02f\n", (float)(initial_partition_cut_size - cut_size) / (float)initial_partition_cut_size);
	
	//compute ratio cut = cut_size / (cell_count[0] * cell_count[1])
	long cell_count[2] = {0, 0};
	for(int i = 0; i < cells.size(); i++)
		cell_count[cells[i]->partition]++;
		
	fprintf(out_file, "Ratio cut: %.08f\t(%d / (%d*%d))\n", ((float)(cut_size)/(float)(cell_count[0]))/ (float)(cell_count[1]), cut_size, cell_count[0], cell_count[1]);
	
	fprintf(out_file, "\nPartitioned cell list:\n");
	fprintf(out_file, "\tname\t\tcell type (area)\tpartition\n");
	for(int i = 0; i < cells.size(); i++)
	{
		fprintf(out_file, "%15s %15s(%d)\t\t%d\n", cells[i]->name, cells[i]->type, cells[i]->area, cells[i]->best_partition);
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x80, %rsp
leaq 0x49ef(%rip), %r15      # 0x8150
leaq -0xa0(%rbp), %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0x2140
movq %r12, %rdi
callq 0x20a0
movups 0x1ab7(%rip), %xmm0     # 0x5239
movups %xmm0, -0xa0(%rbp,%rax)
movw $0x73, -0x90(%rbp,%rax)
leaq 0x1ab0(%rip), %rsi      # 0x524b
movq %r12, %rdi
callq 0x21a0
movq %rax, %rbx
leaq 0x1aa0(%rip), %rdi      # 0x524d
xorl %r14d, %r14d
movq %r12, %rsi
xorl %eax, %eax
callq 0x2040
leaq 0x1aab(%rip), %rsi      # 0x526c
movq %rbx, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x21c0
callq 0x20d0
subq 0x4aa6(%rip), %rax      # 0x8280
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
divsd 0x183e(%rip), %xmm0     # 0x5028
movsd %xmm0, -0x38(%rbp)
callq 0x20d0
subq 0x4a8d(%rip), %rax      # 0x8288
cvtsi2sd %rax, %xmm1
divsd 0x1820(%rip), %xmm1     # 0x5028
movl 0x4966(%rip), %edx      # 0x8174
leaq 0x1a77(%rip), %rsi      # 0x528c
movq %rbx, %rdi
movsd -0x38(%rbp), %xmm0
movb $0x2, %al
callq 0x21c0
movl 0x4a4a(%rip), %edx      # 0x8274
leaq 0x1a89(%rip), %rsi      # 0x52ba
movq %rbx, %rdi
xorl %eax, %eax
callq 0x21c0
movl 0x4a07(%rip), %edx      # 0x8248
leaq 0x1a84(%rip), %rsi      # 0x52cc
movq %rbx, %rdi
xorl %eax, %eax
callq 0x21c0
movl 0x4a1c(%rip), %eax      # 0x8274
xorps %xmm0, %xmm0
cvtsi2ss %eax, %xmm0
subl 0x49e3(%rip), %eax      # 0x8248
xorps %xmm1, %xmm1
cvtsi2ss %eax, %xmm1
divss %xmm0, %xmm1
xorps %xmm0, %xmm0
cvtss2sd %xmm1, %xmm0
leaq 0x1a5d(%rip), %rsi      # 0x52db
movq %rbx, %rdi
movb $0x1, %al
callq 0x21c0
xorps %xmm0, %xmm0
movaps %xmm0, -0x30(%rbp)
movq 0x4972(%rip), %rax      # 0x8208
movq 0x4963(%rip), %rcx      # 0x8200
subq %rcx, %rax
je 0x38d2
sarq $0x3, %rax
cmpq $0x1, %rax
adcq $0x0, %rax
xorl %edx, %edx
movq (%rcx,%rdx,8), %rsi
movslq 0x84(%rsi), %rsi
incq -0x30(%rbp,%rsi,8)
incq %rdx
cmpq %rdx, %rax
jne 0x38b0
movq -0x30(%rbp), %rcx
movq -0x28(%rbp), %r14
jmp 0x38d4
xorl %ecx, %ecx
movl 0x496e(%rip), %edx      # 0x8248
xorps %xmm0, %xmm0
cvtsi2ss %edx, %xmm0
xorps %xmm1, %xmm1
cvtsi2ss %rcx, %xmm1
cvtsi2ss %r14, %xmm2
divss %xmm1, %xmm0
divss %xmm2, %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x19f1(%rip), %rsi      # 0x52f2
movq %rbx, %rdi
movq %r14, %r8
movb $0x1, %al
callq 0x21c0
leaq 0x19fe(%rip), %rdi      # 0x5313
movl $0x18, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x2270
leaq 0x19fe(%rip), %rdi      # 0x532c
movl $0x22, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x2270
movq 0x48b9(%rip), %rax      # 0x8200
cmpq %rax, 0x48ba(%rip)      # 0x8208
je 0x3997
leaq 0x19f8(%rip), %r14      # 0x534f
xorl %r15d, %r15d
movq (%rax,%r15,8), %rdx
leaq 0x64(%rdx), %rcx
movl 0x78(%rdx), %r8d
movl 0x88(%rdx), %r9d
movq %rbx, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x21c0
incq %r15
movq 0x4884(%rip), %rcx      # 0x8208
movq 0x4875(%rip), %rax      # 0x8200
subq %rax, %rcx
sarq $0x3, %rcx
cmpq %r15, %rcx
ja 0x395a
addq $0x80, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq