// File: 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
movq %rsp, %rbp
subq $0x1a0, %rsp            # imm = 0x1A0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x140(%rbp)
callq 0x1c200
movq -0x140(%rbp), %rdi
callq 0x1d550
movq -0x140(%rbp), %rdi
addq $0x8, %rdi
movq -0x10(%rbp), %rsi
callq 0x26f10
movq -0x140(%rbp), %rdi
addq $0x8, %rdi
callq 0x27050
movq -0x140(%rbp), %rdi
addq $0x3b8, %rdi            # imm = 0x3B8
callq 0xc680
movq %rax, %rdi
movq -0x10(%rbp), %rsi
callq 0xb44c0
movq -0x140(%rbp), %rax
movsd %xmm0, 0x120(%rax)
leaq 0xa8bb0(%rip), %rax     # 0xc59a8
testb $0x1, (%rax)
je 0x1cf1b
movl $0x0, -0x14(%rbp)
movq -0x140(%rbp), %rdi
movslq -0x14(%rbp), %rax
movq %rax, -0x148(%rbp)
addq $0x128, %rdi            # imm = 0x128
callq 0x7c90
movq %rax, %rcx
movq -0x148(%rbp), %rax
cmpq %rcx, %rax
jae 0x1ce8d
movq -0x140(%rbp), %rdi
addq $0x408, %rdi            # imm = 0x408
callq 0xc680
movq %rax, %rdi
movq -0x10(%rbp), %rsi
callq 0xb44c0
movq -0x140(%rbp), %rdi
movsd %xmm0, -0x150(%rbp)
addq $0x128, %rdi            # imm = 0x128
movslq -0x14(%rbp), %rsi
callq 0xc6a0
movsd -0x150(%rbp), %xmm0
movsd %xmm0, (%rax)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x1ce08
movl $0x0, -0x18(%rbp)
movq -0x140(%rbp), %rdi
movslq -0x18(%rbp), %rax
movq %rax, -0x158(%rbp)
addq $0x140, %rdi            # imm = 0x140
callq 0x7c90
movq %rax, %rcx
movq -0x158(%rbp), %rax
cmpq %rcx, %rax
jae 0x1cf19
movq -0x140(%rbp), %rdi
addq $0x3c8, %rdi            # imm = 0x3C8
callq 0xc680
movq %rax, %rdi
movq -0x10(%rbp), %rsi
callq 0xb44c0
movq -0x140(%rbp), %rdi
movsd %xmm0, -0x160(%rbp)
addq $0x140, %rdi            # imm = 0x140
movslq -0x18(%rbp), %rsi
callq 0xc6a0
movsd -0x160(%rbp), %xmm0
movsd %xmm0, (%rax)
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x1ce94
jmp 0x1cf49
movq -0x140(%rbp), %rdi
addq $0x3c8, %rdi            # imm = 0x3C8
callq 0xc680
movq %rax, %rdi
movq -0x10(%rbp), %rsi
callq 0xb44c0
movq -0x140(%rbp), %rax
movsd %xmm0, 0x198(%rax)
leaq 0xa8a53(%rip), %rax     # 0xc59a3
testb $0x1, (%rax)
je 0x1d009
leaq 0xa8a44(%rip), %rax     # 0xc59a4
cmpl $0x1, (%rax)
jl 0x1cf93
movq -0x140(%rbp), %rdi
addq $0x3d8, %rdi            # imm = 0x3D8
callq 0xc680
movq %rax, %rdi
movq -0x10(%rbp), %rsi
callq 0xb44c0
movq -0x140(%rbp), %rax
movsd %xmm0, 0x170(%rax)
leaq 0xa8a0a(%rip), %rax     # 0xc59a4
cmpl $0x2, (%rax)
jl 0x1cfcd
movq -0x140(%rbp), %rdi
addq $0x3e8, %rdi            # imm = 0x3E8
callq 0xc680
movq %rax, %rdi
movq -0x10(%rbp), %rsi
callq 0xb44c0
movq -0x140(%rbp), %rax
movsd %xmm0, 0x178(%rax)
leaq 0xa89d0(%rip), %rax     # 0xc59a4
cmpl $0x3, (%rax)
jne 0x1d007
movq -0x140(%rbp), %rdi
addq $0x3f8, %rdi            # imm = 0x3F8
callq 0xc680
movq %rax, %rdi
movq -0x10(%rbp), %rsi
callq 0xb44c0
movq -0x140(%rbp), %rax
movsd %xmm0, 0x180(%rax)
jmp 0x1d009
leaq 0xa8990(%rip), %rax     # 0xc59a0
testb $0x1, (%rax)
je 0x1d0d8
movq -0x140(%rbp), %rdi
addq $0x448, %rdi            # imm = 0x448
callq 0xc680
movq %rax, %rdi
movq -0x10(%rbp), %rsi
callq 0xb44c0
callq 0x6870
movq -0x140(%rbp), %rdi
movsd %xmm0, 0x1b0(%rdi)
addq $0x458, %rdi            # imm = 0x458
callq 0xc680
movq %rax, %rdi
movq -0x10(%rbp), %rsi
callq 0xb44c0
movq -0x140(%rbp), %rdi
movsd %xmm0, 0x1b8(%rdi)
addq $0x468, %rdi            # imm = 0x468
callq 0xc680
movq %rax, %rdi
movq -0x10(%rbp), %rsi
callq 0xb44c0
movq -0x140(%rbp), %rax
movsd %xmm0, 0x1c0(%rax)
cmpl $0x0, 0x1a8(%rax)
jne 0x1d0d6
movq -0x140(%rbp), %rdi
addq $0x478, %rdi            # imm = 0x478
callq 0xc680
movq %rax, %rdi
movq -0x10(%rbp), %rsi
callq 0xb44c0
callq 0x6870
movq -0x140(%rbp), %rax
movsd %xmm0, 0x1c8(%rax)
jmp 0x1d0d8
leaq 0xa88c2(%rip), %rax     # 0xc59a1
testb $0x1, (%rax)
je 0x1d139
movq -0x140(%rbp), %rdi
addq $0x428, %rdi            # imm = 0x428
callq 0xc680
movq %rax, %rdi
movq -0x10(%rbp), %rsi
callq 0xb44c0
movq -0x140(%rbp), %rdi
movsd %xmm0, 0x188(%rdi)
addq $0x438, %rdi            # imm = 0x438
callq 0xc680
movq %rax, %rdi
movq -0x10(%rbp), %rsi
callq 0xb44c0
movq -0x140(%rbp), %rax
movsd %xmm0, 0x190(%rax)
callq 0xab10
movq %rax, %rsi
leaq -0x120(%rbp), %rdi
callq 0x269d0
testb $0x1, -0xa8(%rbp)
je 0x1d1fc
movl $0x0, -0x124(%rbp)
movl -0x124(%rbp), %eax
cmpl -0xa4(%rbp), %eax
jae 0x1d1fa
movq -0x140(%rbp), %rdi
addq $0x418, %rdi            # imm = 0x418
callq 0xc680
movq %rax, %rdi
movq -0x10(%rbp), %rsi
callq 0xb44c0
movsd %xmm0, -0x168(%rbp)
jmp 0x1d19f
movq -0x140(%rbp), %rdi
addq $0x158, %rdi            # imm = 0x158
movl -0x124(%rbp), %eax
movl %eax, %esi
callq 0xc6a0
movsd -0x168(%rbp), %xmm0
movsd %xmm0, (%rax)
movl -0x124(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x124(%rbp)
jmp 0x1d164
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x130(%rbp)
movl %eax, -0x134(%rbp)
leaq -0x120(%rbp), %rdi
callq 0x155c0
jmp 0x1d53d
jmp 0x1d1fc
leaq 0xa87a6(%rip), %rax     # 0xc59a9
testb $0x1, (%rax)
je 0x1d4b2
movq -0x140(%rbp), %rdi
addq $0x308, %rdi            # imm = 0x308
leaq 0xa878b(%rip), %rax     # 0xc59ac
movslq (%rax), %rsi
callq 0x27120
jmp 0x1d22b
movq -0x140(%rbp), %rdi
addq $0x320, %rdi            # imm = 0x320
leaq 0xa876c(%rip), %rax     # 0xc59ac
movslq (%rax), %rsi
callq 0x27120
jmp 0x1d24a
movq -0x140(%rbp), %rdi
addq $0x338, %rdi            # imm = 0x338
leaq 0xa874d(%rip), %rax     # 0xc59ac
movslq (%rax), %rsi
callq 0x27120
jmp 0x1d269
movq -0x140(%rbp), %rdi
addq $0x350, %rdi            # imm = 0x350
leaq 0xa872e(%rip), %rax     # 0xc59ac
movslq (%rax), %rsi
callq 0x27120
jmp 0x1d288
movq -0x140(%rbp), %rdi
addq $0x368, %rdi            # imm = 0x368
leaq 0xa870f(%rip), %rax     # 0xc59ac
movslq (%rax), %rsi
callq 0x27120
jmp 0x1d2a7
movl $0x0, -0x138(%rbp)
movl -0x138(%rbp), %eax
leaq 0xa86ee(%rip), %rcx     # 0xc59ac
cmpl (%rcx), %eax
jge 0x1d4b0
movq -0x140(%rbp), %rdi
addq $0x488, %rdi            # imm = 0x488
movslq -0x138(%rbp), %rsi
callq 0x26ef0
movq %rax, %rdi
callq 0xc680
movq %rax, %rdi
movq -0x10(%rbp), %rsi
callq 0xb44c0
movsd %xmm0, -0x170(%rbp)
jmp 0x1d2fe
movq -0x140(%rbp), %rdi
addq $0x308, %rdi            # imm = 0x308
movslq -0x138(%rbp), %rsi
callq 0xc6a0
movsd -0x170(%rbp), %xmm0
movq -0x140(%rbp), %rdi
movsd %xmm0, (%rax)
addq $0x4a0, %rdi            # imm = 0x4A0
movslq -0x138(%rbp), %rsi
callq 0x26ef0
movq %rax, %rdi
callq 0xc680
movq %rax, %rdi
movq -0x10(%rbp), %rsi
callq 0xb44c0
movsd %xmm0, -0x178(%rbp)
jmp 0x1d35c
movq -0x140(%rbp), %rdi
addq $0x320, %rdi            # imm = 0x320
movslq -0x138(%rbp), %rsi
callq 0xc6a0
movsd -0x178(%rbp), %xmm0
movq -0x140(%rbp), %rdi
movsd %xmm0, (%rax)
addq $0x4b8, %rdi            # imm = 0x4B8
movslq -0x138(%rbp), %rsi
callq 0x26ef0
movq %rax, %rdi
callq 0xc680
movq %rax, %rdi
movq -0x10(%rbp), %rsi
callq 0xb44c0
movsd %xmm0, -0x180(%rbp)
jmp 0x1d3ba
movq -0x140(%rbp), %rdi
addq $0x338, %rdi            # imm = 0x338
movslq -0x138(%rbp), %rsi
callq 0xc6a0
movsd -0x180(%rbp), %xmm0
movq -0x140(%rbp), %rdi
movsd %xmm0, (%rax)
addq $0x4d0, %rdi            # imm = 0x4D0
movslq -0x138(%rbp), %rsi
callq 0x26ef0
movq %rax, %rdi
callq 0xc680
movq %rax, %rdi
movq -0x10(%rbp), %rsi
callq 0xb44c0
movsd %xmm0, -0x188(%rbp)
jmp 0x1d418
movq -0x140(%rbp), %rdi
addq $0x350, %rdi            # imm = 0x350
movslq -0x138(%rbp), %rsi
callq 0xc6a0
movsd -0x188(%rbp), %xmm0
movq -0x140(%rbp), %rdi
movsd %xmm0, (%rax)
addq $0x4e8, %rdi            # imm = 0x4E8
movslq -0x138(%rbp), %rsi
callq 0x26ef0
movq %rax, %rdi
callq 0xc680
movq %rax, %rdi
movq -0x10(%rbp), %rsi
callq 0xb44c0
movsd %xmm0, -0x190(%rbp)
jmp 0x1d476
movq -0x140(%rbp), %rdi
addq $0x368, %rdi            # imm = 0x368
movslq -0x138(%rbp), %rsi
callq 0xc6a0
movsd -0x190(%rbp), %xmm0
movsd %xmm0, (%rax)
movl -0x138(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x138(%rbp)
jmp 0x1d2b1
jmp 0x1d4b2
leaq 0xa84f7(%rip), %rax     # 0xc59b0
testb $0x1, (%rax)
je 0x1d4fe
movq -0x140(%rbp), %rdi
addq $0x500, %rdi            # imm = 0x500
callq 0xc680
movq %rax, %rdi
movq -0x10(%rbp), %rsi
callq 0xb44c0
movsd %xmm0, -0x198(%rbp)
jmp 0x1d4e7
movq -0x140(%rbp), %rax
movsd -0x198(%rbp), %xmm0
movsd %xmm0, 0x1a0(%rax)
movq -0x140(%rbp), %rdi
callq 0x1eb30
jmp 0x1d50c
leaq 0xa848d(%rip), %rax     # 0xc59a0
testb $0x1, (%rax)
je 0x1d528
movq -0x140(%rbp), %rdi
callq 0x1f6c0
jmp 0x1d526
jmp 0x1d528
leaq -0x120(%rbp), %rdi
callq 0x155c0
addq $0x1a0, %rsp            # imm = 0x1A0
popq %rbp
retq
movq -0x130(%rbp), %rdi
callq 0x6830
nopl (%rax)