// File: 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
movq %rsp, %rbp
subq $0x5d0, %rsp            # imm = 0x5D0
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x590(%rbp)
addq $0x678, %rdi            # imm = 0x678
movl -0xc(%rbp), %eax
movl %eax, %esi
callq 0xa8770
movq -0x590(%rbp), %rdi
movq %rax, -0x18(%rbp)
addq $0x648, %rdi            # imm = 0x648
movl -0xc(%rbp), %eax
movl %eax, %esi
callq 0xaa000
movq -0x590(%rbp), %rdi
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x598(%rbp)
addq $0xf8, %rdi
movl -0x10(%rbp), %eax
movl %eax, %esi
callq 0xabd30
movq -0x598(%rbp), %rdi
movl (%rax), %eax
movl %eax, %esi
callq 0xaa4b0
movq -0x590(%rbp), %rdi
movq %rax, -0x28(%rbp)
addq $0xc8, %rdi
movl -0x10(%rbp), %eax
movl %eax, %esi
callq 0xa1e50
movq -0x590(%rbp), %rdi
movq %rax, -0x30(%rbp)
addq $0xe0, %rdi
movl -0x10(%rbp), %eax
movl %eax, %esi
callq 0xa2260
movq %rax, -0x38(%rbp)
movq -0x30(%rbp), %rsi
leaq -0x548(%rbp), %rdi
movq %rdi, -0x588(%rbp)
callq 0xabd50
movq -0x588(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x20bb0
movsd %xmm0, -0x580(%rbp)
jmp 0xab551
movsd -0x580(%rbp), %xmm0
movsd %xmm0, -0x550(%rbp)
movsd -0x550(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0xab5a2
xorps %xmm0, %xmm0
movsd %xmm0, -0x550(%rbp)
jmp 0xab5a2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x558(%rbp)
movl %eax, -0x55c(%rbp)
leaq -0x548(%rbp), %rdi
callq 0x6e200
jmp 0xab7cb
movq -0x18(%rbp), %rdi
callq 0xb26f0
movsd %xmm0, -0x5a0(%rbp)
jmp 0xab5b5
movsd -0x550(%rbp), %xmm0
callq 0x6870
movsd -0x5a0(%rbp), %xmm1
ucomisd %xmm1, %xmm0
jb 0xab6a2
leaq -0x548(%rbp), %rdi
callq 0x233b0
movsd %xmm0, -0x5a8(%rbp)
jmp 0xab5ea
movq -0x38(%rbp), %rdi
callq 0xa93c0
movaps %xmm0, %xmm1
movsd -0x5a8(%rbp), %xmm0
leaq -0x570(%rbp), %rdi
callq 0xb1910
jmp 0xab60c
movq -0x18(%rbp), %rsi
leaq -0x570(%rbp), %rdi
callq 0xb19d0
movsd %xmm0, -0x5b0(%rbp)
jmp 0xab626
movsd -0x5b0(%rbp), %xmm1
movsd -0x550(%rbp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x550(%rbp)
movq -0x28(%rbp), %rdi
callq 0xa9390
movq %rax, %rdi
leaq -0x570(%rbp), %rsi
callq 0xb1a20
movb %al, -0x5b1(%rbp)
jmp 0xab662
movb -0x5b1(%rbp), %al
testb $0x1, %al
jne 0xab66e
jmp 0xab6a0
movq -0x30(%rbp), %rdi
leaq -0x548(%rbp), %rsi
callq 0xa1eb0
jmp 0xab680
movq -0x38(%rbp), %rax
movups -0x570(%rbp), %xmm0
movups %xmm0, (%rax)
movq -0x28(%rbp), %rdi
movl $0x1, %esi
callq 0xaa4d0
jmp 0xab69e
jmp 0xab6a0
jmp 0xab6a2
movq -0x28(%rbp), %rdi
movl $0x1, %esi
callq 0xaa510
jmp 0xab6b2
movq -0x590(%rbp), %rdi
addq $0xf8, %rdi
movl -0x10(%rbp), %eax
movl %eax, %esi
callq 0xabd30
movl (%rax), %eax
movl %eax, -0x574(%rbp)
movl -0x574(%rbp), %eax
movq %rax, -0x5c0(%rbp)
movq -0x20(%rbp), %rdi
callq 0xa41f0
movq %rax, %rcx
movq -0x5c0(%rbp), %rax
subq $0x1, %rcx
cmpq %rcx, %rax
jae 0xab7b6
movq -0x20(%rbp), %rdi
movl -0x574(%rbp), %eax
movl %eax, %esi
callq 0xaa4b0
movq %rax, %rdi
movl $0x1, %esi
callq 0xaa530
jmp 0xab71f
movq -0x20(%rbp), %rdi
movl -0x574(%rbp), %eax
incl %eax
movl %eax, %esi
callq 0xaa4b0
movq %rax, %rdi
callq 0xa9390
movq -0x590(%rbp), %rdi
movq %rax, -0x5d0(%rbp)
addq $0xe0, %rdi
movl -0x10(%rbp), %eax
movl %eax, %esi
callq 0xa2260
movq -0x5d0(%rbp), %rdi
movq %rax, %rsi
callq 0xb1a20
movb %al, -0x5c1(%rbp)
jmp 0xab770
movb -0x5c1(%rbp), %al
testb $0x1, %al
jne 0xab77c
jmp 0xab79e
movq -0x20(%rbp), %rdi
movl -0x574(%rbp), %eax
movl %eax, %esi
callq 0xaa4b0
movq %rax, %rdi
movl $0x1, %esi
callq 0xaa550
jmp 0xab79c
jmp 0xab7a0
jmp 0xab7b6
jmp 0xab7a2
movl -0x574(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x574(%rbp)
jmp 0xab6d2
leaq -0x548(%rbp), %rdi
callq 0x6e200
addq $0x5d0, %rsp            # imm = 0x5D0
popq %rbp
retq
movq -0x558(%rbp), %rdi
callq 0x6830
nopw (%rax,%rax)