// File: /workspace/github_cpp_makefile_star2_O3/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 $0x58, %rsp
movl %ecx, 0x2c(%rsp)
movq %rsi, %r15
movq %rdi, %r14
movl %edx, %eax
movq %rax, 0x8(%rsp)
xorl %r13d, %r13d
testl %edx, %edx
sete %r13b
movl $0xfffffffc, %ebp       # imm = 0xFFFFFFFC
movsd 0x1b01bf(%rip), %xmm0   # 0x5cc950
xorpd %xmm2, %xmm2
leal (,%r13,8), %ebx
movsd 0x1ac873(%rip), %xmm3   # 0x5c9018
movq 0x8(%rsp), %rax
movsd 0x20(%r14,%rax,8), %xmm1
movsd %xmm0, 0x10(%rsp)
mulsd %xmm0, %xmm1
addsd (%r15,%rax,8), %xmm1
movl $0x9, %r12d
movsd %xmm1, 0x18(%rsp)
movapd %xmm1, %xmm4
mulsd %xmm1, %xmm4
movsd 0x1b0173(%rip), %xmm5   # 0x5cc950
movsd %xmm4, (%rsp)
movsd 0x20(%r14,%rbx), %xmm0
mulsd %xmm5, %xmm0
addsd (%r15,%rbx), %xmm0
mulsd %xmm0, %xmm0
addsd %xmm4, %xmm0
movsd 0x18(%r14), %xmm1
mulsd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x41c855
movsd 0x10(%r14), %xmm1
addsd 0x1ad997(%rip), %xmm1   # 0x5ca1b0
mulsd 0x1ad97f(%rip), %xmm1   # 0x5ca1a0
movapd %xmm2, 0x30(%rsp)
movsd %xmm5, 0x20(%rsp)
callq 0x4ecf40
movsd 0x20(%rsp), %xmm5
movsd (%rsp), %xmm4
movsd 0x1ac7d3(%rip), %xmm3   # 0x5c9018
movapd 0x30(%rsp), %xmm2
mulsd 0x18(%rsp), %xmm0
addsd %xmm0, %xmm2
addsd %xmm3, %xmm5
decl %r12d
jne 0x41c7e2
movsd 0x10(%rsp), %xmm0
addsd %xmm3, %xmm0
incl %ebp
cmpl $0x5, %ebp
jne 0x41c7a5
movq 0x8(%rsp), %rax
movsd (%r15,%rax,8), %xmm0
movsd 0x20(%r14,%rax,8), %xmm1
movsd 0x1b00cb(%rip), %xmm3   # 0x5cc958
mulsd %xmm1, %xmm3
mulsd 0x1b00c7(%rip), %xmm1   # 0x5cc960
addsd %xmm0, %xmm3
addsd %xmm0, %xmm1
movsd %xmm1, 0x50(%rsp)
movsd 0x1b00a1(%rip), %xmm0   # 0x5cc950
movl $0x9, %ebp
shll $0x3, %r13d
mulsd %xmm3, %xmm3
movsd %xmm3, 0x48(%rsp)
xorpd %xmm1, %xmm1
movsd %xmm1, 0x18(%rsp)
movapd %xmm2, 0x30(%rsp)
movsd 0x20(%r14,%r13), %xmm1
movsd %xmm0, 0x20(%rsp)
mulsd %xmm0, %xmm1
addsd (%r15,%r13), %xmm1
mulsd %xmm1, %xmm1
movsd 0x48(%rsp), %xmm0
movsd %xmm1, 0x10(%rsp)
addsd %xmm1, %xmm0
movsd 0x10(%r14), %xmm1
ucomisd 0x1ad81d(%rip), %xmm1   # 0x5ca128
jne 0x41c929
jp 0x41c929
callq 0x4ecf00
mulsd 0x1ad884(%rip), %xmm0   # 0x5ca1a0
movsd %xmm0, (%rsp)
movsd 0x10(%r14), %xmm1
jmp 0x41c945
mulsd 0x1ad86f(%rip), %xmm1   # 0x5ca1a0
callq 0x4ecf40
movsd 0x10(%r14), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, (%rsp)
movsd 0x50(%rsp), %xmm0
mulsd %xmm0, %xmm0
addsd 0x10(%rsp), %xmm0
ucomisd 0x1ad7cb(%rip), %xmm1   # 0x5ca128
jne 0x41c970
jp 0x41c970
callq 0x4ecf00
mulsd 0x1ad832(%rip), %xmm0   # 0x5ca1a0
jmp 0x41c983
mulsd 0x1ad828(%rip), %xmm1   # 0x5ca1a0
callq 0x4ecf40
divsd 0x10(%r14), %xmm0
movsd 0x18(%rsp), %xmm1
addsd (%rsp), %xmm1
subsd %xmm0, %xmm1
movsd 0x20(%rsp), %xmm0
addsd 0x1ac678(%rip), %xmm0   # 0x5c9018
decl %ebp
movapd 0x30(%rsp), %xmm2
jne 0x41c8c6
movq 0x8(%rsp), %rax
divsd 0x20(%r14,%rax,8), %xmm1
addsd %xmm1, %xmm2
movsd 0x8(%r14), %xmm0
mulsd %xmm2, %xmm0
cmpb $0x0, 0x2c(%rsp)
je 0x41c9e0
xorpd %xmm1, %xmm1
cmpltsd %xmm1, %xmm2
andnpd %xmm0, %xmm2
movapd %xmm2, %xmm0
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop