// File: /workspace/github_cpp_makefile_star2_O2/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
imulq $0x18, %rax, %r13
addq 0x648(%rdi), %r13
movl %edx, %r12d
movq 0xf8(%rdi), %rax
movl (%rax,%r12,4), %ebp
movq %r14, %rdi
callq 0x38b70
movapd %xmm0, %xmm1
addsd %xmm0, %xmm1
movsd 0x6584(%rip), %xmm0     # 0x3c660
callq 0x66c0
movsd %xmm0, 0x8(%rsp)
movq %r14, %rdi
callq 0x38b80
mulsd 0x8(%rsp), %xmm0
cvttsd2si %xmm0, %r15d
addl %ebp, %r15d
movq 0xf8(%rbx), %rax
cmpl (%rax,%r12,4), %r15d
jne 0x3612a
movq %r14, %rdi
callq 0x38b70
movsd 0x607e(%rip), %xmm1     # 0x3c198
xorl %eax, %eax
ucomisd %xmm0, %xmm1
setbe %al
leal (%r15,%rax,2), %r15d
decl %r15d
movq 0x8(%r13), %rax
subq (%r13), %rax
pushq $0x38
popq %rcx
cqto
idivq %rcx
movl %r15d, %edi
movl %eax, %esi
callq 0x39174
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 0x36ba0
movsd %xmm0, 0x8(%rsp)
movq 0xf8(%rbx), %rax
movl (%rax,%r12,4), %esi
movq %rbx, %rdi
callq 0x36ba0
movsd 0x8(%rsp), %xmm1
subsd %xmm0, %xmm1
movapd %xmm1, %xmm0
addsd 0x10(%rsp), %xmm0
movq (%r13), %rcx
movq 0x8(%r13), %rax
subq %rcx, %rax
cqto
pushq $0x38
popq %rsi
idivq %rsi
movl 0x48(%rbx), %edx
cmpq %rdx, %rax
jne 0x36220
movsd 0x58(%rbx), %xmm1
movsd %xmm1, 0x10(%rsp)
movq 0xf8(%rbx), %rax
movl (%rax,%r12,4), %eax
imulq $0x38, %rax, %rax
movl 0x30(%rcx,%rax), %eax
incl %eax
movsd %xmm0, 0x8(%rsp)
cvtsi2sd %rax, %xmm0
movl 0x30(%rcx,%r15), %eax
incl %eax
cvtsi2sd %rax, %xmm1
divsd %xmm1, %xmm0
callq 0x63b0
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 0x38b70
movsd %xmm0, 0x10(%rsp)
movsd 0x8(%rsp), %xmm0
callq 0x6700
ucomisd 0x10(%rsp), %xmm0
jb 0x36278
addq (%r13), %r15
movq %r12, %rsi
shlq $0x4, %rsi
addq 0xe0(%rbx), %rsi
movq %r15, %rdi
callq 0x3843c
testb %al, %al
je 0x36278
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