// File: /workspace/github_cpp_makefile_star2_O3/Cell-veto[P]postlhc/jellium3.cpp
// Function: double Jellium3::lr_event_rate<2ul>(std::array<double, 2ul> const&, unsigned int)
double lr_event_rate (const vector <DIM> &r_, unsigned direction)
    {
        const double L = period[direction];
        const vector <DIM> shift = unit_vector <DIM> (direction) * (L/2);

        // assign polar pair partner
        const double x_prim = r_[direction];
        const double x_pair = x_prim - 2*L * floor (x_prim/L) - L;

        bool first_copy = fabs (x_prim - x_pair) < 2*L;
        vector <DIM> r[2] = { r_, r_ };
        if (x_prim >= 0.)
            r[0][direction] = x_pair;
        else
            r[1][direction] = x_pair;
        double rsq[2] = { norm_sq (r[0]), norm_sq (r[1]) };

        assert (r[0][direction] < 0.);
        assert (r[1][direction] >= 0.);

        // compute the rate for the polar pair
        double rate = 0.;

        // for large distances, the naive formula for the event rate can be
        // numerically problematic.
        if (fmax (rsq[0], rsq[1]) < 1e6*L*L)
        {
            for (int i = 0; i != 2; ++i)
            {
                double x = r[i][direction];

                double u_rp = (i==0 && first_copy)
                    ? 0.
                    : unit_potential (r[i] + shift);
                double u_rm = (i==1 && first_copy)
                    ? 0.
                    : unit_potential (r[i] - shift);

                rate += (u_rp-u_rm) / L;

                // main charge -- parts smaller than sr_lr_split are handled by the SR code
                if (rsq[i] > sq (sr_lr_split))
                    rate += unit_directional_derivative (x, rsq[i]);
            }
        }
        else if (fmax (rsq[0], rsq[1]) < 1e20*L*L)
        {
            for (int i = 0; i != 2; ++i)
            {
                double x = r[i][direction];
                // avoid catastrophic cancellation in the far field
                // (valid also for exponent = 0)
                rate += x * pow (rsq[i], -.5*6. -.5*exponent) * L*L
                    * (2+exponent) * (1./24) * (3.*rsq[i] - (4+exponent)*x*x);
            }
        }
        else
        {
            // rate < numerical precision
        }

        // asymptotic decay of particle event rate is ~ 1 / r^(n+4).
        double w = (r[0][direction] == r_[direction])
            ? norm_sq (r[1]) / norm_sq (r[0])
            : norm_sq (r[0]) / norm_sq (r[1]);

        rate /= 1 + pow (w, -.5 * (exponent+4.));

        if (rate <= 0.)
            return 0.;
        else
            return stren * rate;
    }

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc0, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movl %edx, %r15d
movsd 0x20(%rdi,%r15,8), %xmm1
movsd %xmm1, 0x8(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
movq %rax, 0x30(%rsp,%r15,8)
movsd 0x1ba5b5(%rip), %xmm0   # 0x5ca0f0
mulsd %xmm1, %xmm0
unpcklpd %xmm0, %xmm0            # xmm0 = xmm0[0,0]
mulpd 0x30(%rsp), %xmm0
movapd %xmm0, 0x90(%rsp)
movsd (%rsi,%r15,8), %xmm2
movapd %xmm2, 0x70(%rsp)
movapd %xmm1, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x50(%rsp)
movapd %xmm2, %xmm0
divsd %xmm1, %xmm0
callq 0x401140
movsd 0x8(%rsp), %xmm4
mulsd 0x50(%rsp), %xmm0
movapd 0x70(%rsp), %xmm2
movapd %xmm2, %xmm1
subsd %xmm0, %xmm1
subsd %xmm4, %xmm1
movups (%r14), %xmm0
movaps %xmm0, 0x30(%rsp)
movupd (%r14), %xmm0
movapd %xmm0, 0x40(%rsp)
xorpd %xmm0, %xmm0
movapd %xmm2, %xmm7
ucomisd %xmm0, %xmm2
jae 0x40fbc9
movsd %xmm1, 0x40(%rsp,%r15,8)
movsd 0x30(%rsp,%r15,8), %xmm5
jmp 0x40fbd4
movsd %xmm1, 0x30(%rsp,%r15,8)
movapd %xmm1, %xmm5
movapd 0x30(%rsp), %xmm0
movupd 0x38(%rsp), %xmm2
movhpd 0x40(%rsp), %xmm0       # xmm0 = xmm0[0],mem[0]
mulpd %xmm0, %xmm0
movhpd 0x48(%rsp), %xmm2       # xmm2 = xmm2[0],mem[0]
mulpd %xmm2, %xmm2
addpd %xmm0, %xmm2
movapd %xmm2, 0x80(%rsp)
movapd %xmm2, 0xa0(%rsp)
xorpd %xmm0, %xmm0
ucomisd %xmm5, %xmm0
jbe 0x40ffae
movsd 0x40(%rsp,%r15,8), %xmm2
ucomisd %xmm0, %xmm2
jb 0x40ffcd
leaq (%rsp,%r15,8), %r12
addq $0x30, %r12
movapd 0x80(%rsp), %xmm6
movapd %xmm6, %xmm3
unpckhpd %xmm6, %xmm3            # xmm3 = xmm3[1],xmm6[1]
movapd %xmm6, %xmm0
cmpunordsd %xmm6, %xmm0
movapd %xmm0, %xmm2
andpd %xmm3, %xmm2
movapd %xmm3, 0xb0(%rsp)
maxsd %xmm6, %xmm3
andnpd %xmm3, %xmm0
orpd %xmm2, %xmm0
movsd 0x1ba470(%rip), %xmm2   # 0x5ca0e0
mulsd %xmm4, %xmm2
mulsd %xmm4, %xmm2
ucomisd %xmm0, %xmm2
movapd %xmm5, 0x60(%rsp)
jbe 0x40fe42
subsd %xmm1, %xmm7
andpd 0x1ba3cc(%rip), %xmm7   # 0x5ca060
movapd %xmm7, 0x70(%rsp)
xorl %r13d, %r13d
xorpd %xmm2, %xmm2
movsd (%r12,%r13,2), %xmm0
movsd %xmm0, 0x58(%rsp)
testq %r13, %r13
movapd %xmm2, 0x10(%rsp)
jne 0x40fd14
movsd 0x50(%rsp), %xmm0
ucomisd 0x70(%rsp), %xmm0
xorpd %xmm4, %xmm4
jbe 0x40fd14
movsd %xmm4, 0x28(%rsp)
movapd 0x30(%rsp,%r13,2), %xmm1
subpd 0x90(%rsp), %xmm1
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
movsd 0x10(%rbx), %xmm1
ucomisd 0x1ba427(%rip), %xmm1   # 0x5ca128
jne 0x40fd5c
jp 0x40fd5c
callq 0x4ecf00
mulsd 0x1ba48e(%rip), %xmm0   # 0x5ca1a0
jmp 0x40fd6e
movapd 0x30(%rsp,%r13,2), %xmm1
addpd 0x90(%rsp), %xmm1
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
movsd 0x10(%rbx), %xmm1
ucomisd 0x1ba3e3(%rip), %xmm1   # 0x5ca128
jne 0x40fd88
jp 0x40fd88
callq 0x4ecf00
movapd %xmm0, %xmm4
mulsd 0x1ba446(%rip), %xmm4   # 0x5ca1a0
jmp 0x40fd9e
mulsd 0x1ba43c(%rip), %xmm1   # 0x5ca1a0
callq 0x4ecf40
divsd 0x10(%rbx), %xmm0
movsd 0x8(%rsp), %xmm1
movapd 0x60(%rsp), %xmm5
movapd 0x10(%rsp), %xmm2
movsd 0x28(%rsp), %xmm4
jmp 0x40fdd0
mulsd 0x1ba410(%rip), %xmm1   # 0x5ca1a0
callq 0x4ecf40
movapd %xmm0, %xmm4
divsd 0x10(%rbx), %xmm4
cmpq $0x8, %r13
movsd 0x8(%rsp), %xmm1
movapd 0x60(%rsp), %xmm5
movapd 0x10(%rsp), %xmm2
jne 0x40fcca
xorpd %xmm0, %xmm0
movsd 0x50(%rsp), %xmm3
ucomisd 0x70(%rsp), %xmm3
jbe 0x40fcca
subsd %xmm0, %xmm4
divsd %xmm1, %xmm4
addsd %xmm4, %xmm2
movsd 0xa0(%rsp,%r13), %xmm0
movsd 0x18(%rbx), %xmm1
mulsd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x40fe2f
movsd 0x10(%rbx), %xmm1
addsd 0x1ba3ae(%rip), %xmm1   # 0x5ca1b0
mulsd 0x1ba396(%rip), %xmm1   # 0x5ca1a0
movapd %xmm2, 0x10(%rsp)
callq 0x4ecf40
movapd 0x10(%rsp), %xmm2
movapd 0x60(%rsp), %xmm5
movsd 0x58(%rsp), %xmm1
mulsd %xmm0, %xmm1
addsd %xmm1, %xmm2
addq $0x8, %r13
cmpq $0x10, %r13
jne 0x40fca1
jmp 0x40ff1c
movsd 0x1ba2ae(%rip), %xmm1   # 0x5ca0f8
mulsd %xmm4, %xmm1
mulsd %xmm4, %xmm1
xorpd %xmm2, %xmm2
ucomisd %xmm0, %xmm1
jbe 0x40ff1c
movsd 0x10(%rbx), %xmm1
xorl %r13d, %r13d
movapd %xmm2, 0x10(%rsp)
movsd (%r12,%r13,2), %xmm0
movsd %xmm0, 0x28(%rsp)
movsd 0xa0(%rsp,%r13), %xmm0
movsd %xmm0, 0x58(%rsp)
mulsd 0x1ba30e(%rip), %xmm1   # 0x5ca1a0
addsd 0x1ba30e(%rip), %xmm1   # 0x5ca1a8
callq 0x4ecf40
movapd 0x60(%rsp), %xmm5
movsd 0x8(%rsp), %xmm1
movsd 0x28(%rsp), %xmm3
mulsd %xmm3, %xmm0
mulsd %xmm1, %xmm0
mulsd %xmm1, %xmm0
movsd 0x10(%rbx), %xmm1
movapd %xmm1, %xmm2
addsd 0x1ba2e2(%rip), %xmm2   # 0x5ca1b0
mulsd %xmm0, %xmm2
mulsd 0x1ba2de(%rip), %xmm2   # 0x5ca1b8
movapd %xmm1, %xmm0
addsd 0x1ba2da(%rip), %xmm0   # 0x5ca1c0
mulsd %xmm3, %xmm0
mulsd %xmm3, %xmm0
movsd 0x58(%rsp), %xmm3
mulsd 0x1ba254(%rip), %xmm3   # 0x5ca150
subsd %xmm0, %xmm3
mulsd %xmm2, %xmm3
movapd 0x10(%rsp), %xmm2
addsd %xmm3, %xmm2
addq $0x8, %r13
cmpq $0x10, %r13
jne 0x40fe68
movapd %xmm2, 0x10(%rsp)
movapd 0xb0(%rsp), %xmm2
movapd %xmm2, %xmm0
movapd 0x80(%rsp), %xmm1
divsd %xmm1, %xmm0
divsd %xmm2, %xmm1
cmpeqsd (%r14,%r15,8), %xmm5
andpd %xmm5, %xmm0
andnpd %xmm1, %xmm5
orpd %xmm0, %xmm5
movsd 0x10(%rbx), %xmm1
addsd 0x1ba260(%rip), %xmm1   # 0x5ca1c0
mulsd 0x1ba238(%rip), %xmm1   # 0x5ca1a0
movapd %xmm5, %xmm0
callq 0x4ecf40
addsd 0x1b909f(%rip), %xmm0   # 0x5c9018
movapd 0x10(%rsp), %xmm2
divsd %xmm0, %xmm2
movsd 0x8(%rbx), %xmm0
mulsd %xmm2, %xmm0
xorpd %xmm1, %xmm1
cmpnlesd %xmm1, %xmm2
andpd %xmm0, %xmm2
movapd %xmm2, %xmm0
addq $0xc0, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
leaq 0x1ba73f(%rip), %rdi    # 0x5ca6f4
leaq 0x1ba74d(%rip), %rsi    # 0x5ca709
leaq 0x1ba753(%rip), %rcx    # 0x5ca716
movl $0x9a, %edx
callq 0x50b050
leaq 0x1ba790(%rip), %rdi    # 0x5ca764
leaq 0x1ba72e(%rip), %rsi    # 0x5ca709
leaq 0x1ba734(%rip), %rcx    # 0x5ca716
movl $0x9b, %edx
callq 0x50b050