// File: /workspace/github_c_makefile_star2_O0/PoulinV[P]AxiCLASS/build/../source/distortions.c
// Function: distortions_compute_branching_ratios
int distortions_compute_branching_ratios(struct precision * ppr,
                                         struct distortions* psd){

  /** Define local variables */
  int index_z,index_type,index_k;
  double f_g, f_y, f_mu;
  double *f_E;
  double bb_vis;
  int last_index = 0;

  /** Allocate space for branching ratios in br_table */
  class_alloc(psd->br_table,
              psd->type_size*sizeof(double*),
              psd->error_message);
  for (index_type=0; index_type<psd->type_size; ++index_type){
    class_alloc(psd->br_table[index_type],
                psd->z_size*sizeof(double),
                psd->error_message);
  }

  /** Calulate branching ratios */
  if (psd->sd_branching_approx != bra_exact) {
    for (index_z=0; index_z<psd->z_size; ++index_z){
      bb_vis = exp(-pow(psd->z[index_z]/psd->z_th,2.5));

      /* 1) Calculate branching ratios using sharp_sharp transition */
      if (psd->sd_branching_approx == bra_sharp_sharp) {
        if (psd->z[index_z]>psd->z_th) {
          f_g = 1.;
          f_y = 0.;
          f_mu = 0.;
        }
        if (psd->z[index_z]<psd->z_th && psd->z[index_z]>psd->z_muy) {
          f_g = 0.;
          f_y = 0.;
          f_mu = 1.;
        }
        if (psd->z[index_z]<psd->z_muy) {
          f_g = 0.;
          f_y = 1.;
          f_mu = 0.;
        }
      }

      /* 2) Calculate branching ratios using sharp_soft transition */
      if (psd->sd_branching_approx == bra_sharp_soft) {
        f_g = 1.-bb_vis;
        if (psd->z[index_z]>psd->z_muy) {
          f_y = 0.;
          f_mu = bb_vis;
        }
        if (psd->z[index_z]<psd->z_muy) {
          f_y = 1.;
          f_mu = 0.;
        }
      }

      /* 3) Calculate branching ratios unsing soft_soft transitions */
      if (psd->sd_branching_approx == bra_soft_soft) {
        f_g = 1.-bb_vis;
        f_y = 1.0/(1.0+pow((1.0+psd->z[index_z])/(6.0e4),2.58));
        f_mu = bb_vis*(1.-exp(-pow((1.0+psd->z[index_z])/(5.8e4),1.88)));
      }

      /* 4) Calculate branching ratios unsing soft_soft_cons transitions */
      if (psd->sd_branching_approx == bra_soft_soft_cons) {
        f_g = 1.-bb_vis;
        f_y = 1.0/(1.0+pow((1.0+psd->z[index_z])/(6.0e4),2.58));
        f_mu = bb_vis*(1.-f_y);
      }

      psd->br_table[psd->index_type_g][index_z] = f_g;
      psd->br_table[psd->index_type_y][index_z] = f_y;
      psd->br_table[psd->index_type_mu][index_z] = f_mu;

    }
  }
  else {
    /* 5) Calculate branching ratios according to Chluba & Jeong 2014 */

    /* Read and spline data from file branching_ratios.dat */
    class_call(distortions_read_br_data(ppr,psd),
               psd->error_message,
               psd->error_message);
    class_call(distortions_spline_br_data(psd),
               psd->error_message,
               psd->error_message);

    /* Allocate local variable */
    class_alloc(f_E,
                psd->sd_PCA_size*sizeof(double),
                psd->error_message);

    /* Interpolate over z */
    for (index_z=0; index_z<psd->z_size; ++index_z){
      class_call(distortions_interpolate_br_data(psd,
                                                 psd->z[index_z],
                                                 &f_g,
                                                 &f_y,
                                                 &f_mu,
                                                 f_E,
                                                 &last_index),
                 psd->error_message,
                 psd->error_message);

      /* Store quantities in the table*/
      psd->br_table[psd->index_type_g][index_z] = f_g;
      psd->br_table[psd->index_type_y][index_z] = f_y;
      psd->br_table[psd->index_type_mu][index_z] = f_mu;
      for (index_k=0; index_k<psd->sd_PCA_size; ++index_k){
        psd->br_table[psd->index_type_PCA+index_k][index_z] = f_E[index_k];
      }

    }

    /* Free space allocated in distortions_read_br_data */
    class_call(distortions_free_br_data(psd),
               psd->error_message,
               psd->error_message);
    free(f_E);

  }

  return _SUCCESS_;
}

