// File: /workspace/github_cpp_makefile_star2_O3/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 0xcd20
movq %rbx, %rdi
callq 0xdaea
leaq 0x8(%rbx), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x15730
movq %r15, %rdi
callq 0x15808
movq 0x3b8(%rbx), %rdi
movq %r14, %rsi
callq 0x3ac1c
movsd %xmm0, 0x120(%rbx)
leaq 0x3519d(%rip), %rax     # 0x428e4
cmpb $0x1, (%rax)
jne 0xd7dc
movq 0x130(%rbx), %rax
cmpq 0x128(%rbx), %rax
je 0xd795
xorl %r15d, %r15d
movq 0x408(%rbx), %rdi
movq %r14, %rsi
callq 0x3ac1c
movq 0x128(%rbx), %rax
movsd %xmm0, (%rax,%r15,8)
incq %r15
movq 0x130(%rbx), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
cmpq %r15, %rcx
ja 0xd763
movq 0x148(%rbx), %rax
cmpq 0x140(%rbx), %rax
je 0xd7f3
xorl %r15d, %r15d
movq 0x3c8(%rbx), %rdi
movq %r14, %rsi
callq 0x3ac1c
movq 0x140(%rbx), %rax
movsd %xmm0, (%rax,%r15,8)
incq %r15
movq 0x148(%rbx), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
cmpq %r15, %rcx
ja 0xd7a8
jmp 0xd7f3
movq 0x3c8(%rbx), %rdi
movq %r14, %rsi
callq 0x3ac1c
movsd %xmm0, 0x198(%rbx)
leaq 0x350e5(%rip), %rax     # 0x428df
cmpb $0x1, (%rax)
jne 0xd85b
leaq 0x350da(%rip), %rax     # 0x428e0
movl (%rax), %ebp
testl %ebp, %ebp
jle 0xd85b
movq 0x3d8(%rbx), %rdi
movq %r14, %rsi
callq 0x3ac1c
movsd %xmm0, 0x170(%rbx)
cmpl $0x1, %ebp
je 0xd85b
movq 0x3e8(%rbx), %rdi
movq %r14, %rsi
callq 0x3ac1c
movsd %xmm0, 0x178(%rbx)
cmpl $0x3, %ebp
jne 0xd85b
movq 0x3f8(%rbx), %rdi
movq %r14, %rsi
callq 0x3ac1c
movsd %xmm0, 0x180(%rbx)
leaq 0x3507a(%rip), %rax     # 0x428dc
movb (%rax), %bpl
cmpb $0x1, %bpl
jne 0xd8da
movq 0x448(%rbx), %rdi
movq %r14, %rsi
callq 0x3ac1c
callq 0x6730
movsd %xmm0, 0x1b0(%rbx)
movq 0x458(%rbx), %rdi
movq %r14, %rsi
callq 0x3ac1c
movsd %xmm0, 0x1b8(%rbx)
movq 0x468(%rbx), %rdi
movq %r14, %rsi
callq 0x3ac1c
movsd %xmm0, 0x1c0(%rbx)
cmpl $0x0, 0x1a8(%rbx)
jne 0xd8da
movq 0x478(%rbx), %rdi
movq %r14, %rsi
callq 0x3ac1c
callq 0x6730
movsd %xmm0, 0x1c8(%rbx)
leaq 0x34ffc(%rip), %rax     # 0x428dd
cmpb $0x1, (%rax)
jne 0xd914
movq 0x428(%rbx), %rdi
movq %r14, %rsi
callq 0x3ac1c
movsd %xmm0, 0x188(%rbx)
movq 0x438(%rbx), %rdi
movq %r14, %rsi
callq 0x3ac1c
movsd %xmm0, 0x190(%rbx)
leaq 0x42ae5(%rip), %rsi     # 0x50400
movq %rsp, %r15
movq %r15, %rdi
callq 0x15552
cmpb $0x1, 0x78(%r15)
jne 0xd95f
cmpl $0x0, 0x7c(%rsp)
je 0xd95f
xorl %r15d, %r15d
movq 0x418(%rbx), %rdi
movq %r14, %rsi
callq 0x3ac1c
movq 0x158(%rbx), %rax
movsd %xmm0, (%rax,%r15,8)
incq %r15
movl 0x7c(%rsp), %eax
cmpq %rax, %r15
jb 0xd937
leaq 0x34f7f(%rip), %rax     # 0x428e5
cmpb $0x1, (%rax)
jne 0xda81
leaq 0x308(%rbx), %rdi
leaq 0x34f6b(%rip), %rax     # 0x428e8
movslq (%rax), %r15
movq %r15, %rsi
callq 0x1589e
leaq 0x320(%rbx), %rdi
movq %r15, %rsi
callq 0x1589e
leaq 0x338(%rbx), %rdi
movq %r15, %rsi
callq 0x1589e
leaq 0x350(%rbx), %rdi
movq %r15, %rsi
callq 0x1589e
leaq 0x368(%rbx), %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0x1589e
testl %r15d, %r15d
jle 0xda81
shlq $0x3, %r15
xorl %r13d, %r13d
movq 0x488(%rbx), %rax
movq (%rax,%r13,2), %rdi
movq %r14, %rsi
callq 0x3ac1c
movq 0x308(%rbx), %rax
movsd %xmm0, (%rax,%r13)
movq 0x4a0(%rbx), %rax
movq (%rax,%r13,2), %rdi
movq %r14, %rsi
callq 0x3ac1c
movq 0x320(%rbx), %rax
movsd %xmm0, (%rax,%r13)
movq 0x4b8(%rbx), %rax
movq (%rax,%r13,2), %rdi
movq %r14, %rsi
callq 0x3ac1c
movq 0x338(%rbx), %rax
movsd %xmm0, (%rax,%r13)
movq 0x4d0(%rbx), %rax
movq (%rax,%r13,2), %rdi
movq %r14, %rsi
callq 0x3ac1c
movq 0x350(%rbx), %rax
movsd %xmm0, (%rax,%r13)
movq 0x4e8(%rbx), %rax
movq (%rax,%r13,2), %rdi
movq %r14, %rsi
callq 0x3ac1c
movq (%r12), %rax
movsd %xmm0, (%rax,%r13)
addq $0x8, %r13
cmpq %r13, %r15
jne 0xd9d7
leaq 0x34e64(%rip), %rax     # 0x428ec
cmpb $0x1, (%rax)
jne 0xdaa4
movq 0x500(%rbx), %rdi
movq %r14, %rsi
callq 0x3ac1c
movsd %xmm0, 0x1a0(%rbx)
movq %rbx, %rdi
callq 0xef06
testb %bpl, %bpl
je 0xdab9
movq %rbx, %rdi
callq 0xf44e
movq %rsp, %rdi
callq 0xb8d2
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xdad7
jmp 0xdad7
movq %rax, %rbx
movq %rsp, %rdi
callq 0xb8d2
movq %rbx, %rdi
callq 0x6710