// File: /workspace/github_cpp_makefile_star2_O2/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 0x4dd6(%rip), %r14      # 0x8160
leaq -0xa0(%rbp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x2150
movq %r15, %rdi
callq 0x20a0
movups 0x1e8e(%rip), %xmm0     # 0x5239
movups %xmm0, -0xa0(%rbp,%rax)
movw $0x73, -0x90(%rbp,%rax)
leaq 0x1e87(%rip), %rsi      # 0x524b
movq %r15, %rdi
callq 0x21b0
movq %rax, %rbx
leaq 0x1e77(%rip), %rdi      # 0x524d
xorl %r12d, %r12d
movq %r15, %rsi
xorl %eax, %eax
callq 0x2040
leaq 0x1e82(%rip), %rsi      # 0x526c
movq %rbx, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x21e0
callq 0x20e0
subq 0x4e8d(%rip), %rax      # 0x8290
cvtsi2sd %rax, %xmm0
divsd 0x1c18(%rip), %xmm0     # 0x5028
movsd %xmm0, -0x38(%rbp)
callq 0x20e0
subq 0x4e77(%rip), %rax      # 0x8298
cvtsi2sd %rax, %xmm1
divsd 0x1bfa(%rip), %xmm1     # 0x5028
movl 0x4d50(%rip), %edx      # 0x8184
leaq 0x1e51(%rip), %rsi      # 0x528c
movq %rbx, %rdi
movsd -0x38(%rbp), %xmm0
movb $0x2, %al
callq 0x21e0
movl 0x4e34(%rip), %edx      # 0x8284
leaq 0x1e63(%rip), %rsi      # 0x52ba
movq %rbx, %rdi
xorl %eax, %eax
callq 0x21e0
movl 0x4df1(%rip), %edx      # 0x8258
leaq 0x1e5e(%rip), %rsi      # 0x52cc
movq %rbx, %rdi
xorl %eax, %eax
callq 0x21e0
movl 0x4e06(%rip), %eax      # 0x8284
cvtsi2ss %eax, %xmm0
subl 0x4dd0(%rip), %eax      # 0x8258
cvtsi2ss %eax, %xmm1
divss %xmm0, %xmm1
cvtss2sd %xmm1, %xmm0
leaq 0x1e40(%rip), %rsi      # 0x52db
movq %rbx, %rdi
movb $0x1, %al
callq 0x21e0
xorps %xmm0, %xmm0
movaps %xmm0, -0x30(%rbp)
movq 0x4d65(%rip), %rax      # 0x8218
movq 0x4d56(%rip), %rcx      # 0x8210
subq %rcx, %rax
sarq $0x3, %rax
cmpq %r12, %rax
jbe 0x34db
movq (%rcx,%r12,8), %rdx
movslq 0x84(%rdx), %rdx
incq -0x30(%rbp,%rdx,8)
incq %r12
jmp 0x34c1
movl 0x4d77(%rip), %edx      # 0x8258
cvtsi2ss %edx, %xmm0
movq -0x30(%rbp), %rcx
cvtsi2ss %rcx, %xmm1
movq -0x28(%rbp), %r8
cvtsi2ss %r8, %xmm2
divss %xmm1, %xmm0
divss %xmm2, %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x1de8(%rip), %rsi      # 0x52f2
movq %rbx, %rdi
movb $0x1, %al
callq 0x21e0
leaq 0x1df8(%rip), %rdi      # 0x5313
pushq $0x18
popq %rsi
pushq $0x1
popq %r14
movq %r14, %rdx
movq %rbx, %rcx
callq 0x2290
leaq 0x1df8(%rip), %rdi      # 0x532c
pushq $0x22
popq %rsi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x2290
leaq 0x1e06(%rip), %r14      # 0x534f
xorl %r15d, %r15d
movq 0x4cc5(%rip), %rcx      # 0x8218
movq 0x4cb6(%rip), %rax      # 0x8210
subq %rax, %rcx
sarq $0x3, %rcx
cmpq %r15, %rcx
jbe 0x358b
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 0x21e0
incq %r15
jmp 0x354c
addq $0x80, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq