// File: /workspace/github_cpp_makefile_star2_O2/j-faria[P]kima/src/RVmodel.cpp
// Function: RVmodel::from_prior(DNest4::RNG&)
void RVmodel::from_prior(RNG& rng)
{
    // preliminaries
    setPriors();
    save_setup();

    planets.from_prior(rng);
    planets.consolidate_diff();

    background = Cprior->generate(rng);

    if(multi_instrument)
    {
        for(int i=0; i<offsets.size(); i++)
            offsets[i] = offsets_prior->generate(rng);
        for(int i=0; i<jitters.size(); i++)
            jitters[i] = Jprior->generate(rng);
    }
    else
    {
        extra_sigma = Jprior->generate(rng);
    }


    if(trend)
    {
        if (degree >= 1) slope = slope_prior->generate(rng);
        if (degree >= 2) quadr = quadr_prior->generate(rng);
        if (degree == 3) cubic = cubic_prior->generate(rng);
    }

    if(GP)
    {
        eta1 = exp(log_eta1_prior->generate(rng)); // m/s

        eta2 = eta2_prior->generate(rng); // days

        eta3 = eta3_prior->generate(rng); // days

        if (kernel == standard)
            eta4 = exp(log_eta4_prior->generate(rng));
    }

    if(MA)
    {
        sigmaMA = sigmaMA_prior->generate(rng);
        tauMA = tauMA_prior->generate(rng);
    }

    auto data = Data::get_instance();
    if (data.indicator_correlations)
    {
        for (unsigned i=0; i<data.number_indicators; i++)
            betas[i] = betaprior->generate(rng);
    }

    if (known_object) { // KO mode!
        KO_P.resize(n_known_object);
        KO_K.resize(n_known_object);
        KO_e.resize(n_known_object);
        KO_phi.resize(n_known_object);
        KO_w.resize(n_known_object);

        for (int i=0; i<n_known_object; i++){
            KO_P[i] = KO_Pprior[i]->generate(rng);
            KO_K[i] = KO_Kprior[i]->generate(rng);
            KO_e[i] = KO_eprior[i]->generate(rng);
            KO_phi[i] = KO_phiprior[i]->generate(rng);
            KO_w[i] = KO_wprior[i]->generate(rng);
        }
    }

    if (studentt)
        nu = nu_prior->generate(rng);


    calculate_mu();

    if(GP) calculate_C();

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
movq %rsi, %r14
movq %rdi, %rbx
callq 0xc60c
movq %rbx, %rdi
callq 0xd046
leaq 0x8(%rbx), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x11c2c
movq %r15, %rdi
callq 0x11d10
movq 0x3b8(%rbx), %rdi
movq %r14, %rsi
callq 0x39b9c
movsd %xmm0, 0x120(%rbx)
leaq 0x3a35b(%rip), %rax     # 0x47014
cmpb $0x1, (%rax)
jne 0xcd3a
movq 0x128(%rbx), %rax
xorl %r15d, %r15d
movq 0x130(%rbx), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
cmpq %r15, %rcx
jbe 0xccfc
movq 0x408(%rbx), %rdi
movq %r14, %rsi
callq 0x39b9c
movq 0x128(%rbx), %rax
movsd %xmm0, (%rax,%r15,8)
incq %r15
jmp 0xccc8
movq 0x140(%rbx), %rax
xorl %r15d, %r15d
movq 0x148(%rbx), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
cmpq %r15, %rcx
jbe 0xcd51
movq 0x3c8(%rbx), %rdi
movq %r14, %rsi
callq 0x39b9c
movq 0x140(%rbx), %rax
movsd %xmm0, (%rax,%r15,8)
incq %r15
jmp 0xcd06
movq 0x3c8(%rbx), %rdi
movq %r14, %rsi
callq 0x39b9c
movsd %xmm0, 0x198(%rbx)
leaq 0x3a2b7(%rip), %rax     # 0x4700f
cmpb $0x1, (%rax)
jne 0xcdb9
leaq 0x3a2ac(%rip), %rax     # 0x47010
movl (%rax), %ebp
testl %ebp, %ebp
jle 0xcdb9
movq 0x3d8(%rbx), %rdi
movq %r14, %rsi
callq 0x39b9c
movsd %xmm0, 0x170(%rbx)
cmpl $0x1, %ebp
je 0xcdb9
movq 0x3e8(%rbx), %rdi
movq %r14, %rsi
callq 0x39b9c
movsd %xmm0, 0x178(%rbx)
cmpl $0x3, %ebp
jne 0xcdb9
movq 0x3f8(%rbx), %rdi
movq %r14, %rsi
callq 0x39b9c
movsd %xmm0, 0x180(%rbx)
leaq 0x3a24c(%rip), %rax     # 0x4700c
movb (%rax), %bpl
cmpb $0x1, %bpl
jne 0xce38
movq 0x448(%rbx), %rdi
movq %r14, %rsi
callq 0x39b9c
callq 0x6700
movsd %xmm0, 0x1b0(%rbx)
movq 0x458(%rbx), %rdi
movq %r14, %rsi
callq 0x39b9c
movsd %xmm0, 0x1b8(%rbx)
movq 0x468(%rbx), %rdi
movq %r14, %rsi
callq 0x39b9c
movsd %xmm0, 0x1c0(%rbx)
cmpl $0x0, 0x1a8(%rbx)
jne 0xce38
movq 0x478(%rbx), %rdi
movq %r14, %rsi
callq 0x39b9c
callq 0x6700
movsd %xmm0, 0x1c8(%rbx)
leaq 0x3a1ce(%rip), %rax     # 0x4700d
cmpb $0x1, (%rax)
jne 0xce72
movq 0x428(%rbx), %rdi
movq %r14, %rsi
callq 0x39b9c
movsd %xmm0, 0x188(%rbx)
movq 0x438(%rbx), %rdi
movq %r14, %rsi
callq 0x39b9c
movsd %xmm0, 0x190(%rbx)
leaq 0x57707(%rip), %rsi     # 0x64580
movq %rsp, %r15
movq %r15, %rdi
callq 0x11aa2
cmpb $0x1, 0x78(%r15)
jne 0xceb8
xorl %r15d, %r15d
movl 0x7c(%rsp), %eax
cmpq %rax, %r15
jae 0xceb8
movq 0x418(%rbx), %rdi
movq %r14, %rsi
callq 0x39b9c
movq 0x158(%rbx), %rax
movsd %xmm0, (%rax,%r15,8)
incq %r15
jmp 0xce8e
leaq 0x3a156(%rip), %rax     # 0x47015
cmpb $0x1, (%rax)
jne 0xcfdd
leaq 0x308(%rbx), %rdi
leaq 0x3a142(%rip), %rax     # 0x47018
movslq (%rax), %r15
movq %r15, %rsi
callq 0x11d8e
leaq 0x320(%rbx), %rdi
movq %r15, %rsi
callq 0x11d8e
leaq 0x338(%rbx), %rdi
movq %r15, %rsi
callq 0x11d8e
leaq 0x350(%rbx), %rdi
movq %r15, %rsi
callq 0x11d8e
leaq 0x368(%rbx), %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0x11d8e
xorl %r13d, %r13d
testl %r15d, %r15d
cmovlel %r13d, %r15d
shlq $0x3, %r15
cmpq %r13, %r15
je 0xcfdd
movq 0x488(%rbx), %rax
movq (%rax,%r13,2), %rdi
movq %r14, %rsi
callq 0x39b9c
movq 0x308(%rbx), %rax
movsd %xmm0, (%rax,%r13)
movq 0x4a0(%rbx), %rax
movq (%rax,%r13,2), %rdi
movq %r14, %rsi
callq 0x39b9c
movq 0x320(%rbx), %rax
movsd %xmm0, (%rax,%r13)
movq 0x4b8(%rbx), %rax
movq (%rax,%r13,2), %rdi
movq %r14, %rsi
callq 0x39b9c
movq 0x338(%rbx), %rax
movsd %xmm0, (%rax,%r13)
movq 0x4d0(%rbx), %rax
movq (%rax,%r13,2), %rdi
movq %r14, %rsi
callq 0x39b9c
movq 0x350(%rbx), %rax
movsd %xmm0, (%rax,%r13)
movq 0x4e8(%rbx), %rax
movq (%rax,%r13,2), %rdi
movq %r14, %rsi
callq 0x39b9c
movq (%r12), %rax
movsd %xmm0, (%rax,%r13)
addq $0x8, %r13
jmp 0xcf2e
leaq 0x3a038(%rip), %rax     # 0x4701c
cmpb $0x1, (%rax)
jne 0xd000
movq 0x500(%rbx), %rdi
movq %r14, %rsi
callq 0x39b9c
movsd %xmm0, 0x1a0(%rbx)
movq %rbx, %rdi
callq 0xdb16
testb %bpl, %bpl
je 0xd015
movq %rbx, %rdi
callq 0xdfc2
movq %rsp, %rdi
callq 0xb0be
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xd033
jmp 0xd033
movq %rax, %rbx
movq %rsp, %rdi
callq 0xb0be
movq %rbx, %rdi
callq 0x66e0