// File: /workspace/github_c_makefile_star2_O3/PoulinV[P]AxiCLASS/build/../source/perturbations.c
// Function: perturbations_workspace_init
int perturbations_workspace_init(
                                 struct precision * ppr,
                                 struct background * pba,
                                 struct thermodynamics * pth,
                                 struct perturbations * ppt,
                                 int index_md,
                                 struct perturbations_workspace * ppw
                                 ) {

  /** Summary: */

  /** - define local variables */

  int index_mt=0;
  int index_ap;
  int l;

  /** - Compute maximum l_max for any multipole */;
  if (_scalars_) {
    ppw->max_l_max = MAX(ppr->l_max_g, ppr->l_max_pol_g);
    if (pba->has_ur == _TRUE_) ppw->max_l_max = MAX(ppw->max_l_max, ppr->l_max_ur);
    if ((pba->has_idr == _TRUE_) && (ppt->idr_nature == idr_free_streaming)) ppw->max_l_max = MAX(ppw->max_l_max, ppr->l_max_idr);
    if (pba->has_ncdm == _TRUE_) ppw->max_l_max = MAX(ppw->max_l_max, ppr->l_max_ncdm);
    if (pba->has_dr == _TRUE_) ppw->max_l_max = MAX(ppw->max_l_max, ppr->l_max_dr);
  }
  if (_tensors_) {
    ppw->max_l_max = MAX(ppr->l_max_g_ten, ppr->l_max_pol_g_ten);
    if (pba->has_ur == _TRUE_) ppw->max_l_max = MAX(ppw->max_l_max, ppr->l_max_ur);
    if (pba->has_ncdm == _TRUE_) ppw->max_l_max = MAX(ppw->max_l_max, ppr->l_max_ncdm);
  }

  /** - Allocate \f$ s_l\f$[ ] array for freestreaming of multipoles (see arXiv:1305.3261) and initialize
      to 1.0, which is the K=0 value. */
  class_alloc(ppw->s_l, sizeof(double)*(ppw->max_l_max+1),ppt->error_message);
  for (l=0; l<=ppw->max_l_max; l++){
    ppw->s_l[l] = 1.0;
  }

  /** - define indices of metric perturbations obeying constraint
      equations (this can be done once and for all, because the
      vector of metric perturbations is the same whatever the
      approximation scheme, unlike the vector of quantities to
      be integrated, which is allocated separately in
      perturbations_vector_init) */

  if (_scalars_) {

    /* newtonian gauge */

    if (ppt->gauge == newtonian) {
      class_define_index(ppw->index_mt_psi,_TRUE_,index_mt,1); /* psi */
      class_define_index(ppw->index_mt_phi_prime,_TRUE_,index_mt,1); /* phi' */
    }

    /* synchronous gauge (note that eta is counted in the vector of
       quantities to be integrated, while here we only consider
       quantities obeying to constraint equations) */

    if (ppt->gauge == synchronous) {
      class_define_index(ppw->index_mt_h_prime,_TRUE_,index_mt,1);       /* h' */
      class_define_index(ppw->index_mt_h_prime_prime,_TRUE_,index_mt,1); /* h'' */
      class_define_index(ppw->index_mt_eta_prime,_TRUE_,index_mt,1);     /* eta' */
      class_define_index(ppw->index_mt_alpha,_TRUE_,index_mt,1);         /* alpha = (h' + 6 tau') / (2 k**2) */
      class_define_index(ppw->index_mt_alpha_prime,_TRUE_,index_mt,1);   /* alpha' */

    }

  }

  if (_vectors_) {

    /* newtonian gauge */

    if (ppt->gauge == newtonian) {

      class_define_index(ppw->index_mt_V_prime,_TRUE_,index_mt,1);

    }

    if (ppt->gauge == synchronous) {

      class_define_index(ppw->index_mt_hv_prime_prime,_TRUE_,index_mt,1);

    }

  }

  if (_tensors_) {
    class_define_index(ppw->index_mt_gw_prime_prime,_TRUE_,index_mt,1);
  }

  ppw->mt_size = index_mt;

  /** - allocate some workspace in which we will store temporarily the
      values of background, thermodynamics, metric and source
      quantities at a given time */

  class_alloc(ppw->pvecback,pba->bg_size*sizeof(double),ppt->error_message);
  class_alloc(ppw->pvecthermo,pth->th_size*sizeof(double),ppt->error_message);
  class_alloc(ppw->pvecmetric,ppw->mt_size*sizeof(double),ppt->error_message);

  /** - count number of approximations, initialize their indices, and allocate their flags */
  index_ap=0;

  class_define_index(ppw->index_ap_tca,_TRUE_,index_ap,1);
  class_define_index(ppw->index_ap_rsa,_TRUE_,index_ap,1);

  if (_scalars_) {

    class_define_index(ppw->index_ap_ufa,pba->has_ur,index_ap,1);
    class_define_index(ppw->index_ap_ncdmfa,pba->has_ncdm,index_ap,1);
    class_define_index(ppw->index_ap_tca_idm_dr,pba->has_idr,index_ap,1);
    class_define_index(ppw->index_ap_rsa_idr,pba->has_idr,index_ap,1);
  }

  ppw->ap_size=index_ap;

  if (ppw->ap_size > 0)
    class_alloc(ppw->approx,ppw->ap_size*sizeof(int),ppt->error_message);

  /** - For definiteness, initialize approximation flags to arbitrary
      values (correct values are overwritten in
      pertub_find_approximation_switches) */

  if (_scalars_) {

    ppw->approx[ppw->index_ap_tca]=(int)tca_on;
    ppw->approx[ppw->index_ap_rsa]=(int)rsa_off;

    if (pba->has_idr == _TRUE_)
      ppw->approx[ppw->index_ap_rsa_idr]=(int)rsa_idr_off;
    if (pba->has_idr == _TRUE_)
      ppw->approx[ppw->index_ap_tca_idm_dr]=(int)tca_idm_dr_off;
    if (pth->has_idm_dr == _TRUE_)
      ppw->approx[ppw->index_ap_tca_idm_dr]=(int)tca_idm_dr_on;

    if (pba->has_ur == _TRUE_) {
      ppw->approx[ppw->index_ap_ufa]=(int)ufa_off;
    }
    if (pba->has_ncdm == _TRUE_) {
      ppw->approx[ppw->index_ap_ncdmfa]=(int)ncdmfa_off;
    }
  }

  if (_tensors_) {

    ppw->approx[ppw->index_ap_tca]=(int)tca_on;
    ppw->approx[ppw->index_ap_rsa]=(int)rsa_off;
  }

  /** - allocate fields where some of the perturbations are stored */

  if (_scalars_) {

    if ((ppt->has_density_transfers == _TRUE_) || (ppt->has_velocity_transfers == _TRUE_) || (ppt->has_source_delta_m == _TRUE_)) {

      class_alloc(ppw->delta_ncdm,pba->N_ncdm*sizeof(double),ppt->error_message);
      class_alloc(ppw->theta_ncdm,pba->N_ncdm*sizeof(double),ppt->error_message);
      class_alloc(ppw->shear_ncdm,pba->N_ncdm*sizeof(double),ppt->error_message);

    }

  }

  return _SUCCESS_;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x818, %rsp            # imm = 0x818
movq %r9, %r14
movq %rcx, %rbx
movq %rdx, 0x8(%rsp)
movq %rsi, %r15
movzwl 0xe(%rcx), %eax
movw %ax, 0x2(%rsp)
cmpw $0x1, %ax
jne 0x79c93
cmpl %r8d, 0x848(%rbx)
jne 0x79c93
movl 0x5b8(%rdi), %ecx
movl 0x5bc(%rdi), %eax
cmpl %eax, %ecx
cmovgl %ecx, %eax
movl %eax, 0x188(%r14)
cmpw $0x1, 0x4c4(%r15)
jne 0x79c33
movl 0x5c4(%rdi), %ecx
cmpl %ecx, %eax
cmovlel %ecx, %eax
movl %eax, 0x188(%r14)
cmpw $0x1, 0x4c6(%r15)
jne 0x79c59
cmpl $0x0, 0x830(%rbx)
jne 0x79c59
movl 0x5c8(%rdi), %ecx
cmpl %ecx, %eax
cmovlel %ecx, %eax
movl %eax, 0x188(%r14)
cmpw $0x1, 0x4be(%r15)
jne 0x79c76
movl 0x5cc(%rdi), %ecx
cmpl %ecx, %eax
cmovlel %ecx, %eax
movl %eax, 0x188(%r14)
cmpw $0x1, 0x4ba(%r15)
jne 0x79c93
movl 0x5c0(%rdi), %ecx
cmpl %ecx, %eax
cmovgl %eax, %ecx
movl %ecx, 0x188(%r14)
movzwl 0x12(%rbx), %ebp
cmpw $0x1, %bp
jne 0x79cf8
cmpl %r8d, 0x84c(%rbx)
jne 0x79cf8
movl 0x5d0(%rdi), %ecx
movl 0x5d4(%rdi), %eax
cmpl %eax, %ecx
cmovgl %ecx, %eax
movl %eax, 0x188(%r14)
cmpw $0x1, 0x4c4(%r15)
jne 0x79cdb
movl 0x5c4(%rdi), %ecx
cmpl %ecx, %eax
cmovlel %ecx, %eax
movl %eax, 0x188(%r14)
cmpw $0x1, 0x4be(%r15)
jne 0x79cf8
movl 0x5cc(%rdi), %ecx
cmpl %ecx, %eax
cmovgl %eax, %ecx
movl %ecx, 0x188(%r14)
movl %r8d, 0x4(%rsp)
movl 0x188(%r14), %r13d
leal 0x1(%r13), %r12d
movslq %r12d, %rdi
shlq $0x3, %rdi
callq 0x8460
movq %rax, 0x190(%r14)
testq %rax, %rax
je 0x79e0c
testl %r13d, %r13d
js 0x79dcd
movl %r12d, %ecx
leaq -0x1(%rcx), %rdx
movq %rdx, %xmm0
pshufd $0x44, %xmm0, %xmm0     # xmm0 = xmm0[0,1,0,1]
leaq 0x8(,%rcx,8), %rcx
andq $-0x10, %rcx
movdqa 0x74f2e(%rip), %xmm1    # 0xeec80
xorl %edx, %edx
movdqa 0x74f34(%rip), %xmm2    # 0xeec90
pxor %xmm2, %xmm0
movabsq $0x3ff0000000000000, %rsi # imm = 0x3FF0000000000000
pcmpeqd %xmm3, %xmm3
movdqa 0x75a1a(%rip), %xmm4    # 0xef790
movdqa %xmm1, %xmm5
pxor %xmm2, %xmm5
movdqa %xmm5, %xmm6
pcmpgtd %xmm0, %xmm6
pcmpeqd %xmm0, %xmm5
pshufd $0xf5, %xmm5, %xmm7     # xmm7 = xmm5[1,1,3,3]
pand %xmm6, %xmm7
pshufd $0xf5, %xmm6, %xmm5     # xmm5 = xmm6[1,1,3,3]
por %xmm7, %xmm5
movd %xmm5, %edi
notl %edi
testb $0x1, %dil
je 0x79dac
movq %rsi, (%rax,%rdx)
pxor %xmm3, %xmm5
pextrw $0x4, %xmm5, %edi
testb $0x1, %dil
je 0x79dc0
movq %rsi, 0x8(%rax,%rdx)
paddq %xmm4, %xmm1
addq $0x10, %rdx
cmpq %rdx, %rcx
jne 0x79d76
xorl %r13d, %r13d
cmpw $0x1, 0x2(%rsp)
jne 0x79e53
movl 0x4(%rsp), %ecx
cmpl %ecx, 0x848(%rbx)
jne 0x79e57
movl 0x83c(%rbx), %eax
cmpl $0x1, %eax
je 0x79e7b
testl %eax, %eax
jne 0x79e57
movabsq $0x100000000, %rax      # imm = 0x100000000
movq %rax, (%r14)
movl $0x2, %r13d
jmp 0x79e57
leal 0x8(,%r13,8), %ecx
leaq 0x741e9(%rip), %rsi     # 0xee004
leaq 0x9b445(%rip), %rdx     # 0x115267
leaq 0x10(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x30af0
addq $0x6c8a, %rbx           # imm = 0x6C8A
leaq 0x741f5(%rip), %rsi     # 0xee034
leaq 0x9b42a(%rip), %rdx     # 0x115270
movq %rbx, %rdi
movl $0xae2, %ecx            # imm = 0xAE2
jmp 0x7a25e
movl 0x4(%rsp), %ecx
cmpw $0x1, 0x10(%rbx)
jne 0x79ea0
cmpl %ecx, 0x850(%rbx)
jne 0x79ea0
movl 0x83c(%rbx), %eax
cmpl $0x1, %eax
je 0x79e99
testl %eax, %eax
jne 0x79ea0
movl %r13d, 0x20(%r14)
jmp 0x79e9d
movdqa 0x90cdd(%rip), %xmm0    # 0x10ab60
movdqu %xmm0, 0x8(%r14)
movl $0x4, 0x18(%r14)
movl $0x5, %r13d
jmp 0x79e57
movl %r13d, 0x24(%r14)
incl %r13d
cmpw $0x1, %bp
jne 0x79eb5
cmpl %ecx, 0x84c(%rbx)
jne 0x79eb5
movl %r13d, 0x1c(%r14)
incl %r13d
movl %r13d, 0x28(%r14)
movslq 0x43c(%r15), %r12
leaq (,%r12,8), %rdi
callq 0x8460
movq %rax, 0x30(%r14)
testq %rax, %rax
je 0x79f73
movq 0x8(%rsp), %rax
movslq 0xf04(%rax), %r12
leaq (,%r12,8), %rdi
callq 0x8460
movq %rax, 0x38(%r14)
testq %rax, %rax
je 0x79fb9
shll $0x3, %r13d
movq %r13, %rdi
callq 0x8460
movq %rax, 0x40(%r14)
testq %rax, %rax
je 0x79fff
movabsq $0x100000000, %rax      # imm = 0x100000000
movq %rax, 0x160(%r14)
movl $0x2, %r13d
cmpw $0x1, 0x2(%rsp)
jne 0x7a041
movl 0x4(%rsp), %r12d
cmpl %r12d, 0x848(%rbx)
jne 0x7a084
cmpw $0x0, 0x4c4(%r15)
je 0x7a048
movl $0x2, 0x170(%r14)
movl $0x3, %r13d
jmp 0x7a04e
shll $0x3, %r12d
leaq 0x74086(%rip), %rsi     # 0xee004
leaq 0x9b308(%rip), %rdx     # 0x11528d
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movl %r12d, %ecx
xorl %eax, %eax
callq 0x30af0
addq $0x6c8a, %rbx           # imm = 0x6C8A
leaq 0x7408f(%rip), %rsi     # 0xee034
leaq 0x9b2c4(%rip), %rdx     # 0x115270
movq %rbx, %rdi
movl $0xb22, %ecx            # imm = 0xB22
jmp 0x7a25e
shll $0x3, %r12d
leaq 0x74040(%rip), %rsi     # 0xee004
leaq 0x9b2d0(%rip), %rdx     # 0x11529b
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movl %r12d, %ecx
xorl %eax, %eax
callq 0x30af0
addq $0x6c8a, %rbx           # imm = 0x6C8A
leaq 0x74049(%rip), %rsi     # 0xee034
leaq 0x9b27e(%rip), %rdx     # 0x115270
movq %rbx, %rdi
movl $0xb23, %ecx            # imm = 0xB23
jmp 0x7a25e
leaq 0x73ffe(%rip), %rsi     # 0xee004
leaq 0x9b29e(%rip), %rdx     # 0x1152ab
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movl %r13d, %ecx
xorl %eax, %eax
callq 0x30af0
addq $0x6c8a, %rbx           # imm = 0x6C8A
leaq 0x74007(%rip), %rsi     # 0xee034
leaq 0x9b23c(%rip), %rdx     # 0x115270
movq %rbx, %rdi
movl $0xb24, %ecx            # imm = 0xB24
jmp 0x7a25e
movl 0x4(%rsp), %r12d
jmp 0x7a084
movl $0x2, %r13d
cmpw $0x0, 0x4be(%r15)
je 0x7a063
movl %r13d, 0x174(%r14)
incl %r13d
cmpw $0x0, 0x4c6(%r15)
je 0x7a084
movl %r13d, 0x168(%r14)
leal 0x1(%r13), %eax
movl %eax, 0x16c(%r14)
addl $0x2, %r13d
movl %r13d, 0x178(%r14)
shll $0x2, %r13d
movq %r13, %rdi
callq 0x8460
movq %rax, 0x180(%r14)
testq %rax, %rax
je 0x7a221
cmpw $0x1, 0x2(%rsp)
jne 0x7a136
cmpl %r12d, 0x848(%rbx)
jne 0x7a136
movq $0x0, (%rax)
cmpw $0x1, 0x4c6(%r15)
jne 0x7a0ea
movslq 0x16c(%r14), %rcx
movl $0x0, (%rax,%rcx,4)
movslq 0x168(%r14), %rcx
movl $0x1, (%rax,%rcx,4)
movq 0x8(%rsp), %rcx
cmpw $0x1, 0x38(%rcx)
jne 0x7a104
movslq 0x168(%r14), %rcx
movl $0x0, (%rax,%rcx,4)
cmpw $0x1, 0x4c4(%r15)
jne 0x7a11d
movslq 0x170(%r14), %rcx
movl $0x0, (%rax,%rcx,4)
cmpw $0x1, 0x4be(%r15)
jne 0x7a136
movslq 0x174(%r14), %rcx
movl $0x0, (%rax,%rcx,4)
cmpw $0x1, %bp
jne 0x7a14c
cmpl %r12d, 0x84c(%rbx)
jne 0x7a14c
movq $0x0, (%rax)
xorl %r12d, %r12d
cmpw $0x1, 0x2(%rsp)
jne 0x7a26e
movl 0x4(%rsp), %eax
cmpl %eax, 0x848(%rbx)
jne 0x7a26e
cmpw $0x1, 0x34(%rbx)
je 0x7a187
cmpw $0x1, 0x36(%rbx)
je 0x7a187
cmpw $0x1, 0x87c(%rbx)
jne 0x7a26e
movslq 0x248(%r15), %r13
movq %r13, %r15
shlq $0x3, %r15
movq %r15, %rdi
callq 0x8460
movq %rax, 0xe8(%r14)
testq %rax, %rax
je 0x7a283
movq %r15, %rdi
callq 0x8460
movq %rax, 0xf0(%r14)
testq %rax, %rax
je 0x7a2c7
movq %r15, %rdi
callq 0x8460
movq %rax, 0xf8(%r14)
testq %rax, %rax
jne 0x7a26e
leal (,%r13,8), %ecx
leaq 0x73e18(%rip), %rsi     # 0xee004
leaq 0x9b0f4(%rip), %rdx     # 0x1152e7
leaq 0x10(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x30af0
addq $0x6c8a, %rbx           # imm = 0x6C8A
leaq 0x73e24(%rip), %rsi     # 0xee034
leaq 0x9b059(%rip), %rdx     # 0x115270
movq %rbx, %rdi
movl $0xb5f, %ecx            # imm = 0xB5F
jmp 0x7a25e
leaq 0x73ddc(%rip), %rsi     # 0xee004
leaq 0x9b08c(%rip), %rdx     # 0x1152bb
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movl %r13d, %ecx
xorl %eax, %eax
callq 0x30af0
addq $0x6c8a, %rbx           # imm = 0x6C8A
leaq 0x73de5(%rip), %rsi     # 0xee034
leaq 0x9b01a(%rip), %rdx     # 0x115270
movq %rbx, %rdi
movl $0xb37, %ecx            # imm = 0xB37
movq %r14, %r8
xorl %eax, %eax
callq 0x30af0
movl $0x1, %r12d
movl %r12d, %eax
addq $0x818, %rsp            # imm = 0x818
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leal (,%r13,8), %ecx
leaq 0x73d72(%rip), %rsi     # 0xee004
leaq 0x9b02e(%rip), %rdx     # 0x1152c7
leaq 0x10(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x30af0
addq $0x6c8a, %rbx           # imm = 0x6C8A
leaq 0x73d7e(%rip), %rsi     # 0xee034
leaq 0x9afb3(%rip), %rdx     # 0x115270
movq %rbx, %rdi
movl $0xb5d, %ecx            # imm = 0xB5D
jmp 0x7a25e
leal (,%r13,8), %ecx
leaq 0x73d2e(%rip), %rsi     # 0xee004
leaq 0x9affa(%rip), %rdx     # 0x1152d7
leaq 0x10(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x30af0
addq $0x6c8a, %rbx           # imm = 0x6C8A
leaq 0x73d3a(%rip), %rsi     # 0xee034
leaq 0x9af6f(%rip), %rdx     # 0x115270
movq %rbx, %rdi
movl $0xb5e, %ecx            # imm = 0xB5E
jmp 0x7a25e