// File: 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
movq %rsp, %rbp
subq $0x1a0, %rsp            # imm = 0x1A0
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x40(%rbp)
movq $0x61c151, %rax         # imm = 0x61C151
movzbl (%rax), %eax
movq %rax, -0x30(%rbp)
movl $0x10, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
addq $0x8, %rdi
setb %al
orb %al, %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
movq %rdi, -0x38(%rbp)
callq 0x425dd0
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, -0x28(%rbp)
movq %rax, (%rcx)
addq $0x8, %rcx
movq %rcx, -0x20(%rbp)
cmpq $0x0, %rax
je 0x41576d
movq -0x20(%rbp), %rax
movq -0x30(%rbp), %rdx
shlq $0x4, %rdx
movq %rax, %rcx
addq %rdx, %rcx
movq %rcx, -0x50(%rbp)
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rdi
movq %rdi, -0x58(%rbp)
callq 0x418e90
jmp 0x415758
movq -0x50(%rbp), %rcx
movq -0x58(%rbp), %rax
addq $0x10, %rax
cmpq %rcx, %rax
movq %rax, -0x48(%rbp)
jne 0x415749
movq -0x40(%rbp), %rax
movq -0x20(%rbp), %rcx
movq %rcx, 0x50(%rax)
movq $0x61e5e4, %rax         # imm = 0x61E5E4
movzbl (%rax), %eax
movq %rax, -0x70(%rbp)
movl $0x10, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
addq $0x8, %rdi
setb %al
orb %al, %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
movq %rdi, -0x78(%rbp)
callq 0x425dd0
movq %rax, %rcx
movq -0x70(%rbp), %rax
movq %rcx, -0x68(%rbp)
movq %rax, (%rcx)
addq $0x8, %rcx
movq %rcx, -0x60(%rbp)
cmpq $0x0, %rax
je 0x41581b
movq -0x60(%rbp), %rax
movq -0x70(%rbp), %rdx
shlq $0x4, %rdx
movq %rax, %rcx
addq %rdx, %rcx
movq %rcx, -0x88(%rbp)
movq %rax, -0x80(%rbp)
movq -0x80(%rbp), %rdi
movq %rdi, -0x90(%rbp)
callq 0x419b50
jmp 0x415800
movq -0x88(%rbp), %rcx
movq -0x90(%rbp), %rax
addq $0x10, %rax
cmpq %rcx, %rax
movq %rax, -0x80(%rbp)
jne 0x4157ee
movq -0x40(%rbp), %rax
movq -0x60(%rbp), %rcx
movq %rcx, 0x88(%rax)
movq $0x61c151, %rax         # imm = 0x61C151
movzbl (%rax), %eax
movl %eax, %edi
movq %rdi, -0x110(%rbp)
callq 0x425dd0
movq -0x110(%rbp), %rdx
movq %rax, %rdi
movq %rdi, -0x108(%rbp)
xorl %esi, %esi
callq 0x401080
movq -0x108(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x58(%rax)
movq $0x61c151, %rax         # imm = 0x61C151
movzbl (%rax), %eax
movl %eax, %edi
movq %rdi, -0x100(%rbp)
callq 0x425dd0
movq -0x100(%rbp), %rdx
movq %rax, %rdi
movq %rdi, -0xf8(%rbp)
xorl %esi, %esi
callq 0x401080
movq -0xf8(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x60(%rax)
movq $0x61c151, %rax         # imm = 0x61C151
movzbl (%rax), %eax
movl $0x2, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
movq %rdi, -0xf0(%rbp)
callq 0x425dd0
movq -0xf0(%rbp), %rdx
movq %rax, %rdi
movq %rdi, -0xe8(%rbp)
xorl %esi, %esi
callq 0x401080
movq -0xe8(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x68(%rax)
movq $0x61c151, %rax         # imm = 0x61C151
movzbl (%rax), %eax
movl %eax, %edi
movq %rdi, -0xe0(%rbp)
callq 0x425dd0
movq -0xe0(%rbp), %rdx
movq %rax, %rdi
movq %rdi, -0xd8(%rbp)
xorl %esi, %esi
callq 0x401080
movq -0xd8(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x70(%rax)
movq $0x61c151, %rax         # imm = 0x61C151
movzbl (%rax), %eax
movl %eax, %edi
movq %rdi, -0xd0(%rbp)
callq 0x425dd0
movq -0xd0(%rbp), %rdx
movq %rax, %rdi
movq %rdi, -0xc8(%rbp)
xorl %esi, %esi
callq 0x401080
movq -0xc8(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x78(%rax)
movq $0x61c153, %rax         # imm = 0x61C153
movzbl (%rax), %eax
movl $0x2, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
movq %rdi, -0xc0(%rbp)
callq 0x425dd0
movq -0xc0(%rbp), %rdx
movq %rax, %rdi
movq %rdi, -0xb8(%rbp)
xorl %esi, %esi
callq 0x401080
movq -0xb8(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x80(%rax)
movq $0x61e5e4, %rax         # imm = 0x61E5E4
movzbl (%rax), %eax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x425dd0
movq %rax, %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x90(%rax)
movq $0x61e5e4, %rax         # imm = 0x61E5E4
movzbl (%rax), %eax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x425dd0
movq %rax, %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x98(%rax)
movq $0x61e5e4, %rax         # imm = 0x61E5E4
movzbl (%rax), %eax
movl %eax, %edi
movq %rdi, -0xb0(%rbp)
callq 0x425dd0
movq -0xb0(%rbp), %rdx
movq %rax, %rdi
movq %rdi, -0xa8(%rbp)
xorl %esi, %esi
callq 0x401080
movq -0xa8(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x110(%rax)
movq $0x61e5e4, %rax         # imm = 0x61E5E4
movzbl (%rax), %eax
movl $0x2, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
movq %rdi, -0xa0(%rbp)
callq 0x425dd0
movq -0xa0(%rbp), %rdx
movq %rax, %rdi
movq %rdi, -0x98(%rbp)
xorl %esi, %esi
callq 0x401080
movq -0x98(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x118(%rax)
movw $0x0, -0x16(%rbp)
movzwl -0x16(%rbp), %eax
movq $0x61e5e4, %rcx         # imm = 0x61E5E4
movzbl (%rcx), %ecx
cmpl %ecx, %eax
jge 0x415c59
movq $0x61e5ac, %rax         # imm = 0x61E5AC
movzwl (%rax), %eax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x425dd0
movq %rax, %rdx
movq -0x40(%rbp), %rax
movq 0x90(%rax), %rax
movzwl -0x16(%rbp), %ecx
movq %rdx, (%rax,%rcx,8)
movq $0x61e5ac, %rax         # imm = 0x61E5AC
movzwl (%rax), %eax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x425dd0
movq %rax, %rdx
movq -0x40(%rbp), %rax
movq 0x98(%rax), %rax
movzwl -0x16(%rbp), %ecx
movq %rdx, (%rax,%rcx,8)
movw -0x16(%rbp), %ax
addw $0x1, %ax
movw %ax, -0x16(%rbp)
jmp 0x415af1
movq -0x20(%rbp), %rcx
movq %rax, %rsi
movq -0x58(%rbp), %rax
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
cmpq %rax, %rcx
movq %rax, -0x118(%rbp)
je 0x415be6
movq -0x118(%rbp), %rdi
addq $-0x10, %rdi
movq %rdi, -0x120(%rbp)
callq 0x419130
movq -0x20(%rbp), %rcx
movq -0x120(%rbp), %rax
cmpq %rcx, %rax
movq %rax, -0x118(%rbp)
jne 0x415bb8
movq -0x38(%rbp), %rsi
movq -0x28(%rbp), %rdi
callq 0x4248b0
jmp 0x415f1f
movq -0x60(%rbp), %rcx
movq %rax, %rsi
movq -0x90(%rbp), %rax
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
cmpq %rax, %rcx
movq %rax, -0x128(%rbp)
je 0x415c47
movq -0x128(%rbp), %rdi
addq $-0x10, %rdi
movq %rdi, -0x130(%rbp)
callq 0x419df0
movq -0x60(%rbp), %rcx
movq -0x130(%rbp), %rax
cmpq %rcx, %rax
movq %rax, -0x128(%rbp)
jne 0x415c19
movq -0x78(%rbp), %rsi
movq -0x68(%rbp), %rdi
callq 0x4248b0
jmp 0x415f1f
movb $0x0, -0x17(%rbp)
movzbl -0x17(%rbp), %eax
movq $0x61c151, %rcx         # imm = 0x61C151
movzbl (%rcx), %ecx
cmpl %ecx, %eax
jge 0x415cf4
movq -0x40(%rbp), %rax
movq 0x50(%rax), %rdi
movzbl -0x17(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rdi
movq 0x58(%rax), %rsi
movzbl -0x17(%rbp), %ecx
movslq %ecx, %rcx
addq %rcx, %rsi
movq 0x60(%rax), %rdx
movzbl -0x17(%rbp), %ecx
movslq %ecx, %rcx
addq %rcx, %rdx
movq 0x68(%rax), %rcx
movzbl -0x17(%rbp), %r8d
movslq %r8d, %r8
shlq %r8
addq %r8, %rcx
movq 0x70(%rax), %r8
movzbl -0x17(%rbp), %r9d
movslq %r9d, %r9
addq %r9, %r8
movq 0x78(%rax), %r9
movzbl -0x17(%rbp), %r10d
movslq %r10d, %r10
addq %r10, %r9
movq 0x8(%rax), %rax
movq %rax, (%rsp)
movzbl -0x17(%rbp), %eax
movl %eax, 0x8(%rsp)
callq 0x419290
movb -0x17(%rbp), %al
addb $0x1, %al
movb %al, -0x17(%rbp)
jmp 0x415c5d
movb $0x0, -0x18(%rbp)
movzbl -0x18(%rbp), %eax
movq $0x61e5e4, %rcx         # imm = 0x61E5E4
movzbl (%rcx), %ecx
cmpl %ecx, %eax
jge 0x415d56
movq -0x40(%rbp), %rax
movq 0x88(%rax), %rdi
movzbl -0x18(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rdi
movq 0x98(%rax), %rcx
movzbl -0x18(%rbp), %edx
movq (%rcx,%rdx,8), %rsi
movq 0x90(%rax), %rcx
movzbl -0x18(%rbp), %edx
movq (%rcx,%rdx,8), %rdx
movq 0x8(%rax), %rcx
movzbl -0x18(%rbp), %r8d
callq 0x419f50
movb -0x18(%rbp), %al
addb $0x1, %al
movb %al, -0x18(%rbp)
jmp 0x415cf8
movq $0x61c151, %rax         # imm = 0x61C151
movzbl (%rax), %eax
movl %eax, %edi
movq %rdi, -0x190(%rbp)
callq 0x425dd0
movq -0x190(%rbp), %rdx
movq %rax, %rdi
movq %rdi, -0x188(%rbp)
xorl %esi, %esi
callq 0x401080
movq -0x188(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0xd8(%rax)
movq $0x61e5e4, %rax         # imm = 0x61E5E4
movzbl (%rax), %eax
movl %eax, %edi
movq %rdi, -0x180(%rbp)
callq 0x425dd0
movq -0x180(%rbp), %rdx
movq %rax, %rdi
movq %rdi, -0x178(%rbp)
xorl %esi, %esi
callq 0x401080
movq -0x178(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0xe0(%rax)
movq $0x61c151, %rax         # imm = 0x61C151
movzbl (%rax), %eax
movl $0x2, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
movq %rdi, -0x170(%rbp)
callq 0x425dd0
movq -0x170(%rbp), %rdx
movq %rax, %rdi
movq %rdi, -0x168(%rbp)
xorl %esi, %esi
callq 0x401080
movq -0x168(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0xe8(%rax)
movq $0x61e5e4, %rax         # imm = 0x61E5E4
movzbl (%rax), %eax
movl $0x2, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
movq %rdi, -0x160(%rbp)
callq 0x425dd0
movq -0x160(%rbp), %rdx
movq %rax, %rdi
movq %rdi, -0x158(%rbp)
xorl %esi, %esi
callq 0x401080
movq -0x158(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0xf0(%rax)
movq $0x61c151, %rax         # imm = 0x61C151
movzbl (%rax), %eax
movl %eax, %edi
movq %rdi, -0x150(%rbp)
callq 0x425dd0
movq -0x150(%rbp), %rdx
movq %rax, %rdi
movq %rdi, -0x148(%rbp)
xorl %esi, %esi
callq 0x401080
movq -0x148(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x100(%rax)
movq $0x61e5e4, %rax         # imm = 0x61E5E4
movzbl (%rax), %eax
movl %eax, %edi
movq %rdi, -0x140(%rbp)
callq 0x425dd0
movq -0x140(%rbp), %rdx
movq %rax, %rdi
movq %rdi, -0x138(%rbp)
xorl %esi, %esi
callq 0x401080
movq -0x138(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x108(%rax)
addq $0x1a0, %rsp            # imm = 0x1A0
popq %rbp
retq
movq -0x10(%rbp), %rdi
callq 0x4d0770
nopl (%rax,%rax)