// File: /workspace/github_cpp_makefile_star2_O2/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 $0x178, %rsp            # imm = 0x178
leaq 0x2b39(%rip), %rdi      # 0x5030
leaq 0x5c62(%rip), %rbx      # 0x8160
movq %rbx, %rsi
xorl %eax, %eax
callq 0x2040
leaq -0x130(%rbp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2150
movq %r14, %rdi
callq 0x20a0
movabsq $0x6e2e6e6769736564, %rcx # imm = 0x6E2E6E6769736564
movq %rcx, -0x130(%rbp,%rax)
movabsq $0x7365646f6e2e6e, %rcx # imm = 0x7365646F6E2E6E
movq %rcx, -0x12b(%rbp,%rax)
leaq 0x2b05(%rip), %rsi      # 0x5052
movq %r14, %rdi
callq 0x21b0
testq %rax, %rax
je 0x2937
movq %rax, %rbx
leaq 0x2e4e(%rip), %rdi      # 0x53b6
callq 0x2210
leaq -0x58(%rbp), %r13
leaq -0x70(%rbp), %r14
leaq -0xa0(%rbp), %r15
movq %rbx, %rdi
callq 0x2220
testl %eax, %eax
jne 0x2911
movq %rbx, %rdi
leaq 0x2ad6(%rip), %rsi      # 0x506c
leaq -0x1a0(%rbp), %rdx
leaq -0xc0(%rbp), %rcx
xorl %eax, %eax
callq 0x2280
movq %rbx, %rdi
callq 0x2220
testl %eax, %eax
jne 0x2911
andl $0x0, -0x98(%rbp)
andq $0x0, -0x90(%rbp)
leaq -0x98(%rbp), %rax
movq %rax, -0x88(%rbp)
movq %rax, -0x80(%rbp)
andq $0x0, -0x78(%rbp)
movq %r13, %rdi
leaq 0x2a87(%rip), %rsi      # 0x5072
movq %r14, %rdx
callq 0x3722
movq %r15, %rdi
movq %r13, %rsi
callq 0x36b8
movl $0x5, (%rax)
movq %r13, %rdi
callq 0x20b0
movq %r13, %rdi
leaq 0x2a61(%rip), %rsi      # 0x5077
movq %r14, %rdx
callq 0x3722
movq %r15, %rdi
movq %r13, %rsi
callq 0x36b8
movl $0x7, (%rax)
movq %r13, %rdi
callq 0x20b0
movq %r13, %rdi
leaq 0x2a3b(%rip), %rsi      # 0x507c
movq %r14, %rdx
callq 0x3722
movq %r15, %rdi
movq %r13, %rsi
callq 0x36b8
movl $0x6, (%rax)
movq %r13, %rdi
callq 0x20b0
movq %r13, %rdi
leaq 0x2a15(%rip), %rsi      # 0x5081
movq %r14, %rdx
callq 0x3722
movq %r15, %rdi
movq %r13, %rsi
callq 0x36b8
movl $0x5, (%rax)
movq %r13, %rdi
callq 0x20b0
movq %r13, %rdi
leaq 0x29ef(%rip), %rsi      # 0x5086
movq %r14, %rdx
callq 0x3722
movq %r15, %rdi
movq %r13, %rsi
callq 0x36b8
movl $0x4, (%rax)
movq %r13, %rdi
callq 0x20b0
movq %r13, %rdi
leaq 0x29c9(%rip), %rsi      # 0x508b
movq %r14, %rdx
callq 0x3722
movq %r15, %rdi
movq %r13, %rsi
callq 0x36b8
movl $0x3, (%rax)
movq %r13, %rdi
callq 0x20b0
movq %r13, %rdi
leaq 0x29a3(%rip), %rsi      # 0x5090
movq %r14, %rdx
callq 0x3722
movq %r15, %rdi
movq %r13, %rsi
callq 0x36b8
movl $0x2, (%rax)
movq %r13, %rdi
callq 0x20b0
movq %r13, %rdi
leaq 0x297d(%rip), %rsi      # 0x5095
movq %r14, %rdx
callq 0x3722
movq %r15, %rdi
movq %r13, %rsi
callq 0x36b8
movl $0x22, (%rax)
movq %r13, %rdi
callq 0x20b0
movq %r13, %rdi
leaq 0x2959(%rip), %rsi      # 0x509c
movq %r14, %rdx
callq 0x3722
movq %r15, %rdi
movq %r13, %rsi
callq 0x36b8
movl $0x1ad, (%rax)          # imm = 0x1AD
movq %r13, %rdi
callq 0x20b0
movq %r13, %rdi
leaq 0x2936(%rip), %rsi      # 0x50a4
movq %r14, %rdx
callq 0x3722
movq %r15, %rdi
movq %r13, %rsi
callq 0x36b8
movl $0x17b, (%rax)          # imm = 0x17B
movq %r13, %rdi
callq 0x20b0
movq %r13, %rdi
leaq 0x2914(%rip), %rsi      # 0x50ad
movq %r14, %rdx
callq 0x3722
movq %r15, %rdi
movq %r13, %rsi
callq 0x36b8
movl $0x3, (%rax)
movq %r13, %rdi
callq 0x20b0
movq %r13, %rdi
leaq 0x28f0(%rip), %rsi      # 0x50b4
movq %r14, %rdx
callq 0x3722
movq %r15, %rdi
movq %r13, %rsi
callq 0x36b8
movl $0x2, (%rax)
movq %r13, %rdi
callq 0x20b0
movq %r13, %rdi
leaq 0x28ca(%rip), %rsi      # 0x50b9
movq %r14, %rdx
callq 0x3722
movq %r15, %rdi
movq %r13, %rsi
callq 0x36b8
movl $0x2, (%rax)
movq %r13, %rdi
callq 0x20b0
movl $0xb0, %edi
callq 0x2180
movq %rax, %r12
xorps %xmm0, %xmm0
movups %xmm0, 0xa0(%rax)
movups %xmm0, 0x90(%rax)
movq %rax, -0x38(%rbp)
movaps %xmm0, -0x70(%rbp)
andq $0x0, -0x60(%rbp)
movq %rax, %rdi
leaq -0x1a0(%rbp), %rsi
callq 0x2150
addq $0x64, %r12
movq %r12, %rdi
leaq -0xc0(%rbp), %r12
movq %r12, %rsi
callq 0x2150
movq %r13, %rdi
movq %r12, %rsi
leaq -0x29(%rbp), %rdx
callq 0x3722
movq %r15, %rdi
movq %r13, %rsi
callq 0x36b8
movl (%rax), %eax
movq -0x38(%rbp), %rcx
movl %eax, 0x78(%rcx)
movq %r13, %rdi
callq 0x20b0
movq -0x38(%rbp), %rdi
andl $0x0, 0x80(%rdi)
andw $0x0, 0x7c(%rdi)
addq $0x98, %rdi
movq %r14, %rsi
callq 0x375e
movq -0x38(%rbp), %rax
andq $0x0, 0x84(%rax)
movl 0x78(%rax), %eax
addl %eax, 0x599d(%rip)      # 0x825c
leaq 0x594a(%rip), %rdi      # 0x8210
leaq -0x38(%rbp), %rsi
callq 0x3832
movq -0x38(%rbp), %r12
movq %r13, %rdi
movq %r12, %rsi
leaq -0x29(%rbp), %rdx
callq 0x3722
leaq 0x593f(%rip), %rdi      # 0x8228
movq %r13, %rsi
callq 0x3856
movq %r12, (%rax)
movq %r13, %rdi
callq 0x20b0
movq %r14, %rdi
callq 0x3d86
movq %r15, %rdi
callq 0x3bec
jmp 0x257c
movq %rbx, %rdi
callq 0x2170
leaq 0x2ac1(%rip), %rdi      # 0x53e1
callq 0x2210
addq $0x178, %rsp            # imm = 0x178
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x569a(%rip), %rax      # 0x7fd8
movq (%rax), %rcx
leaq 0x270c(%rip), %rdi      # 0x5054
pushq $0x17
popq %rsi
pushq $0x1
popq %rdx
callq 0x2290
pushq $0x1
popq %rdi
callq 0x21c0
jmp 0x29a1
jmp 0x29a1
jmp 0x29a1
jmp 0x29a6
jmp 0x29b4
jmp 0x29a6
jmp 0x296f
jmp 0x29b4
jmp 0x29a6
jmp 0x29a1
movq %rax, %rbx
leaq -0x58(%rbp), %rdi
callq 0x20b0
jmp 0x29b7
jmp 0x29a6
jmp 0x29a1
jmp 0x29a6
jmp 0x29a1
jmp 0x29a1
jmp 0x29a1
jmp 0x29a6
jmp 0x29a6
jmp 0x29a1
jmp 0x29a6
jmp 0x29a6
jmp 0x29a1
jmp 0x29a6
jmp 0x29a1
jmp 0x29a6
jmp 0x29a1
jmp 0x29a6
jmp 0x29a1
movq %rax, %rbx
jmp 0x29c0
movq %rax, %rbx
leaq -0x58(%rbp), %rdi
callq 0x20b0
jmp 0x29c0
movq %rax, %rbx
leaq -0x70(%rbp), %rdi
callq 0x3d86
leaq -0xa0(%rbp), %rdi
callq 0x3bec
movq %rbx, %rdi
callq 0x2250