// File: /workspace/github_cpp_makefile_star2_O2/Cell-veto[P]postlhc/jellium4.cpp
// Function: Jellium4<2u, Monodisperse2D>::lr_event_rate(std::array<double, 2ul> const&, unsigned int, bool)
double lr_event_rate (const vector_t &r, unsigned direction, bool clip = true)
    {
        // FIXME 3D missing
        if (DIM != 2)
            std::cerr << "not impl" << ABORT;

        double pr = 0.;

        for (int i = -LATTICE_ORDER; i <= LATTICE_ORDER; ++i)
        {
            double x = r[direction] + i*periods[direction];
            for (int j = -LATTICE_ORDER; j <= LATTICE_ORDER; ++j)
            {
                double y = r[!direction] + j*periods[!direction];
                double rsq = x*x + y*y;
                if (rsq >= sr_lr_split*sr_lr_split)
                    pr += unit_directional_derivative (x, rsq);
            }
        }

        // screening charges
        double spr = 0;
        double xf = r[direction] + (LATTICE_ORDER+.5) * periods[direction];
        double xb = r[direction] - (LATTICE_ORDER+.5) * periods[direction];
        for (int j = -LATTICE_ORDER; j <= LATTICE_ORDER; ++j)
        {
            double y = r[!direction] + j*periods[!direction];
            spr += unit_potential (xf*xf + y*y);
            spr -= unit_potential (xb*xb + y*y);
        }

        pr += spr / periods[direction];

        if (clip && pr < 0.)
            return 0.;
        else
            return stren * pr;
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %ecx, 0x2c(%rsp)
movq %rsi, %r15
movq %rdi, %r14
movl %edx, %r12d
xorl %r13d, %r13d
testl %edx, %edx
sete %r13b
xorpd %xmm2, %xmm2
pushq $-0x4
popq %rbp
movsd 0x1a9487(%rip), %xmm0   # 0x5c1b10
movsd %xmm0, 0x10(%rsp)
movsd (%r15,%r12,8), %xmm0
cmpl $0x5, %ebp
je 0x418773
movsd 0x20(%r14,%r12,8), %xmm1
mulsd 0x10(%rsp), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, 0x20(%rsp)
movapd %xmm1, %xmm3
mulsd %xmm1, %xmm3
pushq $0x9
popq %rbx
movsd 0x1a9448(%rip), %xmm4   # 0x5c1b10
movsd %xmm3, 0x18(%rsp)
subl $0x1, %ebx
jb 0x418758
leal (,%r13,8), %eax
movsd 0x20(%r14,%rax), %xmm0
mulsd %xmm4, %xmm0
addsd (%r15,%rax), %xmm0
mulsd %xmm0, %xmm0
addsd %xmm3, %xmm0
movsd 0x18(%r14), %xmm1
mulsd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x41874b
movsd 0x10(%r14), %xmm1
addsd 0x1a6a92(%rip), %xmm1   # 0x5bf1a8
mulsd 0x1a6a7a(%rip), %xmm1   # 0x5bf198
movapd %xmm2, 0x30(%rsp)
movsd %xmm4, 0x8(%rsp)
callq 0x4e1d70
movsd 0x8(%rsp), %xmm4
movsd 0x18(%rsp), %xmm3
movapd 0x30(%rsp), %xmm2
mulsd 0x20(%rsp), %xmm0
addsd %xmm0, %xmm2
addsd 0x1a58c5(%rip), %xmm4   # 0x5be018
jmp 0x4186ce
movsd 0x10(%rsp), %xmm0
addsd 0x1a58b2(%rip), %xmm0   # 0x5be018
movsd %xmm0, 0x10(%rsp)
incl %ebp
jmp 0x41868f
movsd 0x20(%r14,%r12,8), %xmm1
movsd 0x1a9396(%rip), %xmm3   # 0x5c1b18
mulsd %xmm1, %xmm3
addsd %xmm0, %xmm3
mulsd 0x1a938e(%rip), %xmm1   # 0x5c1b20
addsd %xmm0, %xmm1
movsd 0x1a9372(%rip), %xmm4   # 0x5c1b10
xorpd %xmm0, %xmm0
movsd %xmm0, 0x8(%rsp)
pushq $0x9
popq %rbx
mulsd %xmm3, %xmm3
movsd %xmm3, 0x40(%rsp)
mulsd %xmm1, %xmm1
movsd %xmm1, 0x10(%rsp)
movapd %xmm2, 0x30(%rsp)
subl $0x1, %ebx
jb 0x418856
leal (,%r13,8), %eax
movsd 0x20(%r14,%rax), %xmm1
mulsd %xmm4, %xmm1
addsd (%r15,%rax), %xmm1
mulsd %xmm1, %xmm1
movsd %xmm1, 0x18(%rsp)
movsd 0x40(%rsp), %xmm0
addsd %xmm1, %xmm0
movq %r14, %rdi
movsd %xmm4, 0x20(%rsp)
callq 0x40d77e
movsd 0x8(%rsp), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, 0x8(%rsp)
movsd 0x18(%rsp), %xmm0
addsd 0x10(%rsp), %xmm0
movq %r14, %rdi
callq 0x40d77e
movsd 0x20(%rsp), %xmm4
movapd 0x30(%rsp), %xmm2
movsd 0x8(%rsp), %xmm1
subsd %xmm0, %xmm1
movsd %xmm1, 0x8(%rsp)
addsd 0x1a57c7(%rip), %xmm4   # 0x5be018
jmp 0x4187c5
movsd 0x8(%rsp), %xmm0
divsd 0x20(%r14,%r12,8), %xmm0
addsd %xmm0, %xmm2
movsd 0x8(%r14), %xmm0
mulsd %xmm2, %xmm0
cmpb $0x0, 0x2c(%rsp)
je 0x418889
xorpd %xmm1, %xmm1
cmpltsd %xmm1, %xmm2
andnpd %xmm0, %xmm2
movapd %xmm2, %xmm0
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq