// File: /workspace/github_cpp_makefile_star2_O3/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 $0x609151, %rax         # imm = 0x609151
movzbl (%rax), %r13d
movl %r13d, %r14d
shll $0x4, %r14d
orq $0x8, %r14
movq %r14, %rdi
callq 0x418d20
leaq 0x8(%rax), %r15
movq %rax, (%rsp)
movq %r13, (%rax)
testl %r13d, %r13d
je 0x40f3ad
shll $0x4, %r13d
negq %r13
xorl %ebp, %ebp
movq %r15, %r12
movq %r12, %rdi
callq 0x411234
addq $-0x10, %rbp
addq $0x10, %r12
cmpq %rbp, %r13
jne 0x40f398
movq %r15, 0x50(%rbx)
movq $0x60b5e4, %rax         # imm = 0x60B5E4
movzbl (%rax), %r13d
movl %r13d, %r14d
shll $0x4, %r14d
orq $0x8, %r14
movq %r14, %rdi
callq 0x418d20
leaq 0x8(%rax), %rbp
movq %r13, (%rax)
testl %r13d, %r13d
je 0x40f40d
movq %rax, (%rsp)
shll $0x4, %r13d
negq %r13
xorl %r15d, %r15d
movq %rbp, %r12
movq %r12, %rdi
callq 0x4117ec
addq $-0x10, %r15
addq $0x10, %r12
cmpq %r15, %r13
jne 0x40f3ec
movq $0x60b5e4, %rax         # imm = 0x60B5E4
movb (%rax), %r13b
jmp 0x40f410
xorl %r13d, %r13d
movq %rbp, 0x88(%rbx)
movq $0x609151, %rax         # imm = 0x609151
movzbl (%rax), %r14d
movq %r14, %rdi
callq 0x418d20
movq %rax, %r15
xorl %ebp, %ebp
movq %rax, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x401088
movq %r15, 0x58(%rbx)
movq %r14, %rdi
callq 0x418d20
movq %rax, %r15
movq %rax, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x401088
movq %r15, 0x60(%rbx)
leal (%r14,%r14), %r15d
movq %r15, %rdi
callq 0x418d20
movq %rax, %r12
movq %rax, %rdi
xorl %esi, %esi
movq %r15, %rdx
callq 0x401088
movq %r12, 0x68(%rbx)
movq %r14, %rdi
callq 0x418d20
movq %rax, %r15
movq %rax, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x401088
movq %r15, 0x70(%rbx)
movq %r14, %rdi
callq 0x418d20
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), %r15d
addl %r15d, %r15d
movq %r15, %rdi
callq 0x418d20
movq %rax, %r12
movq %rax, %rdi
xorl %esi, %esi
movq %r15, %rdx
callq 0x401088
movq %r12, 0x80(%rbx)
movzbl %r13b, %r15d
leal (,%r15,8), %r12d
movq %r12, %rdi
callq 0x418d20
movq %rax, 0x90(%rbx)
movq %r12, %rdi
callq 0x418d20
movq %rax, 0x98(%rbx)
movq %r15, %rdi
callq 0x418d20
movq %rax, %r12
movq %rax, %rdi
xorl %esi, %esi
movq %r15, %rdx
callq 0x401088
movq %r12, 0x110(%rbx)
leal (%r15,%r15), %r12d
movq %r12, %rdi
callq 0x418d20
movq %rax, %r13
movq %rax, %rdi
xorl %esi, %esi
movq %r12, %rdx
callq 0x401088
movq %r13, 0x118(%rbx)
testb %r15b, %r15b
je 0x40f5ab
movq $0x60b5ac, %rax         # imm = 0x60B5AC
movzwl (%rax), %r14d
shll $0x3, %r14d
xorl %r15d, %r15d
movq $0x60b5e4, %r12         # imm = 0x60B5E4
movq %r14, %rdi
callq 0x418d20
movq 0x90(%rbx), %rcx
movq %rax, (%rcx,%r15,8)
movq %r14, %rdi
callq 0x418d20
movq 0x98(%rbx), %rcx
movq %rax, (%rcx,%r15,8)
incq %r15
movzbl (%r12), %ebp
cmpq %rbp, %r15
jb 0x40f56b
movq $0x609151, %r13         # imm = 0x609151
movb (%r13), %r14b
jmp 0x40f5b2
movq $0x609151, %r13         # imm = 0x609151
testb %r14b, %r14b
je 0x40f61c
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 0x4113ae
addq $0x10, %rsp
incq %r12
movzbl (%r13), %eax
addq $0x10, %r15
addq $0x2, %r14
cmpq %rax, %r12
jb 0x40f5c0
movq $0x60b5e4, %rcx         # imm = 0x60B5E4
movb (%rcx), %bpl
jmp 0x40f61e
xorl %eax, %eax
testb %bpl, %bpl
je 0x40f674
xorl %r15d, %r15d
xorl %r12d, %r12d
movq $0x60b5e4, %rbp         # imm = 0x60B5E4
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 0x41242c
incq %r12
movzbl (%rbp), %r14d
addq $0x10, %r15
cmpq %r14, %r12
jb 0x40f630
movb (%r13), %al
jmp 0x40f677
xorl %r14d, %r14d
movzbl %al, %r15d
movq %r15, %rdi
callq 0x418d20
movq %rax, %r12
movq %rax, %rdi
xorl %esi, %esi
movq %r15, %rdx
callq 0x401088
movq %r12, 0xd8(%rbx)
movq %r14, %rdi
callq 0x418d20
movq %rax, %r12
movq %rax, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x401088
movq %r12, 0xe0(%rbx)
movl %r15d, %r12d
addl %r12d, %r12d
movq %r12, %rdi
callq 0x418d20
movq %rax, %r13
movq %rax, %rdi
xorl %esi, %esi
movq %r12, %rdx
callq 0x401088
movq %r13, 0xe8(%rbx)
leal (%r14,%r14), %r12d
movq %r12, %rdi
callq 0x418d20
movq %rax, %r13
movq %rax, %rdi
xorl %esi, %esi
movq %r12, %rdx
callq 0x401088
movq %r13, 0xf0(%rbx)
movq %r15, %rdi
callq 0x418d20
movq %rax, %r12
movq %rax, %rdi
xorl %esi, %esi
movq %r15, %rdx
callq 0x401088
movq %r12, 0x100(%rbx)
movq %r14, %rdi
callq 0x418d20
movq %rax, %r15
movq %rax, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x401088
movq %r15, 0x108(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
testq %r15, %r15
je 0x40f770
negq %r15
movq (%rsp), %r12
addq $-0x8, %r12
leaq (%r12,%r15), %rdi
callq 0x412330
addq $-0x10, %r15
jne 0x40f761
jmp 0x40f794
movq %rax, %rbx
testq %rbp, %rbp
je 0x40f794
negq %rbp
movq (%rsp), %r15
addq $-0x8, %r15
leaq (%r15,%rbp), %rdi
callq 0x41132c
addq $-0x10, %rbp
jne 0x40f785
movq (%rsp), %rdi
movq %r14, %rsi
callq 0x417800
movq %rbx, %rdi
callq 0x4c34a0