// File: /workspace/github_cpp_makefile_star2_O2/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 %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movq %rsi, %r12
movq %rdi, %rbx
movl %edx, %r13d
movsd 0x20(%rdi,%r13,8), %xmm1
movsd %xmm1, 0x8(%rsp)
xorps %xmm0, %xmm0
leaq 0x30(%rsp), %r15
movaps %xmm0, (%r15)
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
movq %rax, 0x30(%rsp,%r13,8)
movaps (%r15), %xmm0
movaps %xmm0, (%r15)
movsd 0x1b238a(%rip), %xmm0   # 0x5bf0f8
mulsd %xmm1, %xmm0
leaq 0x90(%rsp), %rsi
movsd %xmm0, (%rsi)
movq %r15, %rdi
callq 0x40d586
movsd %xmm0, 0xa8(%rsp)
movsd %xmm1, 0xb0(%rsp)
movsd (%r12,%r13,8), %xmm2
movapd %xmm2, 0x70(%rsp)
movsd 0x8(%rsp), %xmm1
movapd %xmm1, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x58(%rsp)
movapd %xmm2, %xmm0
divsd %xmm1, %xmm0
callq 0x401140
mulsd 0x58(%rsp), %xmm0
movapd 0x70(%rsp), %xmm1
movapd %xmm1, %xmm4
subsd %xmm0, %xmm4
subsd 0x8(%rsp), %xmm4
movups (%r12), %xmm0
movaps %xmm0, (%r15)
movupd (%r12), %xmm0
movapd %xmm0, 0x10(%r15)
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm1
jae 0x40ce0e
movsd %xmm4, 0x40(%rsp,%r13,8)
movsd 0x30(%rsp,%r13,8), %xmm3
jmp 0x40ce19
movsd %xmm4, 0x30(%rsp,%r13,8)
movapd %xmm4, %xmm3
movupd 0x38(%rsp), %xmm0
movapd 0x30(%rsp), %xmm1
movhpd 0x40(%rsp), %xmm1       # xmm1 = xmm1[0],mem[0]
mulpd %xmm1, %xmm1
movhpd 0x48(%rsp), %xmm0       # xmm0 = xmm0[0],mem[0]
mulpd %xmm0, %xmm0
addpd %xmm1, %xmm0
movapd %xmm0, 0x90(%rsp)
xorpd %xmm1, %xmm1
movsd %xmm3, 0x28(%rsp)
ucomisd %xmm3, %xmm1
jbe 0x40d1a2
movsd %xmm4, 0x10(%rsp)
movsd 0x40(%rsp,%r13,8), %xmm2
ucomisd %xmm1, %xmm2
jb 0x40d1c1
leaq (%rsp,%r13,8), %r14
addq $0x30, %r14
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
callq 0x4e1c90
movsd 0x1b225a(%rip), %xmm1   # 0x5bf0e8
movsd 0x8(%rsp), %xmm2
mulsd %xmm2, %xmm1
mulsd %xmm2, %xmm1
ucomisd %xmm0, %xmm1
jbe 0x40cffd
movq %r13, 0xa0(%rsp)
movq %r12, 0x28(%rsp)
movapd 0x70(%rsp), %xmm0
subsd 0x10(%rsp), %xmm0
andpd 0x1b21a9(%rip), %xmm0   # 0x5bf070
movapd %xmm0, 0x70(%rsp)
xorpd %xmm2, %xmm2
xorl %ebp, %ebp
leaq 0xa8(%rsp), %r12
leaq 0x80(%rsp), %r13
cmpq $0x10, %rbp
je 0x40d0d2
movsd (%r14,%rbp,2), %xmm0
movsd %xmm0, 0x68(%rsp)
testq %rbp, %rbp
movapd %xmm2, 0x10(%rsp)
jne 0x40cf4c
movsd 0x58(%rsp), %xmm0
ucomisd 0x70(%rsp), %xmm0
jbe 0x40cf4c
xorpd %xmm3, %xmm3
movsd %xmm3, 0x60(%rsp)
movq %r15, %rdi
movq %r12, %rsi
callq 0x40d754
movsd %xmm0, 0x80(%rsp)
movsd %xmm1, 0x88(%rsp)
movq %rbx, %rdi
movq %r13, %rsi
callq 0x40d73a
movsd 0x60(%rsp), %xmm3
jmp 0x40cf90
movq %r15, %rdi
movq %r12, %rsi
callq 0x40ba98
movsd %xmm0, 0x80(%rsp)
movsd %xmm1, 0x88(%rsp)
movq %rbx, %rdi
movq %r13, %rsi
callq 0x40d73a
movapd %xmm0, %xmm3
cmpq $0x8, %rbp
jne 0x40cf16
xorpd %xmm0, %xmm0
movsd 0x58(%rsp), %xmm1
ucomisd 0x70(%rsp), %xmm1
jbe 0x40cf16
subsd %xmm0, %xmm3
divsd 0x8(%rsp), %xmm3
movapd 0x10(%rsp), %xmm2
addsd %xmm3, %xmm2
movsd 0x90(%rsp,%rbp), %xmm0
movsd 0x18(%rbx), %xmm1
mulsd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x40cff0
movsd 0x10(%rbx), %xmm1
addsd 0x1b21df(%rip), %xmm1   # 0x5bf1a8
mulsd 0x1b21c7(%rip), %xmm1   # 0x5bf198
movapd %xmm2, 0x10(%rsp)
callq 0x4e1d70
movapd 0x10(%rsp), %xmm2
movsd 0x68(%rsp), %xmm1
mulsd %xmm0, %xmm1
addsd %xmm1, %xmm2
addq $0x8, %rbp
addq $0x10, %r15
jmp 0x40cee3
movsd 0x1b20fb(%rip), %xmm1   # 0x5bf100
mulsd %xmm2, %xmm1
mulsd %xmm2, %xmm1
xorpd %xmm2, %xmm2
ucomisd %xmm0, %xmm1
jbe 0x40d0e6
xorl %r15d, %r15d
cmpq $0x10, %r15
je 0x40d0e6
movsd (%r14,%r15,2), %xmm0
movsd %xmm0, 0x60(%rsp)
movsd 0x90(%rsp,%r15), %xmm0
movsd %xmm0, 0x68(%rsp)
movsd 0x10(%rbx), %xmm1
mulsd 0x1b2147(%rip), %xmm1   # 0x5bf198
addsd 0x1b2147(%rip), %xmm1   # 0x5bf1a0
movapd %xmm2, 0x10(%rsp)
callq 0x4e1d70
movsd 0x60(%rsp), %xmm3
mulsd %xmm3, %xmm0
movsd 0x8(%rsp), %xmm1
mulsd %xmm1, %xmm0
mulsd %xmm1, %xmm0
movsd 0x10(%rbx), %xmm1
movapd %xmm1, %xmm2
addsd 0x1b211b(%rip), %xmm2   # 0x5bf1a8
mulsd %xmm0, %xmm2
mulsd 0x1b2117(%rip), %xmm2   # 0x5bf1b0
addsd 0x1b2117(%rip), %xmm1   # 0x5bf1b8
mulsd %xmm3, %xmm1
mulsd %xmm3, %xmm1
movsd 0x68(%rsp), %xmm0
mulsd 0x1b2091(%rip), %xmm0   # 0x5bf148
subsd %xmm1, %xmm0
mulsd %xmm2, %xmm0
movapd 0x10(%rsp), %xmm2
addsd %xmm0, %xmm2
addq $0x8, %r15
jmp 0x40d01e
movsd (%r14), %xmm0
movq 0x28(%rsp), %r12
movq 0xa0(%rsp), %r13
jmp 0x40d0ec
movsd 0x28(%rsp), %xmm0
ucomisd (%r12,%r13,8), %xmm0
movapd %xmm2, 0x10(%rsp)
jne 0x40d11a
jp 0x40d11a
movapd 0x40(%rsp), %xmm1
movhpd 0x30(%rsp), %xmm1       # xmm1 = xmm1[0],mem[0]
mulpd %xmm1, %xmm1
movsd 0x48(%rsp), %xmm0
movhpd 0x38(%rsp), %xmm0       # xmm0 = xmm0[0],mem[0]
jmp 0x40d136
movupd 0x38(%rsp), %xmm0
movapd 0x30(%rsp), %xmm1
movhpd 0x40(%rsp), %xmm1       # xmm1 = xmm1[0],mem[0]
mulpd %xmm1, %xmm1
movhpd 0x48(%rsp), %xmm0       # xmm0 = xmm0[0],mem[0]
mulpd %xmm0, %xmm0
addpd %xmm1, %xmm0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
divsd %xmm1, %xmm0
movsd 0x10(%rbx), %xmm1
addsd 0x1b2061(%rip), %xmm1   # 0x5bf1b8
mulsd 0x1b2039(%rip), %xmm1   # 0x5bf198
callq 0x4e1d70
addsd 0x1b0eac(%rip), %xmm0   # 0x5be018
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 $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1b2588(%rip), %rdi    # 0x5bf731
leaq 0x1b2596(%rip), %rsi    # 0x5bf746
leaq 0x1b259c(%rip), %rcx    # 0x5bf753
movl $0x9a, %edx
callq 0x4ffe80
leaq 0x1b25d9(%rip), %rdi    # 0x5bf7a1
leaq 0x1b2577(%rip), %rsi    # 0x5bf746
leaq 0x1b257d(%rip), %rcx    # 0x5bf753
movl $0x9b, %edx
callq 0x4ffe80