// File: /workspace/github_cpp_makefile_star2_O1/MPSLab-ASU[P]DiRAC/./src/network.cc
// Function: MultiCastNetwork_Input::setupNetwork(bool*, bool*, unsigned short*, unsigned char*, unsigned char*, PE**, unsigned char)
void MultiCastNetwork_Input::setupNetwork(bool *inConfig, bool *inForward,
  data_type *inData, uint8_t *inRowTag, uint8_t *inColTag,
  PE** PEArray, uint8_t networkId)
{
  // setup row-wise multicast controllers
  // connect them to the accelerator controller
  for(uint16_t i=0; i < nRows_PE_Array; i++) {

    rowWiseMC[i].setupController(1, i, 0);
    rowWiseMC[i].setConfig(inConfig);
    rowWiseMC[i].setForward(inForward);
    rowWiseMC[i].setInData(inData);
    rowWiseMC[i].setInTags(inColTag, inRowTag);
  }

  // set up column-wise multicast controllers
  for(uint16_t i=0; i < nRows_PE_Array; i++) {
    for(uint16_t j=0; j < nCols_PE_Array; j++) {
      // connect each column-wise multicast controller to its
      // corresponding row-wise multicast controller
      colWiseMC[i][j].setupController(0, i, j);
      colWiseMC[i][j].setConfig(rowWiseMC[i].getPtrConfigBus());
      colWiseMC[i][j].setForward(rowWiseMC[i].getPtrForwardBus());
      colWiseMC[i][j].setInData(rowWiseMC[i].getPtrOutData());
      colWiseMC[i][j].setInTags(rowWiseMC[i].getPtrColTagOut());

      // connect each column-wise multicast controller to a PE
      PEArray[i][j].setConfig(colWiseMC[i][j].getPtrConfigBus(), networkId);
      PEArray[i][j].setForward(colWiseMC[i][j].getPtrForwardBus(), networkId);
      PEArray[i][j].setInData(colWiseMC[i][j].getPtrOutData(), networkId);
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq $0x60b5ac, %rbx         # imm = 0x60B5AC
cmpw $0x0, (%rbx)
je 0x411365
movq (%rdi), %rax
addq $0x38, %rax
xorl %r11d, %r11d
movb $0x1, -0x3(%rax)
movw %r11w, -0x2(%rax)
movw $0x0, (%rax)
movq %rsi, -0x38(%rax)
movq %rdx, -0x30(%rax)
movq %rcx, -0x28(%rax)
movq %r9, -0x10(%rax)
movq %r8, -0x18(%rax)
incq %r11
movzwl (%rbx), %r10d
addq $0x40, %rax
cmpq %r10, %r11
jb 0x411333
cmpw $0x0, (%rbx)
je 0x4114b6
xorl %r12d, %r12d
movzbl 0x58(%rsp), %eax
movl %eax, 0x4(%rsp)
movq %rdi, 0x8(%rsp)
movl 0x4(%rsp), %r14d
movq $0x60b5ae, %rax         # imm = 0x60B5AE
cmpw $0x0, (%rax)
je 0x4114a0
movq %r12, %rax
shlq $0x6, %rax
movq %rax, 0x10(%rsp)
xorl %r13d, %r13d
xorl %r15d, %r15d
xorl %ebx, %ebx
movq 0x8(%rdi), %rax
movq (%rax,%r12,8), %rcx
movb $0x0, 0x35(%rcx,%r15)
movw %r12w, 0x36(%rcx,%r15)
movw %bx, 0x38(%rcx,%r15)
movq (%rdi), %rdx
movq 0x10(%rsp), %rdi
leaq 0x1a(%rdx,%rdi), %rsi
movq %rsi, (%rcx,%r15)
movq (%rax,%r12,8), %rcx
leaq 0x1b(%rdx,%rdi), %rsi
movq %rsi, 0x8(%rcx,%r15)
movq (%rax,%r12,8), %rcx
leaq 0x18(%rdx,%rdi), %rsi
movq %rsi, 0x10(%rcx,%r15)
movq (%rax,%r12,8), %rcx
addq %rdi, %rdx
addq $0x30, %rdx
movq %rdx, 0x28(%rcx,%r15)
cmpb $0x1, 0x35(%rcx,%r15)
jne 0x411412
movq $0x0, 0x20(%rcx,%r15)
movq 0x50(%rsp), %rbp
movq (%rbp,%r12,8), %rdi
addq %r13, %rdi
movq (%rax,%r12,8), %rax
leaq (%rax,%r15), %rsi
addq $0x1a, %rsi
movl %r14d, %edx
callq 0x4165a0
movq (%rbp,%r12,8), %rdi
addq %r13, %rdi
movq 0x8(%rsp), %rbp
movq 0x8(%rbp), %rax
movq (%rax,%r12,8), %rax
leaq (%rax,%r15), %rsi
addq $0x1b, %rsi
movl %r14d, %edx
callq 0x4165ac
movq 0x50(%rsp), %rax
movq (%rax,%r12,8), %rdi
addq %r13, %rdi
movq 0x8(%rbp), %rax
movq (%rax,%r12,8), %rax
leaq (%rax,%r15), %rsi
addq $0x18, %rsi
movl %r14d, %edx
callq 0x4165b8
movq %rbp, %rdi
incq %rbx
movq $0x60b5ae, %rax         # imm = 0x60B5AE
movzwl (%rax), %eax
addq $0x40, %r15
addq $0x148, %r13            # imm = 0x148
cmpq %rax, %rbx
jb 0x4113aa
incq %r12
movq $0x60b5ac, %rax         # imm = 0x60B5AC
movzwl (%rax), %eax
cmpq %rax, %r12
jb 0x411385
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop