// File: /workspace/github_cpp_makefile_star2_O1/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 $0xd0, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movl %edx, %r15d
movsd 0x20(%rdi,%r15,8), %xmm2
xorps %xmm0, %xmm0
movaps %xmm0, 0x50(%rsp)
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
movq %rax, 0x50(%rsp,%r15,8)
movaps 0x50(%rsp), %xmm0
movups %xmm0, 0x20(%rsp)
movsd 0x1bb46d(%rip), %xmm0   # 0x5cafb0
mulsd %xmm2, %xmm0
xorl %eax, %eax
movsd 0x20(%rsp,%rax,8), %xmm1
mulsd %xmm0, %xmm1
movsd %xmm1, 0x50(%rsp,%rax,8)
incq %rax
cmpq $0x2, %rax
jne 0x40fb49
leaq 0x60(%rsp), %r13
movups -0x10(%r13), %xmm0
movups %xmm0, 0xb0(%rsp)
movsd (%r14,%r15,8), %xmm1
movapd %xmm1, 0x30(%rsp)
movapd %xmm2, %xmm0
addsd %xmm2, %xmm0
movsd %xmm0, 0x8(%rsp)
movapd %xmm1, %xmm0
divsd %xmm2, %xmm0
movsd %xmm2, (%rsp)
callq 0x401140
movsd (%rsp), %xmm4
mulsd 0x8(%rsp), %xmm0
movapd 0x30(%rsp), %xmm3
movapd %xmm3, %xmm1
subsd %xmm0, %xmm1
subsd %xmm4, %xmm1
movupd (%r14), %xmm0
movapd %xmm0, -0x10(%r13)
movups (%r14), %xmm2
xorpd %xmm0, %xmm0
movapd %xmm3, %xmm6
ucomisd %xmm0, %xmm3
movaps %xmm2, (%r13)
leaq 0x50(%rsp), %r12
cmovaeq %r12, %r13
movsd %xmm1, (%r13,%r15,8)
movsd (%r12), %xmm2
movsd 0x8(%r12), %xmm3
mulsd %xmm2, %xmm2
mulsd %xmm3, %xmm3
addsd %xmm2, %xmm3
movapd %xmm3, 0xa0(%rsp)
movsd %xmm3, 0x70(%rsp)
movsd 0x18(%r12), %xmm3
movsd 0x10(%r12), %xmm2
mulsd %xmm2, %xmm2
mulsd %xmm3, %xmm3
addsd %xmm2, %xmm3
movapd %xmm3, 0x90(%rsp)
movsd %xmm3, 0x78(%rsp)
movsd 0x50(%rsp,%r15,8), %xmm2
movapd %xmm2, 0xc0(%rsp)
ucomisd %xmm2, %xmm0
jbe 0x40fffe
movsd 0x60(%rsp,%r15,8), %xmm2
ucomisd %xmm0, %xmm2
jb 0x41001d
movapd 0xa0(%rsp), %xmm5
movapd %xmm5, %xmm0
cmpunordsd %xmm5, %xmm0
movapd %xmm0, %xmm2
movapd 0x90(%rsp), %xmm3
andpd %xmm3, %xmm2
maxsd %xmm5, %xmm3
andnpd %xmm3, %xmm0
orpd %xmm2, %xmm0
movsd 0x1bb300(%rip), %xmm2   # 0x5cafa0
mulsd %xmm4, %xmm2
mulsd %xmm4, %xmm2
ucomisd %xmm0, %xmm2
jbe 0x40fe93
subsd %xmm1, %xmm6
andpd 0x1bb422(%rip), %xmm6   # 0x5cb0e0
movapd %xmm6, 0x30(%rsp)
xorl %r13d, %r13d
xorpd %xmm2, %xmm2
movq %r13, %rax
shlq $0x4, %rax
addq %rsp, %rax
addq $0x50, %rax
movsd (%rax,%r15,8), %xmm0
movsd %xmm0, 0x88(%rsp)
testq %r13, %r13
movapd %xmm2, 0x10(%rsp)
jne 0x40fd05
movsd 0x8(%rsp), %xmm0
ucomisd 0x30(%rsp), %xmm0
xorpd %xmm3, %xmm3
ja 0x40fd82
xorl %eax, %eax
movsd (%r12,%rax,8), %xmm0
addsd 0xb0(%rsp,%rax,8), %xmm0
movsd %xmm0, 0x20(%rsp,%rax,8)
incq %rax
cmpq $0x2, %rax
jne 0x40fd07
movsd 0x20(%rsp), %xmm1
movsd 0x28(%rsp), %xmm0
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
movsd 0x10(%rbx), %xmm1
ucomisd 0x1bb29e(%rip), %xmm1   # 0x5cafe8
jne 0x40fd61
jp 0x40fd61
callq 0x4ee2b0
movapd %xmm0, %xmm3
mulsd 0x1bb301(%rip), %xmm3   # 0x5cb060
jmp 0x40fd77
mulsd 0x1bb2f7(%rip), %xmm1   # 0x5cb060
callq 0x4ee2f0
movapd %xmm0, %xmm3
divsd 0x10(%rbx), %xmm3
movsd (%rsp), %xmm4
movapd 0x10(%rsp), %xmm2
cmpq $0x1, %r13
jne 0x40fd9e
xorpd %xmm0, %xmm0
movsd 0x8(%rsp), %xmm1
ucomisd 0x30(%rsp), %xmm1
ja 0x40fe1f
xorl %eax, %eax
movsd (%r12,%rax,8), %xmm0
subsd 0xb0(%rsp,%rax,8), %xmm0
movsd %xmm0, 0x20(%rsp,%rax,8)
incq %rax
cmpq $0x2, %rax
jne 0x40fda0
movsd %xmm3, 0x48(%rsp)
movsd 0x20(%rsp), %xmm1
movsd 0x28(%rsp), %xmm0
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
movsd 0x10(%rbx), %xmm1
ucomisd 0x1bb1ff(%rip), %xmm1   # 0x5cafe8
jne 0x40fdfc
jp 0x40fdfc
callq 0x4ee2b0
mulsd 0x1bb266(%rip), %xmm0   # 0x5cb060
jmp 0x40fe0e
mulsd 0x1bb25c(%rip), %xmm1   # 0x5cb060
callq 0x4ee2f0
divsd 0x10(%rbx), %xmm0
movsd (%rsp), %xmm4
movapd 0x10(%rsp), %xmm2
movsd 0x48(%rsp), %xmm3
subsd %xmm0, %xmm3
divsd %xmm4, %xmm3
addsd %xmm3, %xmm2
movsd 0x70(%rsp,%r13,8), %xmm0
movsd 0x18(%rbx), %xmm1
mulsd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x40fe7d
movsd 0x10(%rbx), %xmm1
addsd 0x1bb222(%rip), %xmm1   # 0x5cb070
mulsd 0x1bb20a(%rip), %xmm1   # 0x5cb060
movapd %xmm2, 0x10(%rsp)
callq 0x4ee2f0
movapd 0x10(%rsp), %xmm2
movsd (%rsp), %xmm4
movsd 0x88(%rsp), %xmm1
mulsd %xmm0, %xmm1
addsd %xmm1, %xmm2
incq %r13
addq $0x10, %r12
cmpq $0x2, %r13
jne 0x40fccb
jmp 0x40ff67
movsd 0x1bb11d(%rip), %xmm1   # 0x5cafb8
mulsd %xmm4, %xmm1
mulsd %xmm4, %xmm1
xorpd %xmm2, %xmm2
ucomisd %xmm0, %xmm1
jbe 0x40ff67
leaq (%rsp,%r15,8), %r12
addq $0x50, %r12
xorl %r13d, %r13d
movapd %xmm2, 0x10(%rsp)
movsd (%r12,%r13,2), %xmm0
movsd %xmm0, 0x8(%rsp)
movsd 0x70(%rsp,%r13), %xmm0
movsd %xmm0, 0x30(%rsp)
movsd 0x10(%rbx), %xmm1
mulsd 0x1bb178(%rip), %xmm1   # 0x5cb060
addsd 0x1bb178(%rip), %xmm1   # 0x5cb068
callq 0x4ee2f0
movsd (%rsp), %xmm1
movsd 0x8(%rsp), %xmm3
mulsd %xmm3, %xmm0
mulsd %xmm1, %xmm0
mulsd %xmm1, %xmm0
movsd 0x10(%rbx), %xmm1
movapd %xmm1, %xmm2
addsd 0x1bb153(%rip), %xmm2   # 0x5cb070
mulsd %xmm0, %xmm2
mulsd 0x1bb14f(%rip), %xmm2   # 0x5cb078
addsd 0x1bb14f(%rip), %xmm1   # 0x5cb080
mulsd %xmm3, %xmm1
mulsd %xmm3, %xmm1
movsd 0x30(%rsp), %xmm0
mulsd 0x1bb0c9(%rip), %xmm0   # 0x5cb010
subsd %xmm1, %xmm0
mulsd %xmm2, %xmm0
movapd 0x10(%rsp), %xmm2
addsd %xmm0, %xmm2
addq $0x8, %r13
cmpq $0x10, %r13
jne 0x40febc
movapd %xmm2, 0x10(%rsp)
movapd 0x90(%rsp), %xmm0
movapd %xmm0, %xmm2
movapd 0xa0(%rsp), %xmm1
divsd %xmm1, %xmm2
divsd %xmm0, %xmm1
movapd 0xc0(%rsp), %xmm0
cmpeqsd (%r14,%r15,8), %xmm0
andpd %xmm0, %xmm2
andnpd %xmm1, %xmm0
orpd %xmm2, %xmm0
movsd 0x10(%rbx), %xmm1
addsd 0x1bb0cc(%rip), %xmm1   # 0x5cb080
mulsd 0x1bb0a4(%rip), %xmm1   # 0x5cb060
callq 0x4ee2f0
addsd 0x1ba04f(%rip), %xmm0   # 0x5ca018
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 $0xd0, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
leaq 0x1bb5ff(%rip), %rdi    # 0x5cb604
leaq 0x1bb60d(%rip), %rsi    # 0x5cb619
leaq 0x1bb613(%rip), %rcx    # 0x5cb626
movl $0x9a, %edx
callq 0x50c400
leaq 0x1bb650(%rip), %rdi    # 0x5cb674
leaq 0x1bb5ee(%rip), %rsi    # 0x5cb619
leaq 0x1bb5f4(%rip), %rcx    # 0x5cb626
movl $0x9b, %edx
callq 0x50c400