// File: /workspace/github_c_makefile_star2_O3/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 0x53cf1(%rip), %xmm1    # 0x12a3c8
movsd %xmm0, 0x18(%rsp)
mulsd %xmm0, %xmm1
divsd 0x53ce7(%rip), %xmm1    # 0x12a3d0
movsd %xmm1, 0x10(%rsp)
movq %rdi, %r13
movsd 0x328(%r8), %xmm0
subsd 0x320(%r8), %xmm0
callq 0xd3754
movsd 0x10(%rsp), %xmm1
divsd %xmm0, %xmm1
mulsd 0x320(%r12), %xmm1
movsd %xmm1, 0x320(%r13)
xorl %ebx, %ebx
movsd 0x328(%r15,%rbx), %xmm0
subsd 0x320(%r15,%rbx), %xmm0
divsd 0x18(%rsp), %xmm0
callq 0x8670
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 0xd3754
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 0xd3754
movsd 0x8(%rsp), %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, 0x328(%r13,%rbx)
addq $0x8, %rbx
cmpq $0x130, %rbx            # imm = 0x130
jne 0xd6728
movsd 0x458(%r15), %xmm0
subsd 0x450(%r15), %xmm0
divsd 0x18(%rsp), %xmm0
callq 0x8670
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 0xd3754
mulsd 0x458(%r14), %xmm0
movsd 0x8(%rsp), %xmm1
subsd %xmm0, %xmm1
movsd %xmm1, 0x8(%rsp)
movsd 0x53b79(%rip), %xmm0    # 0x12a3d8
subsd 0x458(%r15), %xmm0
callq 0xd3754
movsd 0x8(%rsp), %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, 0x458(%r13)
movsd 0x53b50(%rip), %xmm0    # 0x12a3d8
subsd 0x458(%r15), %xmm0
divsd 0x18(%rsp), %xmm0
callq 0x8670
divsd 0x18ddc(%rip), %xmm0    # 0xef680
mulsd 0x458(%r13), %xmm0
movsd %xmm0, (%rbp)
movsd 0x598(%r15), %xmm0
subsd 0x590(%r15), %xmm0
callq 0xd3754
movsd 0x10(%rsp), %xmm1
divsd %xmm0, %xmm1
mulsd 0x598(%r12), %xmm1
movsd %xmm1, 0x598(%r14)
xorl %ebx, %ebx
movsd 0x590(%r15,%rbx,8), %xmm0
subsd 0x598(%r15,%rbx,8), %xmm0
divsd 0x18(%rsp), %xmm0
callq 0x8670
mulsd 0x598(%r14,%rbx,8), %xmm0
movsd %xmm0, 0x590(%r13,%rbx,8)
movsd 0x598(%r15,%rbx,8), %xmm0
subsd 0x590(%r15,%rbx,8), %xmm0
movsd 0x590(%r12,%rbx,8), %xmm1
mulsd 0x10(%rsp), %xmm1
movsd %xmm1, 0x8(%rsp)
callq 0xd3754
mulsd 0x590(%r13,%rbx,8), %xmm0
movsd 0x8(%rsp), %xmm1
subsd %xmm0, %xmm1
movsd %xmm1, 0x8(%rsp)
movsd 0x590(%r15,%rbx,8), %xmm0
subsd 0x588(%r15,%rbx,8), %xmm0
callq 0xd3754
movsd 0x8(%rsp), %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, 0x590(%r14,%rbx,8)
leaq -0x1(%rbx), %rax
addq $0xb1, %rbx
cmpq $0x8c, %rbx
movq %rax, %rbx
ja 0xd68e8
movsd 0x460(%r15), %xmm0
subsd 0x468(%r15), %xmm0
divsd 0x18(%rsp), %xmm0
callq 0x8670
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 0xd3754
mulsd 0x460(%r13), %xmm0
movsd 0x10(%rsp), %xmm1
subsd %xmm0, %xmm1
movsd %xmm1, 0x10(%rsp)
movsd 0x460(%r15), %xmm0
addsd 0x539ae(%rip), %xmm0    # 0x12a3e0
callq 0xd3754
movsd 0x10(%rsp), %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, 0x460(%r14)
movsd 0x53986(%rip), %xmm0    # 0x12a3d8
subsd 0x460(%r15), %xmm0
divsd 0x18(%rsp), %xmm0
callq 0x8670
divsd 0x18c12(%rip), %xmm0    # 0xef680
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