// File: /workspace/github_cpp_makefile_star2_O3/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 $0x208, %rsp            # imm = 0x208
leaq 0x557d(%rip), %rsi      # 0x8150
leaq -0x150(%rbp), %rbx
movq %rbx, %rdi
callq 0x2140
movq %rbx, %rdi
callq 0x20a0
movabsq $0x6e2e6e6769736564, %rcx # imm = 0x6E2E6E6769736564
movq %rcx, -0x150(%rbp,%rax)
movl $0x737465, -0x148(%rbp,%rax) # imm = 0x737465
leaq 0x2444(%rip), %rsi      # 0x5052
movq %rbx, %rdi
callq 0x21a0
testq %rax, %rax
je 0x2f31
movq %rax, %r14
leaq 0x27a3(%rip), %rdi      # 0x53cc
callq 0x21f0
movq %r14, %rdi
callq 0x2200
testl %eax, %eax
jne 0x2f0b
leaq -0x40(%rbp), %rbx
leaq -0x1c0(%rbp), %r12
leaq -0xe0(%rbp), %r13
leaq -0x50(%rbp), %r15
movq %r14, -0x58(%rbp)
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 %r14, %rdi
leaq 0x245b(%rip), %rsi      # 0x50e1
movq %r12, %rdx
xorl %eax, %eax
callq 0x2260
movq %r14, %rdi
callq 0x2200
testl %eax, %eax
jne 0x2f0b
movq -0x30(%rbp), %rdi
movq %r12, %rsi
callq 0x2140
movq -0x30(%rbp), %rax
movw $0x0, 0x68(%rax)
cmpl $0x0, 0x64(%rax)
jle 0x2eb2
xorl %r12d, %r12d
movq -0x58(%rbp), %rdi
leaq 0x239e(%rip), %rsi      # 0x506c
movq %r13, %rdx
leaq -0x230(%rbp), %rcx
xorl %eax, %eax
callq 0x2260
movq %rbx, -0x50(%rbp)
movq %r13, %rdi
callq 0x20a0
leaq (%rax,%rbp), %rdx
addq $-0xe0, %rdx
movq %r15, %rdi
movq %r13, %rsi
callq 0x42d6
leaq 0x5510(%rip), %rdi      # 0x8218
movq %r15, %rsi
callq 0x3cae
movq (%rax), %rax
movq 0x98(%rax), %rcx
cmpq 0xa0(%rax), %rcx
je 0x2d8d
leaq -0x68(%rbp), %rax
movq %rax, -0x78(%rbp)
movq %r13, %rdi
callq 0x20a0
leaq (%rax,%rbp), %rdx
addq $-0xe0, %rdx
leaq -0x78(%rbp), %r14
movq %r14, %rdi
movq %r13, %rsi
callq 0x42d6
leaq 0x54c4(%rip), %rdi      # 0x8218
movq %r14, %rsi
callq 0x3cae
movq (%rax), %rax
movq 0xa0(%rax), %rax
movq -0x8(%rax), %rax
cmpq -0x30(%rbp), %rax
setne %r14b
movq -0x78(%rbp), %rdi
leaq -0x68(%rbp), %rax
cmpq %rax, %rdi
je 0x2d90
movq -0x68(%rbp), %rsi
incq %rsi
callq 0x2180
jmp 0x2d90
movb $0x1, %r14b
movq -0x50(%rbp), %rdi
cmpq %rbx, %rdi
je 0x2da5
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x2180
testb %r14b, %r14b
je 0x2ea1
movq %rbx, -0x50(%rbp)
movq %r13, %rdi
callq 0x20a0
leaq (%rax,%rbp), %rdx
addq $-0xe0, %rdx
movq %r15, %rdi
movq %r13, %rsi
callq 0x42d6
leaq 0x5441(%rip), %rdi      # 0x8218
movq %r15, %rsi
callq 0x3cae
movq (%rax), %rdi
movq 0xa0(%rdi), %rsi
cmpq 0xa8(%rdi), %rsi
je 0x2e03
movq -0x30(%rbp), %rax
movq %rax, (%rsi)
addq $0x8, 0xa0(%rdi)
jmp 0x2e13
addq $0x98, %rdi
leaq -0x30(%rbp), %rdx
callq 0x4b52
movq -0x50(%rbp), %rdi
cmpq %rbx, %rdi
je 0x2e28
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x2180
movq -0x30(%rbp), %r14
movq %rbx, -0x50(%rbp)
movq %r13, %rdi
callq 0x20a0
leaq (%rax,%rbp), %rdx
addq $-0xe0, %rdx
movq %r15, %rdi
movq %r13, %rsi
callq 0x42d6
leaq 0x53c3(%rip), %rdi      # 0x8218
movq %r15, %rsi
callq 0x3cae
movq 0x80(%r14), %rsi
cmpq 0x88(%r14), %rsi
je 0x2e7d
movq (%rax), %rax
movq %rax, (%rsi)
addq $0x8, 0x80(%r14)
jmp 0x2e8c
addq $0x78, %r14
movq %r14, %rdi
movq %rax, %rdx
callq 0x46d4
movq -0x50(%rbp), %rdi
cmpq %rbx, %rdi
je 0x2ea1
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x2180
incl %r12d
movq -0x30(%rbp), %rax
cmpl 0x64(%rax), %r12d
jl 0x2cc3
movq 0x53a7(%rip), %rsi      # 0x8260
cmpq 0x53a8(%rip), %rsi      # 0x8268
je 0x2ecf
movq %rax, (%rsi)
addq $0x8, 0x5393(%rip)      # 0x8260
jmp 0x2edf
leaq 0x5382(%rip), %rdi      # 0x8258
leaq -0x30(%rbp), %rdx
callq 0x4b52
movq -0x58(%rbp), %r14
movq %r14, %rdi
leaq 0x21fe(%rip), %rsi      # 0x50eb
xorl %eax, %eax
callq 0x2260
movq %r14, %rdi
callq 0x2200
testl %eax, %eax
leaq -0x1c0(%rbp), %r12
je 0x2c58
movq %r14, %rdi
callq 0x2160
leaq 0x24c7(%rip), %rdi      # 0x53e1
callq 0x21f0
addq $0x208, %rsp            # imm = 0x208
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x22b8
jmp 0x2f78
jmp 0x2f78
movq %rax, %r14
movq -0x78(%rbp), %rdi
leaq -0x68(%rbp), %rax
cmpq %rax, %rdi
je 0x2f61
movq -0x68(%rbp), %rsi
incq %rsi
callq 0x2180
jmp 0x2f61
jmp 0x2f5e
jmp 0x2f5e
jmp 0x2f5e
movq %rax, %r14
movq -0x50(%rbp), %rdi
cmpq %rbx, %rdi
je 0x2f7b
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x2180
jmp 0x2f7b
movq %rax, %r14
movq %r14, %rdi
callq 0x2230