// File: /workspace/github_c_makefile_star2_O2/PoulinV[P]AxiCLASS/build/../source/perturbations.c
// Function: perturbations_find_approximation_number
int perturbations_find_approximation_number(
                                            struct precision * ppr,
                                            struct background * pba,
                                            struct thermodynamics * pth,
                                            struct perturbations * ppt,
                                            int index_md,
                                            double k,
                                            struct perturbations_workspace * ppw,
                                            double tau_ini,
                                            double tau_end,
                                            int * interval_number,
                                            int * interval_number_of /* interval_number_of[index_ap] (already allocated) */
                                            ){

  /** Summary: */
  /* index running over approximations */
  int index_ap;

  /* value of a given approximation at tau_ini and tau_end */
  int flag_ini,flag_end;

  /** - fix default number of intervals to one (if no approximation switch) */

  *interval_number=1;

  /** - loop over each approximation and add the number of approximation switching times */

  for (index_ap=0; index_ap<ppw->ap_size; index_ap++) {

    class_call(perturbations_approximations(ppr,
                                            pba,
                                            pth,
                                            ppt,
                                            index_md,
                                            k,
                                            tau_ini,
                                            ppw),
               ppt->error_message,
               ppt->error_message);

    flag_ini = ppw->approx[index_ap];

    class_call(perturbations_approximations(ppr,
                                            pba,
                                            pth,
                                            ppt,
                                            index_md,
                                            k,
                                            tau_end,
                                            ppw),
               ppt->error_message,
               ppt->error_message);

    flag_end = ppw->approx[index_ap];

    class_test(flag_end<flag_ini,
               ppt->error_message,
               "For each approximation scheme, the declaration of approximation labels in the enumeration must follow chronological order, e.g: enum approx_flags {flag1, flag2, flag3} with flag1 being the initial one and flag3 the final one");

    *interval_number += flag_end-flag_ini;

    interval_number_of[index_ap] = flag_end-flag_ini+1;
  }

  return _SUCCESS_;

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1048, %rsp           # imm = 0x1048
movsd %xmm2, 0x28(%rsp)
movsd %xmm1, 0x30(%rsp)
movq %r9, %r14
movl %r8d, %r12d
movq %rdx, %r13
movq %rsi, %r15
movq %rdi, %rbx
movq 0x1080(%rsp), %rax
movl $0x1, (%rax)
xorl %ebp, %ebp
movsd %xmm0, 0x10(%rsp)
movq %rcx, (%rsp)
movq %rdi, 0x20(%rsp)
movq %rsi, 0x18(%rsp)
movslq 0x178(%r14), %rax
cmpq %rax, %rbp
jge 0x7697c
movq %rbp, 0x38(%rsp)
movq %rbx, %rdi
movq %r15, %rsi
movq %r13, %rdx
movq %rcx, %rbp
movl %r12d, %r8d
movsd 0x30(%rsp), %xmm1
movq %r14, %r9
callq 0x85c21
testl %eax, %eax
jne 0x76983
movq 0x180(%r14), %rax
movq %rbp, %rcx
movq 0x38(%rsp), %rbp
movl (%rax,%rbp,4), %eax
movl %eax, 0xc(%rsp)
movq %rbx, %rdi
movq %r15, %rsi
movq %r13, %r15
movq %r13, %rdx
movl %r12d, %r8d
movsd 0x10(%rsp), %xmm0
movsd 0x28(%rsp), %xmm1
movq %r14, %r9
callq 0x85c21
testl %eax, %eax
jne 0x769c2
movq 0x180(%r14), %rax
movl (%rax,%rbp,4), %eax
subl 0xc(%rsp), %eax
jl 0x76a08
movq 0x1080(%rsp), %rcx
addl %eax, (%rcx)
incl %eax
movq 0x1088(%rsp), %rcx
movl %eax, (%rcx,%rbp,4)
incq %rbp
movq (%rsp), %rcx
movsd 0x10(%rsp), %xmm0
movq %r15, %r13
movq 0x18(%rsp), %r15
movq 0x20(%rsp), %rbx
jmp 0x768b7
xorl %eax, %eax
jmp 0x76a6c
addq $0x6c8a, %rbp           # imm = 0x6C8A
leaq 0x6ea5f(%rip), %rsi     # 0xe53f0
leaq 0x9631a(%rip), %rdx     # 0x10ccb2
leaq 0x40(%rsp), %r14
movq %r14, %rdi
movq %rbp, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0x6e683(%rip), %rsi     # 0xe5034
leaq 0x96346(%rip), %rdx     # 0x10ccfe
movq %rbp, %rdi
movl $0xdf6, %ecx            # imm = 0xDF6
jmp 0x76a03
movq (%rsp), %rbx
addq $0x6c8a, %rbx           # imm = 0x6C8A
leaq 0x6ea1c(%rip), %rsi     # 0xe53f0
leaq 0x9634b(%rip), %rdx     # 0x10cd26
leaq 0x40(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0x6e640(%rip), %rsi     # 0xe5034
leaq 0x96303(%rip), %rdx     # 0x10ccfe
movq %rbx, %rdi
movl $0xe03, %ecx            # imm = 0xE03
movq %r14, %r8
jmp 0x76a62
leaq 0x96363(%rip), %rsi     # 0x10cd72
leaq 0x40(%rsp), %rbx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x2e014
leaq 0x6e65d(%rip), %rsi     # 0xe5082
leaq 0x96427(%rip), %rdx     # 0x10ce53
leaq 0x840(%rsp), %r15
movq %r15, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x2e014
movq (%rsp), %rdi
addq $0x6c8a, %rdi           # imm = 0x6C8A
leaq 0x6e5e1(%rip), %rsi     # 0xe5034
leaq 0x962a4(%rip), %rdx     # 0x10ccfe
movl $0xe09, %ecx            # imm = 0xE09
movq %r15, %r8
xorl %eax, %eax
callq 0x2e014
pushq $0x1
popq %rax
addq $0x1048, %rsp           # imm = 0x1048
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq