// File: Cell-veto[P]postlhc/./ecmc.hpp
// Function: ChainRunner<Jellium3, Monodisperse2D>::measure_chain_expansion(Storage<Monodisperse2D>*, unsigned int, unsigned int)
double measure_chain_expansion (stor_t *stor, unsigned direction_, unsigned num_samples = 100)
    {
        inter.notify_random_context (&random);
        inter.notify_error_bound (stor, stor->cell_diagonal ());

        direction = direction_;
        disp_left = stor->periods () [direction_];

        // estimate median of disp and xdisp
        std::vector <double> ds, xs;

        for (unsigned n = 0; n != num_samples; ++n)
        {
            planned_next = active = stor->random_particle (&random);
            planned_disp = disp_left;
            planned_xdisp = 0.;

            find_sr_events (stor);
            find_lr_events (stor);

            ds.push_back (planned_disp);
            xs.push_back (planned_xdisp);
        }

        std::sort (ds.begin (), ds.end ());
        std::cerr << "calib_stat disp " << ds[0] << " " << ds[num_samples/2]
            << " " << ds.back () << "\n";
        std::sort (xs.begin (), xs.end ());
        std::cerr << "calib_stat xdisp " << xs[0] << " " << xs[num_samples/2]
            << " " << xs.back () << "\n";

        double ret = 1. + xs[num_samples/2]/ds[num_samples/2];
        std::cerr << "calib_stat chexp " << ret << "\n";
        return (ret < 0.) ? 1. : ret;
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x160, %rsp            # imm = 0x160
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
movq -0x8(%rbp), %rsi
movq %rsi, -0xa8(%rbp)
movq %rsi, %rdi
addq $0x30, %rdi
addq $0x1870, %rsi           # imm = 0x1870
callq 0x4190d0
movq -0xa8(%rbp), %rax
addq $0x30, %rax
movq %rax, -0xb8(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0xb0(%rbp)
movq -0x10(%rbp), %rdi
callq 0x4192b0
movq -0xb8(%rbp), %rdi
movq -0xb0(%rbp), %rsi
callq 0x4190e0
movq -0xa8(%rbp), %rax
movl -0x14(%rbp), %ecx
movl %ecx, 0x2448(%rax)
movq -0x10(%rbp), %rsi
movq (%rsi), %rax
leaq -0x30(%rbp), %rdi
callq *0x28(%rax)
movl -0x14(%rbp), %eax
movl %eax, %esi
leaq -0x30(%rbp), %rdi
callq 0x419310
movq %rax, %rcx
movq -0xa8(%rbp), %rax
movsd (%rcx), %xmm0
movsd %xmm0, 0x2450(%rax)
leaq -0x48(%rbp), %rdi
callq 0x41ffb0
leaq -0x60(%rbp), %rdi
callq 0x41ffb0
movl $0x0, -0x64(%rbp)
movl -0x64(%rbp), %eax
cmpl -0x18(%rbp), %eax
je 0x41fae0
movq -0xa8(%rbp), %rsi
movq -0x10(%rbp), %rdi
addq $0x1870, %rsi           # imm = 0x1870
callq 0x419340
movq %rax, -0xc0(%rbp)
jmp 0x41fa27
movq -0xa8(%rbp), %rdi
movq -0xc0(%rbp), %rax
movq %rax, 0x2440(%rdi)
movq %rax, 0x2458(%rdi)
movsd 0x2450(%rdi), %xmm0
movsd %xmm0, 0x2460(%rdi)
movq $0x0, 0x2468(%rdi)
movq -0x10(%rbp), %rsi
callq 0x4193d0
jmp 0x41fa69
movq -0xa8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x419a80
jmp 0x41fa7b
movq -0xa8(%rbp), %rsi
addq $0x2460, %rsi           # imm = 0x2460
leaq -0x48(%rbp), %rdi
callq 0x41ffd0
jmp 0x41fa94
movq -0xa8(%rbp), %rsi
addq $0x2468, %rsi           # imm = 0x2468
leaq -0x60(%rbp), %rdi
callq 0x41ffd0
jmp 0x41faad
jmp 0x41faaf
movl -0x64(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x64(%rbp)
jmp 0x41f9fb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x420140
leaq -0x48(%rbp), %rdi
callq 0x420140
jmp 0x41fe0c
leaq -0x48(%rbp), %rdi
movq %rdi, -0xc8(%rbp)
callq 0x420080
movq -0xc8(%rbp), %rdi
movq %rax, -0x80(%rbp)
callq 0x4200b0
movq %rax, -0x88(%rbp)
movq -0x80(%rbp), %rdi
movq -0x88(%rbp), %rsi
callq 0x420040
jmp 0x41fb19
movq $0x698ac0, %rdi         # imm = 0x698AC0
leaq 0x1dd87a(%rip), %rsi    # 0x5fd3a1
callq 0x4e1b60
movq %rax, -0xd0(%rbp)
jmp 0x41fb35
xorl %eax, %eax
movl %eax, %esi
leaq -0x48(%rbp), %rdi
callq 0x4200e0
movq -0xd0(%rbp), %rdi
movsd (%rax), %xmm0
callq 0x4e2ad0
movq %rax, -0xd8(%rbp)
jmp 0x41fb5b
movq -0xd8(%rbp), %rdi
leaq 0x1e3d44(%rip), %rsi    # 0x6038ad
callq 0x4e1b60
movq %rax, -0xe0(%rbp)
jmp 0x41fb77
movl -0x18(%rbp), %eax
shrl %eax
movl %eax, %esi
leaq -0x48(%rbp), %rdi
callq 0x4200e0
movq -0xe0(%rbp), %rdi
movsd (%rax), %xmm0
callq 0x4e2ad0
movq %rax, -0xe8(%rbp)
jmp 0x41fba0
movq -0xe8(%rbp), %rdi
leaq 0x1e3cff(%rip), %rsi    # 0x6038ad
callq 0x4e1b60
movq %rax, -0xf0(%rbp)
jmp 0x41fbbc
leaq -0x48(%rbp), %rdi
callq 0x420100
movq -0xf0(%rbp), %rdi
movsd (%rax), %xmm0
callq 0x4e2ad0
movq %rax, -0xf8(%rbp)
jmp 0x41fbde
movq -0xf8(%rbp), %rdi
leaq 0x1ee81e(%rip), %rsi    # 0x60e40a
callq 0x4e1b60
jmp 0x41fbf3
leaq -0x60(%rbp), %rdi
movq %rdi, -0x100(%rbp)
callq 0x420080
movq -0x100(%rbp), %rdi
movq %rax, -0x90(%rbp)
callq 0x4200b0
movq %rax, -0x98(%rbp)
movq -0x90(%rbp), %rdi
movq -0x98(%rbp), %rsi
callq 0x420040
jmp 0x41fc32
movq $0x698ac0, %rdi         # imm = 0x698AC0
leaq 0x1dd772(%rip), %rsi    # 0x5fd3b2
callq 0x4e1b60
movq %rax, -0x108(%rbp)
jmp 0x41fc4e
xorl %eax, %eax
movl %eax, %esi
leaq -0x60(%rbp), %rdi
callq 0x4200e0
movq -0x108(%rbp), %rdi
movsd (%rax), %xmm0
callq 0x4e2ad0
movq %rax, -0x110(%rbp)
jmp 0x41fc74
movq -0x110(%rbp), %rdi
leaq 0x1e3c2b(%rip), %rsi    # 0x6038ad
callq 0x4e1b60
movq %rax, -0x118(%rbp)
jmp 0x41fc90
movl -0x18(%rbp), %eax
shrl %eax
movl %eax, %esi
leaq -0x60(%rbp), %rdi
callq 0x4200e0
movq -0x118(%rbp), %rdi
movsd (%rax), %xmm0
callq 0x4e2ad0
movq %rax, -0x120(%rbp)
jmp 0x41fcb9
movq -0x120(%rbp), %rdi
leaq 0x1e3be6(%rip), %rsi    # 0x6038ad
callq 0x4e1b60
movq %rax, -0x128(%rbp)
jmp 0x41fcd5
leaq -0x60(%rbp), %rdi
callq 0x420100
movq -0x128(%rbp), %rdi
movsd (%rax), %xmm0
callq 0x4e2ad0
movq %rax, -0x130(%rbp)
jmp 0x41fcf7
movq -0x130(%rbp), %rdi
leaq 0x1ee705(%rip), %rsi    # 0x60e40a
callq 0x4e1b60
jmp 0x41fd0c
movl -0x18(%rbp), %eax
shrl %eax
movl %eax, %esi
leaq -0x60(%rbp), %rdi
callq 0x4200e0
movsd (%rax), %xmm0
movsd %xmm0, -0x140(%rbp)
movl -0x18(%rbp), %eax
shrl %eax
movl %eax, %esi
leaq -0x48(%rbp), %rdi
callq 0x4200e0
movsd -0x140(%rbp), %xmm0
movsd (%rax), %xmm1
divsd %xmm1, %xmm0
movsd 0x1db2c8(%rip), %xmm1   # 0x5fb018
addsd %xmm1, %xmm0
movsd %xmm0, -0xa0(%rbp)
movq $0x698ac0, %rdi         # imm = 0x698AC0
leaq 0x1dd65a(%rip), %rsi    # 0x5fd3c4
callq 0x4e1b60
movq %rax, -0x138(%rbp)
jmp 0x41fd78
movq -0x138(%rbp), %rdi
movsd -0xa0(%rbp), %xmm0
callq 0x4e2ad0
movq %rax, -0x148(%rbp)
jmp 0x41fd95
movq -0x148(%rbp), %rdi
leaq 0x1ee667(%rip), %rsi    # 0x60e40a
callq 0x4e1b60
jmp 0x41fdaa
xorps %xmm0, %xmm0
ucomisd -0xa0(%rbp), %xmm0
jbe 0x41fdc9
movsd 0x1db259(%rip), %xmm0   # 0x5fb018
movsd %xmm0, -0x150(%rbp)
jmp 0x41fdd9
movsd -0xa0(%rbp), %xmm0
movsd %xmm0, -0x150(%rbp)
movsd -0x150(%rbp), %xmm0
movsd %xmm0, -0x158(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x420140
leaq -0x48(%rbp), %rdi
callq 0x420140
movsd -0x158(%rbp), %xmm0
addq $0x160, %rsp            # imm = 0x160
popq %rbp
retq
movq -0x70(%rbp), %rdi
callq 0x5283c0
nopw %cs:(%rax,%rax)
nop