// Assembly:
subq $0x3888, %rsp           # imm = 0x3888
movq %rdi, 0x3878(%rsp)
movq %rsi, 0x3870(%rsp)
movl $0x0, 0x3834(%rsp)
movq 0x3870(%rsp), %rax
movslq 0xbf0(%rax), %rdi
shlq $0x3, %rdi
callq 0x8460
movq %rax, %rcx
movq 0x3870(%rsp), %rax
movq %rcx, 0xbc0(%rax)
movq 0x3870(%rsp), %rax
cmpq $0x0, 0xbc0(%rax)
jne 0x1909ad
movq 0x3870(%rsp), %rax
movslq 0xbf0(%rax), %rax
shlq $0x3, %rax
movl %eax, 0x3830(%rsp)
leaq 0x3030(%rsp), %rdi
movl 0x3830(%rsp), %ecx
leaq 0x416a6(%rip), %rsi     # 0x1d2004
leaq 0x7aa21(%rip), %rdx     # 0x20b386
movb $0x0, %al
callq 0x5b9c0
movq 0x3870(%rsp), %rdi
addq $0x1602, %rdi           # imm = 0x1602
leaq 0x3030(%rsp), %r8
leaq 0x416aa(%rip), %rsi     # 0x1d2034
leaq 0x7aa03(%rip), %rdx     # 0x20b394
movl $0x293, %ecx            # imm = 0x293
movb $0x0, %al
callq 0x5b9c0
movl $0x1, 0x3884(%rsp)
jmp 0x19144f
movl $0x0, 0x3868(%rsp)
movl 0x3868(%rsp), %eax
movq 0x3870(%rsp), %rcx
cmpl 0xbf0(%rcx), %eax
jge 0x190abe
movq 0x3870(%rsp), %rax
movslq 0x330(%rax), %rdi
shlq $0x3, %rdi
callq 0x8460
movq %rax, %rdx
movq 0x3870(%rsp), %rax
movq 0xbc0(%rax), %rax
movslq 0x3868(%rsp), %rcx
movq %rdx, (%rax,%rcx,8)
movq 0x3870(%rsp), %rax
movq 0xbc0(%rax), %rax
movslq 0x3868(%rsp), %rcx
cmpq $0x0, (%rax,%rcx,8)
jne 0x190aa6
movq 0x3870(%rsp), %rax
movslq 0x330(%rax), %rax
shlq $0x3, %rax
movl %eax, 0x302c(%rsp)
leaq 0x2820(%rsp), %rdi
movl 0x302c(%rsp), %ecx
leaq 0x415ad(%rip), %rsi     # 0x1d2004
leaq 0x7a95b(%rip), %rdx     # 0x20b3b9
movb $0x0, %al
callq 0x5b9c0
movq 0x3870(%rsp), %rdi
addq $0x1602, %rdi           # imm = 0x1602
leaq 0x2820(%rsp), %r8
leaq 0x415b1(%rip), %rsi     # 0x1d2034
leaq 0x7a90a(%rip), %rdx     # 0x20b394
movl $0x297, %ecx            # imm = 0x297
movb $0x0, %al
callq 0x5b9c0
movl $0x1, 0x3884(%rsp)
jmp 0x19144f
jmp 0x190aa8
movl 0x3868(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x3868(%rsp)
jmp 0x1909b8
movq 0x3870(%rsp), %rax
cmpl $0x4, (%rax)
je 0x190fef
movl $0x0, 0x386c(%rsp)
movl 0x386c(%rsp), %eax
movq 0x3870(%rsp), %rcx
cmpl 0x330(%rcx), %eax
jge 0x190fea
movq 0x3870(%rsp), %rax
movq 0x340(%rax), %rax
movslq 0x386c(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq 0x3870(%rsp), %rax
divsd 0x318(%rax), %xmm0
movsd 0x417ff(%rip), %xmm1    # 0x1d2328
callq 0x8610
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
callq 0x8670
movsd %xmm0, 0x3838(%rsp)
movq 0x3870(%rsp), %rax
cmpl $0x0, (%rax)
jne 0x190ca1
movq 0x3870(%rsp), %rax
movq 0x340(%rax), %rax
movslq 0x386c(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq 0x3870(%rsp), %rax
ucomisd 0x318(%rax), %xmm0
jbe 0x190bbb
movsd 0x416ae(%rip), %xmm0    # 0x1d2248
movsd %xmm0, 0x3858(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, 0x3850(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, 0x3848(%rsp)
movq 0x3870(%rsp), %rax
movq 0x340(%rax), %rax
movslq 0x386c(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm1
movq 0x3870(%rsp), %rax
movsd 0x318(%rax), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x190c44
movq 0x3870(%rsp), %rax
movq 0x340(%rax), %rax
movslq 0x386c(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq 0x3870(%rsp), %rax
ucomisd 0x310(%rax), %xmm0
jbe 0x190c44
xorps %xmm0, %xmm0
movsd %xmm0, 0x3858(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, 0x3850(%rsp)
movsd 0x4160d(%rip), %xmm0    # 0x1d2248
movsd %xmm0, 0x3848(%rsp)
movq 0x3870(%rsp), %rax
movq 0x340(%rax), %rax
movslq 0x386c(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm1
movq 0x3870(%rsp), %rax
movsd 0x310(%rax), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x190c9f
xorps %xmm0, %xmm0
movsd %xmm0, 0x3858(%rsp)
movsd 0x415be(%rip), %xmm0    # 0x1d2248
movsd %xmm0, 0x3850(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, 0x3848(%rsp)
jmp 0x190ca1
movq 0x3870(%rsp), %rax
cmpl $0x1, (%rax)
jne 0x190d69
movsd 0x4158e(%rip), %xmm0    # 0x1d2248
subsd 0x3838(%rsp), %xmm0
movsd %xmm0, 0x3858(%rsp)
movq 0x3870(%rsp), %rax
movq 0x340(%rax), %rax
movslq 0x386c(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq 0x3870(%rsp), %rax
ucomisd 0x310(%rax), %xmm0
jbe 0x190d18
xorps %xmm0, %xmm0
movsd %xmm0, 0x3850(%rsp)
movsd 0x3838(%rsp), %xmm0
movsd %xmm0, 0x3848(%rsp)
movq 0x3870(%rsp), %rax
movq 0x340(%rax), %rax
movslq 0x386c(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm1
movq 0x3870(%rsp), %rax
movsd 0x310(%rax), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x190d67
movsd 0x414f6(%rip), %xmm0    # 0x1d2248
movsd %xmm0, 0x3850(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, 0x3848(%rsp)
jmp 0x190d69
movq 0x3870(%rsp), %rax
cmpl $0x2, (%rax)
jne 0x190e7c
movsd 0x414c6(%rip), %xmm0    # 0x1d2248
subsd 0x3838(%rsp), %xmm0
movsd %xmm0, 0x3858(%rsp)
movq 0x3870(%rsp), %rax
movq 0x340(%rax), %rax
movslq 0x386c(%rsp), %rcx
movsd 0x41495(%rip), %xmm0    # 0x1d2248
addsd (%rax,%rcx,8), %xmm0
movsd 0x79560(%rip), %xmm1    # 0x20a320
divsd %xmm1, %xmm0
movsd 0x7954c(%rip), %xmm1    # 0x20a318
callq 0x8610
movsd 0x4146f(%rip), %xmm1    # 0x1d2248
addsd %xmm0, %xmm1
movsd 0x41463(%rip), %xmm0    # 0x1d2248
divsd %xmm1, %xmm0
movsd %xmm0, 0x3850(%rsp)
movsd 0x3838(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
movq 0x3870(%rsp), %rax
movq 0x340(%rax), %rax
movslq 0x386c(%rsp), %rcx
movsd 0x41428(%rip), %xmm0    # 0x1d2248
addsd (%rax,%rcx,8), %xmm0
movsd 0x794e3(%rip), %xmm1    # 0x20a310
divsd %xmm1, %xmm0
movsd 0x794cf(%rip), %xmm1    # 0x20a308
callq 0x8610
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
callq 0x8670
movaps %xmm0, %xmm2
movsd 0x8(%rsp), %xmm0
movsd 0x413dd(%rip), %xmm1    # 0x1d2248
subsd %xmm2, %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, 0x3848(%rsp)
movq 0x3870(%rsp), %rax
cmpl $0x3, (%rax)
jne 0x190f2c
movsd 0x413b3(%rip), %xmm0    # 0x1d2248
subsd 0x3838(%rsp), %xmm0
movsd %xmm0, 0x3858(%rsp)
movq 0x3870(%rsp), %rax
movq 0x340(%rax), %rax
movslq 0x386c(%rsp), %rcx
movsd 0x41382(%rip), %xmm0    # 0x1d2248
addsd (%rax,%rcx,8), %xmm0
movsd 0x7944d(%rip), %xmm1    # 0x20a320
divsd %xmm1, %xmm0
movsd 0x79439(%rip), %xmm1    # 0x20a318
callq 0x8610
movsd 0x4135c(%rip), %xmm1    # 0x1d2248
addsd %xmm0, %xmm1
movsd 0x41350(%rip), %xmm0    # 0x1d2248
divsd %xmm1, %xmm0
movsd %xmm0, 0x3850(%rsp)
movsd 0x3838(%rsp), %xmm0
movsd 0x41332(%rip), %xmm1    # 0x1d2248
subsd 0x3850(%rsp), %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, 0x3848(%rsp)
movsd 0x3858(%rsp), %xmm0
movq 0x3870(%rsp), %rax
movq 0xbc0(%rax), %rax
movq 0x3870(%rsp), %rcx
movslq 0xbe0(%rcx), %rcx
movq (%rax,%rcx,8), %rax
movslq 0x386c(%rsp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movsd 0x3850(%rsp), %xmm0
movq 0x3870(%rsp), %rax
movq 0xbc0(%rax), %rax
movq 0x3870(%rsp), %rcx
movslq 0xbe8(%rcx), %rcx
movq (%rax,%rcx,8), %rax
movslq 0x386c(%rsp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movsd 0x3848(%rsp), %xmm0
movq 0x3870(%rsp), %rax
movq 0xbc0(%rax), %rax
movq 0x3870(%rsp), %rcx
movslq 0xbe4(%rcx), %rcx
movq (%rax,%rcx,8), %rax
movslq 0x386c(%rsp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl 0x386c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x386c(%rsp)
jmp 0x190ada
jmp 0x191444
movq 0x3878(%rsp), %rdi
movq 0x3870(%rsp), %rsi
callq 0x194340
cmpl $0x1, %eax
jne 0x191076
leaq 0x2020(%rsp), %rdi
movq 0x3870(%rsp), %rcx
addq $0x1602, %rcx           # imm = 0x1602
leaq 0x413b1(%rip), %rsi     # 0x1d23d8
leaq 0x7a3a5(%rip), %rdx     # 0x20b3d3
movb $0x0, %al
callq 0x5b9c0
movq 0x3870(%rsp), %rdi
addq $0x1602, %rdi           # imm = 0x1602
leaq 0x2020(%rsp), %r8
leaq 0x40fe1(%rip), %rsi     # 0x1d2034
leaq 0x7a33a(%rip), %rdx     # 0x20b394
movl $0x2d9, %ecx            # imm = 0x2D9
movb $0x0, %al
callq 0x5b9c0
movl $0x1, 0x3884(%rsp)
jmp 0x19144f
movq 0x3870(%rsp), %rdi
callq 0x194e60
cmpl $0x1, %eax
jne 0x1910f5
leaq 0x1820(%rsp), %rdi
movq 0x3870(%rsp), %rcx
addq $0x1602, %rcx           # imm = 0x1602
leaq 0x41332(%rip), %rsi     # 0x1d23d8
leaq 0x7a348(%rip), %rdx     # 0x20b3f5
movb $0x0, %al
callq 0x5b9c0
movq 0x3870(%rsp), %rdi
addq $0x1602, %rdi           # imm = 0x1602
leaq 0x1820(%rsp), %r8
leaq 0x40f62(%rip), %rsi     # 0x1d2034
leaq 0x7a2bb(%rip), %rdx     # 0x20b394
movl $0x2dc, %ecx            # imm = 0x2DC
movb $0x0, %al
callq 0x5b9c0
movl $0x1, 0x3884(%rsp)
jmp 0x19144f
movq 0x3870(%rsp), %rax
movslq 0x4(%rax), %rdi
shlq $0x3, %rdi
callq 0x8460
movq %rax, 0x3840(%rsp)
cmpq $0x0, 0x3840(%rsp)
jne 0x191199
movq 0x3870(%rsp), %rax
movslq 0x4(%rax), %rax
shlq $0x3, %rax
movl %eax, 0x181c(%rsp)
leaq 0x1010(%rsp), %rdi
movl 0x181c(%rsp), %ecx
leaq 0x40eba(%rip), %rsi     # 0x1d2004
leaq 0x7a2c4(%rip), %rdx     # 0x20b415
movb $0x0, %al
callq 0x5b9c0
movq 0x3870(%rsp), %rdi
addq $0x1602, %rdi           # imm = 0x1602
leaq 0x1010(%rsp), %r8
leaq 0x40ebe(%rip), %rsi     # 0x1d2034
leaq 0x7a217(%rip), %rdx     # 0x20b394
movl $0x2e1, %ecx            # imm = 0x2E1
movb $0x0, %al
callq 0x5b9c0
movl $0x1, 0x3884(%rsp)
jmp 0x19144f
movl $0x0, 0x386c(%rsp)
movl 0x386c(%rsp), %eax
movq 0x3870(%rsp), %rcx
cmpl 0x330(%rcx), %eax
jge 0x1913c1
movq 0x3870(%rsp), %rdi
movq 0x3870(%rsp), %rax
movq 0x340(%rax), %rax
movslq 0x386c(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq 0x3840(%rsp), %r8
leaq 0x3858(%rsp), %rsi
leaq 0x3850(%rsp), %rdx
leaq 0x3848(%rsp), %rcx
leaq 0x3834(%rsp), %r9
callq 0x1954d0
cmpl $0x1, %eax
jne 0x191282
leaq 0x810(%rsp), %rdi
movq 0x3870(%rsp), %rcx
addq $0x1602, %rcx           # imm = 0x1602
leaq 0x411a5(%rip), %rsi     # 0x1d23d8
leaq 0x7a1df(%rip), %rdx     # 0x20b419
movb $0x0, %al
callq 0x5b9c0
movq 0x3870(%rsp), %rdi
addq $0x1602, %rdi           # imm = 0x1602
leaq 0x810(%rsp), %r8
leaq 0x40dd5(%rip), %rsi     # 0x1d2034
leaq 0x7a12e(%rip), %rdx     # 0x20b394
movl $0x2ed, %ecx            # imm = 0x2ED
movb $0x0, %al
callq 0x5b9c0
movl $0x1, 0x3884(%rsp)
jmp 0x19144f
movsd 0x3858(%rsp), %xmm0
movq 0x3870(%rsp), %rax
movq 0xbc0(%rax), %rax
movq 0x3870(%rsp), %rcx
movslq 0xbe0(%rcx), %rcx
movq (%rax,%rcx,8), %rax
movslq 0x386c(%rsp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movsd 0x3850(%rsp), %xmm0
movq 0x3870(%rsp), %rax
movq 0xbc0(%rax), %rax
movq 0x3870(%rsp), %rcx
movslq 0xbe8(%rcx), %rcx
movq (%rax,%rcx,8), %rax
movslq 0x386c(%rsp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movsd 0x3848(%rsp), %xmm0
movq 0x3870(%rsp), %rax
movq 0xbc0(%rax), %rax
movq 0x3870(%rsp), %rcx
movslq 0xbe4(%rcx), %rcx
movq (%rax,%rcx,8), %rax
movslq 0x386c(%rsp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl $0x0, 0x3864(%rsp)
movl 0x3864(%rsp), %eax
movq 0x3870(%rsp), %rcx
cmpl 0x4(%rcx), %eax
jge 0x1913a9
movq 0x3840(%rsp), %rax
movslq 0x3864(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq 0x3870(%rsp), %rax
movq 0xbc0(%rax), %rax
movq 0x3870(%rsp), %rcx
movl 0xbec(%rcx), %ecx
addl 0x3864(%rsp), %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movslq 0x386c(%rsp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl 0x3864(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x3864(%rsp)
jmp 0x191335
jmp 0x1913ab
movl 0x386c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x386c(%rsp)
jmp 0x1911a4
movq 0x3870(%rsp), %rdi
callq 0x195c40
cmpl $0x1, %eax
jne 0x191437
leaq 0x10(%rsp), %rdi
movq 0x3870(%rsp), %rcx
addq $0x1602, %rcx           # imm = 0x1602
leaq 0x40fea(%rip), %rsi     # 0x1d23d8
leaq 0x7a07f(%rip), %rdx     # 0x20b474
movb $0x0, %al
callq 0x5b9c0
movq 0x3870(%rsp), %rdi
addq $0x1602, %rdi           # imm = 0x1602
leaq 0x10(%rsp), %r8
leaq 0x40c1d(%rip), %rsi     # 0x1d2034
leaq 0x79f76(%rip), %rdx     # 0x20b394
movl $0x2fc, %ecx            # imm = 0x2FC
movb $0x0, %al
callq 0x5b9c0
movl $0x1, 0x3884(%rsp)
jmp 0x19144f
movq 0x3840(%rsp), %rdi
callq 0x8420
movl $0x0, 0x3884(%rsp)
movl 0x3884(%rsp), %eax
addq $0x3888, %rsp           # imm = 0x3888
retq
nop