// File: j-faria[P]kima/DNest4/code/RJObject/RJObjectImpl.h
// Function: DNest4::RJObject<RVConditionalPrior>::perturb(DNest4::RNG&, bool)
double RJObject<ConditionalPrior>::perturb(RNG& rng, bool hyperparameters)
{
	if(max_num_components == 0)
		return 0.;

	added.resize(0);
	removed.resize(0);
    components_changed_flag = true;

	double logH = 0.;

	int which;
    do
    {
        which = (fixed)?(1 + rng.rand_int(2)):(rng.rand_int(3));
    }while(!hyperparameters && which == 1);

	if(which == 0)
	{
		// Do some birth or death
		logH += perturb_num_components(rng);
	}
	else if(which == 1)
	{
		// Change the hyperparameters
		if(rng.rand() <= 0.5)
		{
			logH += conditional_prior.perturb1(rng, components, u_components);
            components_changed_flag = false;
		}
		else
		{
			removed = components;
			logH += conditional_prior.perturb2(rng, components, u_components);
			added = components;
		}
	}
	else if(which == 2)
	{
		logH += perturb_components(rng);
	}

	return logH;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movb %dl, %al
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
andb $0x1, %al
movb %al, -0x19(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x38(%rbp)
cmpl $0x0, 0x8(%rax)
jne 0x27b62
xorps %xmm0, %xmm0
movsd %xmm0, -0x8(%rbp)
jmp 0x27d02
movq -0x38(%rbp), %rdi
addq $0xe8, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x15ca0
movq -0x38(%rbp), %rdi
addq $0x100, %rdi            # imm = 0x100
xorl %eax, %eax
movl %eax, %esi
callq 0x15ca0
movq -0x38(%rbp), %rax
movb $0x1, 0xb0(%rax)
xorps %xmm0, %xmm0
movsd %xmm0, -0x28(%rbp)
movq -0x38(%rbp), %rax
testb $0x1, 0xc(%rax)
je 0x27bbd
movq -0x18(%rbp), %rdi
movl $0x2, %esi
callq 0xb28c0
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x27bce
movq -0x18(%rbp), %rdi
movl $0x3, %esi
callq 0xb28c0
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
movl %eax, -0x2c(%rbp)
xorl %eax, %eax
testb $0x1, -0x19(%rbp)
movb %al, -0x3d(%rbp)
jne 0x27be9
cmpl $0x1, -0x2c(%rbp)
sete %al
movb %al, -0x3d(%rbp)
movb -0x3d(%rbp), %al
testb $0x1, %al
jne 0x27b9d
cmpl $0x0, -0x2c(%rbp)
jne 0x27c12
movq -0x38(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x313d0
addsd -0x28(%rbp), %xmm0
movsd %xmm0, -0x28(%rbp)
jmp 0x27cf8
cmpl $0x1, -0x2c(%rbp)
jne 0x27cd7
movq -0x18(%rbp), %rdi
callq 0xb26f0
movaps %xmm0, %xmm1
movsd 0x8f568(%rip), %xmm0    # 0xb7198
ucomisd %xmm1, %xmm0
jb 0x27c72
movq -0x38(%rbp), %rcx
movq %rcx, %rdi
addq $0x10, %rdi
movq -0x18(%rbp), %rsi
movq %rcx, %rdx
addq $0xb8, %rdx
addq $0xd0, %rcx
callq 0xb6460
movq -0x38(%rbp), %rax
addsd -0x28(%rbp), %xmm0
movsd %xmm0, -0x28(%rbp)
movb $0x0, 0xb0(%rax)
jmp 0x27cd5
movq -0x38(%rbp), %rdi
movq %rdi, %rsi
addq $0xb8, %rsi
addq $0x100, %rdi            # imm = 0x100
callq 0x31540
movq -0x38(%rbp), %rcx
movq %rcx, %rdi
addq $0x10, %rdi
movq -0x18(%rbp), %rsi
movq %rcx, %rdx
addq $0xb8, %rdx
addq $0xd0, %rcx
callq 0xb6650
movq -0x38(%rbp), %rdi
addsd -0x28(%rbp), %xmm0
movsd %xmm0, -0x28(%rbp)
movq %rdi, %rsi
addq $0xb8, %rsi
addq $0xe8, %rdi
callq 0x31540
jmp 0x27cf6
cmpl $0x2, -0x2c(%rbp)
jne 0x27cf4
movq -0x38(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x31790
addsd -0x28(%rbp), %xmm0
movsd %xmm0, -0x28(%rbp)
jmp 0x27cf6
jmp 0x27cf8
movsd -0x28(%rbp), %xmm0
movsd %xmm0, -0x8(%rbp)
movsd -0x8(%rbp), %xmm0
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)