// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %rax
movq %rdi, %rbx
movq $0x606151, %rax         # imm = 0x606151
movzbl (%rax), %r13d
movl %r13d, %r14d
shll $0x4, %r14d
orq $0x8, %r14
movq %r14, %rdi
callq 0x414190
leaq 0x8(%rax), %r15
movq %rax, (%rsp)
movq %r13, (%rax)
testl %r13d, %r13d
je 0x40bc63
shll $0x4, %r13d
negq %r13
xorl %ebp, %ebp
movq %r15, %r12
movq %r12, %rdi
callq 0x40d928
addq $-0x10, %rbp
addq $0x10, %r12
cmpq %rbp, %r13
jne 0x40bc4e
movq %r15, 0x50(%rbx)
movq $0x6085e4, %rax         # imm = 0x6085E4
movzbl (%rax), %r13d
movl %r13d, %r14d
shll $0x4, %r14d
orq $0x8, %r14
movq %r14, %rdi
callq 0x414190
leaq 0x8(%rax), %r15
movq %r13, (%rax)
testl %r13d, %r13d
je 0x40bcc2
movq %rax, (%rsp)
shll $0x4, %r13d
negq %r13
xorl %ebp, %ebp
movq %r15, %r12
movq %r12, %rdi
callq 0x40de94
addq $-0x10, %rbp
addq $0x10, %r12
cmpq %rbp, %r13
jne 0x40bca1
movq $0x6085e4, %rax         # imm = 0x6085E4
movb (%rax), %bpl
jmp 0x40bcc4
xorl %ebp, %ebp
movq %r15, 0x88(%rbx)
movq $0x606151, %rax         # imm = 0x606151
movzbl (%rax), %r14d
movq %r14, %rdi
callq 0x414190
movq %rax, %r15
xorl %r13d, %r13d
movq %rax, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x401080
movq %r15, 0x58(%rbx)
movq %r14, %rdi
callq 0x414190
movq %rax, %r15
movq %rax, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x401080
movq %r15, 0x60(%rbx)
movl %r14d, %r15d
addl %r15d, %r15d
movq %r15, %rdi
callq 0x414190
movq %rax, %r12
movq %rax, %rdi
xorl %esi, %esi
movq %r15, %rdx
callq 0x401080
movq %r12, 0x68(%rbx)
movq %r14, %rdi
callq 0x414190
movq %rax, %r15
movq %rax, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x401080
movq %r15, 0x70(%rbx)
movq %r14, %rdi
callq 0x414190
movq %rax, %r15
movq %rax, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x401080
movq %r15, 0x78(%rbx)
movq $0x606153, %rax         # imm = 0x606153
movzbl (%rax), %r14d
addl %r14d, %r14d
movq %r14, %rdi
callq 0x414190
movq %rax, %r15
movq %rax, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x401080
movq %r15, 0x80(%rbx)
movzbl %bpl, %r14d
leal (,%r14,8), %r15d
movq %r15, %rdi
callq 0x414190
movq %rax, 0x90(%rbx)
movq %r15, %rdi
callq 0x414190
movq %rax, 0x98(%rbx)
movq %r14, %rdi
callq 0x414190
movq %rax, %r15
movq %rax, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x401080
movq %r15, 0x110(%rbx)
addl %r14d, %r14d
movq %r14, %rdi
callq 0x414190
movq %rax, %r15
movq %rax, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x401080
movq %r15, 0x118(%rbx)
movq $0x6085ac, %rax         # imm = 0x6085AC
movzwl (%rax), %r14d
shll $0x3, %r14d
movzbl %bpl, %eax
cmpq %rax, %r13
jae 0x40be50
movq %r14, %rdi
callq 0x414190
movq 0x90(%rbx), %rcx
movq %rax, (%rcx,%r13,8)
movq %r14, %rdi
callq 0x414190
movq 0x98(%rbx), %rcx
movq %rax, (%rcx,%r13,8)
incq %r13
movq $0x6085e4, %rax         # imm = 0x6085E4
movb (%rax), %bpl
jmp 0x40be12
xorl %r14d, %r14d
xorl %r15d, %r15d
xorl %r12d, %r12d
movq $0x606151, %rax         # imm = 0x606151
movzbl (%rax), %eax
cmpq %rax, %r12
jae 0x40beae
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 0x40da88
popq %rax
popq %rcx
incq %r12
addq $0x10, %r15
addq $0x2, %r14
jmp 0x40be59
xorl %r15d, %r15d
xorl %r12d, %r12d
movq $0x6085e4, %rax         # imm = 0x6085E4
movzbl (%rax), %r14d
cmpq %r14, %r12
jae 0x40befa
movq 0x88(%rbx), %rdi
addq %r15, %rdi
movq 0x98(%rbx), %rax
movq (%rax,%r12,8), %rsi
movq 0x8(%rbx), %rcx
movq 0x90(%rbx), %rax
movq (%rax,%r12,8), %rdx
movzbl %r12b, %r8d
callq 0x40ea86
incq %r12
addq $0x10, %r15
jmp 0x40beb4
movq $0x606151, %rax         # imm = 0x606151
movzbl (%rax), %r15d
movq %r15, %rdi
callq 0x414190
movq %rax, %r12
movq %rax, %rdi
xorl %esi, %esi
movq %r15, %rdx
callq 0x401080
movq %r12, 0xd8(%rbx)
movq %r14, %rdi
callq 0x414190
movq %rax, %r12
movq %rax, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x401080
movq %r12, 0xe0(%rbx)
movl %r15d, %r12d
addl %r12d, %r12d
movq %r12, %rdi
callq 0x414190
movq %rax, %r13
movq %rax, %rdi
xorl %esi, %esi
movq %r12, %rdx
callq 0x401080
movq %r13, 0xe8(%rbx)
leal (%r14,%r14), %r12d
movq %r12, %rdi
callq 0x414190
movq %rax, %r13
movq %rax, %rdi
xorl %esi, %esi
movq %r12, %rdx
callq 0x401080
movq %r13, 0xf0(%rbx)
movq %r15, %rdi
callq 0x414190
movq %rax, %r12
movq %rax, %rdi
xorl %esi, %esi
movq %r15, %rdx
callq 0x401080
movq %r12, 0x100(%rbx)
movq %r14, %rdi
callq 0x414190
movq %rax, %r15
movq %rax, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x401080
movq %r15, 0x108(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
testq %rbp, %rbp
je 0x40bffa
negq %rbp
movq (%rsp), %r15
addq $-0x8, %r15
leaq (%r15,%rbp), %rdi
callq 0x40e9b0
addq $-0x10, %rbp
jne 0x40bfeb
jmp 0x40c01e
movq %rax, %rbx
testq %rbp, %rbp
je 0x40c01e
negq %rbp
movq (%rsp), %r15
addq $-0x8, %r15
leaq (%r15,%rbp), %rdi
callq 0x40da0c
addq $-0x10, %rbp
jne 0x40c00f
movq (%rsp), %rdi
movq %r14, %rsi
callq 0x412c70
movq %rbx, %rdi
callq 0x4bea70