// File: Cell-veto[P]postlhc/jellium3.cpp
// Function: void Jellium3::calibrate<2u>(unsigned int)
void calibrate (unsigned direction)
    {
        typedef vector <DIM> vector_t;
        const double L = period[direction];
        const double r_decay = sr_lr_split; // first decaying inner shell
        const double r_tail  = 2*L;  // last (decaying) inner shell, begin tail
        std::cerr << "jellium3_init shell_radii " << r_decay << " " << r_tail << "\n";
        std::cerr << "jellium3_init error_bound " << error_bound << "\n";

        prober[direction].calib_begin (DIM,
            r_decay, exponent+0.5,               // inner paralpha
            r_tail,  exponent+3);                // tail paralpha (= exponent+4 decay)

        // scan along the sr_lr_split
        for_all_angles <DIM> (100, [&] (const vector_t &unit_vec)
        {
            const double r = sr_lr_split;
            add_sample (direction, r, lr_event_rate (r*unit_vec, direction));
        });

        // in extremely small systems, the first few copies can cause trouble
        for (int i = -10; i <= 10; ++i)
        {
            vector_t ridge = zero_vector <DIM> ();
            ridge[direction] = i*L;
            for (; ridge[direction] < 3*sr_lr_split; ridge[direction] += 1e-3*sr_lr_split)
                add_sample (direction, norm (ridge), lr_event_rate (ridge, direction));
        }

        for_all_angles <DIM> (30, [&] (const vector_t &unit_vec)
        {
            for (double r = 0; r < 2*L; r += 1e-3*sr_lr_split)
                add_sample (direction, r, lr_event_rate (r*unit_vec, direction));

            for (double r = 1.; r < 1e15*L; r *= 1.0001)
                add_sample (direction, r, lr_event_rate (r*unit_vec, direction));
        });

        prober[direction].calib_finish (DIM);
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x70(%rbp)
addq $0x20, %rdi
movl -0xc(%rbp), %eax
movl %eax, %esi
callq 0x419310
movq %rax, %rcx
movq -0x70(%rbp), %rax
movsd (%rcx), %xmm0
movsd %xmm0, -0x18(%rbp)
movsd 0x18(%rax), %xmm0
movsd %xmm0, -0x20(%rbp)
movsd 0x1e23d6(%rip), %xmm0   # 0x5fc2b0
mulsd -0x18(%rbp), %xmm0
movsd %xmm0, -0x28(%rbp)
movq $0x698ac0, %rdi         # imm = 0x698AC0
leaq 0x1e2886(%rip), %rsi    # 0x5fc778
callq 0x4e1b60
movq %rax, %rdi
movsd -0x20(%rbp), %xmm0
callq 0x4e2ad0
movq %rax, %rdi
leaq 0x1e999f(%rip), %rsi    # 0x6038ad
callq 0x4e1b60
movq %rax, %rdi
movsd -0x28(%rbp), %xmm0
callq 0x4e2ad0
movq %rax, %rdi
leaq 0x1f44e0(%rip), %rsi    # 0x60e40a
callq 0x4e1b60
movq $0x698ac0, %rdi         # imm = 0x698AC0
leaq 0x1e2856(%rip), %rsi    # 0x5fc793
callq 0x4e1b60
movq %rax, %rdi
movq -0x70(%rbp), %rax
movsd 0x38(%rax), %xmm0
callq 0x4e2ad0
movq %rax, %rdi
leaq 0x1f44ad(%rip), %rsi    # 0x60e40a
callq 0x4e1b60
movq -0x70(%rbp), %rax
movq %rax, %rdi
addq $0x40, %rdi
movl -0xc(%rbp), %ecx
shlq $0xb, %rcx
addq %rcx, %rdi
movsd -0x20(%rbp), %xmm0
movsd 0x1e231c(%rip), %xmm1   # 0x5fc2a0
addsd 0x10(%rax), %xmm1
movsd -0x28(%rbp), %xmm2
movsd 0x1e237a(%rip), %xmm3   # 0x5fc310
addsd 0x10(%rax), %xmm3
movl $0x2, %esi
callq 0x41a590
movq -0x70(%rbp), %rax
movq %rax, -0x38(%rbp)
leaq -0xc(%rbp), %rax
movq %rax, -0x30(%rbp)
movl $0x64, %edi
leaq -0x38(%rbp), %rsi
callq 0x4141c0
movl $0xfffffff6, -0x3c(%rbp) # imm = 0xFFFFFFF6
cmpl $0xa, -0x3c(%rbp)
jg 0x41a0cb
callq 0x41a980
movsd %xmm0, -0x50(%rbp)
movsd %xmm1, -0x48(%rbp)
cvtsi2sdl -0x3c(%rbp), %xmm0
mulsd -0x18(%rbp), %xmm0
movsd %xmm0, -0x78(%rbp)
movl -0xc(%rbp), %eax
movl %eax, %esi
leaq -0x50(%rbp), %rdi
callq 0x418e10
movsd -0x78(%rbp), %xmm0
movsd %xmm0, (%rax)
movl -0xc(%rbp), %eax
movl %eax, %esi
leaq -0x50(%rbp), %rdi
callq 0x418e10
movq %rax, %rcx
movq -0x70(%rbp), %rax
movsd (%rcx), %xmm1
movsd 0x1e22e6(%rip), %xmm0   # 0x5fc310
mulsd 0x18(%rax), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x41a0bb
movl -0xc(%rbp), %eax
movl %eax, -0x84(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x41aa30
movq -0x70(%rbp), %rdi
movsd %xmm0, -0x80(%rbp)
movl -0xc(%rbp), %edx
leaq -0x50(%rbp), %rsi
callq 0x41aa50
movq -0x70(%rbp), %rdi
movl -0x84(%rbp), %esi
movaps %xmm0, %xmm1
movsd -0x80(%rbp), %xmm0
callq 0x41a9d0
movq -0x70(%rbp), %rax
movsd 0x18(%rax), %xmm0
movsd %xmm0, -0x90(%rbp)
movl -0xc(%rbp), %eax
movl %eax, %esi
leaq -0x50(%rbp), %rdi
callq 0x418e10
movsd -0x90(%rbp), %xmm0
movsd (%rax), %xmm1
movsd 0x1e226e(%rip), %xmm2   # 0x5fc318
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rax)
jmp 0x41a009
jmp 0x41a0bd
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x419fca
movq -0x70(%rbp), %rax
leaq -0x18(%rbp), %rcx
movq %rcx, -0x68(%rbp)
movq %rax, -0x60(%rbp)
leaq -0xc(%rbp), %rax
movq %rax, -0x58(%rbp)
movl $0x1e, %edi
leaq -0x68(%rbp), %rsi
callq 0x414290
movq -0x70(%rbp), %rdi
addq $0x40, %rdi
movl -0xc(%rbp), %eax
shlq $0xb, %rax
addq %rax, %rdi
movl $0x2, %esi
callq 0x41b1e0
addq $0x90, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)