// File: /workspace/github_cpp_makefile_star2_O1/searsm8[P]FM_Partitioning/fmpart.cpp
// Function: readCellsFile()
void readCellsFile()
{
	printf("\nUsing design in %s\n", file_path);

	FILE *cells_file;
	char cells_file_path[100];
	strcpy(cells_file_path, file_path);
	cells_file = fopen(strcat(cells_file_path, "design.nodes"), "r");	
	if (cells_file == NULL) { fprintf(stderr, "Can't open cells_file!\n");	exit(1); }
		
	printf("Reading cells file...\n");
			
	//read through cell instance file design.nodes
	while(!feof(cells_file))
	{
		char inst_name [100];
		char cell_type[20];
		fscanf(cells_file, "%s %s", &inst_name, &cell_type);	 
		if(feof(cells_file)) break;								
		
		//cell_areas map used to find areas with the cell name as keys
		map <string, int> cell_areas;
		cell_areas["FDRE"] = 5;
		cell_areas["LUT6"] = 7;
		cell_areas["LUT5"] = 6;
		cell_areas["LUT4"] = 5;
		cell_areas["LUT3"] = 4;
		cell_areas["LUT2"] = 3;
		cell_areas["LUT1"] = 2;
		cell_areas["CARRY8"] = 34;
		cell_areas["DSP48E2"] = 429;
		cell_areas["RAMB36E2"] = 379;
		cell_areas["BUFGCE"] = 3;
		cell_areas["IBUF"] = 2;
		cell_areas["OBUF"] = 2; 	
		
		//create a new cell and initialize default values
		CELL* current_cell;
		current_cell = new CELL;
		
		vector <NET*> current_net_list;
					
		strcpy(current_cell->name, inst_name);	
		strcpy(current_cell->type, cell_type);				
		current_cell->area = cell_areas[cell_type];			
		current_cell->gain = 0;
		current_cell->fixed = false;
		current_cell->locked = false;
		current_cell->net_list = current_net_list;		
		current_cell->partition = 0; //place all cells in partition 0 initially
		current_cell->best_partition = 0;
		
		partition_area[0] += current_cell->area;
		
		cells.push_back(current_cell);
		
		cells_map[current_cell->name] = current_cell;	
	}
	
	fclose(cells_file);
	printf("done!\n");	
	return;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x188, %rsp            # imm = 0x188
leaq 0x2ad9(%rip), %rdi      # 0x5030
leaq 0x5bf2(%rip), %rbx      # 0x8150
movq %rbx, %rsi
xorl %eax, %eax
callq 0x2040
leaq -0x140(%rbp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2140
movq %r14, %rdi
callq 0x20a0
movabsq $0x6e2e6e6769736564, %rcx # imm = 0x6E2E6E6769736564
movq %rcx, -0x140(%rbp,%rax)
movabsq $0x7365646f6e2e6e, %rcx # imm = 0x7365646F6E2E6E
movq %rcx, -0x13b(%rbp,%rax)
leaq 0x2aa5(%rip), %rsi      # 0x5052
movq %r14, %rdi
callq 0x21a0
testq %rax, %rax
je 0x2b28
movq %rax, %r15
leaq 0x2dee(%rip), %rdi      # 0x53b6
callq 0x21f0
leaq -0x38(%rbp), %rbx
leaq -0x48(%rbp), %r13
leaq -0xb0(%rbp), %r14
movq %r15, -0x60(%rbp)
movq %r15, %rdi
callq 0x2200
testl %eax, %eax
jne 0x2b02
movq %r15, %rdi
leaq 0x2a72(%rip), %rsi      # 0x506c
leaq -0x1b0(%rbp), %rdx
leaq -0xd0(%rbp), %rcx
xorl %eax, %eax
callq 0x2260
movq %r15, %rdi
callq 0x2200
testl %eax, %eax
jne 0x2afe
movl %eax, %r15d
movl $0x0, -0xa8(%rbp)
xorl %ecx, %ecx
movq %rcx, -0xa0(%rbp)
leaq -0xa8(%rbp), %rax
movq %rax, -0x98(%rbp)
movq %rax, -0x90(%rbp)
movq %rcx, -0x88(%rbp)
movq %rbx, -0x48(%rbp)
movq %r13, %rdi
leaq 0x2a13(%rip), %rsi      # 0x5072
leaq 0x2a10(%rip), %rdx      # 0x5076
callq 0x4308
movq %r14, %rdi
movq %r13, %rsi
callq 0x3b30
movl $0x5, (%rax)
movq -0x48(%rbp), %rdi
cmpq %rbx, %rdi
je 0x2691
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2180
movq %rbx, -0x48(%rbp)
movq %r13, %rdi
leaq 0x29d8(%rip), %rsi      # 0x5077
leaq 0x29d5(%rip), %rdx      # 0x507b
callq 0x4308
movq %r14, %rdi
movq %r13, %rsi
callq 0x3b30
movl $0x7, (%rax)
movq -0x48(%rbp), %rdi
cmpq %rbx, %rdi
je 0x26d1
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2180
movq %rbx, -0x48(%rbp)
movq %r13, %rdi
leaq 0x299d(%rip), %rsi      # 0x507c
leaq 0x299a(%rip), %rdx      # 0x5080
callq 0x4308
movq %r14, %rdi
movq %r13, %rsi
callq 0x3b30
movl $0x6, (%rax)
movq -0x48(%rbp), %rdi
cmpq %rbx, %rdi
je 0x2711
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2180
movq %rbx, -0x48(%rbp)
movq %r13, %rdi
leaq 0x2962(%rip), %rsi      # 0x5081
leaq 0x295f(%rip), %rdx      # 0x5085
callq 0x4308
movq %r14, %rdi
movq %r13, %rsi
callq 0x3b30
movl $0x5, (%rax)
movq -0x48(%rbp), %rdi
cmpq %rbx, %rdi
je 0x2751
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2180
movq %rbx, -0x48(%rbp)
movq %r13, %rdi
leaq 0x2927(%rip), %rsi      # 0x5086
leaq 0x2924(%rip), %rdx      # 0x508a
callq 0x4308
movq %r14, %rdi
movq %r13, %rsi
callq 0x3b30
movl $0x4, (%rax)
movq -0x48(%rbp), %rdi
cmpq %rbx, %rdi
je 0x2791
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2180
movq %rbx, -0x48(%rbp)
movq %r13, %rdi
leaq 0x28ec(%rip), %rsi      # 0x508b
leaq 0x28e9(%rip), %rdx      # 0x508f
callq 0x4308
movq %r14, %rdi
movq %r13, %rsi
callq 0x3b30
movl $0x3, (%rax)
movq -0x48(%rbp), %rdi
cmpq %rbx, %rdi
je 0x27d1
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2180
movq %rbx, -0x48(%rbp)
movq %r13, %rdi
leaq 0x28b1(%rip), %rsi      # 0x5090
leaq 0x28ae(%rip), %rdx      # 0x5094
callq 0x4308
movq %r14, %rdi
movq %r13, %rsi
callq 0x3b30
movl $0x2, (%rax)
movq -0x48(%rbp), %rdi
cmpq %rbx, %rdi
je 0x2811
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2180
movq %rbx, -0x48(%rbp)
movq %r13, %rdi
leaq 0x2876(%rip), %rsi      # 0x5095
leaq 0x2875(%rip), %rdx      # 0x509b
callq 0x4308
movq %r14, %rdi
movq %r13, %rsi
callq 0x3b30
movl $0x22, (%rax)
movq -0x48(%rbp), %rdi
cmpq %rbx, %rdi
je 0x2851
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2180
movq %rbx, -0x48(%rbp)
movq %r13, %rdi
leaq 0x283d(%rip), %rsi      # 0x509c
leaq 0x283d(%rip), %rdx      # 0x50a3
callq 0x4308
movq %r14, %rdi
movq %r13, %rsi
callq 0x3b30
movl $0x1ad, (%rax)          # imm = 0x1AD
movq -0x48(%rbp), %rdi
cmpq %rbx, %rdi
je 0x2891
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2180
movq %rbx, -0x48(%rbp)
movq %r13, %rdi
leaq 0x2805(%rip), %rsi      # 0x50a4
leaq 0x2806(%rip), %rdx      # 0x50ac
callq 0x4308
movq %r14, %rdi
movq %r13, %rsi
callq 0x3b30
movl $0x17b, (%rax)          # imm = 0x17B
movq -0x48(%rbp), %rdi
cmpq %rbx, %rdi
je 0x28d1
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2180
movq %rbx, -0x48(%rbp)
movq %r13, %rdi
leaq 0x27ce(%rip), %rsi      # 0x50ad
leaq 0x27cd(%rip), %rdx      # 0x50b3
callq 0x4308
movq %r14, %rdi
movq %r13, %rsi
callq 0x3b30
movl $0x3, (%rax)
movq -0x48(%rbp), %rdi
cmpq %rbx, %rdi
je 0x2911
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2180
movq %rbx, -0x48(%rbp)
movq %r13, %rdi
leaq 0x2795(%rip), %rsi      # 0x50b4
leaq 0x2792(%rip), %rdx      # 0x50b8
callq 0x4308
movq %r14, %rdi
movq %r13, %rsi
callq 0x3b30
movl $0x2, (%rax)
movq -0x48(%rbp), %rdi
cmpq %rbx, %rdi
je 0x2951
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2180
movq %rbx, -0x48(%rbp)
movq %r13, %rdi
leaq 0x275a(%rip), %rsi      # 0x50b9
leaq 0x2757(%rip), %rdx      # 0x50bd
callq 0x4308
movq %r14, %rdi
movq %r13, %rsi
callq 0x3b30
movl $0x2, (%rax)
movq -0x48(%rbp), %rdi
cmpq %rbx, %rdi
je 0x2991
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2180
movl $0xb0, %edi
callq 0x2170
movq %rax, %r12
xorps %xmm0, %xmm0
movups %xmm0, 0xa0(%rax)
movups %xmm0, 0x90(%rax)
movq %rax, -0x58(%rbp)
movaps %xmm0, -0x80(%rbp)
movq $0x0, -0x70(%rbp)
movq %rax, %rdi
leaq -0x1b0(%rbp), %rsi
callq 0x2140
addq $0x64, %r12
movq %r12, %rdi
leaq -0xd0(%rbp), %r12
movq %r12, %rsi
callq 0x2140
movq %rbx, -0x48(%rbp)
movq %r12, %rdi
callq 0x20a0
leaq (%rax,%rbp), %rdx
addq $-0xd0, %rdx
movq %r13, %rdi
movq %r12, %rsi
callq 0x4308
movq %r14, %rdi
movq %r13, %rsi
callq 0x3b30
movl (%rax), %eax
movq -0x58(%rbp), %rcx
movl %eax, 0x78(%rcx)
movq -0x48(%rbp), %rdi
cmpq %rbx, %rdi
je 0x2a2f
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2180
movq -0x58(%rbp), %rdi
movl $0x0, 0x80(%rdi)
movw $0x0, 0x7c(%rdi)
addq $0x98, %rdi
leaq -0x80(%rbp), %rsi
callq 0x3bee
movq -0x58(%rbp), %rax
movq $0x0, 0x84(%rax)
movl 0x78(%rax), %ecx
addl %ecx, 0x57e1(%rip)      # 0x824c
movq 0x5796(%rip), %rsi      # 0x8208
cmpq 0x5797(%rip), %rsi      # 0x8210
je 0x2a88
movq %rax, (%rsi)
addq $0x8, 0x5782(%rip)      # 0x8208
jmp 0x2a98
leaq 0x5771(%rip), %rdi      # 0x8200
leaq -0x58(%rbp), %rdx
callq 0x470c
movq -0x58(%rbp), %r12
movq %r13, %rdi
movq %r12, %rsi
leaq -0x49(%rbp), %rdx
callq 0x3bb0
leaq 0x5766(%rip), %rdi      # 0x8218
movq %r13, %rsi
callq 0x3cce
movq %r12, (%rax)
movq -0x48(%rbp), %rdi
cmpq %rbx, %rdi
je 0x2ad2
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2180
movq -0x80(%rbp), %rdi
testq %rdi, %rdi
je 0x2ae7
movq -0x70(%rbp), %rsi
subq %rdi, %rsi
callq 0x2180
movq %r14, %rdi
callq 0x40ce
testl %r15d, %r15d
movq -0x60(%rbp), %r15
je 0x25e0
jmp 0x2b02
movq -0x60(%rbp), %r15
movq %r15, %rdi
callq 0x2160
leaq 0x28d0(%rip), %rdi      # 0x53e1
callq 0x21f0
addq $0x188, %rsp            # imm = 0x188
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x2290
jmp 0x2b7d
jmp 0x2b84
jmp 0x2b4b
jmp 0x2b84
jmp 0x2b84
jmp 0x2b7d
jmp 0x2b84
jmp 0x2b7d
jmp 0x2b84
jmp 0x2b7d
jmp 0x2b84
jmp 0x2b7d
jmp 0x2b84
jmp 0x2b7d
jmp 0x2b84
movq %rax, %r14
movq -0x48(%rbp), %rdi
cmpq %rbx, %rdi
je 0x2b9c
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2180
jmp 0x2b9c
jmp 0x2b7d
jmp 0x2b99
jmp 0x2b7d
jmp 0x2b7d
jmp 0x2b7d
jmp 0x2b84
jmp 0x2b7d
jmp 0x2b84
jmp 0x2b7d
jmp 0x2b84
jmp 0x2b7d
jmp 0x2b84
movq %rax, %r14
jmp 0x2bb1
jmp 0x2b99
movq %rax, %r14
movq -0x48(%rbp), %rdi
cmpq %rbx, %rdi
je 0x2bb1
movq -0x38(%rbp), %rsi
incq %rsi
jmp 0x2bac
movq %rax, %r14
movq -0x80(%rbp), %rdi
testq %rdi, %rdi
je 0x2bb1
movq -0x70(%rbp), %rsi
subq %rdi, %rsi
callq 0x2180
leaq -0xb0(%rbp), %rdi
callq 0x40ce
movq %r14, %rdi
callq 0x2230