// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rdi, %rbx
leaq 0x1c(%rsp), %r13
movl %esi, (%r13)
movl %esi, %r12d
movsd 0x20(%rdi,%r12,8), %xmm0
movsd %xmm0, 0x40(%rsp)
movsd 0x18(%rdi), %xmm1
movsd %xmm1, 0x10(%rsp)
movsd %xmm0, 0x38(%rsp)
addsd %xmm0, %xmm0
movsd %xmm0, 0x8(%rsp)
movq $0x64eaa0, %r14         # imm = 0x64EAA0
leaq 0x1b302e(%rip), %rsi    # 0x5bf57f
movq %r14, %rdi
callq 0x4a4910
movq %rax, %rdi
movsd 0x10(%rsp), %xmm0
callq 0x4a5640
leaq 0x1b933f(%rip), %rsi    # 0x5c58ad
movq %rax, %rdi
callq 0x4a4910
movq %rax, %rdi
movsd 0x8(%rsp), %xmm0
callq 0x4a5640
leaq 0x1c3e7f(%rip), %r15    # 0x5d040a
movq %rax, %rdi
movq %r15, %rsi
callq 0x4a4910
leaq 0x1b2ffd(%rip), %rsi    # 0x5bf59a
movq %r14, %rdi
callq 0x4a4910
movsd 0x38(%rbx), %xmm0
movq %rax, %rdi
callq 0x4a5640
movq %rax, %rdi
movq %r15, %rsi
callq 0x4a4910
leaq 0x40(%rbx), %r14
shlq $0xb, %r12
leaq (%rbx,%r12), %rdi
addq $0x40, %rdi
movsd 0x10(%rbx), %xmm3
movsd 0x1b2b1e(%rip), %xmm1   # 0x5bf0f8
addsd %xmm3, %xmm1
addsd 0x1b2b62(%rip), %xmm3   # 0x5bf148
pushq $0x2
popq %rsi
movsd 0x10(%rsp), %xmm0
movsd 0x8(%rsp), %xmm2
callq 0x40cacc
leaq 0x48(%rsp), %r15
movq %rbx, (%r15)
movq %r13, 0x8(%r15)
xorpd %xmm1, %xmm1
pushq $0x64
popq %rbp
leaq 0x20(%rsp), %r12
subl $0x1, %ebp
jb 0x40c666
movapd %xmm1, %xmm0
mulsd 0x1b2b35(%rip), %xmm0   # 0x5bf158
movsd %xmm0, 0x8(%rsp)
movsd %xmm1, 0x10(%rsp)
callq 0x4010f0
movsd %xmm0, 0x20(%rsp)
movsd 0x8(%rsp), %xmm0
callq 0x401098
movsd %xmm0, 0x28(%rsp)
movq %r15, %rdi
movq %r12, %rsi
callq 0x40d51c
movsd 0x10(%rsp), %xmm1
addsd 0x1b19b4(%rip), %xmm1   # 0x5be018
jmp 0x40c612
pushq $-0xa
popq %rbp
movsd 0x1b2aef(%rip), %xmm1   # 0x5bf160
leaq 0x20(%rsp), %r15
cmpl $0xb, %ebp
je 0x40c738
movsd 0x38(%rsp), %xmm0
movsd %xmm1, 0x8(%rsp)
mulsd %xmm1, %xmm0
xorpd %xmm1, %xmm1
movapd %xmm1, 0x20(%rsp)
movl 0x1c(%rsp), %r12d
movsd %xmm0, 0x20(%rsp,%r12,8)
movsd 0x18(%rbx), %xmm1
mulsd 0x1b2a96(%rip), %xmm1   # 0x5bf148
ucomisd %xmm0, %xmm1
jbe 0x40c723
movsd 0x20(%rsp), %xmm0
movsd 0x28(%rsp), %xmm1
mulsd %xmm0, %xmm0
mulsd %xmm1, %xmm1
addsd %xmm0, %xmm1
sqrtsd %xmm1, %xmm0
movsd %xmm0, 0x10(%rsp)
movq %rbx, %rdi
movq %r15, %rsi
movl %r12d, %edx
callq 0x40cd1c
movapd %xmm0, %xmm1
movq %rbx, %rdi
movl %r12d, %esi
movsd 0x10(%rsp), %xmm0
callq 0x40ccfe
movsd 0x18(%rbx), %xmm1
movl 0x1c(%rsp), %r12d
movapd %xmm1, %xmm0
mulsd 0x1b2a55(%rip), %xmm0   # 0x5bf168
addsd 0x20(%rsp,%r12,8), %xmm0
movsd %xmm0, 0x20(%rsp,%r12,8)
jmp 0x40c6aa
movsd 0x8(%rsp), %xmm1
addsd 0x1b18e7(%rip), %xmm1   # 0x5be018
incl %ebp
jmp 0x40c676
leaq 0x40(%rsp), %rax
leaq 0x20(%rsp), %r15
movq %rax, (%r15)
movq %rbx, 0x8(%r15)
movq %r13, 0x10(%r15)
xorpd %xmm1, %xmm1
pushq $0x1e
popq %rbp
leaq 0x48(%rsp), %rbx
subl $0x1, %ebp
jb 0x40c7ad
movapd %xmm1, %xmm0
mulsd 0x1b2a06(%rip), %xmm0   # 0x5bf170
movsd %xmm0, 0x8(%rsp)
movsd %xmm1, 0x10(%rsp)
callq 0x4010f0
movsd %xmm0, 0x48(%rsp)
movsd 0x8(%rsp), %xmm0
callq 0x401098
movsd %xmm0, 0x50(%rsp)
movq %r15, %rdi
movq %rbx, %rsi
callq 0x40d7b6
movsd 0x10(%rsp), %xmm1
addsd 0x1b186d(%rip), %xmm1   # 0x5be018
jmp 0x40c759
movl 0x1c(%rsp), %eax
shlq $0xb, %rax
addq %rax, %r14
pushq $0x2
popq %rsi
movq %r14, %rdi
callq 0x40d1e0
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq