// File: /workspace/github_c_makefile_star2_O3/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 $0x868, %rsp            # imm = 0x868
movslq 0x8a4(%rdx), %rax
movq %rax, 0x40(%rsp)
testq %rax, %rax
jle 0xa5358
movq %rcx, %r9
movq %rsi, %r12
movq %rdi, %r14
movq %rdx, 0x18(%rsp)
leaq 0x54(%rsi), %rbx
leaq 0x58(%rsi), %rbp
movq 0x870(%rdi), %rdx
xorl %r13d, %r13d
movq %rcx, 0x20(%rsp)
movq %rsi, 0x30(%rsp)
movslq (%rdx,%r13,4), %rax
movq 0x998(%r14), %rcx
movslq (%rcx,%r13,4), %rdi
imulq %rax, %rdi
shlq $0x3, %rdi
movq %r9, %r15
callq 0x8460
movq %rax, (%r15,%r13,8)
movq 0x870(%r14), %rdx
movl (%rdx,%r13,4), %ecx
testq %rax, %rax
je 0xa53cd
movq %r15, %r9
testl %ecx, %ecx
jle 0xa534a
movq 0x998(%r14), %r10
xorl %esi, %esi
movq %r13, 0x38(%rsp)
movl (%r10,%r13,4), %r15d
testl %r15d, %r15d
jle 0xa533e
movl (%r12), %edi
xorl %r12d, %r12d
movl %esi, 0x10(%rsp)
movl %edi, 0xc(%rsp)
testl %edi, %edi
je 0xa52f2
cmpw $0x1, 0xe(%r14)
jne 0xa52f2
movl 0x848(%r14), %eax
cmpq %rax, %r13
jne 0xa52f2
cmpw $0x1, 0x87c(%r14)
jne 0xa5100
cmpl 0x8d8(%r14), %r12d
je 0xa5198
cmpw $0x1, 0x87e(%r14)
jne 0xa5118
cmpl 0x8dc(%r14), %r12d
je 0xa5198
cmpw $0x1, 0x898(%r14)
jne 0xa512c
cmpl 0x934(%r14), %r12d
je 0xa5198
cmpw $0x1, 0x89a(%r14)
jne 0xa5140
cmpl 0x938(%r14), %r12d
je 0xa5198
cmpw $0x1, 0x8b4(%r14)
jne 0xa5154
cmpl 0x970(%r14), %r12d
je 0xa5198
cmpw $0x1, 0x8b6(%r14)
jne 0xa5168
cmpl 0x974(%r14), %r12d
je 0xa5198
cmpw $0x1, 0x8b8(%r14)
jne 0xa517c
cmpl 0x978(%r14), %r12d
je 0xa5198
cmpw $0x1, 0x8ba(%r14)
jne 0xa52f2
cmpl 0x97c(%r14), %r12d
jne 0xa52f2
movq 0x9c8(%r14), %rax
movslq (%rax,%r13,4), %rdi
movslq 0x9f8(%r14), %rax
movq %rax, 0x28(%rsp)
imulq %rax, %rdi
shlq $0x3, %rdi
callq 0x8460
movq 0x20(%rsp), %r9
movl 0x10(%rsp), %esi
movq (%r9,%r13,8), %rcx
imull %esi, %r15d
addl %r12d, %r15d
movslq %r15d, %rdx
movq %rax, (%rcx,%rdx,8)
movq (%r9,%r13,8), %rax
movq 0x998(%r14), %r10
movl (%r10,%r13,4), %r15d
movl %r15d, %ecx
imull %esi, %ecx
addl %r12d, %ecx
movslq %ecx, %rcx
movq %rcx, 0x50(%rsp)
movq (%rax,%rcx,8), %rdx
testq %rdx, %rdx
je 0xa535c
movq 0x28(%rsp), %rdi
testl %edi, %edi
jle 0xa532c
movq %r10, 0x48(%rsp)
movl %r15d, 0x14(%rsp)
movq 0x9c8(%r14), %rax
movl (%rax,%r13,4), %ecx
leaq (,%rcx,8), %rax
movq %rax, 0x58(%rsp)
xorl %r13d, %r13d
xorl %r9d, %r9d
testl %ecx, %ecx
jle 0xa52c3
movzwl 0x87e(%r14), %r10d
movq 0xa38(%r14), %rax
movq 0x38(%rsp), %rsi
movq (%rax,%rsi,8), %rax
movq 0x50(%rsp), %rsi
movq (%rax,%rsi,8), %r11
movq 0x30(%rsp), %rax
movq 0x150(%rax), %rax
movq %rcx, %rsi
movq %r13, %r8
cmpw $0x1, %r10w
jne 0xa5287
movq %rbp, %r15
cmpl 0x8dc(%r14), %r12d
je 0xa52a1
cmpw $0x1, 0x89a(%r14)
jne 0xa529e
movq %rbp, %r15
cmpl 0x938(%r14), %r12d
je 0xa52a1
movq %rbx, %r15
movsd (%r11,%r8), %xmm0
movslq (%r15), %r15
movq (%rax,%r15,8), %r15
mulsd (%r15,%r8), %xmm0
movsd %xmm0, (%rdx,%r8)
addq $0x8, %r8
decq %rsi
jne 0xa5274
incq %r9
addq 0x58(%rsp), %r13
cmpq %rdi, %r9
jne 0xa5239
movq 0x20(%rsp), %r9
movq 0x38(%rsp), %r13
movl 0x10(%rsp), %esi
movl 0xc(%rsp), %edi
movl 0x14(%rsp), %r15d
movq 0x48(%rsp), %r10
jmp 0xa531e
movq 0xa38(%r14), %rax
movq (%rax,%r13,8), %rax
imull %esi, %r15d
addl %r12d, %r15d
movslq %r15d, %rcx
movq (%rax,%rcx,8), %rax
movq (%r9,%r13,8), %rdx
movq %rax, (%rdx,%rcx,8)
movq 0x998(%r14), %r10
movl (%r10,%r13,4), %r15d
incl %r12d
cmpl %r15d, %r12d
jl 0xa50c4
jmp 0xa5332
movl 0xc(%rsp), %edi
jmp 0xa531e
movq 0x870(%r14), %rdx
movq 0x30(%rsp), %r12
incl %esi
cmpl (%rdx,%r13,4), %esi
jl 0xa50a8
incq %r13
cmpq 0x40(%rsp), %r13
jne 0xa5058
xorl %eax, %eax
jmp 0xa53bb
movq 0x9c8(%r14), %rax
movq 0x28(%rsp), %rcx
imull (%rax,%r13,4), %ecx
shll $0x3, %ecx
leaq 0x48c8d(%rip), %rsi     # 0xee004
leaq 0x79868(%rip), %rdx     # 0x11ebe6
leaq 0x60(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x30af0
movq 0x18(%rsp), %rdi
addq $0x96a, %rdi            # imm = 0x96A
leaq 0x48c94(%rip), %rsi     # 0xee034
leaq 0x79809(%rip), %rdx     # 0x11ebb0
movl $0x2b0, %ecx            # imm = 0x2B0
movq %r14, %r8
xorl %eax, %eax
callq 0x30af0
movl $0x1, %eax
addq $0x868, %rsp            # imm = 0x868
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x998(%r14), %rax
imull (%rax,%r13,4), %ecx
shll $0x3, %ecx
leaq 0x48c21(%rip), %rsi     # 0xee004
leaq 0x6f165(%rip), %rdx     # 0x11454f
leaq 0x60(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x30af0
movq 0x18(%rsp), %rdi
addq $0x96a, %rdi            # imm = 0x96A
leaq 0x48c28(%rip), %rsi     # 0xee034
leaq 0x7979d(%rip), %rdx     # 0x11ebb0
movl $0x29e, %ecx            # imm = 0x29E
jmp 0xa53ac