// File: /workspace/github_cpp_makefile_star2_O3/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, %r14         # imm = 0x60B5AC
cmpw $0x0, (%r14)
je 0x41156c
movb 0x58(%rsp), %bl
movq %rdi, 0x8(%rsp)
movq (%rdi), %r10
addq $0x38, %r10
xorl %r11d, %r11d
movb $0x1, -0x3(%r10)
movw %r11w, -0x2(%r10)
movw $0x0, (%r10)
movq %rsi, -0x38(%r10)
movq %rdx, -0x30(%r10)
movq %rcx, -0x28(%r10)
movq %r9, -0x10(%r10)
movq %r8, -0x18(%r10)
incq %r11
movzwl (%r14), %eax
addq $0x40, %r10
cmpq %rax, %r11
jb 0x4113e1
testw %ax, %ax
movq 0x8(%rsp), %rbp
je 0x41156c
movq $0x60b5ae, %rcx         # imm = 0x60B5AE
movzwl (%rcx), %ecx
xorl %r13d, %r13d
movzbl %bl, %edx
movl %edx, 0x4(%rsp)
movl 0x4(%rsp), %r14d
testw %cx, %cx
je 0x41155b
movq %r13, %rax
shlq $0x6, %rax
movq %rax, 0x10(%rsp)
xorl %r12d, %r12d
xorl %r15d, %r15d
xorl %ebx, %ebx
movq 0x8(%rbp), %rax
movq (%rax,%r13,8), %rcx
movb $0x0, 0x35(%rcx,%r15)
movw %r13w, 0x36(%rcx,%r15)
movw %bx, 0x38(%rcx,%r15)
movq (%rbp), %rdx
movq 0x10(%rsp), %rdi
leaq 0x1a(%rdx,%rdi), %rsi
movq %rsi, (%rcx,%r15)
movq (%rax,%r13,8), %rcx
leaq 0x1b(%rdx,%rdi), %rsi
movq %rsi, 0x8(%rcx,%r15)
movq (%rax,%r13,8), %rcx
leaq 0x18(%rdx,%rdi), %rsi
movq %rsi, 0x10(%rcx,%r15)
movq (%rax,%r13,8), %rcx
addq %rdi, %rdx
addq $0x30, %rdx
movq %rdx, 0x28(%rcx,%r15)
cmpb $0x1, 0x35(%rcx,%r15)
jne 0x4114c2
movq $0x0, 0x20(%rcx,%r15)
movq 0x50(%rsp), %rcx
movq (%rcx,%r13,8), %rdi
movq %rcx, %rbp
addq %r12, %rdi
movq (%rax,%r13,8), %rax
leaq (%rax,%r15), %rsi
addq $0x1a, %rsi
movl %r14d, %edx
callq 0x4170fa
movq (%rbp,%r13,8), %rdi
addq %r12, %rdi
movq 0x8(%rsp), %rbp
movq 0x8(%rbp), %rax
movq (%rax,%r13,8), %rax
leaq (%rax,%r15), %rsi
addq $0x1b, %rsi
movl %r14d, %edx
callq 0x417106
movq 0x50(%rsp), %rax
movq (%rax,%r13,8), %rdi
addq %r12, %rdi
movq 0x8(%rbp), %rax
movq (%rax,%r13,8), %rax
leaq (%rax,%r15), %rsi
addq $0x18, %rsi
movl %r14d, %edx
callq 0x417112
incq %rbx
movq $0x60b5ae, %rax         # imm = 0x60B5AE
movzwl (%rax), %ecx
addq $0x40, %r15
addq $0x148, %r12            # imm = 0x148
cmpq %rcx, %rbx
jb 0x411459
movq $0x60b5ac, %rax         # imm = 0x60B5AC
movzwl (%rax), %eax
jmp 0x41155d
xorl %ecx, %ecx
incq %r13
movzwl %ax, %edx
cmpq %rdx, %r13
jb 0x41143c
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop