// File: /workspace/github_c_makefile_star2_O3/LPD-EPFL[P]mctop/src/mctop_topology.c
// Function: mctop_mem_bandwidth_add
void 
mctop_mem_bandwidth_add(mctop_t* topo,
			double** mem_bw_table_r, double** mem_bw_table1_r,
			double** mem_bw_table_w, double** mem_bw_table1_w)
{
  topo->has_mem = BANDWIDTH;
  topo->mem_bandwidths_r = malloc_assert(topo->n_sockets * sizeof(double));
  topo->mem_bandwidths1_r = malloc_assert(topo->n_sockets * sizeof(double));
  topo->mem_bandwidths_w = malloc_assert(topo->n_sockets * sizeof(double));
  topo->mem_bandwidths1_w = malloc_assert(topo->n_sockets * sizeof(double));

  for (int s = 0; s < topo->n_sockets; s++)
    {
      socket_t* socket = topo->sockets + s;
      socket->mem_bandwidths_r = malloc_assert(socket->n_nodes * sizeof(double));
      socket->mem_bandwidths1_r = malloc_assert(socket->n_nodes * sizeof(double));
      socket->mem_bandwidths_w = malloc_assert(socket->n_nodes * sizeof(double));
      socket->mem_bandwidths1_w = malloc_assert(socket->n_nodes * sizeof(double));
      for (int n = 0; n < socket->n_nodes; n++)
	{
	  socket->mem_bandwidths_r[n] = mem_bw_table_r[s][n];
	  socket->mem_bandwidths1_r[n] = mem_bw_table1_r[s][n];
	  socket->mem_bandwidths_w[n] = mem_bw_table_w[s][n];
	  socket->mem_bandwidths1_w[n] = mem_bw_table1_w[s][n];
	}
      topo->mem_bandwidths_r[s] = socket->mem_bandwidths_r[socket->local_node];
      topo->mem_bandwidths1_r[s] = socket->mem_bandwidths1_r[socket->local_node];
      topo->mem_bandwidths_w[s] = socket->mem_bandwidths_w[socket->local_node];
      topo->mem_bandwidths1_w[s] = socket->mem_bandwidths1_w[socket->local_node];
    }

  mctop_fix_siblings_by_bandwidth(topo);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %r8, 0x38(%rsp)
movq %rcx, 0x30(%rsp)
movq %rdx, 0x28(%rsp)
movq %rsi, 0x20(%rsp)
movq %rdi, %r14
movl $0x2, 0x30(%rdi)
movl 0x18(%rdi), %eax
movq %rax, 0x10(%rsp)
leaq (,%rax,8), %rbx
movq %rbx, %rdi
callq 0x21d0
testq %rax, %rax
je 0x890d
movq %rax, %r15
movq %rax, 0x60(%r14)
movq %rbx, %rdi
callq 0x21d0
testq %rax, %rax
je 0x890d
movq %rax, %r13
movq %rax, 0x68(%r14)
movq %rbx, %rdi
callq 0x21d0
testq %rax, %rax
je 0x890d
movq %rax, %rbp
movq %rax, 0x70(%r14)
movq %rbx, %rdi
callq 0x21d0
testq %rax, %rax
je 0x890d
movq %rax, 0x78(%r14)
cmpq $0x0, 0x10(%rsp)
je 0x88fe
movq %r14, 0x18(%rsp)
movq 0x20(%r14), %rbx
xorl %r12d, %r12d
movq %r15, 0x60(%rsp)
movq %r13, 0x58(%rsp)
movq %rbp, 0x50(%rsp)
movq %rax, 0x48(%rsp)
movq %rbx, 0x40(%rsp)
imulq $0xa8, %r12, %r15
movl 0x70(%rbx,%r15), %r14d
leaq (,%r14,8), %rdi
movq %rdi, 0x8(%rsp)
callq 0x21d0
testq %rax, %rax
je 0x890d
movq %rax, %r13
addq %rbx, %r15
movq %rax, 0x80(%r15)
movq 0x8(%rsp), %rdi
callq 0x21d0
testq %rax, %rax
je 0x890d
movq %rax, %rbx
movq %rax, 0x88(%r15)
movq 0x8(%rsp), %rdi
callq 0x21d0
testq %rax, %rax
je 0x890d
movq %rax, %rbp
movq %rax, 0x90(%r15)
movq 0x8(%rsp), %rdi
callq 0x21d0
testq %rax, %rax
je 0x890d
movq %rax, 0x98(%r15)
testq %r14, %r14
je 0x8729
movq 0x20(%rsp), %rcx
movq (%rcx,%r12,8), %rcx
movq 0x28(%rsp), %rdx
movq (%rdx,%r12,8), %rdx
movq 0x30(%rsp), %rsi
movq (%rsi,%r12,8), %rsi
movq 0x38(%rsp), %rdi
movq (%rdi,%r12,8), %rdi
xorl %r8d, %r8d
movsd (%rcx,%r8,8), %xmm0
movsd %xmm0, (%r13,%r8,8)
movsd (%rdx,%r8,8), %xmm0
movsd %xmm0, (%rbx,%r8,8)
movsd (%rsi,%r8,8), %xmm0
movsd %xmm0, (%rbp,%r8,8)
movsd (%rdi,%r8,8), %xmm0
movsd %xmm0, (%rax,%r8,8)
incq %r8
cmpq %r8, %r14
jne 0x86ef
movl 0x6c(%r15), %ecx
movsd (%r13,%rcx,8), %xmm0
movq 0x60(%rsp), %r15
movsd %xmm0, (%r15,%r12,8)
movsd (%rbx,%rcx,8), %xmm0
movq 0x58(%rsp), %r13
movsd %xmm0, (%r13,%r12,8)
movsd (%rbp,%rcx,8), %xmm0
movq 0x50(%rsp), %rbp
movsd %xmm0, (%rbp,%r12,8)
movsd (%rax,%rcx,8), %xmm0
movq 0x48(%rsp), %rax
movsd %xmm0, (%rax,%r12,8)
incq %r12
cmpq 0x10(%rsp), %r12
movq 0x40(%rsp), %rbx
jne 0x863b
cmpl $0x0, 0x10(%rsp)
movq 0x18(%rsp), %rcx
je 0x88fe
xorl %r12d, %r12d
movq 0x20(%rcx), %r14
imulq $0xa8, %r12, %r15
movl 0x50(%r14,%r15), %ebx
leaq (,%rbx,8), %rdi
callq 0x21d0
testq %rax, %rax
je 0x890d
addq %r15, %r14
movq %rax, 0x60(%r14)
testl %ebx, %ebx
movq %r12, 0x10(%rsp)
je 0x87e8
xorl %eax, %eax
movq 0x58(%r14), %rcx
movq 0x60(%r14), %rdx
movq (%rcx,%rax,8), %rcx
movq %rcx, (%rdx,%rax,8)
incq %rax
cmpq %rax, %rbx
jne 0x87d0
cmpl $0x2, %ebx
jb 0x88e5
xorl %ebp, %ebp
movl $0x1, %r13d
movq 0x58(%r14), %rax
movq -0x8(%rax,%r13,8), %rbx
movq (%rax,%r13,8), %r15
movl 0x8(%rbx), %eax
cmpl 0x8(%r15), %eax
jne 0x8863
movq %rbx, %rdi
movq %r14, %rsi
callq 0x8d50
movq %rax, %r12
movq %r15, %rdi
movq %r14, %rsi
callq 0x8d50
movq %r14, %rdi
movq %rax, %rsi
callq 0x8d40
movsd %xmm0, 0x8(%rsp)
movq %r14, %rdi
movq %r12, %rsi
callq 0x8d40
movsd 0x8(%rsp), %xmm1
ucomisd %xmm0, %xmm1
jbe 0x8863
movq 0x58(%r14), %rax
movq %r15, -0x8(%rax,%r13,8)
movq 0x58(%r14), %rax
movq %rbx, (%rax,%r13,8)
incl %ebp
movq 0x60(%r14), %rax
movq -0x8(%rax,%r13,8), %rbx
movq (%rax,%r13,8), %r15
movl 0x8(%rbx), %eax
cmpl 0x8(%r15), %eax
jne 0x88cd
movq %rbx, %rdi
movq %r14, %rsi
callq 0x8d50
movq %rax, %r12
movq %r15, %rdi
movq %r14, %rsi
callq 0x8d50
movq %rax, %rdi
movq %r14, %rsi
callq 0x8d40
movsd %xmm0, 0x8(%rsp)
movq %r12, %rdi
movq %r14, %rsi
callq 0x8d40
movsd 0x8(%rsp), %xmm1
ucomisd %xmm0, %xmm1
jbe 0x88cd
movq 0x60(%r14), %rax
movq %r15, -0x8(%rax,%r13,8)
movq 0x60(%r14), %rax
movq %rbx, (%rax,%r13,8)
incl %ebp
incq %r13
movl 0x50(%r14), %ebx
cmpl %r13d, %ebx
ja 0x87f9
testl %ebp, %ebp
jne 0x87e8
movq 0x10(%rsp), %r12
incq %r12
movq 0x18(%rsp), %rcx
movl 0x18(%rcx), %eax
cmpq %rax, %r12
jb 0x8798
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3a34(%rip), %rdi      # 0xc348
leaq 0x21e4(%rip), %rsi      # 0xaaff
leaq 0x21f6(%rip), %rcx      # 0xab18
movl $0x59, %edx
callq 0x2110