// File: 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
movq %rsp, %rbp
subq $0x170, %rsp            # imm = 0x170
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movq -0x10(%rbp), %rdi
movq %rdi, -0x118(%rbp)
addq $0x20, %rdi
movl -0x1c(%rbp), %eax
movl %eax, %esi
callq 0x419310
movsd (%rax), %xmm0
movsd %xmm0, -0x28(%rbp)
movl -0x1c(%rbp), %eax
movl %eax, %edi
callq 0x41c160
movsd %xmm0, -0x48(%rbp)
movsd %xmm1, -0x40(%rbp)
movsd -0x28(%rbp), %xmm0
movsd 0x1e1807(%rip), %xmm1   # 0x5fc2b0
divsd %xmm1, %xmm0
movsd %xmm0, -0x50(%rbp)
leaq -0x48(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x41bcb0
movsd %xmm0, -0x38(%rbp)
movsd %xmm1, -0x30(%rbp)
movq -0x18(%rbp), %rdi
movl -0x1c(%rbp), %eax
movl %eax, %esi
callq 0x418dc0
movsd (%rax), %xmm0
movsd %xmm0, -0x58(%rbp)
movsd -0x58(%rbp), %xmm0
movsd %xmm0, -0x110(%rbp)
movsd 0x1e17bb(%rip), %xmm0   # 0x5fc2b0
mulsd -0x28(%rbp), %xmm0
movsd %xmm0, -0x108(%rbp)
movsd -0x58(%rbp), %xmm0
divsd -0x28(%rbp), %xmm0
callq 0x401138
movsd -0x110(%rbp), %xmm1
movaps %xmm0, %xmm2
movsd -0x108(%rbp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
subsd -0x28(%rbp), %xmm0
movsd %xmm0, -0x60(%rbp)
movsd -0x58(%rbp), %xmm1
subsd -0x60(%rbp), %xmm1
movaps 0x1e1862(%rip), %xmm0   # 0x5fc3c0
pand %xmm0, %xmm1
movsd 0x1e1746(%rip), %xmm0   # 0x5fc2b0
mulsd -0x28(%rbp), %xmm0
ucomisd %xmm1, %xmm0
seta %al
andb $0x1, %al
movb %al, -0x61(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rcx
movq %rcx, -0x90(%rbp)
movq 0x8(%rax), %rax
movq %rax, -0x88(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rcx
movq %rcx, -0x80(%rbp)
movq 0x8(%rax), %rax
movq %rax, -0x78(%rbp)
movsd -0x58(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x41abe1
movsd -0x60(%rbp), %xmm0
movsd %xmm0, -0x120(%rbp)
leaq -0x90(%rbp), %rdi
movl -0x1c(%rbp), %eax
movl %eax, %esi
callq 0x418e10
movsd -0x120(%rbp), %xmm0
movsd %xmm0, (%rax)
jmp 0x41ac0f
movsd -0x60(%rbp), %xmm0
movsd %xmm0, -0x128(%rbp)
leaq -0x90(%rbp), %rdi
addq $0x10, %rdi
movl -0x1c(%rbp), %eax
movl %eax, %esi
callq 0x418e10
movsd -0x128(%rbp), %xmm0
movsd %xmm0, (%rax)
leaq -0x90(%rbp), %rdi
callq 0x41c000
movsd %xmm0, -0xa0(%rbp)
leaq -0x90(%rbp), %rdi
addq $0x10, %rdi
callq 0x41c000
movsd %xmm0, -0x98(%rbp)
leaq -0x90(%rbp), %rdi
movl -0x1c(%rbp), %eax
movl %eax, %esi
callq 0x418e10
xorps %xmm0, %xmm0
ucomisd (%rax), %xmm0
jbe 0x41ac57
jmp 0x41ac76
leaq 0x1e1d8b(%rip), %rdi    # 0x5fc9e9
leaq 0x1e1d99(%rip), %rsi    # 0x5fc9fe
movl $0x9a, %edx
leaq 0x1e1d9a(%rip), %rcx    # 0x5fca0b
callq 0x53d020
leaq -0x90(%rbp), %rdi
addq $0x10, %rdi
movl -0x1c(%rbp), %eax
movl %eax, %esi
callq 0x418e10
movsd (%rax), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x41ac9a
jmp 0x41acb9
leaq 0x1e1db8(%rip), %rdi    # 0x5fca59
leaq 0x1e1d56(%rip), %rsi    # 0x5fc9fe
movl $0x9b, %edx
leaq 0x1e1d57(%rip), %rcx    # 0x5fca0b
callq 0x53d020
xorps %xmm0, %xmm0
movsd %xmm0, -0xa8(%rbp)
movsd -0xa0(%rbp), %xmm3
movsd -0x98(%rbp), %xmm2
movaps %xmm2, %xmm4
movaps %xmm3, %xmm1
cmpunordsd %xmm1, %xmm1
movaps %xmm1, %xmm0
pand %xmm4, %xmm0
maxsd %xmm3, %xmm2
pandn %xmm2, %xmm1
por %xmm0, %xmm1
movsd 0x1e159e(%rip), %xmm0   # 0x5fc298
mulsd -0x28(%rbp), %xmm0
mulsd -0x28(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x41aee8
movl $0x0, -0xac(%rbp)
cmpl $0x2, -0xac(%rbp)
je 0x41aee3
movslq -0xac(%rbp), %rax
leaq -0x90(%rbp), %rdi
shlq $0x4, %rax
addq %rax, %rdi
movl -0x1c(%rbp), %eax
movl %eax, %esi
callq 0x418e10
movsd (%rax), %xmm0
movsd %xmm0, -0xb8(%rbp)
cmpl $0x0, -0xac(%rbp)
jne 0x41ad6c
testb $0x1, -0x61(%rbp)
je 0x41ad6c
xorps %xmm0, %xmm0
movsd %xmm0, -0x130(%rbp)
jmp 0x41adb5
movslq -0xac(%rbp), %rax
leaq -0x90(%rbp), %rdi
shlq $0x4, %rax
addq %rax, %rdi
leaq -0x38(%rbp), %rsi
callq 0x418b70
movq -0x118(%rbp), %rdi
movsd %xmm0, -0xd0(%rbp)
movsd %xmm1, -0xc8(%rbp)
leaq -0xd0(%rbp), %rsi
callq 0x41c1b0
movsd %xmm0, -0x130(%rbp)
movsd -0x130(%rbp), %xmm0
movsd %xmm0, -0xc0(%rbp)
cmpl $0x1, -0xac(%rbp)
jne 0x41ade1
testb $0x1, -0x61(%rbp)
je 0x41ade1
xorps %xmm0, %xmm0
movsd %xmm0, -0x138(%rbp)
jmp 0x41ae2a
movslq -0xac(%rbp), %rax
leaq -0x90(%rbp), %rdi
shlq $0x4, %rax
addq %rax, %rdi
leaq -0x38(%rbp), %rsi
callq 0x41c1e0
movq -0x118(%rbp), %rdi
movsd %xmm0, -0xe8(%rbp)
movsd %xmm1, -0xe0(%rbp)
leaq -0xe8(%rbp), %rsi
callq 0x41c1b0
movsd %xmm0, -0x138(%rbp)
movq -0x118(%rbp), %rax
movsd -0x138(%rbp), %xmm0
movsd %xmm0, -0xd8(%rbp)
movsd -0xc0(%rbp), %xmm0
subsd -0xd8(%rbp), %xmm0
divsd -0x28(%rbp), %xmm0
addsd -0xa8(%rbp), %xmm0
movsd %xmm0, -0xa8(%rbp)
movslq -0xac(%rbp), %rcx
movsd -0xa0(%rbp,%rcx,8), %xmm0
movsd %xmm0, -0x140(%rbp)
movsd 0x18(%rax), %xmm0
callq 0x418110
movaps %xmm0, %xmm1
movsd -0x140(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x41aecd
movq -0x118(%rbp), %rdi
movsd -0xb8(%rbp), %xmm0
movslq -0xac(%rbp), %rax
movsd -0xa0(%rbp,%rax,8), %xmm1
callq 0x41c270
addsd -0xa8(%rbp), %xmm0
movsd %xmm0, -0xa8(%rbp)
jmp 0x41aecf
movl -0xac(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xac(%rbp)
jmp 0x41ad18
jmp 0x41b083
movsd -0xa0(%rbp), %xmm3
movsd -0x98(%rbp), %xmm2
movaps %xmm2, %xmm4
movaps %xmm3, %xmm1
cmpunordsd %xmm1, %xmm1
movaps %xmm1, %xmm0
pand %xmm4, %xmm0
maxsd %xmm3, %xmm2
pandn %xmm2, %xmm1
por %xmm0, %xmm1
movsd 0x1e138a(%rip), %xmm0   # 0x5fc2a8
mulsd -0x28(%rbp), %xmm0
mulsd -0x28(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x41b07f
movl $0x0, -0xec(%rbp)
cmpl $0x2, -0xec(%rbp)
je 0x41b07d
movslq -0xec(%rbp), %rax
leaq -0x90(%rbp), %rdi
shlq $0x4, %rax
addq %rax, %rdi
movl -0x1c(%rbp), %eax
movl %eax, %esi
callq 0x418e10
movq %rax, %rcx
movq -0x118(%rbp), %rax
movsd (%rcx), %xmm0
movsd %xmm0, -0xf8(%rbp)
movsd -0xf8(%rbp), %xmm0
movsd %xmm0, -0x148(%rbp)
movslq -0xec(%rbp), %rcx
movsd -0xa0(%rbp,%rcx,8), %xmm0
movsd 0x10(%rax), %xmm1
movsd 0x1e13b5(%rip), %xmm2   # 0x5fc360
mulsd %xmm2, %xmm1
movsd 0x1e13b1(%rip), %xmm2   # 0x5fc368
addsd %xmm2, %xmm1
callq 0x51ef10
movq -0x118(%rbp), %rax
movaps %xmm0, %xmm1
movsd -0x148(%rbp), %xmm0
mulsd %xmm1, %xmm0
mulsd -0x28(%rbp), %xmm0
mulsd -0x28(%rbp), %xmm0
movsd 0x1e12c8(%rip), %xmm1   # 0x5fc2b0
addsd 0x10(%rax), %xmm1
mulsd %xmm1, %xmm0
movsd 0x1e135f(%rip), %xmm1   # 0x5fc358
mulsd %xmm1, %xmm0
movslq -0xec(%rbp), %rcx
movsd -0xa0(%rbp,%rcx,8), %xmm2
movsd 0x1e133b(%rip), %xmm1   # 0x5fc350
addsd 0x10(%rax), %xmm1
mulsd -0xf8(%rbp), %xmm1
mulsd -0xf8(%rbp), %xmm1
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
movsd 0x1e12c7(%rip), %xmm3   # 0x5fc310
mulsd %xmm3, %xmm2
addsd %xmm1, %xmm2
movsd -0xa8(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0xa8(%rbp)
movl -0xec(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xec(%rbp)
jmp 0x41af3c
jmp 0x41b081
jmp 0x41b081
jmp 0x41b083
leaq -0x90(%rbp), %rdi
movl -0x1c(%rbp), %eax
movl %eax, %esi
callq 0x418e10
movsd (%rax), %xmm0
movsd %xmm0, -0x150(%rbp)
movq -0x18(%rbp), %rdi
movl -0x1c(%rbp), %eax
movl %eax, %esi
callq 0x418dc0
movsd -0x150(%rbp), %xmm0
ucomisd (%rax), %xmm0
jne 0x41b0fb
jp 0x41b0fb
leaq -0x90(%rbp), %rdi
addq $0x10, %rdi
callq 0x41c000
movsd %xmm0, -0x160(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x41c000
movaps %xmm0, %xmm1
movsd -0x160(%rbp), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, -0x158(%rbp)
jmp 0x41b136
leaq -0x90(%rbp), %rdi
callq 0x41c000
movsd %xmm0, -0x168(%rbp)
leaq -0x90(%rbp), %rdi
addq $0x10, %rdi
callq 0x41c000
movaps %xmm0, %xmm1
movsd -0x168(%rbp), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, -0x158(%rbp)
movq -0x118(%rbp), %rax
movsd -0x158(%rbp), %xmm0
movsd %xmm0, -0x100(%rbp)
movsd -0x100(%rbp), %xmm0
movsd 0x1e11f3(%rip), %xmm2   # 0x5fc350
addsd 0x10(%rax), %xmm2
movsd 0x1e11f6(%rip), %xmm1   # 0x5fc360
mulsd %xmm2, %xmm1
callq 0x51ef10
movsd 0x1dfe9d(%rip), %xmm1   # 0x5fb018
addsd %xmm0, %xmm1
movsd -0xa8(%rbp), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, -0xa8(%rbp)
xorps %xmm0, %xmm0
ucomisd -0xa8(%rbp), %xmm0
jb 0x41b1aa
xorps %xmm0, %xmm0
movsd %xmm0, -0x8(%rbp)
jmp 0x41b1c3
movq -0x118(%rbp), %rax
movsd 0x8(%rax), %xmm0
mulsd -0xa8(%rbp), %xmm0
movsd %xmm0, -0x8(%rbp)
movsd -0x8(%rbp), %xmm0
addq $0x170, %rsp            # imm = 0x170
popq %rbp
retq
nopw %cs:(%rax,%rax)
nopl (%rax,%rax)