// File: /workspace/github_c_makefile_star2_O2/PoulinV[P]AxiCLASS/build/../external/HyRec2020/hydrogen.c
// Function: populate_Diffusion
void populate_Diffusion(double *Aup, double *Adn, double *A2p_up, double *A2p_dn,
                        double TM, double Eb_tab[NVIRT], double A1s_tab[NVIRT]) {

  unsigned b;
  double DE2;

  DE2 = E21*E21*2.*TM/mH;

 /****** RED WING ******/
  b = NSUBLYA - NDIFF/2;
  Aup[b] = DE2 / square(Eb_tab[b+1] - Eb_tab[b]) * A1s_tab[b];    /* A{0,1}. Assume A{0,-1} = 0 */

  for (b = NSUBLYA - NDIFF/2 + 1; b < NSUBLYA-1; b++) {
    Adn[b] = exp((Eb_tab[b] - Eb_tab[b-1])/TM) * Aup[b-1];                      /* Detailed balance */
    Aup[b] = (DE2 * A1s_tab[b] - square(Eb_tab[b] - Eb_tab[b-1]) * Adn[b])
                    /square(Eb_tab[b+1] - Eb_tab[b]);        /* Aup[b] , Adn[b] must add up to correct diffusion rate */
  }
  /* Last bin below Lyman alpha */
  b = NSUBLYA - 1;
  Adn[b] = exp((Eb_tab[b] - Eb_tab[b-1])/TM) * Aup[b-1];

  Aup[b] = (DE2 * A1s_tab[b] - square(Eb_tab[b] - Eb_tab[b-1]) * Adn[b])
                  /square(E21 - Eb_tab[b]);
  *A2p_dn = exp((E21 - Eb_tab[b])/TM)/3.* Aup[b];   /* 2p -> NSUBLYA-1 rate obtained by detailed balance */


  /****** BLUE WING ******/
  b = NSUBLYA + NDIFF/2 - 1;
  Adn[b] = DE2 / square(Eb_tab[b] - Eb_tab[b-1]) * A1s_tab[b];

  for (b = NSUBLYA + NDIFF/2 - 2; b > NSUBLYA; b--) {
    Aup[b] = exp((Eb_tab[b] - Eb_tab[b+1])/TM) * Adn[b+1];
    Adn[b] = (DE2 * A1s_tab[b] - square(Eb_tab[b+1] - Eb_tab[b]) * Aup[b])
                /square(Eb_tab[b] - Eb_tab[b-1]);
  }
  /* First bin above Lyman alpha */
  b = NSUBLYA;
  Aup[b] = exp((Eb_tab[b] - Eb_tab[b+1])/TM) * Adn[b+1];

  Adn[b] = (DE2 * A1s_tab[b] - square(Eb_tab[b+1] - Eb_tab[b]) * Aup[b])
               /square(Eb_tab[b] - E21);
  *A2p_up = exp((E21 - Eb_tab[b])/TM)/3. * Adn[b];   /* 2p -> NSUBLYA rate obtained by detailed balance */

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %r9, %r12
movq %r8, %r15
movq %rcx, %rbp
movq %rdx, 0x20(%rsp)
movq %rsi, %r14
movsd 0x5281b(%rip), %xmm1    # 0x121268
movsd %xmm0, 0x18(%rsp)
mulsd %xmm0, %xmm1
divsd 0x52811(%rip), %xmm1    # 0x121270
movsd %xmm1, 0x10(%rsp)
movq %rdi, %r13
movsd 0x328(%r8), %xmm0
subsd 0x320(%r8), %xmm0
callq 0xcbe48
movsd 0x10(%rsp), %xmm1
divsd %xmm0, %xmm1
mulsd 0x320(%r12), %xmm1
movsd %xmm1, 0x320(%r13)
xorl %ebx, %ebx
cmpq $0x130, %rbx            # imm = 0x130
je 0xceb5d
movsd 0x328(%r15,%rbx), %xmm0
subsd 0x320(%r15,%rbx), %xmm0
divsd 0x18(%rsp), %xmm0
callq 0x86a0
mulsd 0x320(%r13,%rbx), %xmm0
movsd %xmm0, 0x328(%r14,%rbx)
movsd 0x328(%r15,%rbx), %xmm0
subsd 0x320(%r15,%rbx), %xmm0
movsd 0x328(%r12,%rbx), %xmm1
mulsd 0x10(%rsp), %xmm1
movsd %xmm1, 0x8(%rsp)
callq 0xcbe48
mulsd 0x328(%r14,%rbx), %xmm0
movsd 0x8(%rsp), %xmm1
subsd %xmm0, %xmm1
movsd %xmm1, 0x8(%rsp)
movsd 0x330(%r15,%rbx), %xmm0
subsd 0x328(%r15,%rbx), %xmm0
callq 0xcbe48
movsd 0x8(%rsp), %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, 0x328(%r13,%rbx)
addq $0x8, %rbx
jmp 0xcea9e
movsd 0x458(%r15), %xmm0
subsd 0x450(%r15), %xmm0
divsd 0x18(%rsp), %xmm0
callq 0x86a0
mulsd 0x450(%r13), %xmm0
movsd %xmm0, 0x458(%r14)
movsd 0x458(%r15), %xmm0
subsd 0x450(%r15), %xmm0
movsd 0x458(%r12), %xmm1
mulsd 0x10(%rsp), %xmm1
movsd %xmm1, 0x8(%rsp)
callq 0xcbe48
mulsd 0x458(%r14), %xmm0
movsd 0x8(%rsp), %xmm1
subsd %xmm0, %xmm1
movsd %xmm1, 0x8(%rsp)
movsd 0x5269e(%rip), %xmm0    # 0x121278
subsd 0x458(%r15), %xmm0
callq 0xcbe48
movsd 0x8(%rsp), %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, 0x458(%r13)
movsd 0x52675(%rip), %xmm0    # 0x121278
subsd 0x458(%r15), %xmm0
divsd 0x18(%rsp), %xmm0
callq 0x86a0
divsd 0x17b29(%rip), %xmm0    # 0xe6748
mulsd 0x458(%r13), %xmm0
movsd %xmm0, (%rbp)
movsd 0x598(%r15), %xmm0
subsd 0x590(%r15), %xmm0
callq 0xcbe48
movsd 0x10(%rsp), %xmm1
divsd %xmm0, %xmm1
mulsd 0x598(%r12), %xmm1
movsd %xmm1, 0x598(%r14)
xorl %ebp, %ebp
leaq 0xb2(%rbp), %rax
cmpq $0x8d, %rax
jb 0xced27
movsd 0x590(%r15,%rbp,8), %xmm0
subsd 0x598(%r15,%rbp,8), %xmm0
divsd 0x18(%rsp), %xmm0
callq 0x86a0
mulsd 0x598(%r14,%rbp,8), %xmm0
movsd %xmm0, 0x590(%r13,%rbp,8)
movsd 0x598(%r15,%rbp,8), %xmm0
subsd 0x590(%r15,%rbp,8), %xmm0
movsd 0x590(%r12,%rbp,8), %xmm1
mulsd 0x10(%rsp), %xmm1
movsd %xmm1, 0x8(%rsp)
callq 0xcbe48
mulsd 0x590(%r13,%rbp,8), %xmm0
movsd 0x8(%rsp), %xmm1
subsd %xmm0, %xmm1
movsd %xmm1, 0x8(%rsp)
movsd 0x590(%r15,%rbp,8), %xmm0
subsd 0x588(%r15,%rbp,8), %xmm0
callq 0xcbe48
movsd 0x8(%rsp), %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, 0x590(%r14,%rbp,8)
decq %rbp
jmp 0xcec63
movsd 0x460(%r15), %xmm0
subsd 0x468(%r15), %xmm0
divsd 0x18(%rsp), %xmm0
callq 0x86a0
mulsd 0x468(%r14), %xmm0
movsd %xmm0, 0x460(%r13)
movsd 0x468(%r15), %xmm0
subsd 0x460(%r15), %xmm0
movsd 0x10(%rsp), %xmm1
mulsd 0x460(%r12), %xmm1
movsd %xmm1, 0x10(%rsp)
callq 0xcbe48
mulsd 0x460(%r13), %xmm0
movsd 0x10(%rsp), %xmm1
subsd %xmm0, %xmm1
movsd %xmm1, 0x10(%rsp)
movsd 0x460(%r15), %xmm0
addsd 0x524d3(%rip), %xmm0    # 0x121280
callq 0xcbe48
movsd 0x10(%rsp), %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, 0x460(%r14)
movsd 0x524ab(%rip), %xmm0    # 0x121278
subsd 0x460(%r15), %xmm0
divsd 0x18(%rsp), %xmm0
callq 0x86a0
divsd 0x1795f(%rip), %xmm0    # 0xe6748
mulsd 0x460(%r14), %xmm0
movq 0x20(%rsp), %rax
movsd %xmm0, (%rax)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq