// File: /workspace/github_cpp_makefile_star2_O1/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 %rbx
subq $0x88, %rsp
leaq 0x49b5(%rip), %r14      # 0x8150
leaq -0xa0(%rbp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x2140
movq %r15, %rdi
callq 0x20a0
movups 0x1a7d(%rip), %xmm0     # 0x5239
movups %xmm0, -0xa0(%rbp,%rax)
movw $0x73, -0x90(%rbp,%rax)
leaq 0x1a76(%rip), %rsi      # 0x524b
movq %r15, %rdi
callq 0x21a0
movq %rax, %rbx
leaq 0x1a66(%rip), %rdi      # 0x524d
movq %r15, %rsi
xorl %eax, %eax
callq 0x2040
leaq 0x1a74(%rip), %rsi      # 0x526c
movq %rbx, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x21c0
callq 0x20d0
subq 0x4a6f(%rip), %rax      # 0x8280
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
divsd 0x1807(%rip), %xmm0     # 0x5028
movsd %xmm0, -0x38(%rbp)
callq 0x20d0
subq 0x4a56(%rip), %rax      # 0x8288
cvtsi2sd %rax, %xmm1
divsd 0x17e9(%rip), %xmm1     # 0x5028
movl 0x492f(%rip), %edx      # 0x8174
leaq 0x1a40(%rip), %rsi      # 0x528c
movq %rbx, %rdi
movsd -0x38(%rbp), %xmm0
movb $0x2, %al
callq 0x21c0
movl 0x4a13(%rip), %edx      # 0x8274
leaq 0x1a52(%rip), %rsi      # 0x52ba
movq %rbx, %rdi
xorl %eax, %eax
callq 0x21c0
movl 0x49d0(%rip), %edx      # 0x8248
leaq 0x1a4d(%rip), %rsi      # 0x52cc
movq %rbx, %rdi
xorl %eax, %eax
callq 0x21c0
movl 0x49e5(%rip), %eax      # 0x8274
xorps %xmm0, %xmm0
cvtsi2ss %eax, %xmm0
subl 0x49ac(%rip), %eax      # 0x8248
xorps %xmm1, %xmm1
cvtsi2ss %eax, %xmm1
divss %xmm0, %xmm1
xorps %xmm0, %xmm0
cvtss2sd %xmm1, %xmm0
leaq 0x1a26(%rip), %rsi      # 0x52db
movq %rbx, %rdi
movb $0x1, %al
callq 0x21c0
xorps %xmm0, %xmm0
movaps %xmm0, -0x30(%rbp)
movq 0x493b(%rip), %rax      # 0x8208
movq 0x492c(%rip), %rcx      # 0x8200
subq %rcx, %rax
je 0x38ff
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 0x38e7
movl 0x4943(%rip), %edx      # 0x8248
xorps %xmm0, %xmm0
cvtsi2ss %edx, %xmm0
movq -0x30(%rbp), %rcx
xorps %xmm1, %xmm1
cvtsi2ss %rcx, %xmm1
movq -0x28(%rbp), %r8
cvtsi2ss %r8, %xmm2
divss %xmm1, %xmm0
divss %xmm2, %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x19be(%rip), %rsi      # 0x52f2
movq %rbx, %rdi
movb $0x1, %al
callq 0x21c0
leaq 0x19ce(%rip), %rdi      # 0x5313
movl $0x18, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x2270
leaq 0x19ce(%rip), %rdi      # 0x532c
movl $0x22, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x2270
movq 0x4889(%rip), %rax      # 0x8200
cmpq %rax, 0x488a(%rip)      # 0x8208
je 0x39c7
leaq 0x19c8(%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 0x4854(%rip), %rcx      # 0x8208
movq 0x4845(%rip), %rax      # 0x8200
subq %rax, %rcx
sarq $0x3, %rcx
cmpq %r15, %rcx
ja 0x398a
addq $0x88, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq