// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x218, %rsp            # imm = 0x218
leaq 0x5570(%rip), %rsi      # 0x8150
leaq -0x160(%rbp), %rbx
movq %rbx, %rdi
callq 0x2140
movq %rbx, %rdi
callq 0x20a0
movabsq $0x6e2e6e6769736564, %rcx # imm = 0x6E2E6E6769736564
movq %rcx, -0x160(%rbp,%rax)
movl $0x737465, -0x158(%rbp,%rax) # imm = 0x737465
leaq 0x2437(%rip), %rsi      # 0x5052
movq %rbx, %rdi
callq 0x21a0
testq %rax, %rax
je 0x2f7b
movq %rax, %rbx
leaq 0x2796(%rip), %rdi      # 0x53cc
callq 0x21f0
leaq -0x48(%rbp), %r15
leaq -0x1d0(%rbp), %r14
leaq -0x58(%rbp), %r13
movq %rbx, -0x88(%rbp)
movq %rbx, %rdi
callq 0x2200
testl %eax, %eax
jne 0x2f55
movl $0x90, %edi
callq 0x2170
xorps %xmm0, %xmm0
movups %xmm0, 0x78(%rax)
movq $0x0, 0x88(%rax)
movq %rax, -0x30(%rbp)
leaq 0x64(%rax), %rcx
movq %rbx, %rdi
leaq 0x2452(%rip), %rsi      # 0x50e1
movq %r14, %rdx
xorl %eax, %eax
callq 0x2260
movq %rbx, %rdi
callq 0x2200
testl %eax, %eax
jne 0x2f55
movl %eax, -0x5c(%rbp)
movq -0x30(%rbp), %rdi
movq %r14, %rsi
callq 0x2140
movq -0x30(%rbp), %rax
movw $0x0, 0x68(%rax)
cmpl $0x0, 0x64(%rax)
jle 0x2f06
xorl %ecx, %ecx
movl %ecx, -0x34(%rbp)
movq %rbx, %rdi
leaq 0x2391(%rip), %rsi      # 0x506c
leaq -0xf0(%rbp), %r14
movq %r14, %rdx
leaq -0x240(%rbp), %rcx
xorl %eax, %eax
callq 0x2260
movq %r15, -0x58(%rbp)
movq %r14, %rdi
callq 0x20a0
leaq (%rax,%rbp), %rdx
addq $-0xf0, %rdx
movq %r13, %rdi
movq %r14, %rsi
callq 0x4308
leaq 0x54fc(%rip), %rdi      # 0x8218
movq %r13, %rsi
callq 0x3cce
movq (%rax), %rax
movq 0x98(%rax), %r14
movq 0xa0(%rax), %rbx
cmpq %rbx, %r14
je 0x2d98
movq %r15, %r12
leaq -0x70(%rbp), %rax
movq %rax, -0x80(%rbp)
leaq -0xf0(%rbp), %r15
movq %r15, %rdi
callq 0x20a0
leaq (%rax,%rbp), %rdx
addq $-0xf0, %rdx
leaq -0x80(%rbp), %r13
movq %r13, %rdi
movq %r15, %rsi
callq 0x4308
leaq 0x54a3(%rip), %rdi      # 0x8218
movq %r13, %rsi
movq %r12, %r15
callq 0x3cce
movq (%rax), %rax
movq 0xa0(%rax), %rax
movq -0x8(%rax), %rax
cmpq -0x30(%rbp), %rax
setne %r15b
jmp 0x2d9b
movb $0x1, %r15b
cmpq %rbx, %r14
movq -0x88(%rbp), %rbx
leaq -0x58(%rbp), %r13
je 0x2dc4
movq -0x80(%rbp), %rdi
leaq -0x70(%rbp), %rax
cmpq %rax, %rdi
je 0x2dc4
movq -0x70(%rbp), %rsi
incq %rsi
callq 0x2180
movq -0x58(%rbp), %rdi
leaq -0x48(%rbp), %rax
cmpq %rax, %rdi
je 0x2ddd
movq -0x48(%rbp), %rsi
incq %rsi
callq 0x2180
testb %r15b, %r15b
leaq -0x48(%rbp), %r15
movl -0x34(%rbp), %ecx
je 0x2ef7
movq %r15, -0x58(%rbp)
leaq -0xf0(%rbp), %r14
movq %r14, %rdi
callq 0x20a0
leaq (%rax,%rbp), %rdx
addq $-0xf0, %rdx
movq %r13, %rdi
movq %r14, %rsi
callq 0x4308
leaq 0x53fb(%rip), %rdi      # 0x8218
movq %r13, %rsi
callq 0x3cce
movq (%rax), %rdi
movq 0xa0(%rdi), %rsi
cmpq 0xa8(%rdi), %rsi
je 0x2e49
movq -0x30(%rbp), %rax
movq %rax, (%rsi)
addq $0x8, 0xa0(%rdi)
jmp 0x2e59
addq $0x98, %rdi
leaq -0x30(%rbp), %rdx
callq 0x4b94
movq -0x58(%rbp), %rdi
cmpq %r15, %rdi
je 0x2e6e
movq -0x48(%rbp), %rsi
incq %rsi
callq 0x2180
movq -0x30(%rbp), %r14
movq %r15, %r12
movq %r15, -0x58(%rbp)
leaq -0xf0(%rbp), %r15
movq %r15, %rdi
callq 0x20a0
leaq (%rax,%rbp), %rdx
addq $-0xf0, %rdx
movq %r13, %rdi
movq %r15, %rsi
callq 0x4308
leaq 0x5373(%rip), %rdi      # 0x8218
movq %r13, %rsi
movq %r12, %r15
callq 0x3cce
movq 0x80(%r14), %rsi
cmpq 0x88(%r14), %rsi
je 0x2ed0
movq (%rax), %rax
movq %rax, (%rsi)
addq $0x8, 0x80(%r14)
jmp 0x2edf
addq $0x78, %r14
movq %r14, %rdi
movq %rax, %rdx
callq 0x470c
movq -0x58(%rbp), %rdi
cmpq %r15, %rdi
je 0x2ef4
movq -0x48(%rbp), %rsi
incq %rsi
callq 0x2180
movl -0x34(%rbp), %ecx
incl %ecx
movq -0x30(%rbp), %rax
cmpl 0x64(%rax), %ecx
jl 0x2cce
movq 0x5353(%rip), %rsi      # 0x8260
cmpq 0x5354(%rip), %rsi      # 0x8268
je 0x2f23
movq %rax, (%rsi)
addq $0x8, 0x533f(%rip)      # 0x8260
jmp 0x2f33
leaq 0x532e(%rip), %rdi      # 0x8258
leaq -0x30(%rbp), %rdx
callq 0x4b94
movq %rbx, %rdi
leaq 0x21ae(%rip), %rsi      # 0x50eb
xorl %eax, %eax
callq 0x2260
cmpl $0x0, -0x5c(%rbp)
leaq -0x1d0(%rbp), %r14
je 0x2c51
movq %rbx, %rdi
callq 0x2160
leaq 0x247d(%rip), %rdi      # 0x53e1
callq 0x21f0
addq $0x218, %rsp            # imm = 0x218
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x22b8
jmp 0x2fc8
jmp 0x2fc8
movq %rax, %r14
movq -0x80(%rbp), %rdi
leaq -0x70(%rbp), %rax
cmpq %rax, %rdi
je 0x2fb1
movq -0x70(%rbp), %rsi
incq %rsi
callq 0x2180
jmp 0x2fb1
movq %rax, %r14
movq %r12, %r15
jmp 0x2fb1
jmp 0x2fae
jmp 0x2fae
movq %rax, %r14
movq -0x58(%rbp), %rdi
cmpq %r15, %rdi
je 0x2fcb
movq -0x48(%rbp), %rsi
incq %rsi
callq 0x2180
jmp 0x2fcb
movq %rax, %r14
movq %r14, %rdi
callq 0x2230