// File: /workspace/github_c_makefile_star2_O2/PoulinV[P]AxiCLASS/build/../external/HMcode/hmcode.c
// Function: hmcode
int hmcode(
           struct precision *ppr,
           struct background *pba,
           struct perturbations *ppt,
           struct primordial *ppm,
           struct fourier *pfo,
           int index_pk,
           int index_tau,
           double tau,
           double *pk_nl,
           double **lnpk_l,
           double **ddlnpk_l,
           double *k_nl,
           short *nl_corr_not_computable_at_this_k,
           struct hmcode_workspace * phw
           ) {

  double *pk_nl_baseline;
  double *pk_nl_denominator;
  int index_k;

  /* The baryonic contribution is calculated as the ratio of three different
     simpler models, which are computed below
     (baryonic/unfitted_nobaryons * nobaryons) */
  if (pfo->hm_version == hmcode_version_2020_baryonic) {

    class_call(hmcode_compute(ppr, pba, ppt, ppm, pfo,
                              index_pk, index_tau, tau,
                              pk_nl, lnpk_l, ddlnpk_l,
                              k_nl, nl_corr_not_computable_at_this_k,
                              phw),
               pfo->error_message,
               pfo->error_message);

    class_alloc(pk_nl_baseline,
                pfo->k_size*sizeof(double),
                pfo->error_message);

    pfo->hm_version = hmcode_version_2020;

    class_call(hmcode_compute(ppr, pba, ppt, ppm, pfo,
                              index_pk, index_tau, tau,
                              pk_nl_baseline, lnpk_l, ddlnpk_l,
                              k_nl, nl_corr_not_computable_at_this_k,
                              phw),
               pfo->error_message,
               pfo->error_message);

    pfo->hm_version = hmcode_version_2020_unfitted;

    class_alloc(pk_nl_denominator,
                pfo->k_size*sizeof(double),
                pfo->error_message);

    class_call(hmcode_compute(ppr, pba, ppt, ppm, pfo,
                              index_pk, index_tau, tau,
                              pk_nl_denominator, lnpk_l, ddlnpk_l,
                              k_nl, nl_corr_not_computable_at_this_k,
                              phw),
               pfo->error_message,
               pfo->error_message);

    pfo->hm_version = hmcode_version_2020_baryonic;

    for(index_k=0;index_k<pfo->k_size;++index_k){
      pk_nl[index_k] = pk_nl[index_k] * pk_nl_baseline[index_k] / pk_nl_denominator[index_k];
    }

    free(pk_nl_baseline);
    free(pk_nl_denominator);
  }
  else { //In this case we can do the normal analysis
    class_call(hmcode_compute(ppr, pba, ppt, ppm, pfo,
                              index_pk, index_tau, tau,
                              pk_nl, lnpk_l, ddlnpk_l,
                              k_nl, nl_corr_not_computable_at_this_k,
                              phw),
               pfo->error_message,
               pfo->error_message);
  }

  return _SUCCESS_;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x818, %rsp            # imm = 0x818
movl %r9d, %ebp
movq %r8, %rbx
movq %rsi, %r15
movq %rdi, %r12
movl 0x850(%rsp), %eax
movl 0xc(%r8), %r14d
subq $0x8, %rsp
movsd %xmm0, 0x8(%rsp)
pushq 0x888(%rsp)
pushq 0x888(%rsp)
pushq 0x888(%rsp)
pushq 0x888(%rsp)
pushq 0x888(%rsp)
pushq 0x888(%rsp)
pushq %rax
callq 0xd6d0d
addq $0x40, %rsp
movl %eax, %ecx
cmpl $0x3, %r14d
jne 0xd6a77
cmpl $0x1, %ecx
jne 0xd6abe
addq $0x192, %rbx            # imm = 0x192
leaq 0xe9a7(%rip), %rsi      # 0xe53f0
leaq 0x4c780(%rip), %rdx     # 0x1231d0
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0xe5cb(%rip), %rsi      # 0xe5034
leaq 0x23ad1(%rip), %rdx     # 0xfa541
pushq $0x42
jmp 0xd6ca0
xorl %eax, %eax
cmpl $0x1, %ecx
jne 0xd6cb1
addq $0x192, %rbx            # imm = 0x192
leaq 0xe960(%rip), %rsi      # 0xe53f0
leaq 0x4c739(%rip), %rdx     # 0x1231d0
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0xe584(%rip), %rsi      # 0xe5034
leaq 0x23a8a(%rip), %rdx     # 0xfa541
pushq $0x70
jmp 0xd6ca0
movslq 0x6c(%rbx), %r13
leaq (,%r13,8), %rdi
callq 0x8490
testq %rax, %rax
je 0xd6b6e
movq %rax, %r14
movl $0x1, 0xc(%rbx)
subq $0x8, %rsp
movq %r12, %rdi
movq %r15, %rsi
movq %rbx, %r8
movl %ebp, %r9d
movsd 0x8(%rsp), %xmm0
pushq 0x888(%rsp)
pushq 0x888(%rsp)
pushq 0x888(%rsp)
pushq 0x888(%rsp)
pushq 0x888(%rsp)
pushq %rax
movl 0x888(%rsp), %eax
pushq %rax
callq 0xd6d0d
addq $0x40, %rsp
cmpl $0x1, %eax
jne 0xd6bae
addq $0x192, %rbx            # imm = 0x192
leaq 0xe8b0(%rip), %rsi      # 0xe53f0
leaq 0x4c720(%rip), %rdx     # 0x123267
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0xe4d4(%rip), %rsi      # 0xe5034
leaq 0x239da(%rip), %rdx     # 0xfa541
pushq $0x50
jmp 0xd6ca0
shll $0x3, %r13d
leaq 0xe48b(%rip), %rsi      # 0xe5004
leaq 0x4c6d8(%rip), %rdx     # 0x123258
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movl %r13d, %ecx
xorl %eax, %eax
callq 0x2e014
addq $0x192, %rbx            # imm = 0x192
leaq 0xe494(%rip), %rsi      # 0xe5034
leaq 0x2399a(%rip), %rdx     # 0xfa541
pushq $0x46
jmp 0xd6ca0
movl $0x2, 0xc(%rbx)
movslq 0x6c(%rbx), %rax
movq %rax, 0x8(%rsp)
leaq (,%rax,8), %rdi
callq 0x8490
testq %rax, %rax
je 0xd6c64
movq %rax, %r13
subq $0x8, %rsp
movq %r12, %rdi
movq %r15, %rsi
movq %rbx, %r8
movl %ebp, %r9d
movsd 0x8(%rsp), %xmm0
pushq 0x888(%rsp)
pushq 0x888(%rsp)
pushq 0x888(%rsp)
pushq 0x888(%rsp)
pushq 0x888(%rsp)
pushq %rax
movl 0x888(%rsp), %eax
pushq %rax
callq 0xd6d0d
addq $0x40, %rsp
cmpl $0x1, %eax
jne 0xd6cc3
addq $0x192, %rbx            # imm = 0x192
leaq 0xe7b7(%rip), %rsi      # 0xe53f0
leaq 0x4c6ca(%rip), %rdx     # 0x12330a
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0xe3db(%rip), %rsi      # 0xe5034
leaq 0x238e1(%rip), %rdx     # 0xfa541
pushq $0x5e
jmp 0xd6ca0
movq 0x8(%rsp), %rcx
shll $0x3, %ecx
leaq 0xe391(%rip), %rsi      # 0xe5004
leaq 0x4c67e(%rip), %rdx     # 0x1232f8
leaq 0x10(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x2e014
addq $0x192, %rbx            # imm = 0x192
leaq 0xe39d(%rip), %rsi      # 0xe5034
leaq 0x238a3(%rip), %rdx     # 0xfa541
pushq $0x56
popq %rcx
movq %rbx, %rdi
movq %r14, %r8
xorl %eax, %eax
callq 0x2e014
pushq $0x1
popq %rax
addq $0x818, %rsp            # imm = 0x818
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x3, 0xc(%rbx)
movslq 0x6c(%rbx), %rax
xorl %ecx, %ecx
movq 0x858(%rsp), %rdx
cmpq %rax, %rcx
jge 0xd6cf9
movsd (%rdx,%rcx,8), %xmm0
mulsd (%r14,%rcx,8), %xmm0
divsd (%r13,%rcx,8), %xmm0
movsd %xmm0, (%rdx,%rcx,8)
incq %rcx
jmp 0xd6cd8
movq %r14, %rdi
callq 0x8430
movq %r13, %rdi
callq 0x8430
xorl %eax, %eax
jmp 0xd6cb1