// File: /workspace/github_cpp_makefile_star2_O3/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 0x2ad9(%rip), %rdi      # 0x5030
leaq 0x5bf2(%rip), %rbx      # 0x8150
movq %rbx, %rsi
xorl %eax, %eax
callq 0x2040
leaq -0x130(%rbp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2140
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 0x2aa5(%rip), %rsi      # 0x5052
movq %r14, %rdi
callq 0x21a0
testq %rax, %rax
je 0x2b1b
movq %rax, %rbx
leaq 0x2dee(%rip), %rdi      # 0x53b6
callq 0x21f0
movq %rbx, %rdi
callq 0x2200
testl %eax, %eax
jne 0x2af5
leaq -0x38(%rbp), %r12
leaq -0x48(%rbp), %r13
leaq -0xa0(%rbp), %r14
movq %rbx, %rdi
leaq 0x2a76(%rip), %rsi      # 0x506c
leaq -0x1a0(%rbp), %rdx
leaq -0xc0(%rbp), %rcx
xorl %eax, %eax
callq 0x2260
movq %rbx, %rdi
callq 0x2200
testl %eax, %eax
jne 0x2af5
movl $0x0, -0x98(%rbp)
xorl %ecx, %ecx
movq %rcx, -0x90(%rbp)
leaq -0x98(%rbp), %rax
movq %rax, -0x88(%rbp)
movq %rax, -0x80(%rbp)
movq %rcx, -0x78(%rbp)
movq %r12, -0x48(%rbp)
movq %r13, %rdi
leaq 0x2a20(%rip), %rsi      # 0x5072
leaq 0x2a1d(%rip), %rdx      # 0x5076
callq 0x42d6
movq %r14, %rdi
movq %r13, %rsi
callq 0x3b02
movl $0x5, (%rax)
movq -0x48(%rbp), %rdi
cmpq %r12, %rdi
je 0x2684
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2180
movq %r12, -0x48(%rbp)
movq %r13, %rdi
leaq 0x29e5(%rip), %rsi      # 0x5077
leaq 0x29e2(%rip), %rdx      # 0x507b
callq 0x42d6
movq %r14, %rdi
movq %r13, %rsi
callq 0x3b02
movl $0x7, (%rax)
movq -0x48(%rbp), %rdi
cmpq %r12, %rdi
je 0x26c4
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2180
movq %r12, -0x48(%rbp)
movq %r13, %rdi
leaq 0x29aa(%rip), %rsi      # 0x507c
leaq 0x29a7(%rip), %rdx      # 0x5080
callq 0x42d6
movq %r14, %rdi
movq %r13, %rsi
callq 0x3b02
movl $0x6, (%rax)
movq -0x48(%rbp), %rdi
cmpq %r12, %rdi
je 0x2704
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2180
movq %r12, -0x48(%rbp)
movq %r13, %rdi
leaq 0x296f(%rip), %rsi      # 0x5081
leaq 0x296c(%rip), %rdx      # 0x5085
callq 0x42d6
movq %r14, %rdi
movq %r13, %rsi
callq 0x3b02
movl $0x5, (%rax)
movq -0x48(%rbp), %rdi
cmpq %r12, %rdi
je 0x2744
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2180
movq %r12, -0x48(%rbp)
movq %r13, %rdi
leaq 0x2934(%rip), %rsi      # 0x5086
leaq 0x2931(%rip), %rdx      # 0x508a
callq 0x42d6
movq %r14, %rdi
movq %r13, %rsi
callq 0x3b02
movl $0x4, (%rax)
movq -0x48(%rbp), %rdi
cmpq %r12, %rdi
je 0x2784
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2180
movq %r12, -0x48(%rbp)
movq %r13, %rdi
leaq 0x28f9(%rip), %rsi      # 0x508b
leaq 0x28f6(%rip), %rdx      # 0x508f
callq 0x42d6
movq %r14, %rdi
movq %r13, %rsi
callq 0x3b02
movl $0x3, (%rax)
movq -0x48(%rbp), %rdi
cmpq %r12, %rdi
je 0x27c4
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2180
movq %r12, -0x48(%rbp)
movq %r13, %rdi
leaq 0x28be(%rip), %rsi      # 0x5090
leaq 0x28bb(%rip), %rdx      # 0x5094
callq 0x42d6
movq %r14, %rdi
movq %r13, %rsi
callq 0x3b02
movl $0x2, (%rax)
movq -0x48(%rbp), %rdi
cmpq %r12, %rdi
je 0x2804
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2180
movq %r12, -0x48(%rbp)
movq %r13, %rdi
leaq 0x2883(%rip), %rsi      # 0x5095
leaq 0x2882(%rip), %rdx      # 0x509b
callq 0x42d6
movq %r14, %rdi
movq %r13, %rsi
callq 0x3b02
movl $0x22, (%rax)
movq -0x48(%rbp), %rdi
cmpq %r12, %rdi
je 0x2844
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2180
movq %r12, -0x48(%rbp)
movq %r13, %rdi
leaq 0x284a(%rip), %rsi      # 0x509c
leaq 0x284a(%rip), %rdx      # 0x50a3
callq 0x42d6
movq %r14, %rdi
movq %r13, %rsi
callq 0x3b02
movl $0x1ad, (%rax)          # imm = 0x1AD
movq -0x48(%rbp), %rdi
cmpq %r12, %rdi
je 0x2884
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2180
movq %r12, -0x48(%rbp)
movq %r13, %rdi
leaq 0x2812(%rip), %rsi      # 0x50a4
leaq 0x2813(%rip), %rdx      # 0x50ac
callq 0x42d6
movq %r14, %rdi
movq %r13, %rsi
callq 0x3b02
movl $0x17b, (%rax)          # imm = 0x17B
movq -0x48(%rbp), %rdi
cmpq %r12, %rdi
je 0x28c4
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2180
movq %r12, -0x48(%rbp)
movq %r13, %rdi
leaq 0x27db(%rip), %rsi      # 0x50ad
leaq 0x27da(%rip), %rdx      # 0x50b3
callq 0x42d6
movq %r14, %rdi
movq %r13, %rsi
callq 0x3b02
movl $0x3, (%rax)
movq -0x48(%rbp), %rdi
cmpq %r12, %rdi
je 0x2904
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2180
movq %r12, -0x48(%rbp)
movq %r13, %rdi
leaq 0x27a2(%rip), %rsi      # 0x50b4
leaq 0x279f(%rip), %rdx      # 0x50b8
callq 0x42d6
movq %r14, %rdi
movq %r13, %rsi
callq 0x3b02
movl $0x2, (%rax)
movq -0x48(%rbp), %rdi
cmpq %r12, %rdi
je 0x2944
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2180
movq %r12, -0x48(%rbp)
movq %r13, %rdi
leaq 0x2767(%rip), %rsi      # 0x50b9
leaq 0x2764(%rip), %rdx      # 0x50bd
callq 0x42d6
movq %r14, %rdi
movq %r13, %rsi
callq 0x3b02
movl $0x2, (%rax)
movq -0x48(%rbp), %rdi
cmpq %r12, %rdi
je 0x2984
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2180
movl $0xb0, %edi
callq 0x2170
movq %rax, %r15
xorps %xmm0, %xmm0
movups %xmm0, 0xa0(%rax)
movups %xmm0, 0x90(%rax)
movq %rax, -0x58(%rbp)
movaps %xmm0, -0x70(%rbp)
movq $0x0, -0x60(%rbp)
movq %rax, %rdi
leaq -0x1a0(%rbp), %rsi
callq 0x2140
addq $0x64, %r15
movq %r15, %rdi
leaq -0xc0(%rbp), %r15
movq %r15, %rsi
callq 0x2140
movq %r12, -0x48(%rbp)
movq %r15, %rdi
callq 0x20a0
leaq (%rax,%rbp), %rdx
addq $-0xc0, %rdx
movq %r13, %rdi
movq %r15, %rsi
callq 0x42d6
movq %r14, %rdi
movq %r13, %rsi
callq 0x3b02
movl (%rax), %eax
movq -0x58(%rbp), %rdi
movl %eax, 0x78(%rdi)
movq -0x48(%rbp), %rax
cmpq %r12, %rax
je 0x2a29
movq -0x38(%rbp), %rsi
incq %rsi
movq %rax, %rdi
callq 0x2180
movq -0x58(%rbp), %rdi
movl $0x0, 0x80(%rdi)
movw $0x0, 0x7c(%rdi)
addq $0x98, %rdi
leaq -0x70(%rbp), %rsi
callq 0x3bc0
movq -0x58(%rbp), %rax
movq $0x0, 0x84(%rax)
movl 0x78(%rax), %ecx
addl %ecx, 0x57eb(%rip)      # 0x824c
movq 0x57a0(%rip), %rsi      # 0x8208
cmpq 0x57a1(%rip), %rsi      # 0x8210
je 0x2a7e
movq %rax, (%rsi)
addq $0x8, 0x578c(%rip)      # 0x8208
jmp 0x2a8e
leaq 0x577b(%rip), %rdi      # 0x8200
leaq -0x58(%rbp), %rdx
callq 0x46d4
movq -0x58(%rbp), %r15
movq %r13, %rdi
movq %r15, %rsi
leaq -0x49(%rbp), %rdx
callq 0x3b82
leaq 0x5770(%rip), %rdi      # 0x8218
movq %r13, %rsi
callq 0x3cae
movq %r15, (%rax)
movq -0x48(%rbp), %rdi
cmpq %r12, %rdi
je 0x2ac8
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2180
movq -0x70(%rbp), %rdi
testq %rdi, %rdi
je 0x2add
movq -0x60(%rbp), %rsi
subq %rdi, %rsi
callq 0x2180
movq %r14, %rdi
callq 0x409a
movq %rbx, %rdi
callq 0x2200
testl %eax, %eax
je 0x25ec
movq %rbx, %rdi
callq 0x2160
leaq 0x28dd(%rip), %rdi      # 0x53e1
callq 0x21f0
addq $0x178, %rsp            # imm = 0x178
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x2290
jmp 0x2b87
jmp 0x2b8c
jmp 0x2b87
jmp 0x2b87
jmp 0x2b87
jmp 0x2b87
jmp 0x2b32
jmp 0x2b68
jmp 0x2b68
movq %rax, %rbx
movq -0x48(%rbp), %rdi
cmpq %r12, %rdi
je 0x2b8f
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2180
jmp 0x2b8f
jmp 0x2b68
jmp 0x2b68
jmp 0x2b68
jmp 0x2b8c
jmp 0x2b87
jmp 0x2b87
jmp 0x2b87
jmp 0x2b68
jmp 0x2b68
jmp 0x2b68
jmp 0x2b68
jmp 0x2b68
jmp 0x2b68
jmp 0x2b68
movq %rax, %rbx
movq -0x48(%rbp), %rdi
cmpq %r12, %rdi
je 0x2ba4
movq -0x38(%rbp), %rsi
incq %rsi
jmp 0x2b9f
jmp 0x2b87
jmp 0x2b87
jmp 0x2b87
jmp 0x2b87
jmp 0x2b87
movq %rax, %rbx
jmp 0x2ba4
movq %rax, %rbx
movq -0x70(%rbp), %rdi
testq %rdi, %rdi
je 0x2ba4
movq -0x60(%rbp), %rsi
subq %rdi, %rsi
callq 0x2180
leaq -0xa0(%rbp), %rdi
callq 0x409a
movq %rbx, %rdi
callq 0x2230