// File: /workspace/github_c_makefile_star2_O2/PoulinV[P]AxiCLASS/build/../source/transfer.c
// Function: transfer_perturbation_copy_sources_and_nl_corrections
int transfer_perturbation_copy_sources_and_nl_corrections(
                                                          struct perturbations * ppt,
                                                          struct fourier * pfo,
                                                          struct transfer * ptr,
                                                          double *** sources
                                                          ) {
  int index_md;
  int index_ic;
  int index_tp;
  int index_k;
  int index_tau;

  for (index_md = 0; index_md < ptr->md_size; index_md++) {

    class_alloc(sources[index_md],
                ppt->ic_size[index_md]*ppt->tp_size[index_md]*sizeof(double*),
                ptr->error_message);

    for (index_ic = 0; index_ic < ppt->ic_size[index_md]; index_ic++) {

      for (index_tp = 0; index_tp < ppt->tp_size[index_md]; index_tp++) {

        if ((pfo->method != nl_none) && (_scalars_) &&
            (((ppt->has_source_delta_m == _TRUE_) && (index_tp == ppt->index_tp_delta_m)) ||
             ((ppt->has_source_delta_cb == _TRUE_) && (index_tp == ppt->index_tp_delta_cb)) ||
             ((ppt->has_source_theta_m == _TRUE_) && (index_tp == ppt->index_tp_theta_m)) ||
             ((ppt->has_source_theta_cb == _TRUE_) && (index_tp == ppt->index_tp_theta_cb)) ||
             ((ppt->has_source_phi == _TRUE_) && (index_tp == ppt->index_tp_phi)) ||
             ((ppt->has_source_phi_prime == _TRUE_) && (index_tp == ppt->index_tp_phi_prime)) ||
             ((ppt->has_source_phi_plus_psi == _TRUE_) && (index_tp == ppt->index_tp_phi_plus_psi)) ||
             ((ppt->has_source_psi == _TRUE_) && (index_tp == ppt->index_tp_psi)))) {

          class_alloc(sources[index_md][index_ic * ppt->tp_size[index_md] + index_tp],
                      ppt->k_size[index_md]*ppt->tau_size*sizeof(double),
                      ptr->error_message);

          for (index_tau=0; index_tau<ppt->tau_size; index_tau++) {
            for (index_k=0; index_k<ppt->k_size[index_md]; index_k++) {
              if (((ppt->has_source_delta_cb == _TRUE_) && (index_tp == ppt->index_tp_delta_cb)) ||
                  ((ppt->has_source_theta_cb == _TRUE_) && (index_tp == ppt->index_tp_theta_cb))){
                sources[index_md]
                  [index_ic * ppt->tp_size[index_md] + index_tp]
                  [index_tau * ppt->k_size[index_md] + index_k] =
                  ppt->sources[index_md]
                  [index_ic * ppt->tp_size[index_md] + index_tp]
                  [index_tau * ppt->k_size[index_md] + index_k]
                  * pfo->nl_corr_density[pfo->index_pk_cb][index_tau * ppt->k_size[index_md] + index_k];
              }
              else{
                sources[index_md]
                  [index_ic * ppt->tp_size[index_md] + index_tp]
                  [index_tau * ppt->k_size[index_md] + index_k] =
                  ppt->sources[index_md]
                  [index_ic * ppt->tp_size[index_md] + index_tp]
                  [index_tau * ppt->k_size[index_md] + index_k]
                  * pfo->nl_corr_density[pfo->index_pk_m][index_tau * ppt->k_size[index_md] + index_k];
              }
            }
          }
        }
        else {
          sources[index_md][index_ic * ppt->tp_size[index_md] + index_tp] =
            ppt->sources[index_md][index_ic * ppt->tp_size[index_md] + index_tp];
        }
      }
    }
  }

  return _SUCCESS_;

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x838, %rsp            # imm = 0x838
movq %rsi, %r13
movq %rdi, %r15
movq %rdx, 0x10(%rsp)
movl 0x8a4(%rdx), %edx
leaq 0x54(%rsi), %r14
leaq 0x58(%rsi), %rbp
xorl %eax, %eax
testl %edx, %edx
cmovlel %eax, %edx
movq %rdx, %rax
xorl %ebx, %ebx
movq %rcx, 0x18(%rsp)
movq %rdx, 0x28(%rsp)
cmpq %rax, %rbx
je 0xa03f9
movq 0x870(%r15), %rax
movq 0x998(%r15), %rdx
movslq (%rax,%rbx,4), %rax
movslq (%rdx,%rbx,4), %rdi
imulq %rax, %rdi
shlq $0x3, %rdi
callq 0x8490
movq 0x18(%rsp), %rcx
movq %rax, (%rcx,%rbx,8)
testq %rax, %rax
je 0xa03fd
xorl %edx, %edx
movq 0x870(%r15), %rax
cmpl (%rax,%rbx,4), %edx
jge 0xa037f
movl %edx, 0x8(%rsp)
xorl %r12d, %r12d
movq 0x998(%r15), %rax
movl (%rax,%rbx,4), %edx
cmpl %edx, %r12d
jge 0xa0374
cmpl $0x0, (%r13)
je 0xa034a
cmpw $0x1, 0xe(%r15)
jne 0xa034a
movl 0x848(%r15), %eax
cmpq %rax, %rbx
jne 0xa034a
cmpw $0x1, 0x87c(%r15)
jne 0xa01a0
cmpl 0x8d8(%r15), %r12d
je 0xa0238
cmpw $0x1, 0x87e(%r15)
jne 0xa01b8
cmpl 0x8dc(%r15), %r12d
je 0xa0238
cmpw $0x1, 0x898(%r15)
jne 0xa01cc
cmpl 0x934(%r15), %r12d
je 0xa0238
cmpw $0x1, 0x89a(%r15)
jne 0xa01e0
cmpl 0x938(%r15), %r12d
je 0xa0238
cmpw $0x1, 0x8b4(%r15)
jne 0xa01f4
cmpl 0x970(%r15), %r12d
je 0xa0238
cmpw $0x1, 0x8b6(%r15)
jne 0xa0208
cmpl 0x974(%r15), %r12d
je 0xa0238
cmpw $0x1, 0x8b8(%r15)
jne 0xa021c
cmpl 0x978(%r15), %r12d
je 0xa0238
cmpw $0x1, 0x8ba(%r15)
jne 0xa034a
cmpl 0x97c(%r15), %r12d
jne 0xa034a
movq 0x9c8(%r15), %rax
movslq (%rax,%rbx,4), %rdi
movslq 0x9f8(%r15), %rcx
movq %rcx, 0x20(%rsp)
imulq %rcx, %rdi
shlq $0x3, %rdi
movl %edx, 0xc(%rsp)
callq 0x8490
movq 0x18(%rsp), %rcx
movq (%rcx,%rbx,8), %rsi
movl 0x8(%rsp), %edi
movl 0xc(%rsp), %edx
imull %edi, %edx
addl %r12d, %edx
movslq %edx, %rdx
movq %rax, (%rsi,%rdx,8)
movq (%rcx,%rbx,8), %rdx
movq 0x998(%r15), %rax
movl (%rax,%rbx,4), %eax
imull %edi, %eax
addl %r12d, %eax
cltq
movq (%rdx,%rax,8), %r11
testq %r11, %r11
je 0xa038c
xorl %edx, %edx
movq 0x20(%rsp), %rdi
testl %edi, %edi
movl $0x0, %esi
cmovgl %edi, %esi
cmpl %esi, %edx
je 0xa036c
movq 0x9c8(%r15), %rdi
movl (%rdi,%rbx,4), %r8d
testl %r8d, %r8d
movl $0x0, %edi
cmovgl %r8d, %edi
imull %edx, %r8d
movslq %r8d, %r8
subq $0x1, %rdi
jb 0xa0343
cmpw $0x1, 0x87e(%r15)
jne 0xa02f5
movq %rbp, %r9
cmpl 0x8dc(%r15), %r12d
je 0xa030f
cmpw $0x1, 0x89a(%r15)
jne 0xa030c
movq %rbp, %r9
cmpl 0x938(%r15), %r12d
je 0xa030f
movq %r14, %r9
movq 0xa38(%r15), %r10
movq (%r10,%rbx,8), %r10
movq (%r10,%rax,8), %r10
movsd (%r10,%r8,8), %xmm0
movq 0x150(%r13), %r10
movslq (%r9), %r9
movq (%r10,%r9,8), %r9
mulsd (%r9,%r8,8), %xmm0
movsd %xmm0, (%r11,%r8,8)
incq %r8
jmp 0xa02d8
incl %edx
jmp 0xa02b2
movq 0xa38(%r15), %rax
movq (%rax,%rbx,8), %rax
imull 0x8(%rsp), %edx
addl %r12d, %edx
movslq %edx, %rsi
movq (%rax,%rsi,8), %rax
movq (%rcx,%rbx,8), %rdx
movq %rax, (%rdx,%rsi,8)
incl %r12d
jmp 0xa014e
movl 0x8(%rsp), %edx
incl %edx
jmp 0xa0137
incq %rbx
movq 0x28(%rsp), %rax
jmp 0xa00f7
movq 0x9c8(%r15), %rax
movl (%rax,%rbx,4), %ecx
imull 0x20(%rsp), %ecx
shll $0x3, %ecx
leaq 0x44c5f(%rip), %rsi     # 0xe5004
leaq 0x756ca(%rip), %rdx     # 0x115a76
leaq 0x30(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x2e014
movq 0x10(%rsp), %rdi
addq $0x96a, %rdi            # imm = 0x96A
leaq 0x44c66(%rip), %rsi     # 0xe5034
leaq 0x7566b(%rip), %rdx     # 0x115a40
movl $0x2b0, %ecx            # imm = 0x2B0
movq %r14, %r8
xorl %eax, %eax
callq 0x2e014
pushq $0x1
popq %rax
addq $0x838, %rsp            # imm = 0x838
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %eax, %eax
jmp 0xa03e7
movq 0x870(%r15), %rax
movq 0x998(%r15), %rdx
movl (%rax,%rbx,4), %ecx
imull (%rdx,%rbx,4), %ecx
shll $0x3, %ecx
leaq 0x44be8(%rip), %rsi     # 0xe5004
leaq 0x6afcc(%rip), %rdx     # 0x10b3ef
leaq 0x30(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x2e014
movq 0x10(%rsp), %rdi
addq $0x96a, %rdi            # imm = 0x96A
leaq 0x44bef(%rip), %rsi     # 0xe5034
leaq 0x755f4(%rip), %rdx     # 0x115a40
movl $0x29e, %ecx            # imm = 0x29E
jmp 0xa03da