// File: j-faria[P]kima/examples/trends/../../DNest4/code/SamplerImpl.h
// Function: DNest4::Sampler<RVmodel>::Sampler(unsigned int, double, DNest4::Options const&, bool)
Sampler<ModelType>::Sampler(unsigned int num_threads, double compression,
							const Options& options, bool save_to_disk)
:save_to_disk(save_to_disk)
,thin_print(1)
,threads(num_threads, nullptr)
,barrier(nullptr)
,num_threads(num_threads)
,compression(compression)
,options(options)
,particles(options.num_particles*num_threads)
,log_likelihoods(options.num_particles*num_threads)
,level_assignments(options.num_particles*num_threads, 0)
,levels(1, LikelihoodType())
,copies_of_levels(num_threads, levels)
,all_above()
,rngs(num_threads)
,count_saves(0)
,count_mcmc_steps_since_save(0)
,count_mcmc_steps(0)
,above(num_threads)
{
	assert(num_threads >= 1);
	assert(compression > 1.);

    if(options.max_num_levels == 0 && std::abs(compression - exp(1.0)) > 1E-6)
    {
        std::cerr<<"# ERROR: Cannot use -c with max_num_levels=0 (AUTO).";
        std::cerr<<std::endl;
        exit(0);
    }

    // Find best ever particle
    auto indices = argsort(log_likelihoods);
    best_ever_particle = particles[indices.back()];
    best_ever_log_likelihood = log_likelihoods[indices.back()];
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1c0, %rsp            # imm = 0x1C0
movb %cl, %al
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movsd %xmm0, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
andb $0x1, %al
movb %al, -0x21(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xd8(%rbp)
movb -0x21(%rbp), %cl
andb $0x1, %cl
movb %cl, (%rax)
movl $0x1, 0x4(%rax)
addq $0x8, %rax
movq %rax, -0xd0(%rbp)
movl -0xc(%rbp), %eax
movq %rax, -0xc8(%rbp)
movq $0x0, -0x30(%rbp)
leaq -0x31(%rbp), %rdi
movq %rdi, -0xc0(%rbp)
callq 0xa1670
movq -0xd0(%rbp), %rdi
movq -0xc8(%rbp), %rsi
movq -0xc0(%rbp), %rcx
leaq -0x30(%rbp), %rdx
callq 0xa1690
jmp 0xa0c69
leaq -0x31(%rbp), %rdi
callq 0xa1710
movq -0xd8(%rbp), %rdi
movq $0x0, 0x20(%rdi)
movl -0xc(%rbp), %eax
movl %eax, 0x28(%rdi)
movsd -0x18(%rbp), %xmm0
movsd %xmm0, 0x30(%rdi)
addq $0x38, %rdi
movq %rdi, -0xe0(%rbp)
movq -0x20(%rbp), %rsi
callq 0xa1730
jmp 0xa0ca7
movq -0xd8(%rbp), %rax
addq $0xc8, %rax
movq %rax, -0xf8(%rbp)
movq -0x20(%rbp), %rax
movl (%rax), %eax
movl -0xc(%rbp), %ecx
imull %ecx, %eax
movq %rax, -0xf0(%rbp)
leaq -0x45(%rbp), %rdi
movq %rdi, -0xe8(%rbp)
callq 0xa17f0
movq -0xf8(%rbp), %rdi
movq -0xf0(%rbp), %rsi
movq -0xe8(%rbp), %rdx
callq 0xa1810
jmp 0xa0cfa
leaq -0x45(%rbp), %rdi
callq 0xa1880
movq -0xd8(%rbp), %rax
addq $0xe0, %rax
movq %rax, -0x110(%rbp)
movq -0x20(%rbp), %rax
movl (%rax), %eax
movl -0xc(%rbp), %ecx
imull %ecx, %eax
movq %rax, -0x108(%rbp)
leaq -0x46(%rbp), %rdi
movq %rdi, -0x100(%rbp)
callq 0xa18a0
movq -0x110(%rbp), %rdi
movq -0x108(%rbp), %rsi
movq -0x100(%rbp), %rdx
callq 0xa18c0
jmp 0xa0d56
leaq -0x46(%rbp), %rdi
callq 0xa1930
movq -0xd8(%rbp), %rax
addq $0xf8, %rax
movq %rax, -0x128(%rbp)
movq -0x20(%rbp), %rax
movl (%rax), %eax
movl -0xc(%rbp), %ecx
imull %ecx, %eax
movq %rax, -0x120(%rbp)
movl $0x0, -0x4c(%rbp)
leaq -0x4d(%rbp), %rdi
movq %rdi, -0x118(%rbp)
callq 0xa1950
movq -0x128(%rbp), %rdi
movq -0x120(%rbp), %rsi
movq -0x118(%rbp), %rcx
leaq -0x4c(%rbp), %rdx
callq 0xa1970
jmp 0xa0dbd
leaq -0x4d(%rbp), %rdi
callq 0xa19f0
movq -0xd8(%rbp), %rdi
addq $0x110, %rdi            # imm = 0x110
movq %rdi, -0x130(%rbp)
callq 0x6c820
jmp 0xa0de2
movq -0xd8(%rbp), %rdi
addq $0x620, %rdi            # imm = 0x620
callq 0xb18e0
jmp 0xa0df7
movq -0xd8(%rbp), %rax
addq $0x630, %rax            # imm = 0x630
movq %rax, -0x138(%rbp)
leaq -0x98(%rbp), %rdi
callq 0xb18e0
jmp 0xa0e19
leaq -0x88(%rbp), %rdi
leaq -0x98(%rbp), %rsi
callq 0xb1390
jmp 0xa0e2e
leaq -0x99(%rbp), %rdi
movq %rdi, -0x140(%rbp)
callq 0xa1a10
movq -0x138(%rbp), %rdi
movq -0x140(%rbp), %rcx
movl $0x1, %esi
leaq -0x88(%rbp), %rdx
callq 0xa1a30
jmp 0xa0e62
leaq -0x99(%rbp), %rdi
callq 0xa1ab0
movq -0xd8(%rbp), %rax
movq %rax, %rcx
addq $0x648, %rcx            # imm = 0x648
movq %rcx, -0x160(%rbp)
movl -0xc(%rbp), %ecx
movq %rcx, -0x158(%rbp)
addq $0x630, %rax            # imm = 0x630
movq %rax, -0x150(%rbp)
leaq -0x9a(%rbp), %rdi
movq %rdi, -0x148(%rbp)
callq 0xa1ad0
movq -0x160(%rbp), %rdi
movq -0x158(%rbp), %rsi
movq -0x150(%rbp), %rdx
movq -0x148(%rbp), %rcx
callq 0xa1af0
jmp 0xa0ed3
leaq -0x9a(%rbp), %rdi
callq 0xa1b70
movq -0xd8(%rbp), %rax
movq %rax, %rdi
addq $0x660, %rdi            # imm = 0x660
movq %rdi, -0x180(%rbp)
xorps %xmm0, %xmm0
movups %xmm0, 0x660(%rax)
movq $0x0, 0x670(%rax)
callq 0xa1b90
movq -0xd8(%rbp), %rax
addq $0x678, %rax            # imm = 0x678
movq %rax, -0x178(%rbp)
movl -0xc(%rbp), %eax
movq %rax, -0x170(%rbp)
leaq -0x9b(%rbp), %rdi
movq %rdi, -0x168(%rbp)
callq 0xa1bb0
movq -0x178(%rbp), %rdi
movq -0x170(%rbp), %rsi
movq -0x168(%rbp), %rdx
callq 0xa1bd0
jmp 0xa0f5e
leaq -0x9b(%rbp), %rdi
callq 0xa1c40
movq -0xd8(%rbp), %rax
movl $0x0, 0x690(%rax)
movl $0x0, 0x694(%rax)
movq $0x0, 0x698(%rax)
addq $0x6a0, %rax            # imm = 0x6A0
movq %rax, -0x198(%rbp)
movl -0xc(%rbp), %eax
movq %rax, -0x190(%rbp)
leaq -0x9c(%rbp), %rdi
movq %rdi, -0x188(%rbp)
callq 0xa1c60
movq -0x198(%rbp), %rdi
movq -0x190(%rbp), %rsi
movq -0x188(%rbp), %rdx
callq 0xa1c80
jmp 0xa0fd6
leaq -0x9c(%rbp), %rdi
callq 0xa1cf0
cmpl $0x1, -0xc(%rbp)
jb 0xa0fed
jmp 0xa111b
leaq 0x2a4bd(%rip), %rdi     # 0xcb4b1
leaq 0x2a4c7(%rip), %rsi     # 0xcb4c2
movl $0x23, %edx
leaq 0x2a4db(%rip), %rcx     # 0xcb4e2
callq 0x6340
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x31(%rbp), %rdi
callq 0xa1710
jmp 0xa134f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0xa1343
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x45(%rbp), %rdi
callq 0xa1880
jmp 0xa1337
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x46(%rbp), %rdi
callq 0xa1930
jmp 0xa132b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x4d(%rbp), %rdi
callq 0xa19f0
jmp 0xa131f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0xa1313
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0xa1307
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x99(%rbp), %rdi
callq 0xa1ab0
jmp 0xa1307
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x9a(%rbp), %rdi
callq 0xa1b70
jmp 0xa12fb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x9b(%rbp), %rdi
callq 0xa1c40
jmp 0xa12e3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x9c(%rbp), %rdi
callq 0xa1cf0
jmp 0xa12d7
movsd -0x18(%rbp), %xmm0
movsd 0x15f08(%rip), %xmm1    # 0xb7030
ucomisd %xmm1, %xmm0
jbe 0xa1130
jmp 0xa114f
leaq 0x2a410(%rip), %rdi     # 0xcb547
leaq 0x2a384(%rip), %rsi     # 0xcb4c2
movl $0x24, %edx
leaq 0x2a398(%rip), %rcx     # 0xcb4e2
callq 0x6340
movq -0x20(%rbp), %rax
cmpl $0x0, 0x10(%rax)
jne 0xa11ed
movsd -0x18(%rbp), %xmm0
movsd %xmm0, -0x1a8(%rbp)
movsd 0x15ebe(%rip), %xmm0    # 0xb7030
callq 0x6870
movaps %xmm0, %xmm1
movsd -0x1a8(%rbp), %xmm0
subsd %xmm1, %xmm0
callq 0x2b830
movsd %xmm0, -0x1a0(%rbp)
jmp 0xa1195
movsd -0x1a0(%rbp), %xmm0
movsd 0x24753(%rip), %xmm1    # 0xc58f8
ucomisd %xmm1, %xmm0
jbe 0xa11ed
movq 0x78e36(%rip), %rdi     # 0x119fe8
leaq 0x2a39f(%rip), %rsi     # 0xcb558
callq 0x64f0
jmp 0xa11c0
movq 0x78e21(%rip), %rdi     # 0x119fe8
movq 0x78d4a(%rip), %rsi     # 0x119f18
callq 0x6530
jmp 0xa11d5
xorl %edi, %edi
callq 0x65d0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0xa12cb
movq -0xd8(%rbp), %rsi
addq $0xe0, %rsi
leaq -0xb8(%rbp), %rdi
callq 0xa1d10
jmp 0xa1209
movq -0xd8(%rbp), %rax
addq $0xc8, %rax
movq %rax, -0x1b0(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0xa1e70
movq -0x1b0(%rbp), %rdi
movq (%rax), %rsi
callq 0xa1e50
movq -0xd8(%rbp), %rdi
movq %rax, %rsi
addq $0x110, %rdi            # imm = 0x110
callq 0xa1eb0
jmp 0xa1250
movq -0xd8(%rbp), %rax
addq $0xe0, %rax
movq %rax, -0x1b8(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0xa1e70
movq -0x1b8(%rbp), %rdi
movq (%rax), %rsi
callq 0xa2260
movq %rax, %rcx
movq -0xd8(%rbp), %rax
movq (%rcx), %rdx
movq %rdx, 0x620(%rax)
movq 0x8(%rcx), %rcx
movq %rcx, 0x628(%rax)
leaq -0xb8(%rbp), %rdi
callq 0xa2280
addq $0x1c0, %rsp            # imm = 0x1C0
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0xa2280
movq -0x198(%rbp), %rdi
callq 0x6e020
movq -0x178(%rbp), %rdi
callq 0x6e080
movq -0x180(%rbp), %rdi
callq 0x6e0e0
movq -0x160(%rbp), %rdi
callq 0x6e140
movq -0x138(%rbp), %rdi
callq 0x6e1a0
movq -0x130(%rbp), %rdi
callq 0x6e200
movq -0x128(%rbp), %rdi
callq 0x6e410
movq -0x110(%rbp), %rdi
callq 0x6e0e0
movq -0xf8(%rbp), %rdi
callq 0x6e470
movq -0xe0(%rbp), %rdi
callq 0x6e4d0
movq -0xd0(%rbp), %rdi
callq 0x6e510
movq -0x40(%rbp), %rdi
callq 0x6830
nopl (%rax,%rax)