// File: searsm8[P]FM_Partitioning/fmpart.cpp
// Function: recallBestSolution()
void recallBestSolution()
{
	cut_size = min_cut_size;
	
	//reset the cells partitions to the best solution
	//unlock all cells
	for(int i = 0; i < cells.size(); i++)
	{
		cells[i]->partition = cells[i]->best_partition;
		cells[i]->locked = false;		
	}				

	//reset the partition counts for the best solution
	for(int i = 0; i < nets.size(); i++)
	{	
		//reset nets	
		nets[i]->partition_count[0] = 0;
		nets[i]->partition_count[1] = 0;
		
		nets[i]->has_locked[0] = 0; 
		nets[i]->has_locked[1] = 0;
		
		for(int j = 0; j < nets[i]->cell_list.size(); j++)
		{
			//count how many cells in each partition on this net
			nets[i]->partition_count[nets[i]->cell_list[j]->partition]++;			
		}		
	}
	
	//recalculate the gains for the best solution
	computeGains(); 
	
	//set the partition areas to the best solution
	partition_area[0] = 0;
	partition_area[1] = 0;
	
	for(int i = 0; i < cells.size(); i++)
	{		
		partition_area[cells[i]->partition] += cells[i]->area;
	}	
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movl 0xd3a2(%rip), %eax      # 0x112d0
movl %eax, 0xd374(%rip)      # 0x112a8
movl $0x0, -0x4(%rbp)
movslq -0x4(%rbp), %rax
movq %rax, -0x18(%rbp)
leaq 0xd316(%rip), %rdi      # 0x11260
callq 0x5260
movq %rax, %rcx
movq -0x18(%rbp), %rax
cmpq %rcx, %rax
jae 0x3fb5
movslq -0x4(%rbp), %rsi
leaq 0xd2fa(%rip), %rdi      # 0x11260
callq 0x5280
movq (%rax), %rax
movl 0x88(%rax), %eax
movl %eax, -0x1c(%rbp)
movslq -0x4(%rbp), %rsi
leaq 0xd2de(%rip), %rdi      # 0x11260
callq 0x5280
movl -0x1c(%rbp), %ecx
movq (%rax), %rax
movl %ecx, 0x84(%rax)
movslq -0x4(%rbp), %rsi
leaq 0xd2c2(%rip), %rdi      # 0x11260
callq 0x5280
movq (%rax), %rax
movb $0x0, 0x7d(%rax)
movl -0x4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4(%rbp)
jmp 0x3f3b
movl $0x0, -0x8(%rbp)
movslq -0x8(%rbp), %rax
movq %rax, -0x28(%rbp)
leaq 0xd2ed(%rip), %rdi      # 0x112b8
callq 0x52a0
movq %rax, %rcx
movq -0x28(%rbp), %rax
cmpq %rcx, %rax
jae 0x40ea
movslq -0x8(%rbp), %rsi
leaq 0xd2cd(%rip), %rdi      # 0x112b8
callq 0x52c0
movq (%rax), %rax
movl $0x0, 0x6c(%rax)
movslq -0x8(%rbp), %rsi
leaq 0xd2b3(%rip), %rdi      # 0x112b8
callq 0x52c0
movq (%rax), %rax
movl $0x0, 0x70(%rax)
movslq -0x8(%rbp), %rsi
leaq 0xd299(%rip), %rdi      # 0x112b8
callq 0x52c0
movq (%rax), %rax
movb $0x0, 0x6a(%rax)
movslq -0x8(%rbp), %rsi
leaq 0xd282(%rip), %rdi      # 0x112b8
callq 0x52c0
movq (%rax), %rax
movb $0x0, 0x6b(%rax)
movl $0x0, -0xc(%rbp)
movslq -0xc(%rbp), %rax
movq %rax, -0x30(%rbp)
movslq -0x8(%rbp), %rsi
leaq 0xd25c(%rip), %rdi      # 0x112b8
callq 0x52c0
movq (%rax), %rdi
addq $0x78, %rdi
callq 0x5260
movq %rax, %rcx
movq -0x30(%rbp), %rax
cmpq %rcx, %rax
jae 0x40da
movslq -0x8(%rbp), %rsi
leaq 0xd234(%rip), %rdi      # 0x112b8
callq 0x52c0
movq (%rax), %rax
movq %rax, -0x38(%rbp)
movslq -0x8(%rbp), %rsi
leaq 0xd21d(%rip), %rdi      # 0x112b8
callq 0x52c0
movq (%rax), %rdi
addq $0x78, %rdi
movslq -0xc(%rbp), %rsi
callq 0x5280
movq %rax, %rcx
movq -0x38(%rbp), %rax
movq (%rcx), %rcx
movslq 0x84(%rcx), %rcx
movl 0x6c(%rax,%rcx,4), %edx
addl $0x1, %edx
movl %edx, 0x6c(%rax,%rcx,4)
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x4049
jmp 0x40dc
movl -0x8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8(%rbp)
jmp 0x3fbc
callq 0x3c40
movl $0x0, 0xd1b3(%rip)      # 0x112ac
movl $0x0, 0xd1ad(%rip)      # 0x112b0
movl $0x0, -0x10(%rbp)
movslq -0x10(%rbp), %rax
movq %rax, -0x40(%rbp)
leaq 0xd147(%rip), %rdi      # 0x11260
callq 0x5260
movq %rax, %rcx
movq -0x40(%rbp), %rax
cmpq %rcx, %rax
jae 0x417f
movslq -0x10(%rbp), %rsi
leaq 0xd12b(%rip), %rdi      # 0x11260
callq 0x5280
movq (%rax), %rax
movl 0x78(%rax), %eax
movl %eax, -0x44(%rbp)
movslq -0x10(%rbp), %rsi
leaq 0xd112(%rip), %rdi      # 0x11260
callq 0x5280
movl -0x44(%rbp), %edx
movq (%rax), %rax
movslq 0x84(%rax), %rcx
leaq 0xd145(%rip), %rax      # 0x112ac
addl (%rax,%rcx,4), %edx
leaq 0xd13b(%rip), %rax      # 0x112ac
movl %edx, (%rax,%rcx,4)
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x410a
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)