// File: /workspace/github_cpp_makefile_star2_O2/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 $0x6085ac, %rax         # imm = 0x6085AC
movzwl (%rax), %ebp
movl %ebp, %r14d
shll $0x3, %r14d
movq %r14, %rdi
callq 0x414190
movq %rax, 0x8(%rbx)
movq %r14, %rdi
callq 0x414190
movq %rax, 0x10(%rbx)
movq %r14, %rdi
callq 0x414190
movq %rax, 0x18(%rbx)
movq %r14, %rdi
callq 0x414190
movq %rax, 0x20(%rbx)
movq %r14, %rdi
callq 0x414190
movq %rax, 0x28(%rbx)
movq %r14, %rdi
callq 0x414190
movq %rax, 0x30(%rbx)
movq %r14, %rdi
callq 0x414190
movq %rax, 0x38(%rbx)
movq %r14, %rdi
callq 0x414190
movq %rax, 0x40(%rbx)
xorl %r13d, %r13d
movzwl %bp, %eax
cmpq %rax, %r13
jae 0x40bbb8
movq $0x6085ae, %rax         # imm = 0x6085AE
movzwl (%rax), %r15d
imulq $0x148, %r15, %r14      # imm = 0x148
addq $0x8, %r14
movq %r14, %rdi
callq 0x414190
leaq 0x8(%rax), %rcx
movq %r15, (%rax)
testq %r15, %r15
je 0x40b9fe
movq %rax, 0x8(%rsp)
imulq $-0x148, %r15, %r15     # imm = 0xFEB8
movq %rcx, 0x10(%rsp)
movq %rcx, %r12
xorl %ebp, %ebp
movq %r12, %rdi
callq 0x411a18
addq $-0x148, %rbp           # imm = 0xFEB8
addq $0x148, %r12            # imm = 0x148
cmpq %rbp, %r15
jne 0x40b9d1
movq $0x6085ae, %rax         # imm = 0x6085AE
movzwl (%rax), %r12d
movq 0x10(%rsp), %rcx
jmp 0x40ba01
xorl %r12d, %r12d
movq 0x8(%rbx), %rax
movq %rcx, (%rax,%r13,8)
movzwl %r12w, %r14d
movq %r14, %rdi
callq 0x414190
movq %rax, %r15
movq %rax, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x401080
movq 0x10(%rbx), %rax
movq %r15, (%rax,%r13,8)
movq %r14, %rdi
callq 0x414190
movq %rax, %r15
movq %rax, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x401080
movq 0x18(%rbx), %rax
movq %r15, (%rax,%r13,8)
movq %r14, %rdi
callq 0x414190
movq %rax, %r15
movq %rax, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x401080
movq 0x20(%rbx), %rax
movq %r15, (%rax,%r13,8)
movq %r14, %rdi
callq 0x414190
movq %rax, %r15
movq %rax, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x401080
movq 0x28(%rbx), %rax
movq %r15, (%rax,%r13,8)
movq %r14, %rdi
callq 0x414190
movq %rax, %r15
movq %rax, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x401080
movq 0x30(%rbx), %rax
movq %r15, (%rax,%r13,8)
movq %r14, %rdi
callq 0x414190
movq %rax, %r15
movq %rax, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x401080
movq 0x38(%rbx), %rax
movq %r15, (%rax,%r13,8)
movq %r14, %rdi
callq 0x414190
movq %rax, %r15
movq %rax, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x401080
movq 0x40(%rbx), %rax
movq %r15, (%rax,%r13,8)
movzwl %r13w, %ebp
xorl %r14d, %r14d
xorl %r15d, %r15d
movzwl %r12w, %eax
cmpq %rax, %r15
jae 0x40bba6
movq 0x8(%rbx), %rax
movq (%rax,%r13,8), %rdi
addq %r14, %rdi
movzwl %r15w, %edx
movl %ebp, %esi
callq 0x411f00
movq 0x8(%rbx), %rax
movq (%rax,%r13,8), %rdi
addq %r14, %rdi
callq 0x411f0e
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 0x411f9a
popq %rax
popq %rcx
incq %r15
movq $0x6085ae, %rax         # imm = 0x6085AE
movzwl (%rax), %r12d
addq $0x148, %r14            # imm = 0x148
jmp 0x40baf7
incq %r13
movq $0x6085ac, %rax         # imm = 0x6085AC
movzwl (%rax), %ebp
jmp 0x40b985
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
testq %rbp, %rbp
je 0x40bbf0
negq %rbp
movq 0x8(%rsp), %r15
addq $-0x140, %r15           # imm = 0xFEC0
leaq (%r15,%rbp), %rdi
callq 0x411d3c
addq $-0x148, %rbp           # imm = 0xFEB8
jne 0x40bbde
movq 0x8(%rsp), %rdi
movq %r14, %rsi
callq 0x412c70
movq %rbx, %rdi
callq 0x4bea70
nop