// File: /workspace/github_c_makefile_star2_O3/PoulinV[P]AxiCLASS/build/../source/perturbations.c
// Function: perturbations_free
int perturbations_free(
                       struct perturbations * ppt
                       ) {

  int index_md,index_ic,index_tp;
  int filenum;

  perturbations_free_input(ppt);

  if (ppt->has_perturbations == _TRUE_) {

    for (index_md = 0; index_md < ppt->md_size; index_md++) {

      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++) {

          free(ppt->sources[index_md][index_ic*ppt->tp_size[index_md]+index_tp]);
          if (ppt->ln_tau_size > 1)
            free(ppt->ddlate_sources[index_md][index_ic*ppt->tp_size[index_md]+index_tp]);

        }
      }

      free(ppt->sources[index_md]);
      free(ppt->late_sources[index_md]);
      free(ppt->ddlate_sources[index_md]);

      free(ppt->k[index_md]);

    }

    free(ppt->tau_sampling);
    if (ppt->ln_tau_size > 1)
      free(ppt->ln_tau);

    free(ppt->tp_size);

    free(ppt->ic_size);

    free(ppt->k);

    free(ppt->k_size_cmb);

    free(ppt->k_size_cl);

    free(ppt->k_size);

    free(ppt->sources);

    if(ppt->has_scf == _TRUE_ && ppt->scf_has_perturbations == _TRUE_){
      free(ppt->scf_kg_eq[ppt->index_md_scalars]);
      free(ppt->scf_kg_eq);
      if (ppt->has_vectors == _TRUE_) {
        free(ppt->scf_kg_eq[ppt->index_md_vectors]);
        free(ppt->scf_kg_eq);
    }
      if (ppt->has_tensors == _TRUE_) {
        free(ppt->scf_kg_eq[ppt->index_md_tensors]);
        free(ppt->scf_kg_eq);
    }
    }
    free(ppt->late_sources);
    free(ppt->ddlate_sources);

    /** Stuff related to perturbations output: */

    /** - Free non-NULL pointers */
    if (ppt->k_output_values_num > 0 )
      free(ppt->index_k_output_values);

    for (filenum = 0; filenum<_MAX_NUMBER_OF_K_FILES_; filenum++){
      if (ppt->scalar_perturbations_data[filenum] != NULL)
        free(ppt->scalar_perturbations_data[filenum]);
      if (ppt->vector_perturbations_data[filenum] != NULL)
        free(ppt->vector_perturbations_data[filenum]);
      if (ppt->tensor_perturbations_data[filenum] != NULL)
        free(ppt->tensor_perturbations_data[filenum]);
    }

  }

  ppt->is_allocated = _FALSE_;
  return _SUCCESS_;

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdi, %rbx
callq 0x778d1
cmpw $0x1, (%rbx)
jne 0x77b78
cmpl $0x0, 0x854(%rbx)
jle 0x77a0f
xorl %r14d, %r14d
movq 0x870(%rbx), %rcx
cmpl $0x0, (%rcx,%r14,4)
jle 0x779bc
movq 0x998(%rbx), %rax
xorl %ebp, %ebp
movl (%rax,%r14,4), %edx
testl %edx, %edx
jle 0x779b4
movslq %ebp, %r15
xorl %r12d, %r12d
movq 0xa38(%rbx), %rax
movq (%rax,%r14,8), %rax
imull %ebp, %edx
movslq %edx, %rcx
addq %r12, %rcx
movq (%rax,%rcx,8), %rdi
callq 0x8410
cmpl $0x2, 0xa60(%rbx)
jl 0x7799a
movq 0x998(%rbx), %rax
movq 0xa70(%rbx), %rcx
movq (%rcx,%r14,8), %rcx
movslq (%rax,%r14,4), %rax
imulq %r15, %rax
addq %r12, %rax
movq (%rcx,%rax,8), %rdi
callq 0x8410
movq 0x998(%rbx), %rax
movl (%rax,%r14,4), %edx
incq %r12
cmpl %edx, %r12d
jl 0x7794e
movq 0x870(%rbx), %rcx
incl %ebp
cmpl (%rcx,%r14,4), %ebp
jl 0x77940
movq 0xa38(%rbx), %rax
movq (%rax,%r14,8), %rdi
callq 0x8410
movq 0xa68(%rbx), %rax
movq (%rax,%r14,8), %rdi
callq 0x8410
movq 0xa70(%rbx), %rax
movq (%rax,%r14,8), %rdi
callq 0x8410
movq 0x9d0(%rbx), %rax
movq (%rax,%r14,8), %rdi
callq 0x8410
incq %r14
movslq 0x854(%rbx), %rax
cmpq %rax, %r14
jl 0x77925
movq 0x9f0(%rbx), %rdi
callq 0x8410
cmpl $0x2, 0xa60(%rbx)
jl 0x77a30
movq 0xa58(%rbx), %rdi
callq 0x8410
movq 0x998(%rbx), %rdi
callq 0x8410
movq 0x870(%rbx), %rdi
callq 0x8410
movq 0x9d0(%rbx), %rdi
callq 0x8410
movq 0x9b0(%rbx), %rdi
callq 0x8410
movq 0x9b8(%rbx), %rdi
callq 0x8410
movq 0x9c8(%rbx), %rdi
callq 0x8410
movq 0xa38(%rbx), %rdi
callq 0x8410
cmpw $0x1, 0x8(%rbx)
jne 0x77b09
cmpw $0x1, 0x4(%rbx)
jne 0x77b09
movq 0x9d8(%rbx), %rax
movslq 0x848(%rbx), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x8410
movq 0x9d8(%rbx), %rdi
callq 0x8410
cmpw $0x1, 0x10(%rbx)
jne 0x77adf
movq 0x9d8(%rbx), %rax
movslq 0x850(%rbx), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x8410
movq 0x9d8(%rbx), %rdi
callq 0x8410
cmpw $0x1, 0x12(%rbx)
jne 0x77b09
movq 0x9d8(%rbx), %rax
movslq 0x84c(%rbx), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x8410
movq 0x9d8(%rbx), %rdi
callq 0x8410
movq 0xa68(%rbx), %rdi
callq 0x8410
movq 0xa70(%rbx), %rdi
callq 0x8410
cmpl $0x0, 0x6d4(%rbx)
jle 0x77b36
movq 0xa78(%rbx), %rdi
callq 0x8410
movq $-0x1e, %r14
movq 0x6940(%rbx,%r14,8), %rdi
testq %rdi, %rdi
je 0x77b4f
callq 0x8410
movq 0x6a30(%rbx,%r14,8), %rdi
testq %rdi, %rdi
je 0x77b61
callq 0x8410
movq 0x6b20(%rbx,%r14,8), %rdi
testq %rdi, %rdi
je 0x77b73
callq 0x8410
incq %r14
jne 0x77b3d
movw $0x0, 0x748a(%rbx)
xorl %eax, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq