// File: /workspace/github_c_makefile_star2_O2/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 $0x28, %rsp
movq %r8, %r14
movq %rcx, %r15
movq %rdx, %r12
movq %rsi, %r13
movq %rdi, %rbp
movl $0x2, 0x30(%rdi)
movl 0x18(%rdi), %edi
shlq $0x3, %rdi
callq 0x6856
movq %rax, 0x60(%rbp)
movl 0x18(%rbp), %edi
shlq $0x3, %rdi
callq 0x6856
movq %rax, 0x68(%rbp)
movl 0x18(%rbp), %edi
shlq $0x3, %rdi
callq 0x6856
movq %rax, 0x70(%rbp)
movl 0x18(%rbp), %edi
shlq $0x3, %rdi
callq 0x6856
movq %rax, 0x78(%rbp)
xorl %ebx, %ebx
movq %rbp, 0x20(%rsp)
movl 0x18(%rbp), %eax
cmpq %rax, %rbx
jae 0x7b3e
movq 0x20(%rbp), %rax
movq %rax, 0x8(%rsp)
imulq $0xa8, %rbx, %rcx
movq %rcx, 0x10(%rsp)
leaq (%rax,%rcx), %rbp
movl 0x70(%rax,%rcx), %edi
shlq $0x3, %rdi
callq 0x6856
movq 0x8(%rsp), %rcx
movq 0x10(%rsp), %rdx
movq %rax, 0x80(%rcx,%rdx)
movl 0x70(%rcx,%rdx), %edi
shlq $0x3, %rdi
callq 0x6856
movq 0x8(%rsp), %rcx
movq 0x10(%rsp), %rdx
movq %rax, 0x88(%rcx,%rdx)
movl 0x70(%rcx,%rdx), %edi
shlq $0x3, %rdi
callq 0x6856
movq 0x8(%rsp), %rcx
movq 0x10(%rsp), %rdx
movq %rax, 0x90(%rcx,%rdx)
movl 0x70(%rcx,%rdx), %edi
shlq $0x3, %rdi
callq 0x6856
movq 0x10(%rsp), %rcx
movq 0x8(%rsp), %rdx
movq %rax, 0x98(%rdx,%rcx)
movl 0x70(%rdx,%rcx), %ecx
xorl %edx, %edx
cmpq %rdx, %rcx
je 0x7ade
movq (%r13,%rbx,8), %rsi
movsd (%rsi,%rdx,8), %xmm0
movq 0x80(%rbp), %rsi
movsd %xmm0, (%rsi,%rdx,8)
movq (%r12,%rbx,8), %rsi
movsd (%rsi,%rdx,8), %xmm0
movq 0x88(%rbp), %rsi
movsd %xmm0, (%rsi,%rdx,8)
movq (%r15,%rbx,8), %rsi
movsd (%rsi,%rdx,8), %xmm0
movq 0x90(%rbp), %rsi
movsd %xmm0, (%rsi,%rdx,8)
movq (%r14,%rbx,8), %rsi
movsd (%rsi,%rdx,8), %xmm0
movsd %xmm0, (%rax,%rdx,8)
incq %rdx
jmp 0x7a86
movq 0x80(%rbp), %rcx
movl 0x6c(%rbp), %edx
movsd (%rcx,%rdx,8), %xmm0
movq 0x20(%rsp), %rsi
movq 0x60(%rsi), %rcx
movsd %xmm0, (%rcx,%rbx,8)
movq 0x88(%rbp), %rcx
movsd (%rcx,%rdx,8), %xmm0
movq 0x68(%rsi), %rcx
movsd %xmm0, (%rcx,%rbx,8)
movq 0x90(%rbp), %rcx
movq %rsi, %rbp
movsd (%rcx,%rdx,8), %xmm0
movq 0x70(%rsi), %rcx
movsd %xmm0, (%rcx,%rbx,8)
movsd (%rax,%rdx,8), %xmm0
movq 0x78(%rsi), %rax
movsd %xmm0, (%rax,%rbx,8)
incq %rbx
jmp 0x79df
xorl %ecx, %ecx
pushq $0x1
popq %r13
movl %eax, %eax
cmpq %rax, %rcx
jae 0x7cb5
movq 0x20(%rbp), %rbx
movq %rcx, 0x10(%rsp)
imulq $0xa8, %rcx, %r15
leaq (%rbx,%r15), %r14
movl 0x50(%rbx,%r15), %edi
shlq $0x3, %rdi
callq 0x6856
movq %rax, 0x60(%rbx,%r15)
movl 0x50(%rbx,%r15), %eax
xorl %ecx, %ecx
cmpq %rcx, %rax
je 0x7b97
movq 0x58(%r14), %rdx
movq 0x60(%r14), %rsi
movq (%rdx,%rcx,8), %rdx
movq %rdx, (%rsi,%rcx,8)
incq %rcx
jmp 0x7b7d
xorl %ebx, %ebx
movq %r13, %rbp
movl %eax, %eax
cmpq %rax, %rbp
jb 0x7bb4
movq %r13, %rbp
testl %ebx, %ebx
movl $0x0, %ebx
jne 0x7b9e
jmp 0x7ca0
movq 0x58(%r14), %rax
movq -0x8(%rax,%rbp,8), %r15
movq (%rax,%rbp,8), %r12
movl 0x8(%r15), %eax
cmpl 0x8(%r12), %eax
jne 0x7c24
movq %r15, %rdi
movq %r14, %rsi
callq 0x80d8
movq %rax, 0x8(%rsp)
movq %r12, %rdi
movq %r14, %rsi
callq 0x80d8
movq %r14, %rdi
movq %rax, %rsi
callq 0x80a5
movsd %xmm0, 0x18(%rsp)
movq %r14, %rdi
movq 0x8(%rsp), %rsi
callq 0x80a5
movsd 0x18(%rsp), %xmm1
ucomisd %xmm0, %xmm1
jbe 0x7c24
movq 0x58(%r14), %rax
movq %r12, -0x8(%rax,%rbp,8)
movq 0x58(%r14), %rax
movq %r15, (%rax,%rbp,8)
incl %ebx
movq 0x60(%r14), %rax
movq -0x8(%rax,%rbp,8), %r15
movq (%rax,%rbp,8), %r12
movl 0x8(%r15), %eax
cmpl 0x8(%r12), %eax
jne 0x7c94
movq %r15, %rdi
movq %r14, %rsi
callq 0x80d8
movq %rax, 0x8(%rsp)
movq %r12, %rdi
movq %r14, %rsi
callq 0x80d8
movq %rax, %rdi
movq %r14, %rsi
callq 0x80a5
movsd %xmm0, 0x18(%rsp)
movq 0x8(%rsp), %rdi
movq %r14, %rsi
callq 0x80a5
movsd 0x18(%rsp), %xmm1
ucomisd %xmm0, %xmm1
jbe 0x7c94
movq 0x60(%r14), %rax
movq %r12, -0x8(%rax,%rbp,8)
movq 0x60(%r14), %rax
movq %r15, (%rax,%rbp,8)
incl %ebx
incq %rbp
movl 0x50(%r14), %eax
jmp 0x7b9c
movq 0x10(%rsp), %rcx
incq %rcx
movq 0x20(%rsp), %rbp
movl 0x18(%rbp), %eax
jmp 0x7b44
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq