// File: /workspace/github_cpp_makefile_star2_O1/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), %rcx
leaq (%rax,%rax,2), %rsi
movl %edx, %ebp
movq 0xf8(%rdi), %rax
movl (%rax,%rbp,4), %eax
imulq $0x38, %rax, %r14
movq %rcx, 0x18(%rsp)
movq %rsi, 0x10(%rsp)
addq (%rcx,%rsi,8), %r14
imulq $0x510, %rbp, %r15      # imm = 0x510
addq 0xc8(%rdi), %r15
movq %rbp, 0x20(%rsp)
shlq $0x4, %rbp
movq 0xe0(%rdi), %rax
addq %rbp, %rax
movq %rax, 0x8(%rsp)
leaq 0x48(%rsp), %r13
movq %r13, %rdi
movq %r15, %rsi
callq 0x38cae
movq %r13, %rdi
movq %r12, %rsi
callq 0x101a2
movsd %xmm0, 0x30(%rsp)
movq %r12, %rdi
callq 0x3c02c
movsd %xmm0, 0x28(%rsp)
xorpd %xmm0, %xmm0
minsd 0x30(%rsp), %xmm0
callq 0x6730
ucomisd 0x28(%rsp), %xmm0
jb 0x388c5
leaq 0x48(%rsp), %rdi
callq 0x114f4
movq 0x8(%rsp), %r13
movsd 0x8(%r13), %xmm1
leaq 0x38(%rsp), %rdi
callq 0x3b586
leaq 0x38(%rsp), %rdi
movq %r12, %rsi
callq 0x3b5ea
leaq 0x38(%rsp), %rsi
movq %r14, %rdi
callq 0x3b61c
testb %al, %al
je 0x388c5
leaq 0x48(%rsp), %rsi
movq %r15, %rdi
callq 0x3621c
movupd 0x38(%rsp), %xmm0
movupd %xmm0, (%r13)
incq 0x28(%r14)
incq 0x30(%r14)
movq 0x18(%rsp), %rax
movq 0x10(%rsp), %rcx
leaq (%rax,%rcx,8), %r14
movq 0xf8(%rbx), %rax
movq 0x20(%rsp), %rcx
movl (%rax,%rcx,4), %r15d
movq (%r14), %rax
movq 0x8(%r14), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
movabsq $0x6db6db6db6db6db7, %rdx # imm = 0x6DB6DB6DB6DB6DB7
imulq %rdx, %rcx
decq %rcx
cmpq %r15, %rcx
jbe 0x38964
leal 0x1(%r15), %r13d
imulq $0x38, %r15, %r12
incq 0x18(%rax,%r12)
movl %r13d, %r15d
imulq $0x38, %r15, %rdi
addq %rax, %rdi
movq 0xe0(%rbx), %rsi
addq %rbp, %rsi
callq 0x3b61c
testb %al, %al
je 0x38964
movq (%r14), %rax
incq 0x20(%rax,%r12)
movq (%r14), %rax
movq 0x8(%r14), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
movabsq $0x6db6db6db6db6db7, %rdx # imm = 0x6DB6DB6DB6DB6DB7
imulq %rdx, %rcx
decq %rcx
incl %r13d
cmpq %r15, %rcx
ja 0x3890f
leaq 0x48(%rsp), %rdi
callq 0x2148e
addq $0x558, %rsp            # imm = 0x558
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x38984
jmp 0x38984
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x2148e
movq %rbx, %rdi
callq 0x6710
nop