// File: /workspace/github_c_makefile_star2_O1/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 0xe257e
addq $0x40, %rsp
movl %eax, %ecx
cmpl $0x3, %r14d
jne 0xe22c5
cmpl $0x1, %ecx
jne 0xe2312
addq $0x192, %rbx            # imm = 0x192
leaq 0xf15f(%rip), %rsi      # 0xf13f0
leaq 0x4d098(%rip), %rdx     # 0x12f330
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30c2c
leaq 0xed83(%rip), %rsi      # 0xf1034
leaq 0x24399(%rip), %rdx     # 0x106651
movq %rbx, %rdi
movl $0x42, %ecx
jmp 0xe2510
xorl %eax, %eax
cmpl $0x1, %ecx
jne 0xe251f
addq $0x192, %rbx            # imm = 0x192
leaq 0xf112(%rip), %rsi      # 0xf13f0
leaq 0x4d04b(%rip), %rdx     # 0x12f330
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30c2c
leaq 0xed36(%rip), %rsi      # 0xf1034
leaq 0x2434c(%rip), %rdx     # 0x106651
movq %rbx, %rdi
movl $0x70, %ecx
jmp 0xe2510
movslq 0x6c(%rbx), %r13
leaq (,%r13,8), %rdi
callq 0x8460
testq %rax, %rax
je 0xe23cc
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 0xe257e
addq $0x40, %rsp
cmpl $0x1, %eax
jne 0xe2412
addq $0x192, %rbx            # imm = 0x192
leaq 0xf058(%rip), %rsi      # 0xf13f0
leaq 0x4d028(%rip), %rdx     # 0x12f3c7
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30c2c
leaq 0xec7c(%rip), %rsi      # 0xf1034
leaq 0x24292(%rip), %rdx     # 0x106651
movq %rbx, %rdi
movl $0x50, %ecx
jmp 0xe2510
shll $0x3, %r13d
leaq 0xec2d(%rip), %rsi      # 0xf1004
leaq 0x4cfda(%rip), %rdx     # 0x12f3b8
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movl %r13d, %ecx
xorl %eax, %eax
callq 0x30c2c
addq $0x192, %rbx            # imm = 0x192
leaq 0xec36(%rip), %rsi      # 0xf1034
leaq 0x2424c(%rip), %rdx     # 0x106651
movq %rbx, %rdi
movl $0x46, %ecx
jmp 0xe2510
movl $0x2, 0xc(%rbx)
movslq 0x6c(%rbx), %rax
movq %rax, 0x8(%rsp)
leaq (,%rax,8), %rdi
callq 0x8460
testq %rax, %rax
je 0xe24ce
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 0xe257e
addq $0x40, %rsp
cmpl $0x1, %eax
jne 0xe2531
addq $0x192, %rbx            # imm = 0x192
leaq 0xef53(%rip), %rsi      # 0xf13f0
leaq 0x4cfc6(%rip), %rdx     # 0x12f46a
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30c2c
leaq 0xeb77(%rip), %rsi      # 0xf1034
leaq 0x2418d(%rip), %rdx     # 0x106651
movq %rbx, %rdi
movl $0x5e, %ecx
jmp 0xe2510
movq 0x8(%rsp), %rcx
shll $0x3, %ecx
leaq 0xeb27(%rip), %rsi      # 0xf1004
leaq 0x4cf74(%rip), %rdx     # 0x12f458
leaq 0x10(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x30c2c
addq $0x192, %rbx            # imm = 0x192
leaq 0xeb33(%rip), %rsi      # 0xf1034
leaq 0x24149(%rip), %rdx     # 0x106651
movq %rbx, %rdi
movl $0x56, %ecx
movq %r14, %r8
xorl %eax, %eax
callq 0x30c2c
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 0xe256a
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 0xe254b
movq %r14, %rdi
callq 0x8410
movq %r13, %rdi
callq 0x8410
xorl %eax, %eax
jmp 0xe251f