// File: 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
subq $0xd0, %rsp
leaq -0x70(%rbp), %rdi
leaq 0xcbea(%rip), %rsi      # 0x111b0
callq 0x21a0
leaq -0x70(%rbp), %rdi
leaq 0x6cdc(%rip), %rsi      # 0xb2b2
callq 0x22f0
movq %rax, %rdi
leaq 0x6cdf(%rip), %rsi      # 0xb2c4
callq 0x2240
movq %rax, -0x8(%rbp)
leaq -0x70(%rbp), %rsi
leaq 0x6ccd(%rip), %rdi      # 0xb2c6
movb $0x0, %al
callq 0x2040
movq -0x8(%rbp), %rdi
leaq 0x6cda(%rip), %rsi      # 0xb2e5
leaq 0xcb9e(%rip), %rdx      # 0x111b0
movb $0x0, %al
callq 0x2270
movq -0x8(%rbp), %rax
movq %rax, -0x98(%rbp)
callq 0x2110
subq 0xccb0(%rip), %rax      # 0x112e0
cvtsi2sd %rax, %xmm0
movsd 0x69d3(%rip), %xmm1     # 0xb010
divsd %xmm1, %xmm0
movsd %xmm0, -0x90(%rbp)
callq 0x2110
movq -0x98(%rbp), %rdi
movsd -0x90(%rbp), %xmm0
subq 0xcc84(%rip), %rax      # 0x112e8
cvtsi2sd %rax, %xmm1
movsd 0x699f(%rip), %xmm2     # 0xb010
divsd %xmm2, %xmm1
movl 0xcb59(%rip), %edx      # 0x111d4
leaq 0x6c83(%rip), %rsi      # 0xb305
movb $0x2, %al
callq 0x2270
movq -0x8(%rbp), %rdi
movl 0xcc41(%rip), %edx      # 0x112d4
leaq 0x6c99(%rip), %rsi      # 0xb333
movb $0x0, %al
callq 0x2270
movq -0x8(%rbp), %rdi
movl 0xcbfd(%rip), %edx      # 0x112a8
leaq 0x6c93(%rip), %rsi      # 0xb345
movb $0x0, %al
callq 0x2270
movq -0x8(%rbp), %rdi
movl 0xcc11(%rip), %eax      # 0x112d4
subl 0xcbdf(%rip), %eax      # 0x112a8
cvtsi2ss %eax, %xmm0
cvtsi2ssl 0xcbff(%rip), %xmm1 # 0x112d4
divss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x6c70(%rip), %rsi      # 0xb354
movb $0x1, %al
callq 0x2270
leaq -0x80(%rbp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x20d0
movl $0x0, -0x84(%rbp)
movslq -0x84(%rbp), %rax
movq %rax, -0xa0(%rbp)
leaq 0xcb46(%rip), %rdi      # 0x11260
callq 0x5260
movq %rax, %rcx
movq -0xa0(%rbp), %rax
cmpq %rcx, %rax
jae 0x476a
movslq -0x84(%rbp), %rsi
leaq 0xcb24(%rip), %rdi      # 0x11260
callq 0x5280
movq (%rax), %rax
movslq 0x84(%rax), %rax
movq -0x80(%rbp,%rax,8), %rcx
addq $0x1, %rcx
movq %rcx, -0x80(%rbp,%rax,8)
movl -0x84(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x84(%rbp)
jmp 0x4705
movq -0x8(%rbp), %rdi
cvtsi2ssl 0xcb32(%rip), %xmm0 # 0x112a8
cvtsi2ssq -0x80(%rbp), %xmm1
divss %xmm1, %xmm0
cvtsi2ssq -0x78(%rbp), %xmm1
divss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
movl 0xcb14(%rip), %edx      # 0x112a8
movq -0x80(%rbp), %rcx
movq -0x78(%rbp), %r8
leaq 0x6bc8(%rip), %rsi      # 0xb36b
movb $0x1, %al
callq 0x2270
movq -0x8(%rbp), %rdi
leaq 0x6bd7(%rip), %rsi      # 0xb38c
movb $0x0, %al
callq 0x2270
movq -0x8(%rbp), %rdi
leaq 0x6bde(%rip), %rsi      # 0xb3a5
movb $0x0, %al
callq 0x2270
movl $0x0, -0x88(%rbp)
movslq -0x88(%rbp), %rax
movq %rax, -0xa8(%rbp)
leaq 0xca73(%rip), %rdi      # 0x11260
callq 0x5260
movq %rax, %rcx
movq -0xa8(%rbp), %rax
cmpq %rcx, %rax
jae 0x48c8
movq -0x8(%rbp), %rax
movq %rax, -0xc8(%rbp)
movslq -0x88(%rbp), %rsi
leaq 0xca42(%rip), %rdi      # 0x11260
callq 0x5280
movq (%rax), %rax
movq %rax, -0xc0(%rbp)
movslq -0x88(%rbp), %rsi
leaq 0xca25(%rip), %rdi      # 0x11260
callq 0x5280
movq (%rax), %rax
addq $0x64, %rax
movq %rax, -0xb8(%rbp)
movslq -0x88(%rbp), %rsi
leaq 0xca04(%rip), %rdi      # 0x11260
callq 0x5280
movq (%rax), %rax
movl 0x78(%rax), %eax
movl %eax, -0xac(%rbp)
movslq -0x88(%rbp), %rsi
leaq 0xc9e5(%rip), %rdi      # 0x11260
callq 0x5280
movq -0xc8(%rbp), %rdi
movq -0xc0(%rbp), %rdx
movq -0xb8(%rbp), %rcx
movl -0xac(%rbp), %r8d
movq (%rax), %rax
movl 0x88(%rax), %r9d
leaq 0x6b1b(%rip), %rsi      # 0xb3c8
movb $0x0, %al
callq 0x2270
movl -0x88(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x88(%rbp)
jmp 0x47d8
addq $0xd0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)