// File: 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
subq $0x4c0, %rsp            # imm = 0x4C0
leaq 0x8a46(%rip), %rdi      # 0xb018
leaq 0xebd7(%rip), %rsi      # 0x111b0
movb $0x0, %al
callq 0x2040
leaq -0x70(%rbp), %rdi
leaq 0xebc5(%rip), %rsi      # 0x111b0
callq 0x21a0
leaq -0x70(%rbp), %rdi
leaq 0x8a32(%rip), %rsi      # 0xb02d
callq 0x22f0
movq %rax, %rdi
leaq 0x8a30(%rip), %rsi      # 0xb03a
callq 0x2240
movq %rax, -0x8(%rbp)
cmpq $0x0, -0x8(%rbp)
jne 0x263c
movq 0xe9b7(%rip), %rax      # 0x10fd8
movq (%rax), %rdi
leaq 0x8a11(%rip), %rsi      # 0xb03c
movb $0x0, %al
callq 0x2270
movl $0x1, %edi
callq 0x2250
leaq 0x8a11(%rip), %rdi      # 0xb054
movb $0x0, %al
callq 0x2040
movq -0x8(%rbp), %rdi
callq 0x22a0
cmpl $0x0, %eax
setne %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x2664
jmp 0x328e
movq -0x8(%rbp), %rdi
leaq 0x89fc(%rip), %rsi      # 0xb06b
leaq -0xe0(%rbp), %rdx
leaq -0x100(%rbp), %rcx
movb $0x0, %al
callq 0x2310
movq -0x8(%rbp), %rdi
callq 0x22a0
cmpl $0x0, %eax
je 0x2697
jmp 0x328e
leaq -0x130(%rbp), %rdi
callq 0x4ba0
leaq -0x151(%rbp), %rdi
movq %rdi, -0x3c0(%rbp)
callq 0x22e0
movq -0x3c0(%rbp), %rdx
leaq 0x89ad(%rip), %rsi      # 0xb071
leaq -0x150(%rbp), %rdi
callq 0x4ca0
jmp 0x26d2
leaq -0x130(%rbp), %rdi
leaq -0x150(%rbp), %rsi
callq 0x4bc0
movq %rax, -0x3c8(%rbp)
jmp 0x26ee
movq -0x3c8(%rbp), %rax
movl $0x5, (%rax)
leaq -0x150(%rbp), %rdi
callq 0x2100
leaq -0x151(%rbp), %rdi
callq 0x2210
leaq -0x189(%rbp), %rdi
movq %rdi, -0x3d0(%rbp)
callq 0x22e0
movq -0x3d0(%rbp), %rdx
leaq 0x8942(%rip), %rsi      # 0xb076
leaq -0x188(%rbp), %rdi
callq 0x4ca0
jmp 0x2742
leaq -0x130(%rbp), %rdi
leaq -0x188(%rbp), %rsi
callq 0x4bc0
movq %rax, -0x3d8(%rbp)
jmp 0x275e
movq -0x3d8(%rbp), %rax
movl $0x7, (%rax)
leaq -0x188(%rbp), %rdi
callq 0x2100
leaq -0x189(%rbp), %rdi
callq 0x2210
leaq -0x1b1(%rbp), %rdi
movq %rdi, -0x3e0(%rbp)
callq 0x22e0
movq -0x3e0(%rbp), %rdx
leaq 0x88d7(%rip), %rsi      # 0xb07b
leaq -0x1b0(%rbp), %rdi
callq 0x4ca0
jmp 0x27b2
leaq -0x130(%rbp), %rdi
leaq -0x1b0(%rbp), %rsi
callq 0x4bc0
movq %rax, -0x3e8(%rbp)
jmp 0x27ce
movq -0x3e8(%rbp), %rax
movl $0x6, (%rax)
leaq -0x1b0(%rbp), %rdi
callq 0x2100
leaq -0x1b1(%rbp), %rdi
callq 0x2210
leaq -0x1d9(%rbp), %rdi
movq %rdi, -0x3f0(%rbp)
callq 0x22e0
movq -0x3f0(%rbp), %rdx
leaq 0x886c(%rip), %rsi      # 0xb080
leaq -0x1d8(%rbp), %rdi
callq 0x4ca0
jmp 0x2822
leaq -0x130(%rbp), %rdi
leaq -0x1d8(%rbp), %rsi
callq 0x4bc0
movq %rax, -0x3f8(%rbp)
jmp 0x283e
movq -0x3f8(%rbp), %rax
movl $0x5, (%rax)
leaq -0x1d8(%rbp), %rdi
callq 0x2100
leaq -0x1d9(%rbp), %rdi
callq 0x2210
leaq -0x201(%rbp), %rdi
movq %rdi, -0x400(%rbp)
callq 0x22e0
movq -0x400(%rbp), %rdx
leaq 0x8801(%rip), %rsi      # 0xb085
leaq -0x200(%rbp), %rdi
callq 0x4ca0
jmp 0x2892
leaq -0x130(%rbp), %rdi
leaq -0x200(%rbp), %rsi
callq 0x4bc0
movq %rax, -0x408(%rbp)
jmp 0x28ae
movq -0x408(%rbp), %rax
movl $0x4, (%rax)
leaq -0x200(%rbp), %rdi
callq 0x2100
leaq -0x201(%rbp), %rdi
callq 0x2210
leaq -0x229(%rbp), %rdi
movq %rdi, -0x410(%rbp)
callq 0x22e0
movq -0x410(%rbp), %rdx
leaq 0x8796(%rip), %rsi      # 0xb08a
leaq -0x228(%rbp), %rdi
callq 0x4ca0
jmp 0x2902
leaq -0x130(%rbp), %rdi
leaq -0x228(%rbp), %rsi
callq 0x4bc0
movq %rax, -0x418(%rbp)
jmp 0x291e
movq -0x418(%rbp), %rax
movl $0x3, (%rax)
leaq -0x228(%rbp), %rdi
callq 0x2100
leaq -0x229(%rbp), %rdi
callq 0x2210
leaq -0x251(%rbp), %rdi
movq %rdi, -0x420(%rbp)
callq 0x22e0
movq -0x420(%rbp), %rdx
leaq 0x872b(%rip), %rsi      # 0xb08f
leaq -0x250(%rbp), %rdi
callq 0x4ca0
jmp 0x2972
leaq -0x130(%rbp), %rdi
leaq -0x250(%rbp), %rsi
callq 0x4bc0
movq %rax, -0x428(%rbp)
jmp 0x298e
movq -0x428(%rbp), %rax
movl $0x2, (%rax)
leaq -0x250(%rbp), %rdi
callq 0x2100
leaq -0x251(%rbp), %rdi
callq 0x2210
leaq -0x279(%rbp), %rdi
movq %rdi, -0x430(%rbp)
callq 0x22e0
movq -0x430(%rbp), %rdx
leaq 0x86c0(%rip), %rsi      # 0xb094
leaq -0x278(%rbp), %rdi
callq 0x4ca0
jmp 0x29e2
leaq -0x130(%rbp), %rdi
leaq -0x278(%rbp), %rsi
callq 0x4bc0
movq %rax, -0x438(%rbp)
jmp 0x29fe
movq -0x438(%rbp), %rax
movl $0x22, (%rax)
leaq -0x278(%rbp), %rdi
callq 0x2100
leaq -0x279(%rbp), %rdi
callq 0x2210
leaq -0x2a1(%rbp), %rdi
movq %rdi, -0x440(%rbp)
callq 0x22e0
movq -0x440(%rbp), %rdx
leaq 0x8657(%rip), %rsi      # 0xb09b
leaq -0x2a0(%rbp), %rdi
callq 0x4ca0
jmp 0x2a52
leaq -0x130(%rbp), %rdi
leaq -0x2a0(%rbp), %rsi
callq 0x4bc0
movq %rax, -0x448(%rbp)
jmp 0x2a6e
movq -0x448(%rbp), %rax
movl $0x1ad, (%rax)          # imm = 0x1AD
leaq -0x2a0(%rbp), %rdi
callq 0x2100
leaq -0x2a1(%rbp), %rdi
callq 0x2210
leaq -0x2c9(%rbp), %rdi
movq %rdi, -0x450(%rbp)
callq 0x22e0
movq -0x450(%rbp), %rdx
leaq 0x85ef(%rip), %rsi      # 0xb0a3
leaq -0x2c8(%rbp), %rdi
callq 0x4ca0
jmp 0x2ac2
leaq -0x130(%rbp), %rdi
leaq -0x2c8(%rbp), %rsi
callq 0x4bc0
movq %rax, -0x458(%rbp)
jmp 0x2ade
movq -0x458(%rbp), %rax
movl $0x17b, (%rax)          # imm = 0x17B
leaq -0x2c8(%rbp), %rdi
callq 0x2100
leaq -0x2c9(%rbp), %rdi
callq 0x2210
leaq -0x2f1(%rbp), %rdi
movq %rdi, -0x460(%rbp)
callq 0x22e0
movq -0x460(%rbp), %rdx
leaq 0x8588(%rip), %rsi      # 0xb0ac
leaq -0x2f0(%rbp), %rdi
callq 0x4ca0
jmp 0x2b32
leaq -0x130(%rbp), %rdi
leaq -0x2f0(%rbp), %rsi
callq 0x4bc0
movq %rax, -0x468(%rbp)
jmp 0x2b4e
movq -0x468(%rbp), %rax
movl $0x3, (%rax)
leaq -0x2f0(%rbp), %rdi
callq 0x2100
leaq -0x2f1(%rbp), %rdi
callq 0x2210
leaq -0x319(%rbp), %rdi
movq %rdi, -0x470(%rbp)
callq 0x22e0
movq -0x470(%rbp), %rdx
leaq 0x851f(%rip), %rsi      # 0xb0b3
leaq -0x318(%rbp), %rdi
callq 0x4ca0
jmp 0x2ba2
leaq -0x130(%rbp), %rdi
leaq -0x318(%rbp), %rsi
callq 0x4bc0
movq %rax, -0x478(%rbp)
jmp 0x2bbe
movq -0x478(%rbp), %rax
movl $0x2, (%rax)
leaq -0x318(%rbp), %rdi
callq 0x2100
leaq -0x319(%rbp), %rdi
callq 0x2210
leaq -0x341(%rbp), %rdi
movq %rdi, -0x480(%rbp)
callq 0x22e0
movq -0x480(%rbp), %rdx
leaq 0x84b4(%rip), %rsi      # 0xb0b8
leaq -0x340(%rbp), %rdi
callq 0x4ca0
jmp 0x2c12
leaq -0x130(%rbp), %rdi
leaq -0x340(%rbp), %rsi
callq 0x4bc0
movq %rax, -0x488(%rbp)
jmp 0x2c2e
movq -0x488(%rbp), %rax
movl $0x2, (%rax)
leaq -0x340(%rbp), %rdi
callq 0x2100
leaq -0x341(%rbp), %rdi
callq 0x2210
movl $0xb0, %edi
callq 0x21d0
movq %rax, -0x490(%rbp)
jmp 0x2c66
movq -0x490(%rbp), %rdi
callq 0x4d50
movq -0x490(%rbp), %rax
movq %rax, -0x350(%rbp)
leaq -0x368(%rbp), %rdi
callq 0x4b20
movq -0x350(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0x21a0
movq -0x350(%rbp), %rdi
addq $0x64, %rdi
leaq -0x100(%rbp), %rsi
movq %rsi, -0x4a0(%rbp)
callq 0x21a0
leaq -0x389(%rbp), %rdi
movq %rdi, -0x498(%rbp)
callq 0x22e0
movq -0x4a0(%rbp), %rsi
movq -0x498(%rbp), %rdx
leaq -0x388(%rbp), %rdi
callq 0x4ca0
jmp 0x2cec
leaq -0x130(%rbp), %rdi
leaq -0x388(%rbp), %rsi
callq 0x4bc0
movq %rax, -0x4a8(%rbp)
jmp 0x2d08
movq -0x4a8(%rbp), %rax
movl (%rax), %ecx
movq -0x350(%rbp), %rax
movl %ecx, 0x78(%rax)
leaq -0x388(%rbp), %rdi
callq 0x2100
leaq -0x389(%rbp), %rdi
callq 0x2210
movq -0x350(%rbp), %rax
movl $0x0, 0x80(%rax)
movq -0x350(%rbp), %rax
movb $0x0, 0x7c(%rax)
movq -0x350(%rbp), %rax
movb $0x0, 0x7d(%rax)
movq -0x350(%rbp), %rdi
addq $0x98, %rdi
leaq -0x368(%rbp), %rsi
callq 0x4d90
jmp 0x2d76
movq -0x350(%rbp), %rax
movl $0x0, 0x84(%rax)
movq -0x350(%rbp), %rax
movl $0x0, 0x88(%rax)
movq -0x350(%rbp), %rax
movl 0x78(%rax), %ecx
movl 0xe504(%rip), %eax      # 0x112ac
addl %ecx, %eax
movl %eax, 0xe4fc(%rip)      # 0x112ac
leaq 0xe4a9(%rip), %rdi      # 0x11260
leaq -0x350(%rbp), %rsi
callq 0x4fe0
jmp 0x2dc5
movq -0x350(%rbp), %rax
movq %rax, -0x4b8(%rbp)
leaq -0x3b1(%rbp), %rdi
movq %rdi, -0x4b0(%rbp)
callq 0x22e0
movq -0x4b8(%rbp), %rsi
movq -0x4b0(%rbp), %rdx
leaq -0x3b0(%rbp), %rdi
callq 0x4ca0
jmp 0x2e02
leaq 0xe46f(%rip), %rdi      # 0x11278
leaq -0x3b0(%rbp), %rsi
callq 0x5050
movq %rax, -0x4c0(%rbp)
jmp 0x2e1e
movq -0x4c0(%rbp), %rax
movq -0x4b8(%rbp), %rcx
movq %rcx, (%rax)
leaq -0x3b0(%rbp), %rdi
callq 0x2100
leaq -0x3b1(%rbp), %rdi
callq 0x2210
leaq -0x368(%rbp), %rdi
callq 0x4b40
leaq -0x130(%rbp), %rdi
callq 0x5130
jmp 0x264a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x160(%rbp)
movl %eax, -0x164(%rbp)
jmp 0x2e96
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x160(%rbp)
movl %eax, -0x164(%rbp)
leaq -0x150(%rbp), %rdi
callq 0x2100
leaq -0x151(%rbp), %rdi
callq 0x2210
jmp 0x3280
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x160(%rbp)
movl %eax, -0x164(%rbp)
jmp 0x2ed9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x160(%rbp)
movl %eax, -0x164(%rbp)
leaq -0x188(%rbp), %rdi
callq 0x2100
leaq -0x189(%rbp), %rdi
callq 0x2210
jmp 0x3280
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x160(%rbp)
movl %eax, -0x164(%rbp)
jmp 0x2f1c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x160(%rbp)
movl %eax, -0x164(%rbp)
leaq -0x1b0(%rbp), %rdi
callq 0x2100
leaq -0x1b1(%rbp), %rdi
callq 0x2210
jmp 0x3280
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x160(%rbp)
movl %eax, -0x164(%rbp)
jmp 0x2f5f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x160(%rbp)
movl %eax, -0x164(%rbp)
leaq -0x1d8(%rbp), %rdi
callq 0x2100
leaq -0x1d9(%rbp), %rdi
callq 0x2210
jmp 0x3280
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x160(%rbp)
movl %eax, -0x164(%rbp)
jmp 0x2fa2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x160(%rbp)
movl %eax, -0x164(%rbp)
leaq -0x200(%rbp), %rdi
callq 0x2100
leaq -0x201(%rbp), %rdi
callq 0x2210
jmp 0x3280
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x160(%rbp)
movl %eax, -0x164(%rbp)
jmp 0x2fe5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x160(%rbp)
movl %eax, -0x164(%rbp)
leaq -0x228(%rbp), %rdi
callq 0x2100
leaq -0x229(%rbp), %rdi
callq 0x2210
jmp 0x3280
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x160(%rbp)
movl %eax, -0x164(%rbp)
jmp 0x3028
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x160(%rbp)
movl %eax, -0x164(%rbp)
leaq -0x250(%rbp), %rdi
callq 0x2100
leaq -0x251(%rbp), %rdi
callq 0x2210
jmp 0x3280
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x160(%rbp)
movl %eax, -0x164(%rbp)
jmp 0x306b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x160(%rbp)
movl %eax, -0x164(%rbp)
leaq -0x278(%rbp), %rdi
callq 0x2100
leaq -0x279(%rbp), %rdi
callq 0x2210
jmp 0x3280
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x160(%rbp)
movl %eax, -0x164(%rbp)
jmp 0x30ae
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x160(%rbp)
movl %eax, -0x164(%rbp)
leaq -0x2a0(%rbp), %rdi
callq 0x2100
leaq -0x2a1(%rbp), %rdi
callq 0x2210
jmp 0x3280
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x160(%rbp)
movl %eax, -0x164(%rbp)
jmp 0x30f1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x160(%rbp)
movl %eax, -0x164(%rbp)
leaq -0x2c8(%rbp), %rdi
callq 0x2100
leaq -0x2c9(%rbp), %rdi
callq 0x2210
jmp 0x3280
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x160(%rbp)
movl %eax, -0x164(%rbp)
jmp 0x3134
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x160(%rbp)
movl %eax, -0x164(%rbp)
leaq -0x2f0(%rbp), %rdi
callq 0x2100
leaq -0x2f1(%rbp), %rdi
callq 0x2210
jmp 0x3280
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x160(%rbp)
movl %eax, -0x164(%rbp)
jmp 0x3177
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x160(%rbp)
movl %eax, -0x164(%rbp)
leaq -0x318(%rbp), %rdi
callq 0x2100
leaq -0x319(%rbp), %rdi
callq 0x2210
jmp 0x3280
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x160(%rbp)
movl %eax, -0x164(%rbp)
jmp 0x31ba
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x160(%rbp)
movl %eax, -0x164(%rbp)
leaq -0x340(%rbp), %rdi
callq 0x2100
leaq -0x341(%rbp), %rdi
callq 0x2210
jmp 0x3280
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x160(%rbp)
movl %eax, -0x164(%rbp)
jmp 0x3280
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x160(%rbp)
movl %eax, -0x164(%rbp)
jmp 0x3214
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x160(%rbp)
movl %eax, -0x164(%rbp)
leaq -0x388(%rbp), %rdi
callq 0x2100
leaq -0x389(%rbp), %rdi
callq 0x2210
jmp 0x3274
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x160(%rbp)
movl %eax, -0x164(%rbp)
jmp 0x3274
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x160(%rbp)
movl %eax, -0x164(%rbp)
jmp 0x3268
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x160(%rbp)
movl %eax, -0x164(%rbp)
leaq -0x3b0(%rbp), %rdi
callq 0x2100
leaq -0x3b1(%rbp), %rdi
callq 0x2210
leaq -0x368(%rbp), %rdi
callq 0x4b40
leaq -0x130(%rbp), %rdi
callq 0x5130
jmp 0x32ae
movq -0x8(%rbp), %rdi
callq 0x21c0
leaq 0x7e1f(%rip), %rdi      # 0xb0bd
movb $0x0, %al
callq 0x2040
addq $0x4c0, %rsp            # imm = 0x4C0
popq %rbp
retq
movq -0x160(%rbp), %rdi
callq 0x22d0
nopw (%rax,%rax)