// File: /workspace/github_cpp_makefile_star2_O1/MPSLab-ASU[P]DiRAC/./src/controller.cc
// Function: controller::setup_PEs()
void controller::setup_PEs() {
	PEs = new PE*[nRows_PE_Array];
  bus_trigger_PEs_exec            = new bool*[nRows_PE_Array];
  bus_trigger_PEs_zero_initialize = new bool*[nRows_PE_Array];
  bus_trigger_PEs_write_back      = new bool*[nRows_PE_Array];
  bus_trigger_PEs_spatial_reduce  = new bool*[nRows_PE_Array];
  bus_trigger_PEs_update_buf_num_Op1 = new bool*[nRows_PE_Array];
  bus_trigger_PEs_update_buf_num_Op2 = new bool*[nRows_PE_Array];
  bus_trigger_PEs_update_buf_num_Op3 = new bool*[nRows_PE_Array];

	for(auto i=0; i < nRows_PE_Array; i++) {
		PEs[i] = new PE[nCols_PE_Array];
    bus_trigger_PEs_exec[i]             = new bool[nCols_PE_Array]();
    bus_trigger_PEs_zero_initialize[i]  = new bool[nCols_PE_Array]();
    bus_trigger_PEs_write_back[i]       = new bool[nCols_PE_Array]();
    bus_trigger_PEs_spatial_reduce[i]   = new bool[nCols_PE_Array]();
    bus_trigger_PEs_update_buf_num_Op1[i] = new bool[nCols_PE_Array]();
    bus_trigger_PEs_update_buf_num_Op2[i] = new bool[nCols_PE_Array]();
    bus_trigger_PEs_update_buf_num_Op3[i] = new bool[nCols_PE_Array]();

		for(auto j=0; j < nCols_PE_Array; j++) {
      PEs[i][j].setup(i,j);
			PEs[i][j].initialize();
      PEs[i][j].setTriggerFromController( &bus_trigger_PEs_exec[i][j],
        &bus_trigger_PEs_zero_initialize[i][j],
        &bus_trigger_PEs_write_back[i][j],
        &bus_trigger_PEs_spatial_reduce[i][j],
        &bus_trigger_PEs_update_buf_num_Op1[i][j],
        &bus_trigger_PEs_update_buf_num_Op2[i][j],
        &bus_trigger_PEs_update_buf_num_Op3[i][j]);
		}
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
movq $0x60b5ac, %r15         # imm = 0x60B5AC
movzwl (%r15), %r14d
shll $0x3, %r14d
movq %r14, %rdi
callq 0x4181e0
movq %rax, 0x8(%rbx)
movq %r14, %rdi
callq 0x4181e0
movq %rax, 0x10(%rbx)
movq %r14, %rdi
callq 0x4181e0
movq %rax, 0x18(%rbx)
movq %r14, %rdi
callq 0x4181e0
movq %rax, 0x20(%rbx)
movq %r14, %rdi
callq 0x4181e0
movq %rax, 0x28(%rbx)
movq %r14, %rdi
callq 0x4181e0
movq %rax, 0x30(%rbx)
movq %r14, %rdi
callq 0x4181e0
movq %rax, 0x38(%rbx)
movq %r14, %rdi
callq 0x4181e0
movq %rax, 0x40(%rbx)
cmpw $0x0, (%r15)
je 0x40f28e
xorl %r13d, %r13d
movq $0x60b5ae, %r12         # imm = 0x60B5AE
movzwl (%r12), %r14d
imulq $0x148, %r14, %rdi      # imm = 0x148
addq $0x8, %rdi
movq %rdi, 0x10(%rsp)
callq 0x4181e0
leaq 0x8(%rax), %r15
movq %rax, 0x8(%rsp)
movq %r14, (%rax)
testq %r14, %r14
je 0x40f0c5
imulq $-0x148, %r14, %r14     # imm = 0xFEB8
movq %r15, %r12
xorl %ebp, %ebp
movq %r12, %rdi
callq 0x41588c
addq $-0x148, %rbp           # imm = 0xFEB8
addq $0x148, %r12            # imm = 0x148
cmpq %rbp, %r14
jne 0x40f0aa
movq 0x8(%rbx), %rax
movq %r15, (%rax,%r13,8)
movq $0x60b5ae, %r12         # imm = 0x60B5AE
movzwl (%r12), %r14d
movq %r14, %rdi
callq 0x4181e0
movq %rax, %r15
movq %rax, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x401088
movq 0x10(%rbx), %rax
movq %r15, (%rax,%r13,8)
movq %r14, %rdi
callq 0x4181e0
movq %rax, %r15
movq %rax, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x401088
movq 0x18(%rbx), %rax
movq %r15, (%rax,%r13,8)
movq %r14, %rdi
callq 0x4181e0
movq %rax, %r15
movq %rax, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x401088
movq 0x20(%rbx), %rax
movq %r15, (%rax,%r13,8)
movq %r14, %rdi
callq 0x4181e0
movq %rax, %r15
movq %rax, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x401088
movq 0x28(%rbx), %rax
movq %r15, (%rax,%r13,8)
movq %r14, %rdi
callq 0x4181e0
movq %rax, %r15
movq %rax, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x401088
movq 0x30(%rbx), %rax
movq %r15, (%rax,%r13,8)
movq %r14, %rdi
callq 0x4181e0
movq %rax, %r15
movq %rax, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x401088
movq 0x38(%rbx), %rax
movq %r15, (%rax,%r13,8)
movq %r14, %rdi
callq 0x4181e0
movq %rax, %r15
movq %rax, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x401088
movq 0x40(%rbx), %rax
movq %r15, (%rax,%r13,8)
cmpw $0x0, (%r12)
je 0x40f278
movzwl %r13w, %ebp
xorl %r14d, %r14d
xorl %r15d, %r15d
movq 0x8(%rbx), %rax
movq (%rax,%r13,8), %rdi
addq %r14, %rdi
movzwl %r15w, %edx
movl %ebp, %esi
callq 0x415da6
movq 0x8(%rbx), %rax
movq (%rax,%r13,8), %rdi
addq %r14, %rdi
callq 0x415db6
movq 0x8(%rbx), %rax
movq 0x10(%rbx), %rcx
movq (%rax,%r13,8), %rdi
addq %r14, %rdi
movq (%rcx,%r13,8), %rsi
addq %r15, %rsi
movq 0x18(%rbx), %rax
movq (%rax,%r13,8), %rdx
addq %r15, %rdx
movq 0x20(%rbx), %rax
movq (%rax,%r13,8), %rcx
addq %r15, %rcx
movq 0x28(%rbx), %rax
movq (%rax,%r13,8), %r8
addq %r15, %r8
movq 0x30(%rbx), %rax
movq (%rax,%r13,8), %r9
addq %r15, %r9
movq 0x38(%rbx), %rax
movq (%rax,%r13,8), %rax
addq %r15, %rax
movq 0x40(%rbx), %r10
movq (%r10,%r13,8), %r10
addq %r15, %r10
pushq %r10
pushq %rax
callq 0x415e4e
movq $0x60b5ae, %r12         # imm = 0x60B5AE
addq $0x10, %rsp
incq %r15
movzwl (%r12), %eax
addq $0x148, %r14            # imm = 0x148
cmpq %rax, %r15
jb 0x40f1cf
incq %r13
movq $0x60b5ac, %rax         # imm = 0x60B5AC
movzwl (%rax), %eax
cmpq %rax, %r13
jb 0x40f073
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
testq %rbp, %rbp
je 0x40f2c6
negq %rbp
movq 0x8(%rsp), %r14
addq $-0x140, %r14           # imm = 0xFEC0
leaq (%r14,%rbp), %rdi
callq 0x415bd6
addq $-0x148, %rbp           # imm = 0xFEB8
jne 0x40f2b4
movq 0x8(%rsp), %rdi
movq 0x10(%rsp), %rsi
callq 0x416cc0
movq %rbx, %rdi
callq 0x4c2960
nop