// File: searsm8[P]FM_Partitioning/fmpart.cpp
// Function: readNetsFile()
void readNetsFile()
{	
	FILE *nets_file;			
	char cells_file_path[100];
	strcpy(cells_file_path, file_path);
	nets_file = fopen(strcat(cells_file_path, "design.nets"), "r");			
	if (nets_file == NULL) { fprintf(stderr, "Can't open nets_file!\n");	exit(1); }
	
	printf("Reading nets file...\n");	
			
	while(!feof(nets_file))
	{
		//read in the net name and number of pins
		NET* current_net;
		current_net = new NET;
			
		char net_name[100];
		fscanf(nets_file, "%*s %s %d", &net_name, &current_net->num_pins);
		if(feof(nets_file)) break;
		
		strcpy(current_net->name, net_name);
		current_net->cutstate = false; //assume not cut
		current_net->critical = false;									
	
		//read each cell in the net, add to net_list and cell_list per FM paper
		for(int c = 0; c < current_net->num_pins; c++)
		{
			char cell_name [100];
			char pin_name [100];	

			fscanf(nets_file, "%s %s", &cell_name, &pin_name);
						
			//avoid adding duplicates
			if(cells_map[cell_name]->net_list.empty() ||
			   cells_map[cell_name]->net_list.back() != current_net )
			{
				//add net to cell's net_list.				
				cells_map[cell_name]->net_list.push_back(current_net);

				//add the new cell to the net's cell_list
				current_net->cell_list.push_back(cells_map[cell_name]);	
			}					
		}
		
		nets.push_back(current_net);			
		fscanf(nets_file, "%*s"); //scan in the "endnet" line				
	}

	fclose(nets_file);
	printf("done!\n");
	return;			
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2e0, %rsp            # imm = 0x2E0
leaq -0x70(%rbp), %rdi
leaq 0xdeda(%rip), %rsi      # 0x111b0
callq 0x21a0
leaq -0x70(%rbp), %rdi
leaq 0x7dde(%rip), %rsi      # 0xb0c4
callq 0x22f0
movq %rax, %rdi
leaq 0x7d45(%rip), %rsi      # 0xb03a
callq 0x2240
movq %rax, -0x8(%rbp)
cmpq $0x0, -0x8(%rbp)
jne 0x3327
movq 0xdccc(%rip), %rax      # 0x10fd8
movq (%rax), %rdi
leaq 0x7dba(%rip), %rsi      # 0xb0d0
movb $0x0, %al
callq 0x2270
movl $0x1, %edi
callq 0x2250
leaq 0x7db9(%rip), %rdi      # 0xb0e7
movb $0x0, %al
callq 0x2040
movq -0x8(%rbp), %rdi
callq 0x22a0
cmpl $0x0, %eax
setne %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x334f
jmp 0x37d1
movl $0x90, %edi
callq 0x21d0
movq %rax, %rdi
movq %rdi, -0x278(%rbp)
callq 0x5150
movq -0x278(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x8(%rbp), %rdi
movq -0x78(%rbp), %rcx
addq $0x64, %rcx
leaq 0x7d77(%rip), %rsi      # 0xb0fd
leaq -0xe0(%rbp), %rdx
movb $0x0, %al
callq 0x2310
movq -0x8(%rbp), %rdi
callq 0x22a0
cmpl $0x0, %eax
je 0x33a7
jmp 0x37d1
movq -0x78(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0x21a0
movq -0x78(%rbp), %rax
movb $0x0, 0x68(%rax)
movq -0x78(%rbp), %rax
movb $0x0, 0x69(%rax)
movl $0x0, -0xe4(%rbp)
movl -0xe4(%rbp), %eax
movq -0x78(%rbp), %rcx
cmpl 0x64(%rcx), %eax
jge 0x37aa
movq -0x8(%rbp), %rdi
leaq 0x7c7c(%rip), %rsi      # 0xb06b
xorl %eax, %eax
leaq -0x150(%rbp), %rdx
movq %rdx, -0x288(%rbp)
leaq -0x1c0(%rbp), %rcx
callq 0x2310
leaq -0x1e1(%rbp), %rdi
movq %rdi, -0x280(%rbp)
callq 0x22e0
movq -0x288(%rbp), %rsi
movq -0x280(%rbp), %rdx
movb $0x0, -0x21a(%rbp)
movb $0x0, -0x21b(%rbp)
leaq -0x1e0(%rbp), %rdi
callq 0x4ca0
jmp 0x3448
leaq 0xde29(%rip), %rdi      # 0x11278
leaq -0x1e0(%rbp), %rsi
callq 0x5050
movq %rax, -0x290(%rbp)
jmp 0x3464
movq -0x290(%rbp), %rax
movq (%rax), %rdi
addq $0x98, %rdi
callq 0x5170
movb %al, %cl
movb $0x1, %al
testb $0x1, %cl
movb %al, -0x291(%rbp)
jne 0x3508
leaq -0x219(%rbp), %rdi
movq %rdi, -0x2a0(%rbp)
callq 0x22e0
movq -0x2a0(%rbp), %rdx
movb $0x1, -0x21a(%rbp)
leaq -0x218(%rbp), %rdi
leaq -0x150(%rbp), %rsi
callq 0x4ca0
jmp 0x34bf
movb $0x1, -0x21b(%rbp)
leaq 0xddab(%rip), %rdi      # 0x11278
leaq -0x218(%rbp), %rsi
callq 0x5050
movq %rax, -0x2a8(%rbp)
jmp 0x34e2
movq -0x2a8(%rbp), %rax
movq (%rax), %rdi
addq $0x98, %rdi
callq 0x51b0
movq (%rax), %rax
cmpq -0x78(%rbp), %rax
setne %al
movb %al, -0x291(%rbp)
movb -0x291(%rbp), %al
movb %al, -0x2a9(%rbp)
testb $0x1, -0x21b(%rbp)
jne 0x351f
jmp 0x352b
leaq -0x218(%rbp), %rdi
callq 0x2100
testb $0x1, -0x21a(%rbp)
jne 0x3536
jmp 0x3542
leaq -0x219(%rbp), %rdi
callq 0x2210
leaq -0x1e0(%rbp), %rdi
callq 0x2100
leaq -0x1e1(%rbp), %rdi
callq 0x2210
movb -0x2a9(%rbp), %al
testb $0x1, %al
jne 0x3569
jmp 0x3794
leaq -0x241(%rbp), %rdi
movq %rdi, -0x2b8(%rbp)
callq 0x22e0
movq -0x2b8(%rbp), %rdx
leaq -0x240(%rbp), %rdi
leaq -0x150(%rbp), %rsi
callq 0x4ca0
jmp 0x3598
leaq 0xdcd9(%rip), %rdi      # 0x11278
leaq -0x240(%rbp), %rsi
callq 0x5050
movq %rax, -0x2c0(%rbp)
jmp 0x35b4
movq -0x2c0(%rbp), %rax
movq (%rax), %rdi
addq $0x98, %rdi
leaq -0x78(%rbp), %rsi
callq 0x51f0
jmp 0x35d0
leaq -0x240(%rbp), %rdi
callq 0x2100
leaq -0x241(%rbp), %rdi
callq 0x2210
movq -0x78(%rbp), %rax
addq $0x78, %rax
movq %rax, -0x2d0(%rbp)
leaq -0x269(%rbp), %rdi
movq %rdi, -0x2c8(%rbp)
callq 0x22e0
movq -0x2c8(%rbp), %rdx
leaq -0x268(%rbp), %rdi
leaq -0x150(%rbp), %rsi
callq 0x4ca0
jmp 0x3626
leaq 0xdc4b(%rip), %rdi      # 0x11278
leaq -0x268(%rbp), %rsi
callq 0x5050
movq %rax, -0x2d8(%rbp)
jmp 0x3642
movq -0x2d8(%rbp), %rsi
movq -0x2d0(%rbp), %rdi
callq 0x4fe0
jmp 0x3657
leaq -0x268(%rbp), %rdi
callq 0x2100
leaq -0x269(%rbp), %rdi
callq 0x2210
jmp 0x3794
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1f0(%rbp)
movl %eax, -0x1f4(%rbp)
jmp 0x3700
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1f0(%rbp)
movl %eax, -0x1f4(%rbp)
jmp 0x36f4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1f0(%rbp)
movl %eax, -0x1f4(%rbp)
jmp 0x36db
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1f0(%rbp)
movl %eax, -0x1f4(%rbp)
testb $0x1, -0x21b(%rbp)
jne 0x36cd
jmp 0x36d9
leaq -0x218(%rbp), %rdi
callq 0x2100
jmp 0x36db
testb $0x1, -0x21a(%rbp)
jne 0x36e6
jmp 0x36f2
leaq -0x219(%rbp), %rdi
callq 0x2210
jmp 0x36f4
leaq -0x1e0(%rbp), %rdi
callq 0x2100
leaq -0x1e1(%rbp), %rdi
callq 0x2210
jmp 0x37f1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1f0(%rbp)
movl %eax, -0x1f4(%rbp)
jmp 0x3743
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1f0(%rbp)
movl %eax, -0x1f4(%rbp)
leaq -0x240(%rbp), %rdi
callq 0x2100
leaq -0x241(%rbp), %rdi
callq 0x2210
jmp 0x37f1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1f0(%rbp)
movl %eax, -0x1f4(%rbp)
jmp 0x3786
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1f0(%rbp)
movl %eax, -0x1f4(%rbp)
leaq -0x268(%rbp), %rdi
callq 0x2100
leaq -0x269(%rbp), %rdi
callq 0x2210
jmp 0x37f1
jmp 0x3796
movl -0xe4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xe4(%rbp)
jmp 0x33d1
leaq 0xdb07(%rip), %rdi      # 0x112b8
leaq -0x78(%rbp), %rsi
callq 0x51f0
movq -0x8(%rbp), %rdi
leaq 0x7942(%rip), %rsi      # 0xb107
movb $0x0, %al
callq 0x2310
jmp 0x3335
movq -0x8(%rbp), %rdi
callq 0x21c0
leaq 0x78dc(%rip), %rdi      # 0xb0bd
movb $0x0, %al
callq 0x2040
addq $0x2e0, %rsp            # imm = 0x2E0
popq %rbp
retq
movq -0x1f0(%rbp), %rdi
callq 0x22d0
nopl (%rax)