// File: /workspace/github_cpp_makefile_star2_O1/MPSLab-ASU[P]DiRAC/./src/controller.cc
// Function: controller::setup_interconnect()
void controller::setup_interconnect()
{
  network_inputs        = new MultiCastNetwork_Input[inNetworks];
  network_outputs       = new MultiCastNetwork_Output[outNetworks];
  configNetwork         = new bool[inNetworks]();
  forwardDataToNetwork  = new bool[inNetworks]();
  dataOutToNetwork      = new data_type[inNetworks]();
  rowTagDataToNetwork   = new uint8_t[inNetworks]();
  colTagDataToNetwork   = new uint8_t[inNetworks]();
  cnt_data_distribution = new uint16_t[totalNetworks]();
  dataInFromNetwork     = new data_type**[outNetworks];
  writeBackFromNetwork  = new bool**[outNetworks];
  is_data_collected     = new bool[outNetworks]();
  collected_data        = new data_type[outNetworks]();

  for(uint16_t it=0; it < outNetworks; it++)
  {
    dataInFromNetwork[it]     = new data_type*[nRows_PE_Array];
    writeBackFromNetwork[it]  = new bool*[nRows_PE_Array];
  }

  for(uint8_t i=0; i < inNetworks; i++)
  {
    network_inputs[i].setupNetwork(configNetwork+i, forwardDataToNetwork+i,
      dataOutToNetwork+i, rowTagDataToNetwork+i, colTagDataToNetwork+i,
      PEs, i);
  }

  for(uint8_t i=0; i < outNetworks; i++)
  {
    network_outputs[i].setupNetwork(writeBackFromNetwork[i],
      dataInFromNetwork[i], PEs, i);
  }

  cnt_prefetch_via_network_RF_pass = new uint8_t[inNetworks]();
	cnt_writeback_via_network_RF_pass = new uint8_t[outNetworks]();
  idx_read_network_packet = new uint16_t[inNetworks]();
  idx_write_network_packet = new uint16_t[outNetworks]();
  network_read_op_comm_completed = new bool[inNetworks]();
  network_write_op_comm_completed = new bool[outNetworks]();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
movq $0x609151, %rax         # imm = 0x609151
movzbl (%rax), %ebp
movl %ebp, %r14d
shll $0x4, %r14d
orq $0x8, %r14
movq %r14, %rdi
callq 0x4181e0
leaq 0x8(%rax), %r15
movq %rax, 0x8(%rsp)
movq %rbp, (%rax)
testl %ebp, %ebp
je 0x40f33d
shll $0x4, %ebp
negq %rbp
xorl %r13d, %r13d
movq %r15, %r12
movq %r12, %rdi
callq 0x411198
addq $-0x10, %r13
addq $0x10, %r12
cmpq %r13, %rbp
jne 0x40f328
movq %r15, 0x50(%rbx)
movq $0x60b5e4, %rbp         # imm = 0x60B5E4
movzbl (%rbp), %r14d
movl %r14d, %r13d
shll $0x4, %r13d
orq $0x8, %r13
movq %r13, %rdi
callq 0x4181e0
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq %rax, 0x10(%rsp)
movq %r14, (%rax)
testl %r14d, %r14d
je 0x40f39a
shll $0x4, %r14d
negq %r14
xorl %r15d, %r15d
movq 0x8(%rsp), %r12
movq %r12, %rdi
callq 0x41174a
addq $-0x10, %r15
addq $0x10, %r12
cmpq %r15, %r14
jne 0x40f385
movq 0x8(%rsp), %rax
movq %rax, 0x88(%rbx)
movq $0x609151, %rax         # imm = 0x609151
movzbl (%rax), %r14d
movq %r14, %rdi
callq 0x4181e0
movq %rax, %r15
movq %rax, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x401088
movq %r15, 0x58(%rbx)
movq %r14, %rdi
callq 0x4181e0
movq %rax, %r15
movq %rax, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x401088
movq %r15, 0x60(%rbx)
movl %r14d, %r15d
addl %r15d, %r15d
movq %r15, %rdi
callq 0x4181e0
movq %rax, %r12
movq %rax, %rdi
xorl %esi, %esi
movq %r15, %rdx
callq 0x401088
movq %r12, 0x68(%rbx)
movq %r14, %rdi
callq 0x4181e0
movq %rax, %r15
movq %rax, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x401088
movq %r15, 0x70(%rbx)
movq %r14, %rdi
callq 0x4181e0
movq %rax, %r15
movq %rax, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x401088
movq %r15, 0x78(%rbx)
movq $0x609153, %rax         # imm = 0x609153
movzbl (%rax), %r14d
addl %r14d, %r14d
movq %r14, %rdi
callq 0x4181e0
movq %rax, %r15
movq %rax, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x401088
movq %r15, 0x80(%rbx)
movzbl (%rbp), %r14d
leal (,%r14,8), %r15d
movq %r15, %rdi
callq 0x4181e0
movq %rax, 0x90(%rbx)
movq %r15, %rdi
callq 0x4181e0
movq %rax, 0x98(%rbx)
movq %r14, %rdi
callq 0x4181e0
movq %rax, %r15
movq %rax, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x401088
movq %r15, 0x110(%rbx)
addl %r14d, %r14d
movq %r14, %rdi
callq 0x4181e0
movq %rax, %r15
movq %rax, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x401088
movq %r15, 0x118(%rbx)
cmpb $0x0, (%rbp)
je 0x40f526
movq $0x60b5ac, %rax         # imm = 0x60B5AC
movzwl (%rax), %r14d
shll $0x3, %r14d
xorl %r15d, %r15d
movq %r14, %rdi
callq 0x4181e0
movq 0x90(%rbx), %rcx
movq %rax, (%rcx,%r15,8)
movq %r14, %rdi
callq 0x4181e0
movq 0x98(%rbx), %rcx
movq %rax, (%rcx,%r15,8)
incq %r15
movzbl (%rbp), %eax
cmpq %rax, %r15
jb 0x40f4f4
movq $0x609151, %r13         # imm = 0x609151
cmpb $0x0, (%r13)
je 0x40f58d
xorl %r14d, %r14d
xorl %r15d, %r15d
xorl %r12d, %r12d
movq 0x50(%rbx), %rdi
addq %r15, %rdi
movq 0x58(%rbx), %rsi
addq %r12, %rsi
movq 0x60(%rbx), %rdx
addq %r12, %rdx
movq 0x68(%rbx), %rcx
addq %r14, %rcx
movq 0x70(%rbx), %r8
addq %r12, %r8
movq 0x78(%rbx), %r9
addq %r12, %r9
movzbl %r12b, %eax
pushq %rax
pushq 0x8(%rbx)
callq 0x41130e
addq $0x10, %rsp
incq %r12
movzbl (%r13), %eax
addq $0x10, %r15
addq $0x2, %r14
cmpq %rax, %r12
jb 0x40f53d
movb (%rbp), %r12b
testb %r12b, %r12b
je 0x40f5da
xorl %r14d, %r14d
xorl %r15d, %r15d
movq 0x88(%rbx), %rdi
addq %r14, %rdi
movq 0x98(%rbx), %rax
movq (%rax,%r15,8), %rsi
movq 0x8(%rbx), %rcx
movq 0x90(%rbx), %rax
movq (%rax,%r15,8), %rdx
movzbl %r15b, %r8d
callq 0x411912
incq %r15
movzbl (%rbp), %r12d
addq $0x10, %r14
cmpq %r12, %r15
jb 0x40f59c
movq $0x609151, %rax         # imm = 0x609151
movzbl (%rax), %r14d
movq %r14, %rdi
callq 0x4181e0
movq %rax, %r15
movq %rax, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x401088
movq %r15, 0xd8(%rbx)
movzbl %r12b, %r15d
movq %r15, %rdi
callq 0x4181e0
movq %rax, %r12
movq %rax, %rdi
xorl %esi, %esi
movq %r15, %rdx
callq 0x401088
movq %r12, 0xe0(%rbx)
movl %r14d, %r12d
addl %r12d, %r12d
movq %r12, %rdi
callq 0x4181e0
movq %rax, %r13
movq %rax, %rdi
xorl %esi, %esi
movq %r12, %rdx
callq 0x401088
movq %r13, 0xe8(%rbx)
movl %r15d, %r12d
addl %r12d, %r12d
movq %r12, %rdi
callq 0x4181e0
movq %rax, %r13
movq %rax, %rdi
xorl %esi, %esi
movq %r12, %rdx
callq 0x401088
movq %r13, 0xf0(%rbx)
movq %r14, %rdi
callq 0x4181e0
movq %rax, %r12
movq %rax, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x401088
movq %r12, 0x100(%rbx)
movq %r15, %rdi
callq 0x4181e0
movq %rax, %r14
movq %rax, %rdi
xorl %esi, %esi
movq %r15, %rdx
callq 0x401088
movq %r14, 0x108(%rbx)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
testq %r15, %r15
je 0x40f6e1
negq %r15
movq 0x10(%rsp), %r14
addq $-0x8, %r14
leaq (%r14,%r15), %rdi
callq 0x41181a
addq $-0x10, %r15
jne 0x40f6d2
movq 0x10(%rsp), %rdi
movq %r13, %rsi
jmp 0x40f716
movq %rax, %rbx
testq %r13, %r13
je 0x40f70e
negq %r13
movq 0x8(%rsp), %r15
addq $-0x8, %r15
leaq (%r15,%r13), %rdi
callq 0x411290
addq $-0x10, %r13
jne 0x40f6ff
movq 0x8(%rsp), %rdi
movq %r14, %rsi
callq 0x416cc0
movq %rbx, %rdi
callq 0x4c2960
nop