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

	// Reference to this thread's copy of levels
	std::vector<Level>& _levels = copies_of_levels[thread];

	// Generate proposal
	int proposal = static_cast<int>(level_assignments[which])
						+ static_cast<int>(pow(10., 2.*rng.rand())*rng.randn());

	// If the proposal was to not move, go +- one level
	if(proposal == static_cast<int>(level_assignments[which]))
		proposal = ((rng.rand() < 0.5)?(proposal-1):(proposal+1));

	// Wrap into allowed range
	proposal = DNest4::mod(proposal, static_cast<int>(_levels.size()));

	// Acceptance probability
	double log_A = -_levels[proposal].get_log_X()
					+ _levels[level_assignments[which]].get_log_X();

	// Pushing up part
	log_A += log_push(proposal) - log_push(level_assignments[which]);

	// Enforce uniform exploration part (if all levels exist)
	if(_levels.size() == options.max_num_levels)
		log_A += options.beta*log((double)(_levels[level_assignments[which]].get_tries() + 1)/(double)(_levels[proposal].get_tries() + 1));

	// Prevent exponentiation of huge numbers
	if(log_A > 0.)
		log_A = 0.;

	// Make a LikelihoodType for the proposal
	if(rng.rand() <= exp(log_A) && _levels[proposal].get_log_likelihood() < log_likelihoods[which])
	{
		// Accept
		level_assignments[which] = static_cast<unsigned int>(proposal);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
movl %esi, %eax
imulq $0x9f8, %rax, %r14      # imm = 0x9F8
addq 0x678(%rdi), %r14
leaq (%rax,%rax,2), %r13
shlq $0x3, %r13
addq 0x648(%rdi), %r13
movl %edx, %r12d
movq 0xf8(%rdi), %rax
movl (%rax,%r12,4), %ebp
movq %r14, %rdi
callq 0x3c02c
movapd %xmm0, %xmm1
addsd %xmm0, %xmm1
movsd 0x6ca0(%rip), %xmm0     # 0x3f690
callq 0x66f0
movsd %xmm0, 0x8(%rsp)
movq %r14, %rdi
callq 0x3c054
mulsd 0x8(%rsp), %xmm0
cvttsd2si %xmm0, %r15d
addl %ebp, %r15d
movq 0xf8(%rbx), %rax
cmpl (%rax,%r12,4), %r15d
jne 0x38a3e
movq %r14, %rdi
callq 0x3c02c
movsd 0x676a(%rip), %xmm1     # 0x3f198
xorl %eax, %eax
ucomisd %xmm0, %xmm1
setbe %al
leal (%r15,%rax,2), %r15d
decl %r15d
movq 0x8(%r13), %rax
subq (%r13), %rax
shrq $0x3, %rax
imull $0xb6db6db7, %eax, %esi # imm = 0xB6DB6DB7
movl %r15d, %edi
callq 0x3c677
movl %eax, %ebp
cltq
movq (%r13), %rcx
imulq $0x38, %rax, %r15
movq 0xf8(%rbx), %rax
movl (%rax,%r12,4), %eax
imulq $0x38, %rax, %rax
movsd 0x10(%rcx,%rax), %xmm0
subsd 0x10(%rcx,%r15), %xmm0
movsd %xmm0, 0x10(%rsp)
movq %rbx, %rdi
movl %ebp, %esi
callq 0x39968
movsd %xmm0, 0x8(%rsp)
movq 0xf8(%rbx), %rax
movl (%rax,%r12,4), %esi
movq %rbx, %rdi
callq 0x39968
movsd 0x8(%rsp), %xmm1
subsd %xmm0, %xmm1
movapd %xmm1, %xmm0
addsd 0x10(%rsp), %xmm0
movq (%r13), %rax
movq 0x8(%r13), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
movabsq $0x6db6db6db6db6db7, %rdx # imm = 0x6DB6DB6DB6DB6DB7
imulq %rcx, %rdx
movl 0x48(%rbx), %ecx
cmpq %rcx, %rdx
jne 0x38b44
movsd 0x58(%rbx), %xmm1
movsd %xmm1, 0x10(%rsp)
movq 0xf8(%rbx), %rcx
movl (%rcx,%r12,4), %ecx
imulq $0x38, %rcx, %rcx
movl 0x30(%rax,%rcx), %ecx
incl %ecx
movsd %xmm0, 0x8(%rsp)
xorps %xmm0, %xmm0
cvtsi2sd %rcx, %xmm0
movl 0x30(%rax,%r15), %eax
incl %eax
xorps %xmm1, %xmm1
cvtsi2sd %rax, %xmm1
divsd %xmm1, %xmm0
callq 0x63c0
mulsd 0x10(%rsp), %xmm0
movsd 0x8(%rsp), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, 0x8(%rsp)
movsd 0x8(%rsp), %xmm0
xorpd %xmm1, %xmm1
minsd %xmm0, %xmm1
movsd %xmm1, 0x8(%rsp)
movq %r14, %rdi
callq 0x3c02c
movsd %xmm0, 0x10(%rsp)
movsd 0x8(%rsp), %xmm0
callq 0x6730
ucomisd 0x10(%rsp), %xmm0
jb 0x38b9c
addq (%r13), %r15
movq %r12, %rsi
shlq $0x4, %rsi
addq 0xe0(%rbx), %rsi
movq %r15, %rdi
callq 0x3b61c
testb %al, %al
je 0x38b9c
movq 0xf8(%rbx), %rax
movl %ebp, (%rax,%r12,4)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop