// File: j-faria[P]kima/src/RVmodel.cpp
// Function: RVmodel::setPriors()
void RVmodel::setPriors()  // BUG: should be done by only one thread!
{
    auto data = Data::get_instance();

    betaprior = make_prior<Gaussian>(0, 1);
    // sigmaMA_prior = make_prior<ModifiedLogUniform>(1.0, 10.);
    // sigmaMA_prior = make_prior<TruncatedGaussian>(0.0, 1.0, -1.0, 1.0);
    sigmaMA_prior = make_prior<Uniform>(-1, 1);
    tauMA_prior = make_prior<LogUniform>(1, 100);
    
    if (!Cprior)
        Cprior = make_prior<Uniform>(data.get_RV_min(), data.get_RV_max());

    if (!Jprior)
        Jprior = make_prior<ModifiedLogUniform>(min(1.0, 0.1*data.get_max_RV_span()), data.get_max_RV_span());

    // if (!slope_prior)
    //     slope_prior = make_prior<Uniform>( -data.topslope(), data.topslope() );

    if (trend){
        if (degree == 0)
            throw std::logic_error("trend=true but degree=0, what gives?");
        if (degree > 3)
            throw std::range_error("can't go higher than 3rd degree trends");
        if (degree >= 1 & !slope_prior)
            slope_prior = make_prior<Gaussian>( 0.0, pow(10, data.get_trend_magnitude(1)) );
        if (degree >= 2 & !quadr_prior)
            quadr_prior = make_prior<Gaussian>( 0.0, pow(10, data.get_trend_magnitude(2)) );
        if (degree == 3 & !cubic_prior)
            cubic_prior = make_prior<Gaussian>( 0.0, pow(10, data.get_trend_magnitude(3)) );
    }

    if (!offsets_prior)
        offsets_prior = make_prior<Uniform>( -data.get_RV_span(), data.get_RV_span() );

    if (GP) { /* GP parameters */
        if (!log_eta1_prior)
            log_eta1_prior = make_prior<Uniform>(-5, 5);
        if (!eta2_prior)
            eta2_prior = make_prior<LogUniform>(1, 100);
        if (!eta3_prior)
            eta3_prior = make_prior<Uniform>(10, 40);
        if (!log_eta4_prior & kernel==standard)
            log_eta4_prior = make_prior<Uniform>(-1, 1);
    }

    if (known_object) { // KO mode!
        // if (n_known_object == 0) cout << "Warning: `known_object` is true, but `n_known_object` is set to 0";
        for (int i = 0; i < n_known_object; i++){
            if (!KO_Pprior[i] || !KO_Kprior[i] || !KO_eprior[i] || !KO_phiprior[i] || !KO_wprior[i])
                throw std::logic_error("When known_object=true, please set priors for each (KO_Pprior, KO_Kprior, KO_eprior, KO_phiprior, KO_wprior)");
        }
    }

    if (studentt)
        nu_prior = make_prior<LogUniform>(2, 1000);

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x350, %rsp            # imm = 0x350
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x2b8(%rbp)
callq 0xab10
movq %rax, %rsi
leaq -0x110(%rbp), %rdi
callq 0x269d0
movq -0x2b8(%rbp), %rsi
movl $0x0, -0x124(%rbp)
movl $0x1, -0x128(%rbp)
leaq -0x120(%rbp), %rdi
leaq -0x124(%rbp), %rdx
leaq -0x128(%rbp), %rcx
callq 0x26bf0
jmp 0x1c265
movq -0x2b8(%rbp), %rdi
addq $0x418, %rdi            # imm = 0x418
leaq -0x120(%rbp), %rsi
movq %rsi, -0x2c0(%rbp)
callq 0x26c30
movq -0x2c0(%rbp), %rdi
callq 0x26c60
movq -0x2b8(%rbp), %rsi
movl $0xffffffff, -0x14c(%rbp) # imm = 0xFFFFFFFF
movl $0x1, -0x150(%rbp)
leaq -0x148(%rbp), %rdi
leaq -0x14c(%rbp), %rdx
leaq -0x150(%rbp), %rcx
callq 0x26c80
jmp 0x1c2c9
movq -0x2b8(%rbp), %rdi
addq $0x428, %rdi            # imm = 0x428
leaq -0x148(%rbp), %rsi
movq %rsi, -0x2c8(%rbp)
callq 0xc1f0
movq -0x2c8(%rbp), %rdi
callq 0xc220
movq -0x2b8(%rbp), %rsi
movl $0x1, -0x164(%rbp)
movl $0x64, -0x168(%rbp)
leaq -0x160(%rbp), %rdi
leaq -0x164(%rbp), %rdx
leaq -0x168(%rbp), %rcx
callq 0x26cc0
jmp 0x1c32d
movq -0x2b8(%rbp), %rdi
addq $0x438, %rdi            # imm = 0x438
leaq -0x160(%rbp), %rsi
callq 0xc440
leaq -0x160(%rbp), %rdi
callq 0xc470
movq -0x2b8(%rbp), %rdi
addq $0x3b8, %rdi            # imm = 0x3B8
callq 0xc050
testb $0x1, %al
jne 0x1c41c
leaq -0x110(%rbp), %rdi
callq 0x26d40
movsd %xmm0, -0x2d0(%rbp)
jmp 0x1c384
movsd -0x2d0(%rbp), %xmm0
movsd %xmm0, -0x180(%rbp)
leaq -0x110(%rbp), %rdi
callq 0x26da0
movsd %xmm0, -0x2d8(%rbp)
jmp 0x1c3aa
movq -0x2b8(%rbp), %rsi
movsd -0x2d8(%rbp), %xmm0
movsd %xmm0, -0x188(%rbp)
leaq -0x178(%rbp), %rdi
leaq -0x180(%rbp), %rdx
leaq -0x188(%rbp), %rcx
callq 0x26d00
jmp 0x1c3dd
movq -0x2b8(%rbp), %rdi
addq $0x3b8, %rdi            # imm = 0x3B8
leaq -0x178(%rbp), %rsi
callq 0xc1f0
leaq -0x178(%rbp), %rdi
callq 0xc220
jmp 0x1c41c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x130(%rbp)
movl %eax, -0x134(%rbp)
jmp 0x1cd4a
movq -0x2b8(%rbp), %rdi
addq $0x3c8, %rdi            # imm = 0x3C8
callq 0xc050
testb $0x1, %al
jne 0x1c505
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
movq %rax, -0x1a0(%rbp)
leaq -0x110(%rbp), %rdi
callq 0x13e40
movsd %xmm0, -0x2e0(%rbp)
jmp 0x1c45e
movsd -0x2e0(%rbp), %xmm0
movsd 0x9b222(%rip), %xmm1    # 0xb7690
mulsd %xmm1, %xmm0
movsd %xmm0, -0x1a8(%rbp)
leaq -0x1a0(%rbp), %rdi
leaq -0x1a8(%rbp), %rsi
callq 0x26e40
movq %rax, -0x2e8(%rbp)
jmp 0x1c496
leaq -0x110(%rbp), %rdi
callq 0x13e40
movsd %xmm0, -0x2f0(%rbp)
jmp 0x1c4ac
movq -0x2e8(%rbp), %rdx
movq -0x2b8(%rbp), %rsi
movsd -0x2f0(%rbp), %xmm0
movsd %xmm0, -0x1b0(%rbp)
leaq -0x198(%rbp), %rdi
leaq -0x1b0(%rbp), %rcx
callq 0x26e00
jmp 0x1c4df
movq -0x2b8(%rbp), %rdi
addq $0x3c8, %rdi            # imm = 0x3C8
leaq -0x198(%rbp), %rsi
callq 0xc510
leaq -0x198(%rbp), %rdi
callq 0xc540
leaq 0xa9497(%rip), %rax     # 0xc59a3
testb $0x1, (%rax)
je 0x1c897
leaq 0xa9488(%rip), %rax     # 0xc59a4
cmpl $0x0, (%rax)
jne 0x1c588
movl $0x10, %edi
callq 0x6250
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x2f8(%rbp)
leaq 0x9b465(%rip), %rsi     # 0xb79a4
callq 0x66e0
jmp 0x1c546
movq -0x2f8(%rbp), %rdi
movq 0xfda7c(%rip), %rsi     # 0x119fd0
movq 0xfda2d(%rip), %rdx     # 0x119f88
callq 0x67e0
jmp 0x1cd62
movq -0x2f8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x130(%rbp)
movl %eax, -0x134(%rbp)
callq 0x63b0
jmp 0x1cd4a
leaq 0xa9415(%rip), %rax     # 0xc59a4
cmpl $0x3, (%rax)
jle 0x1c5fb
movl $0x10, %edi
callq 0x6250
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x300(%rbp)
leaq 0x9b417(%rip), %rsi     # 0xb79c9
callq 0x67f0
jmp 0x1c5b9
movq -0x300(%rbp), %rdi
movq 0xfd9f1(%rip), %rsi     # 0x119fb8
movq 0xfd99a(%rip), %rdx     # 0x119f68
callq 0x67e0
jmp 0x1cd62
movq -0x300(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x130(%rbp)
movl %eax, -0x134(%rbp)
callq 0x63b0
jmp 0x1cd4a
movq -0x2b8(%rbp), %rdi
leaq 0xa939b(%rip), %rax     # 0xc59a4
cmpl $0x1, (%rax)
setge %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x304(%rbp)
addq $0x3d8, %rdi            # imm = 0x3D8
callq 0xc050
movb %al, %cl
movl -0x304(%rbp), %eax
xorb $-0x1, %cl
andb $0x1, %cl
movzbl %cl, %ecx
andl %ecx, %eax
cmpl $0x0, %eax
je 0x1c6d9
movq $0x0, -0x1c8(%rbp)
leaq -0x110(%rbp), %rdi
movl $0x1, %esi
callq 0x14490
movl %eax, -0x308(%rbp)
jmp 0x1c666
movl -0x308(%rbp), %esi
movl $0xa, %edi
callq 0x26ec0
movsd %xmm0, -0x310(%rbp)
jmp 0x1c680
movq -0x2b8(%rbp), %rsi
movsd -0x310(%rbp), %xmm0
movsd %xmm0, -0x1d0(%rbp)
leaq -0x1c0(%rbp), %rdi
leaq -0x1c8(%rbp), %rdx
leaq -0x1d0(%rbp), %rcx
callq 0x26e80
jmp 0x1c6b3
movq -0x2b8(%rbp), %rdi
addq $0x3d8, %rdi            # imm = 0x3D8
leaq -0x1c0(%rbp), %rsi
callq 0x26c30
leaq -0x1c0(%rbp), %rdi
callq 0x26c60
movq -0x2b8(%rbp), %rdi
leaq 0xa92bd(%rip), %rax     # 0xc59a4
cmpl $0x2, (%rax)
setge %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x314(%rbp)
addq $0x3e8, %rdi            # imm = 0x3E8
callq 0xc050
movb %al, %cl
movl -0x314(%rbp), %eax
xorb $-0x1, %cl
andb $0x1, %cl
movzbl %cl, %ecx
andl %ecx, %eax
cmpl $0x0, %eax
je 0x1c7b7
movq $0x0, -0x1e8(%rbp)
leaq -0x110(%rbp), %rdi
movl $0x2, %esi
callq 0x14490
movl %eax, -0x318(%rbp)
jmp 0x1c744
movl -0x318(%rbp), %esi
movl $0xa, %edi
callq 0x26ec0
movsd %xmm0, -0x320(%rbp)
jmp 0x1c75e
movq -0x2b8(%rbp), %rsi
movsd -0x320(%rbp), %xmm0
movsd %xmm0, -0x1f0(%rbp)
leaq -0x1e0(%rbp), %rdi
leaq -0x1e8(%rbp), %rdx
leaq -0x1f0(%rbp), %rcx
callq 0x26e80
jmp 0x1c791
movq -0x2b8(%rbp), %rdi
addq $0x3e8, %rdi            # imm = 0x3E8
leaq -0x1e0(%rbp), %rsi
callq 0x26c30
leaq -0x1e0(%rbp), %rdi
callq 0x26c60
movq -0x2b8(%rbp), %rdi
leaq 0xa91df(%rip), %rax     # 0xc59a4
cmpl $0x3, (%rax)
sete %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x324(%rbp)
addq $0x3f8, %rdi            # imm = 0x3F8
callq 0xc050
movb %al, %cl
movl -0x324(%rbp), %eax
xorb $-0x1, %cl
andb $0x1, %cl
movzbl %cl, %ecx
andl %ecx, %eax
cmpl $0x0, %eax
je 0x1c895
movq $0x0, -0x208(%rbp)
leaq -0x110(%rbp), %rdi
movl $0x3, %esi
callq 0x14490
movl %eax, -0x328(%rbp)
jmp 0x1c822
movl -0x328(%rbp), %esi
movl $0xa, %edi
callq 0x26ec0
movsd %xmm0, -0x330(%rbp)
jmp 0x1c83c
movq -0x2b8(%rbp), %rsi
movsd -0x330(%rbp), %xmm0
movsd %xmm0, -0x210(%rbp)
leaq -0x200(%rbp), %rdi
leaq -0x208(%rbp), %rdx
leaq -0x210(%rbp), %rcx
callq 0x26e80
jmp 0x1c86f
movq -0x2b8(%rbp), %rdi
addq $0x3f8, %rdi            # imm = 0x3F8
leaq -0x200(%rbp), %rsi
callq 0x26c30
leaq -0x200(%rbp), %rdi
callq 0x26c60
jmp 0x1c897
movq -0x2b8(%rbp), %rdi
addq $0x408, %rdi            # imm = 0x408
callq 0xc050
testb $0x1, %al
jne 0x1c952
leaq -0x110(%rbp), %rdi
callq 0x13da0
movsd %xmm0, -0x338(%rbp)
jmp 0x1c8c8
movsd -0x338(%rbp), %xmm0
movaps 0x9ae69(%rip), %xmm1    # 0xb7740
pxor %xmm1, %xmm0
movlpd %xmm0, -0x228(%rbp)
leaq -0x110(%rbp), %rdi
callq 0x13da0
movsd %xmm0, -0x340(%rbp)
jmp 0x1c8f9
movq -0x2b8(%rbp), %rsi
movsd -0x340(%rbp), %xmm0
movsd %xmm0, -0x230(%rbp)
leaq -0x220(%rbp), %rdi
leaq -0x228(%rbp), %rdx
leaq -0x230(%rbp), %rcx
callq 0x26d00
jmp 0x1c92c
movq -0x2b8(%rbp), %rdi
addq $0x408, %rdi            # imm = 0x408
leaq -0x220(%rbp), %rsi
callq 0xc1f0
leaq -0x220(%rbp), %rdi
callq 0xc220
leaq 0xa9047(%rip), %rax     # 0xc59a0
testb $0x1, (%rax)
je 0x1cb55
movq -0x2b8(%rbp), %rdi
addq $0x448, %rdi            # imm = 0x448
callq 0xc050
testb $0x1, %al
jne 0x1c9d6
movq -0x2b8(%rbp), %rsi
movl $0xfffffffb, -0x244(%rbp) # imm = 0xFFFFFFFB
movl $0x5, -0x248(%rbp)
leaq -0x240(%rbp), %rdi
leaq -0x244(%rbp), %rdx
leaq -0x248(%rbp), %rcx
callq 0x26c80
jmp 0x1c9b0
movq -0x2b8(%rbp), %rdi
addq $0x448, %rdi            # imm = 0x448
leaq -0x240(%rbp), %rsi
callq 0xc1f0
leaq -0x240(%rbp), %rdi
callq 0xc220
movq -0x2b8(%rbp), %rdi
addq $0x458, %rdi            # imm = 0x458
callq 0xc050
testb $0x1, %al
jne 0x1ca4a
movq -0x2b8(%rbp), %rsi
movl $0x1, -0x25c(%rbp)
movl $0x64, -0x260(%rbp)
leaq -0x258(%rbp), %rdi
leaq -0x25c(%rbp), %rdx
leaq -0x260(%rbp), %rcx
callq 0x26cc0
jmp 0x1ca24
movq -0x2b8(%rbp), %rdi
addq $0x458, %rdi            # imm = 0x458
leaq -0x258(%rbp), %rsi
callq 0xc440
leaq -0x258(%rbp), %rdi
callq 0xc470
movq -0x2b8(%rbp), %rdi
addq $0x468, %rdi            # imm = 0x468
callq 0xc050
testb $0x1, %al
jne 0x1cabe
movq -0x2b8(%rbp), %rsi
movl $0xa, -0x274(%rbp)
movl $0x28, -0x278(%rbp)
leaq -0x270(%rbp), %rdi
leaq -0x274(%rbp), %rdx
leaq -0x278(%rbp), %rcx
callq 0x26c80
jmp 0x1ca98
movq -0x2b8(%rbp), %rdi
addq $0x468, %rdi            # imm = 0x468
leaq -0x270(%rbp), %rsi
callq 0xc1f0
leaq -0x270(%rbp), %rdi
callq 0xc220
movq -0x2b8(%rbp), %rdi
addq $0x478, %rdi            # imm = 0x478
callq 0xc050
movq -0x2b8(%rbp), %rcx
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, 0x1a8(%rcx)
sete %cl
andb $0x1, %cl
movzbl %cl, %ecx
andl %ecx, %eax
cmpl $0x0, %eax
je 0x1cb53
movq -0x2b8(%rbp), %rsi
movl $0xffffffff, -0x28c(%rbp) # imm = 0xFFFFFFFF
movl $0x1, -0x290(%rbp)
leaq -0x288(%rbp), %rdi
leaq -0x28c(%rbp), %rdx
leaq -0x290(%rbp), %rcx
callq 0x26c80
jmp 0x1cb2d
movq -0x2b8(%rbp), %rdi
addq $0x478, %rdi            # imm = 0x478
leaq -0x288(%rbp), %rsi
callq 0xc1f0
leaq -0x288(%rbp), %rdi
callq 0xc220
jmp 0x1cb55
leaq 0xa8e4d(%rip), %rax     # 0xc59a9
testb $0x1, (%rax)
je 0x1cccc
movl $0x0, -0x294(%rbp)
movl -0x294(%rbp), %eax
leaq 0xa8e30(%rip), %rcx     # 0xc59ac
cmpl (%rcx), %eax
jge 0x1ccca
movq -0x2b8(%rbp), %rdi
addq $0x488, %rdi            # imm = 0x488
movslq -0x294(%rbp), %rsi
callq 0x26ef0
movq %rax, %rdi
callq 0xc050
testb $0x1, %al
jne 0x1cbaf
jmp 0x1cc4d
movq -0x2b8(%rbp), %rdi
addq $0x4a0, %rdi            # imm = 0x4A0
movslq -0x294(%rbp), %rsi
callq 0x26ef0
movq %rax, %rdi
callq 0xc050
testb $0x1, %al
jne 0x1cbd7
jmp 0x1cc4d
movq -0x2b8(%rbp), %rdi
addq $0x4b8, %rdi            # imm = 0x4B8
movslq -0x294(%rbp), %rsi
callq 0x26ef0
movq %rax, %rdi
callq 0xc050
testb $0x1, %al
jne 0x1cbff
jmp 0x1cc4d
movq -0x2b8(%rbp), %rdi
addq $0x4d0, %rdi            # imm = 0x4D0
movslq -0x294(%rbp), %rsi
callq 0x26ef0
movq %rax, %rdi
callq 0xc050
testb $0x1, %al
jne 0x1cc27
jmp 0x1cc4d
movq -0x2b8(%rbp), %rdi
addq $0x4e8, %rdi            # imm = 0x4E8
movslq -0x294(%rbp), %rsi
callq 0x26ef0
movq %rax, %rdi
callq 0xc050
testb $0x1, %al
jne 0x1ccb4
movl $0x10, %edi
callq 0x6250
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x348(%rbp)
leaq 0x9ad85(%rip), %rsi     # 0xb79f0
callq 0x66e0
jmp 0x1cc72
movq -0x348(%rbp), %rdi
movq 0xfd350(%rip), %rsi     # 0x119fd0
movq 0xfd301(%rip), %rdx     # 0x119f88
callq 0x67e0
jmp 0x1cd62
movq -0x348(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x130(%rbp)
movl %eax, -0x134(%rbp)
callq 0x63b0
jmp 0x1cd4a
jmp 0x1ccb6
movl -0x294(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x294(%rbp)
jmp 0x1cb6f
jmp 0x1cccc
leaq 0xa8cdd(%rip), %rax     # 0xc59b0
testb $0x1, (%rax)
je 0x1cd35
movq -0x2b8(%rbp), %rsi
movl $0x2, -0x2ac(%rbp)
movl $0x3e8, -0x2b0(%rbp)    # imm = 0x3E8
leaq -0x2a8(%rbp), %rdi
leaq -0x2ac(%rbp), %rdx
leaq -0x2b0(%rbp), %rcx
callq 0x26cc0
jmp 0x1cd0f
movq -0x2b8(%rbp), %rdi
addq $0x500, %rdi            # imm = 0x500
leaq -0x2a8(%rbp), %rsi
callq 0xc440
leaq -0x2a8(%rbp), %rdi
callq 0xc470
leaq -0x110(%rbp), %rdi
callq 0x155c0
addq $0x350, %rsp            # imm = 0x350
popq %rbp
retq
leaq -0x110(%rbp), %rdi
callq 0x155c0
movq -0x130(%rbp), %rdi
callq 0x6830
nopw %cs:(%rax,%rax)