// File: /workspace/github_c_makefile_star2_O3/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 0xdf066
addq $0x40, %rsp
movl %eax, %ecx
cmpl $0x3, %r14d
jne 0xdedad
cmpl $0x1, %ecx
jne 0xdedfa
addq $0x192, %rbx            # imm = 0x192
leaq 0xf677(%rip), %rsi      # 0xee3f0
leaq 0x4d5e0(%rip), %rdx     # 0x12c360
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30af0
leaq 0xf29b(%rip), %rsi      # 0xee034
leaq 0x248d9(%rip), %rdx     # 0x103679
movq %rbx, %rdi
movl $0x42, %ecx
jmp 0xdeff8
xorl %eax, %eax
cmpl $0x1, %ecx
jne 0xdf007
addq $0x192, %rbx            # imm = 0x192
leaq 0xf62a(%rip), %rsi      # 0xee3f0
leaq 0x4d593(%rip), %rdx     # 0x12c360
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30af0
leaq 0xf24e(%rip), %rsi      # 0xee034
leaq 0x2488c(%rip), %rdx     # 0x103679
movq %rbx, %rdi
movl $0x70, %ecx
jmp 0xdeff8
movslq 0x6c(%rbx), %r13
leaq (,%r13,8), %rdi
callq 0x8460
testq %rax, %rax
je 0xdeeb4
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 0xdf066
addq $0x40, %rsp
cmpl $0x1, %eax
jne 0xdeefa
addq $0x192, %rbx            # imm = 0x192
leaq 0xf570(%rip), %rsi      # 0xee3f0
leaq 0x4d570(%rip), %rdx     # 0x12c3f7
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30af0
leaq 0xf194(%rip), %rsi      # 0xee034
leaq 0x247d2(%rip), %rdx     # 0x103679
movq %rbx, %rdi
movl $0x50, %ecx
jmp 0xdeff8
shll $0x3, %r13d
leaq 0xf145(%rip), %rsi      # 0xee004
leaq 0x4d522(%rip), %rdx     # 0x12c3e8
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movl %r13d, %ecx
xorl %eax, %eax
callq 0x30af0
addq $0x192, %rbx            # imm = 0x192
leaq 0xf14e(%rip), %rsi      # 0xee034
leaq 0x2478c(%rip), %rdx     # 0x103679
movq %rbx, %rdi
movl $0x46, %ecx
jmp 0xdeff8
movl $0x2, 0xc(%rbx)
movslq 0x6c(%rbx), %rax
movq %rax, 0x8(%rsp)
leaq (,%rax,8), %rdi
callq 0x8460
testq %rax, %rax
je 0xdefb6
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 0xdf066
addq $0x40, %rsp
cmpl $0x1, %eax
jne 0xdf019
addq $0x192, %rbx            # imm = 0x192
leaq 0xf46b(%rip), %rsi      # 0xee3f0
leaq 0x4d50e(%rip), %rdx     # 0x12c49a
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30af0
leaq 0xf08f(%rip), %rsi      # 0xee034
leaq 0x246cd(%rip), %rdx     # 0x103679
movq %rbx, %rdi
movl $0x5e, %ecx
jmp 0xdeff8
movq 0x8(%rsp), %rcx
shll $0x3, %ecx
leaq 0xf03f(%rip), %rsi      # 0xee004
leaq 0x4d4bc(%rip), %rdx     # 0x12c488
leaq 0x10(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x30af0
addq $0x192, %rbx            # imm = 0x192
leaq 0xf04b(%rip), %rsi      # 0xee034
leaq 0x24689(%rip), %rdx     # 0x103679
movq %rbx, %rdi
movl $0x56, %ecx
movq %r14, %r8
xorl %eax, %eax
callq 0x30af0
movl $0x1, %eax
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
testq %rax, %rax
movq 0x858(%rsp), %rdx
jle 0xdf052
xorl %ecx, %ecx
movsd (%rdx,%rcx,8), %xmm0
mulsd (%r14,%rcx,8), %xmm0
divsd (%r13,%rcx,8), %xmm0
movsd %xmm0, (%rdx,%rcx,8)
incq %rcx
cmpq %rcx, %rax
jne 0xdf033
movq %r14, %rdi
callq 0x8410
movq %r13, %rdi
callq 0x8410
xorl %eax, %eax
jmp 0xdf007