// File: /workspace/github_cpp_makefile_star2_O2/j-faria[P]kima/examples/trends/../../DNest4/code/SamplerImpl.h
// Function: DNest4::Sampler<RVmodel>::update_particle(unsigned int, unsigned int)
void Sampler<ModelType>::update_particle(unsigned int thread, unsigned int which)
{
	// Reference to the RNG for this thread
	RNG& rng = rngs[thread];

	// Reference to copies_of_levels[thread]
	std::vector<Level>& _levels = copies_of_levels[thread];

	// Reference to the level we're in
	Level& level = _levels[level_assignments[which]];

	// Reference to the particle being moved
	ModelType& particle = particles[which];
	LikelihoodType& logl = log_likelihoods[which];

	// Do the proposal for the particle
	ModelType proposal = particle;
	double log_H = proposal.perturb(rng);

	// Prevent unnecessary exponentiation of a large number
	if(log_H > 0.0)
		log_H = 0.0;

    if(rng.rand() <= exp(log_H))
    {
    	LikelihoodType logl_proposal(proposal.log_likelihood(),
												logl.get_tiebreaker());

    	// Do the proposal for the tiebreaker
    	log_H += logl_proposal.perturb(rng);

	    // Accept?
	    if(level.get_log_likelihood() < logl_proposal)
	    {
		    particle = proposal;
		    logl = logl_proposal;
		    level.increment_accepts(1);
	    }
    }

	level.increment_tries(1);

	// Count visits and exceeds
	unsigned int current_level = level_assignments[which];
	for(; current_level < (_levels.size()-1); ++current_level)
	{
		_levels[current_level].increment_visits(1);
		if(_levels[current_level+1].get_log_likelihood() <
											log_likelihoods[which])
			_levels[current_level].increment_exceeds(1);
		else
			break;
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x558, %rsp            # imm = 0x558
movq %rdi, %rbx
movl %esi, %eax
imulq $0x9f8, %rax, %r12      # imm = 0x9F8
addq 0x678(%rdi), %r12
movq 0x648(%rdi), %rbp
imulq $0x18, %rax, %rcx
movl %edx, %r14d
movq 0xf8(%rdi), %rax
movl (%rax,%r14,4), %eax
imulq $0x38, %rax, %rax
movq %rcx, 0x10(%rsp)
addq (%rbp,%rcx), %rax
movq %rax, 0x30(%rsp)
imulq $0x510, %r14, %r15      # imm = 0x510
addq 0xc8(%rdi), %r15
movq %r14, 0x18(%rsp)
shlq $0x4, %r14
movq 0xe0(%rdi), %rax
addq %r14, %rax
movq %rax, 0x8(%rsp)
leaq 0x48(%rsp), %r13
movq %r13, %rdi
movq %r15, %rsi
callq 0x36388
movq %r13, %rdi
movq %r12, %rsi
callq 0xea60
movsd %xmm0, 0x28(%rsp)
movq %r12, %rdi
callq 0x38b70
movsd %xmm0, 0x20(%rsp)
xorpd %xmm0, %xmm0
minsd 0x28(%rsp), %xmm0
callq 0x6700
ucomisd 0x20(%rsp), %xmm0
movq 0x30(%rsp), %r13
jb 0x35feb
leaq 0x48(%rsp), %rdi
callq 0xfc60
movq 0x8(%rsp), %rax
movsd 0x8(%rax), %xmm1
leaq 0x38(%rsp), %rdi
callq 0x383a8
leaq 0x38(%rsp), %rdi
movq %r12, %rsi
callq 0x3840a
leaq 0x38(%rsp), %rsi
movq %r13, %rdi
callq 0x3843c
testb %al, %al
je 0x35feb
leaq 0x48(%rsp), %rsi
movq %r15, %rdi
callq 0x33b6a
movupd 0x38(%rsp), %xmm0
movq 0x8(%rsp), %rax
movupd %xmm0, (%rax)
incq 0x28(%r13)
addq 0x10(%rsp), %rbp
incq 0x30(%r13)
movq 0xf8(%rbx), %rax
movq 0x18(%rsp), %rcx
movl (%rax,%rcx,4), %r12d
movq (%rbp), %rcx
pushq $0x38
popq %r15
movl %r12d, %esi
movq 0x8(%rbp), %rax
subq %rcx, %rax
cqto
idivq %r15
decq %rax
cmpq %rsi, %rax
jbe 0x36055
imulq $0x38, %rsi, %r13
incq 0x18(%rcx,%r13)
leal 0x1(%rsi), %r12d
imulq $0x38, %r12, %rdi
addq %rcx, %rdi
movq 0xe0(%rbx), %rsi
addq %r14, %rsi
callq 0x3843c
testb %al, %al
je 0x36055
movq (%rbp), %rcx
incq 0x20(%rcx,%r13)
jmp 0x3600c
leaq 0x48(%rsp), %rdi
callq 0x21392
addq $0x558, %rsp            # imm = 0x558
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x36075
jmp 0x36075
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x21392
movq %rbx, %rdi
callq 0x66e0