// File: monikakushwaha28[P]Fiduccia_Matthesys-using-c-/Fiduccia_Mattheyses_v1.0.cpp
// Function: re_cal_DS()
void re_cal_DS()
{
	//erasing entire net card map
	net_card.erase(net_card.begin(), net_card.end());

	l = 0;
	cell = 0;
	count1 = 0;
	countn1 = 0;

	//reverting back the changes
	for (l = max_gain_pos; l < fixed_cell_list.size(); l++)
	{
		cell = fixed_cell_list[l];
		node_map[cell][1] = -1 * (node_map[cell][1]);
	}

	//unfix all fix nodes
	for (nodeiter r = node_map.begin(); r != node_map.end(); r++)
	{
		node_map[r->first][2] = 0;
	}

	//re building net card
	for (netnodeiter t = net_node_map.begin(); t != net_node_map.end(); t++)
	{
		count1 = 0;
		countn1 = 0;
		newnetname = t->first;
		for (int y = 0; y < t->second.size(); y++)
		{
			if (node_map[net_node_map[newnetname][y]][1] == 1)
			{
				count1 = count1 + 1;
			}
			if (node_map[net_node_map[newnetname][y]][1] == -1)
			{
				countn1 = countn1 + 1;
			}
		}
		net_card[newnetname].push_back(count1);
		net_card[newnetname].push_back(countn1);
	}

	//re building gain bucket
	for (int i = 0; i < free_nodes.size(); i++)
	{
		int current_node = free_nodes.at(i);
		gain = 0;
		for (int var = 0; var < node_net_map[current_node].size(); var++)
		{
			current_net = node_net_map[current_node].at(var);
			net_count1 = net_card[current_net].at(0);
			net_countn1 = net_card[current_net].at(1);
			current_wgt = node_map[current_node].at(0);
			current_part = node_map[current_node].at(1);
			if (current_part == 1)
			{
				if (net_count1 == 1)
				{
					gain = gain + 1;
				}
				else if (net_countn1 == 0)
				{
					gain = gain - 1;
				}
			}
			else
			{
				if (net_count1 == 0)
				{
					gain = gain - 1;
				}
				else if (net_countn1 == 1)
				{
					gain = gain + 1;
				}
			}
		}
		gain_bucket[gain].push_back(current_node);
		node_map[current_node][3] = gain;
	}

	//reinitializing fix bucket
	fixed_cell_list.clear();

	//Realizing the FM Algorithm
	//Variables
	gain_cell = 0;
	wp1 = wp1_mincut;
	wpn1 = wpn1_mincut;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
leaq 0x141e6(%rip), %rdi     # 0x16c98
callq 0x6c00
movq %rax, -0x10(%rbp)
leaq -0x8(%rbp), %rdi
leaq -0x10(%rbp), %rsi
callq 0x6c30
leaq 0x141c9(%rip), %rdi     # 0x16c98
callq 0x6c50
movq %rax, -0x20(%rbp)
leaq -0x18(%rbp), %rdi
leaq -0x20(%rbp), %rsi
callq 0x6c30
movq -0x8(%rbp), %rsi
movq -0x18(%rbp), %rdx
leaq 0x141a4(%rip), %rdi     # 0x16c98
callq 0x6bb0
movq %rax, -0x28(%rbp)
movl $0x0, 0x14011(%rip)     # 0x16b18
movl $0x0, 0x1400b(%rip)     # 0x16b1c
movl $0x0, 0x13ff5(%rip)     # 0x16b10
movl $0x0, 0x13fef(%rip)     # 0x16b14
movl 0x14071(%rip), %eax     # 0x16b9c
movl %eax, 0x13fe7(%rip)     # 0x16b18
movslq 0x13fe0(%rip), %rax     # 0x16b18
movq %rax, -0x78(%rbp)
leaq 0x1419d(%rip), %rdi     # 0x16ce0
callq 0x6c80
movq %rax, %rcx
movq -0x78(%rbp), %rax
cmpq %rcx, %rax
jae 0x2bd1
movslq 0x13fbd(%rip), %rsi     # 0x16b18
leaq 0x1417e(%rip), %rdi     # 0x16ce0
callq 0x6ca0
movl (%rax), %eax
movl %eax, 0x13fad(%rip)     # 0x16b1c
leaq 0x14062(%rip), %rdi     # 0x16bd8
leaq 0x13f9f(%rip), %rsi     # 0x16b1c
callq 0x6cc0
movq %rax, %rdi
movl $0x1, %esi
callq 0x6ca0
imull $0xffffffff, (%rax), %eax # imm = 0xFFFFFFFF
movl %eax, -0x7c(%rbp)
leaq 0x14039(%rip), %rdi     # 0x16bd8
leaq 0x13f76(%rip), %rsi     # 0x16b1c
callq 0x6cc0
movq %rax, %rdi
movl $0x1, %esi
callq 0x6ca0
movl -0x7c(%rbp), %ecx
movl %ecx, (%rax)
movl 0x13f55(%rip), %eax     # 0x16b18
addl $0x1, %eax
movl %eax, 0x13f4c(%rip)     # 0x16b18
jmp 0x2b31
leaq 0x14000(%rip), %rdi     # 0x16bd8
callq 0x6da0
movq %rax, -0x30(%rbp)
leaq 0x13ff0(%rip), %rdi     # 0x16bd8
callq 0x6e00
movq %rax, -0x38(%rbp)
leaq -0x30(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x6dd0
testb $0x1, %al
jne 0x2c04
jmp 0x2c40
leaq -0x30(%rbp), %rdi
callq 0x6e30
movq %rax, %rsi
leaq 0x13fc1(%rip), %rdi     # 0x16bd8
callq 0x6cc0
movq %rax, %rdi
movl $0x2, %esi
callq 0x6ca0
movl $0x0, (%rax)
leaq -0x30(%rbp), %rdi
xorl %esi, %esi
callq 0x6e50
movq %rax, -0x40(%rbp)
jmp 0x2be1
leaq 0x13ff1(%rip), %rdi     # 0x16c38
callq 0x6c00
movq %rax, -0x48(%rbp)
leaq 0x13fe1(%rip), %rdi     # 0x16c38
callq 0x6c50
movq %rax, -0x50(%rbp)
leaq -0x48(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x6e90
testb $0x1, %al
jne 0x2c76
jmp 0x2de2
movl $0x0, 0x13e90(%rip)     # 0x16b10
movl $0x0, 0x13e8a(%rip)     # 0x16b14
leaq -0x48(%rbp), %rdi
callq 0x6ec0
movq %rax, %rsi
leaq 0x13e43(%rip), %rdi     # 0x16ae0
callq 0x2040
movl $0x0, -0x54(%rbp)
movslq -0x54(%rbp), %rax
movq %rax, -0x88(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x6ec0
movq %rax, %rdi
addq $0x20, %rdi
callq 0x6c80
movq %rax, %rcx
movq -0x88(%rbp), %rax
cmpq %rcx, %rax
jae 0x2d8a
leaq 0x13f55(%rip), %rdi     # 0x16c38
leaq 0x13df6(%rip), %rsi     # 0x16ae0
callq 0x6ee0
movq %rax, %rdi
movslq -0x54(%rbp), %rsi
callq 0x6ca0
movq %rax, %rsi
leaq 0x13ed3(%rip), %rdi     # 0x16bd8
callq 0x6cc0
movq %rax, %rdi
movl $0x1, %esi
callq 0x6ca0
cmpl $0x1, (%rax)
jne 0x2d2b
movl 0x13dee(%rip), %eax     # 0x16b10
addl $0x1, %eax
movl %eax, 0x13de5(%rip)     # 0x16b10
leaq 0x13f06(%rip), %rdi     # 0x16c38
leaq 0x13da7(%rip), %rsi     # 0x16ae0
callq 0x6ee0
movq %rax, %rdi
movslq -0x54(%rbp), %rsi
callq 0x6ca0
movq %rax, %rsi
leaq 0x13e84(%rip), %rdi     # 0x16bd8
callq 0x6cc0
movq %rax, %rdi
movl $0x1, %esi
callq 0x6ca0
cmpl $-0x1, (%rax)
jne 0x2d7a
movl 0x13da3(%rip), %eax     # 0x16b14
addl $0x1, %eax
movl %eax, 0x13d9a(%rip)     # 0x16b14
jmp 0x2d7c
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x2ca9
leaq 0x13f07(%rip), %rdi     # 0x16c98
leaq 0x13d48(%rip), %rsi     # 0x16ae0
callq 0x6ee0
movq %rax, %rdi
leaq 0x13d69(%rip), %rsi     # 0x16b10
callq 0x6fc0
leaq 0x13ee5(%rip), %rdi     # 0x16c98
leaq 0x13d26(%rip), %rsi     # 0x16ae0
callq 0x6ee0
movq %rax, %rdi
leaq 0x13d4b(%rip), %rsi     # 0x16b14
callq 0x6fc0
leaq -0x48(%rbp), %rdi
xorl %esi, %esi
callq 0x7030
movq %rax, -0x60(%rbp)
jmp 0x2c50
movl $0x0, -0x64(%rbp)
movslq -0x64(%rbp), %rax
movq %rax, -0x90(%rbp)
leaq 0x13ecd(%rip), %rdi     # 0x16cc8
callq 0x6c80
movq %rax, %rcx
movq -0x90(%rbp), %rax
cmpq %rcx, %rax
jae 0x3015
movslq -0x64(%rbp), %rsi
leaq 0x13eaa(%rip), %rdi     # 0x16cc8
callq 0x7070
movl (%rax), %eax
movl %eax, -0x68(%rbp)
movl $0x0, 0x13d1a(%rip)     # 0x16b4c
movl $0x0, -0x6c(%rbp)
movslq -0x6c(%rbp), %rax
movq %rax, -0x98(%rbp)
leaq 0x13dbd(%rip), %rdi     # 0x16c08
leaq -0x68(%rbp), %rsi
callq 0x70b0
movq %rax, %rdi
callq 0x7190
movq %rax, %rcx
movq -0x98(%rbp), %rax
cmpq %rcx, %rax
jae 0x2fb7
leaq 0x13d92(%rip), %rdi     # 0x16c08
leaq -0x68(%rbp), %rsi
callq 0x70b0
movq %rax, %rdi
movslq -0x6c(%rbp), %rsi
callq 0x71b0
movq %rax, %rsi
leaq 0x13c0b(%rip), %rdi     # 0x16aa0
callq 0x2040
leaq 0x13df7(%rip), %rdi     # 0x16c98
leaq 0x13bf8(%rip), %rsi     # 0x16aa0
callq 0x6ee0
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x7070
movl (%rax), %eax
movl %eax, 0x13c83(%rip)     # 0x16b44
leaq 0x13dd0(%rip), %rdi     # 0x16c98
leaq 0x13bd1(%rip), %rsi     # 0x16aa0
callq 0x6ee0
movq %rax, %rdi
movl $0x1, %esi
callq 0x7070
movl (%rax), %eax
movl %eax, 0x13c5f(%rip)     # 0x16b48
leaq 0x13ce8(%rip), %rdi     # 0x16bd8
leaq -0x68(%rbp), %rsi
callq 0x6cc0
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x7070
movl (%rax), %eax
movl %eax, 0x13c2f(%rip)     # 0x16b3c
leaq 0x13cc4(%rip), %rdi     # 0x16bd8
leaq -0x68(%rbp), %rsi
callq 0x6cc0
movq %rax, %rdi
movl $0x1, %esi
callq 0x7070
movl (%rax), %eax
movl %eax, 0x13c0e(%rip)     # 0x16b40
cmpl $0x1, 0x13c07(%rip)     # 0x16b40
jne 0x2f71
cmpl $0x1, 0x13c02(%rip)     # 0x16b44
jne 0x2f55
movl 0x13c02(%rip), %eax     # 0x16b4c
addl $0x1, %eax
movl %eax, 0x13bf9(%rip)     # 0x16b4c
jmp 0x2f6f
cmpl $0x0, 0x13bec(%rip)     # 0x16b48
jne 0x2f6d
movl 0x13be8(%rip), %eax     # 0x16b4c
subl $0x1, %eax
movl %eax, 0x13bdf(%rip)     # 0x16b4c
jmp 0x2f6f
jmp 0x2fa7
cmpl $0x0, 0x13bcc(%rip)     # 0x16b44
jne 0x2f8b
movl 0x13bcc(%rip), %eax     # 0x16b4c
subl $0x1, %eax
movl %eax, 0x13bc3(%rip)     # 0x16b4c
jmp 0x2fa5
cmpl $0x1, 0x13bb6(%rip)     # 0x16b48
jne 0x2fa3
movl 0x13bb2(%rip), %eax     # 0x16b4c
addl $0x1, %eax
movl %eax, 0x13ba9(%rip)     # 0x16b4c
jmp 0x2fa5
jmp 0x2fa7
jmp 0x2fa9
movl -0x6c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6c(%rbp)
jmp 0x2e39
leaq 0x13caa(%rip), %rdi     # 0x16c68
leaq 0x13b87(%rip), %rsi     # 0x16b4c
callq 0x6cc0
movq %rax, %rdi
leaq -0x68(%rbp), %rsi
callq 0x6fc0
movl 0x13b70(%rip), %eax     # 0x16b4c
movl %eax, -0x9c(%rbp)
leaq 0x13bef(%rip), %rdi     # 0x16bd8
leaq -0x68(%rbp), %rsi
callq 0x6cc0
movq %rax, %rdi
movl $0x3, %esi
callq 0x6ca0
movl -0x9c(%rbp), %ecx
movl %ecx, (%rax)
movl -0x64(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x64(%rbp)
jmp 0x2de9
leaq 0x13cc4(%rip), %rdi     # 0x16ce0
callq 0x71f0
movl $0x0, 0x13b49(%rip)     # 0x16b74
movss 0x13afd(%rip), %xmm0    # 0x16b30
movss %xmm0, 0x13aed(%rip)    # 0x16b28
movss 0x13af1(%rip), %xmm0    # 0x16b34
movss %xmm0, 0x13ae1(%rip)    # 0x16b2c
addq $0xa0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)