// File: /workspace/github_c_makefile_star2_O3/debbiemarkslab[P]plmc/src/plm.c
// Function: OutputParametersFull
void OutputParametersFull(char *outputFile, const numeric_t *x,
    alignment_t *ali, options_t *options) {
/* File format */
    FILE *fpOutput = NULL;
    fpOutput = fopen(outputFile, "w");
    if (fpOutput != NULL) {
        /* 1: nSites */
        int32_t nSites = (int32_t) ali->nSites;
        fwrite(&nSites, sizeof(nSites), 1, fpOutput);

        /* 2: nCodes */
        int32_t nCodes = (int32_t) ali->nCodes;
        fwrite(&nCodes, sizeof(nCodes), 1, fpOutput);

        /* 3: nSeqs */
        int32_t nSeqs = (int32_t) ali->nSeqs;
        fwrite(&nSeqs, sizeof(nSeqs), 1, fpOutput);

        /* 4: nSkippedSeqs */
        int32_t nSkippedSeqs = (int32_t) ali->nSkippedSeqs;
        fwrite(&nSkippedSeqs, sizeof(nSkippedSeqs), 1, fpOutput);

        /* 5: number of iterations */
        int32_t maxIter = (int32_t) options->maxIter;
        fwrite(&maxIter, sizeof(maxIter), 1, fpOutput);

        /* 6: theta */
        OUTPUT_PRECISION theta = (OUTPUT_PRECISION) options->theta;
        fwrite(&theta, sizeof(theta), 1, fpOutput);

        /* 7: lambda for fields (lh) */
        OUTPUT_PRECISION lh = (OUTPUT_PRECISION) options->lambdaH;
        fwrite(&lh, sizeof(lh), 1, fpOutput);

        /* 8: lambda for couplings (le) */
        OUTPUT_PRECISION le = (OUTPUT_PRECISION) options->lambdaE;
        fwrite(&le, sizeof(le), 1, fpOutput);

        /* 9: group lambda for couplings (lg) */
        OUTPUT_PRECISION lg = (OUTPUT_PRECISION) options->lambdaGroup;
        fwrite(&lg, sizeof(lg), 1, fpOutput);

        /* 10: effective sample size (nEff) */
        OUTPUT_PRECISION nEff = (OUTPUT_PRECISION) ali->nEff;
        fwrite(&nEff, sizeof(nEff), 1, fpOutput);

        /* 11: alphabet */
        int isGapped = (options->estimatorMAP == INFER_MAP_PLM_GAPREDUCE);
        for (int i = 0; i < ali->nCodes; i++) {
            int8_t letter = (int8_t) ali->alphabet[i + isGapped];
            fwrite(&letter, sizeof(letter), 1, fpOutput);
        }

        /* 12: sequence number of neighbors (self included) */
        int skipix = 0, reducedix = 0;
        for (int s = 0; s < ali->nSeqs + ali->nSkippedSeqs; s++) {
            if (skipix < ali->nSkippedSeqs && s == ali->skippedSeqs[skipix]) {
                /* Skip skipped sequences */
                OUTPUT_PRECISION w = (OUTPUT_PRECISION) 0;
                fwrite(&w, sizeof(w), 1, fpOutput);
                skipix++;
            } else {
                numeric_t nNeighbors = ali->weights[reducedix];
                nNeighbors = 1.0 / (nNeighbors * options->scale);
                OUTPUT_PRECISION w = (OUTPUT_PRECISION) nNeighbors;
                fwrite(&w, sizeof(w), 1, fpOutput);
                reducedix++;
            }
        }

        /* 13: (Focus mode) target sequence */
        if (ali->target >= 0) {
            for (int i = 0; i < ali->nSites; i++) {
                int8_t c = (int8_t) ali->alphabet[seq(ali->target, i)];
                fwrite(&c, sizeof(c), 1, fpOutput);
            }
        } else {
            int8_t c = (int8_t) ali->alphabet[0];
            for (int i = 0; i < ali->nSites; i++)
                fwrite(&c, sizeof(c), 1, fpOutput);
        }

        /* 14: (Focus mode) offset map */
        if (ali->target >= 0) {
            for (int i = 0; i < ali->nSites; i++) {
                int32_t ix = (int32_t) ali->offsets[i];
                fwrite(&ix, sizeof(ix), 1, fpOutput);
            }
        } else {
            for (int i = 0; i < ali->nSites; i++) {
                int32_t ix = (int32_t) i + 1;
                fwrite(&ix, sizeof(ix), 1, fpOutput);
            }
        }

        /* 15: sitewise marginals fi */
        for (int i = 0; i < ali->nSites; i++)
            for (int ai = 0; ai < ali->nCodes; ai++) {
                OUTPUT_PRECISION f = (OUTPUT_PRECISION) fi(i, ai);
                fwrite(&f, sizeof(f), 1, fpOutput);
            }

        /* 16: sitewise parameters hi */
        for (int i = 0; i < ali->nSites; i++)
            for (int ai = 0; ai < ali->nCodes; ai++) {
                OUTPUT_PRECISION h = (OUTPUT_PRECISION) xHi(i, ai);
                fwrite(&h, sizeof(h), 1, fpOutput);
            }

        /* 17: pairwise marginals fij */
        for (int i = 0; i < ali->nSites - 1; i++)
            for (int j = i + 1; j < ali->nSites; j++)
                for (int ai = 0; ai < ali->nCodes; ai++)
                    for (int aj = 0; aj < ali->nCodes; aj++) {
                        OUTPUT_PRECISION f =
                            (OUTPUT_PRECISION) fij(i, j, ai, aj);
                        fwrite(&f, sizeof(f), 1, fpOutput);
                    }

        /* 18: couplings eij */
        for (int i = 0; i < ali->nSites - 1; i++)
            for (int j = i + 1; j < ali->nSites; j++)
                for (int ai = 0; ai < ali->nCodes; ai++)
                    for (int aj = 0; aj < ali->nCodes; aj++) {
                        OUTPUT_PRECISION e =
                            (OUTPUT_PRECISION) xEij(i, j, ai, aj);
                        fwrite(&e, sizeof(e), 1, fpOutput);
                    }
        fclose(fpOutput);
    } else {
        fprintf(stderr, "Error writing parameters\n");
        exit(1);
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rcx, %r15
movq %rdx, %rbx
movq %rsi, %r14
leaq 0x7387(%rip), %rsi      # 0xd430
callq 0x11d0
testq %rax, %rax
je 0x670b
movq %rax, %r12
movq %r14, 0x28(%rsp)
movl 0x4(%rbx), %eax
leaq 0x64(%rsp), %rdi
movl %eax, (%rdi)
movl $0x4, %esi
movl $0x1, %edx
movq %r12, %rcx
callq 0x1210
movl 0x8(%rbx), %eax
leaq 0x60(%rsp), %rdi
movl %eax, (%rdi)
movl $0x4, %esi
movl $0x1, %edx
movq %r12, %rcx
callq 0x1210
movl (%rbx), %eax
leaq 0x5c(%rsp), %rdi
movl %eax, (%rdi)
movl $0x4, %esi
movl $0x1, %edx
movq %r12, %rcx
callq 0x1210
movl 0x28(%rbx), %eax
leaq 0x58(%rsp), %rdi
movl %eax, (%rdi)
movl $0x4, %esi
movl $0x1, %edx
movq %r12, %rcx
callq 0x1210
movl 0x1c(%r15), %eax
leaq 0x54(%rsp), %rdi
movl %eax, (%rdi)
movl $0x4, %esi
movl $0x1, %edx
movq %r12, %rcx
callq 0x1210
cvtsd2ss 0x30(%r15), %xmm0
leaq 0x50(%rsp), %rdi
movss %xmm0, (%rdi)
movl $0x4, %esi
movl $0x1, %edx
movq %r12, %rcx
callq 0x1210
xorps %xmm0, %xmm0
cvtsd2ss 0x40(%r15), %xmm0
leaq 0x4c(%rsp), %rdi
movss %xmm0, (%rdi)
movl $0x4, %esi
movl $0x1, %edx
movq %r12, %rcx
callq 0x1210
xorps %xmm0, %xmm0
cvtsd2ss 0x48(%r15), %xmm0
leaq 0x48(%rsp), %rdi
movss %xmm0, (%rdi)
movl $0x4, %esi
movl $0x1, %edx
movq %r12, %rcx
callq 0x1210
movq %r15, %r13
xorps %xmm0, %xmm0
cvtsd2ss 0x50(%r15), %xmm0
leaq 0x44(%rsp), %rdi
movss %xmm0, (%rdi)
movl $0x4, %esi
movl $0x1, %edx
movq %r12, %rcx
callq 0x1210
xorps %xmm0, %xmm0
cvtsd2ss 0x48(%rbx), %xmm0
leaq 0x40(%rsp), %rdi
movss %xmm0, (%rdi)
movl $0x4, %esi
movl $0x1, %edx
movq %r12, %rcx
callq 0x1210
cmpl $0x0, 0x8(%rbx)
jle 0x6233
xorl %r14d, %r14d
cmpl $0x1, 0x18(%r13)
sete %r14b
xorl %r15d, %r15d
movq 0x10(%rbx), %rax
addq %r14, %rax
movsbl (%r15,%rax), %edi
movq %r12, %rsi
callq 0x1140
incq %r15
movslq 0x8(%rbx), %rax
cmpq %rax, %r15
jl 0x6213
movq %r12, 0x8(%rsp)
movl 0x28(%rbx), %eax
movl (%rbx), %ecx
addl %eax, %ecx
jle 0x62e1
movq %r13, %r15
xorl %ebp, %ebp
leaq 0x4(%rsp), %r13
xorl %r14d, %r14d
xorl %r12d, %r12d
cmpl %eax, %r12d
jge 0x628a
movq 0x30(%rbx), %rax
movslq %r12d, %rcx
cmpl (%rax,%rcx,4), %ebp
jne 0x628a
movl $0x0, 0x4(%rsp)
movl $0x4, %esi
movl $0x1, %edx
movq %r13, %rdi
movq 0x8(%rsp), %rcx
callq 0x1210
incl %r12d
jmp 0x62d0
movq 0x50(%rbx), %rax
movslq %r14d, %r14
movsd (%rax,%r14,8), %xmm0
mulsd 0x38(%r15), %xmm0
movsd 0x6dc3(%rip), %xmm1     # 0xd068
divsd %xmm0, %xmm1
xorps %xmm0, %xmm0
cvtsd2ss %xmm1, %xmm0
movss %xmm0, 0x4(%rsp)
movl $0x4, %esi
movl $0x1, %edx
movq %r13, %rdi
movq 0x8(%rsp), %rcx
callq 0x1210
incl %r14d
incl %ebp
movl 0x28(%rbx), %eax
movl (%rbx), %ecx
addl %eax, %ecx
cmpl %ecx, %ebp
jl 0x6255
cmpl $0x0, 0x38(%rbx)
movl 0x4(%rbx), %eax
js 0x6331
testl %eax, %eax
movq 0x28(%rsp), %r15
movq 0x8(%rsp), %r13
jle 0x66f5
xorl %r14d, %r14d
movq 0x10(%rbx), %rcx
movq 0x20(%rbx), %rdx
movslq 0x38(%rbx), %rsi
cltq
imulq %rsi, %rax
addq %r14, %rax
movslq (%rdx,%rax,4), %rax
movsbl (%rcx,%rax), %edi
movq %r13, %rsi
callq 0x1140
movl 0x4(%rbx), %eax
incq %r14
cmpl %eax, %r14d
jl 0x62ff
jmp 0x6362
testl %eax, %eax
movq 0x28(%rsp), %r15
movq 0x8(%rsp), %r13
jle 0x66f5
movq 0x10(%rbx), %rax
movsbl (%rax), %ebp
xorl %r14d, %r14d
movl %ebp, %edi
movq %r13, %rsi
callq 0x1140
incl %r14d
movl 0x4(%rbx), %eax
cmpl %eax, %r14d
jl 0x634d
cmpl $0x0, 0x38(%rbx)
js 0x63a7
testl %eax, %eax
jle 0x66f5
xorl %r14d, %r14d
leaq 0x4(%rsp), %r12
movq 0x40(%rbx), %rax
movl (%rax,%r14,4), %eax
movl %eax, 0x4(%rsp)
movl $0x4, %esi
movl $0x1, %edx
movq %r12, %rdi
movq %r13, %rcx
callq 0x1210
incq %r14
movslq 0x4(%rbx), %rax
cmpq %rax, %r14
jl 0x6378
jmp 0x63d8
testl %eax, %eax
jle 0x66f5
xorl %ebp, %ebp
leaq 0x4(%rsp), %r12
incl %ebp
movl %ebp, 0x4(%rsp)
movl $0x4, %esi
movl $0x1, %edx
movq %r12, %rdi
movq %r13, %rcx
callq 0x1210
movl 0x4(%rbx), %eax
cmpl %eax, %ebp
jl 0x63b6
testl %eax, %eax
jle 0x66f5
movl 0x8(%rbx), %ecx
xorl %ebp, %ebp
leaq 0x4(%rsp), %r12
testl %ecx, %ecx
jle 0x6432
xorl %r14d, %r14d
movq 0x58(%rbx), %rax
movl 0x4(%rbx), %ecx
imull %r14d, %ecx
addl %ebp, %ecx
movslq %ecx, %rcx
xorps %xmm0, %xmm0
cvtsd2ss (%rax,%rcx,8), %xmm0
movss %xmm0, 0x4(%rsp)
movl $0x4, %esi
movl $0x1, %edx
movq %r12, %rdi
movq %r13, %rcx
callq 0x1210
incl %r14d
movl 0x8(%rbx), %ecx
cmpl %ecx, %r14d
jl 0x63f1
movl 0x4(%rbx), %eax
incl %ebp
cmpl %eax, %ebp
jl 0x63ea
testl %eax, %eax
jle 0x66f5
movl 0x8(%rbx), %ecx
xorl %ebp, %ebp
leaq 0x4(%rsp), %r12
testl %ecx, %ecx
jle 0x648e
xorl %r14d, %r14d
movl 0x4(%rbx), %eax
imull %r14d, %eax
addl %ebp, %eax
cltq
xorps %xmm0, %xmm0
cvtsd2ss (%r15,%rax,8), %xmm0
movss %xmm0, 0x4(%rsp)
movl $0x4, %esi
movl $0x1, %edx
movq %r12, %rdi
movq %r13, %rcx
callq 0x1210
incl %r14d
movl 0x8(%rbx), %ecx
cmpl %ecx, %r14d
jl 0x6451
movl 0x4(%rbx), %eax
incl %ebp
cmpl %eax, %ebp
jl 0x644a
cmpl $0x2, %eax
jl 0x66f5
xorl %ecx, %ecx
leaq 0x4(%rsp), %rbp
movq %rbx, 0x18(%rsp)
movq 0x18(%rsp), %r14
movl %ecx, %esi
leal 0x1(%rsi), %edx
cmpl %eax, %edx
movl %edx, 0x14(%rsp)
jge 0x65a6
leal -0x1(%rsi), %ecx
imull %esi, %ecx
movl %ecx, %r8d
shrl $0x1f, %r8d
addl %ecx, %r8d
sarl %r8d
movq %r8, 0x20(%rsp)
movl 0x8(%rbx), %r11d
movl %edx, %r8d
movq %rsi, 0x30(%rsp)
testl %r11d, %r11d
jle 0x659a
movq 0x20(%rsp), %rax
addl %r8d, %eax
leal -0x1(%r8), %edx
imull %r8d, %edx
movl %edx, %r15d
shrl $0x1f, %r15d
addl %edx, %r15d
sarl %r15d
addl %esi, %r15d
cmpl %r8d, %esi
cmovael %eax, %r15d
xorl %r13d, %r13d
movq %r8, 0x38(%rsp)
testl %r11d, %r11d
movq 0x8(%rsp), %rbx
jle 0x658a
xorl %r12d, %r12d
cmpl %r8d, %esi
movq 0x60(%r14), %rax
movl %r13d, %edx
cmovbl %r12d, %edx
movl %r12d, %esi
cmovbl %r13d, %esi
movl %r11d, %r8d
imull %r15d, %r8d
addl %edx, %r8d
imull %r11d, %r8d
addl %esi, %r8d
movslq %r8d, %rdx
xorps %xmm0, %xmm0
cvtsd2ss (%rax,%rdx,8), %xmm0
movss %xmm0, 0x4(%rsp)
movl $0x4, %esi
movl $0x1, %edx
movq %rbp, %rdi
movq %rbx, %rcx
callq 0x1210
movq 0x38(%rsp), %r8
movq 0x30(%rsp), %rsi
incl %r12d
movl 0x8(%r14), %r11d
cmpl %r11d, %r12d
jl 0x6528
incl %r13d
cmpl %r11d, %r13d
jl 0x651b
movq 0x18(%rsp), %rbx
movl 0x4(%rbx), %eax
incl %r8d
cmpl %eax, %r8d
jl 0x64e3
leal -0x1(%rax), %ecx
movl 0x14(%rsp), %edx
cmpl %ecx, %edx
movl %edx, %ecx
jl 0x64ae
cmpl $0x2, %eax
movq 0x8(%rsp), %r13
jl 0x66f5
xorl %ecx, %ecx
leaq 0x4(%rsp), %r14
movl %ecx, %esi
leal 0x1(%rsi), %edx
cmpl %eax, %edx
movl %edx, 0x14(%rsp)
jge 0x66df
leal -0x1(%rsi), %ecx
imull %esi, %ecx
movl %ecx, %r8d
shrl $0x1f, %r8d
addl %ecx, %r8d
sarl %r8d
movq %r8, 0x20(%rsp)
movl 0x8(%rbx), %ebx
movl %edx, %r8d
movq %rsi, 0x30(%rsp)
testl %ebx, %ebx
jle 0x66d3
movq 0x20(%rsp), %rax
addl %r8d, %eax
leal -0x1(%r8), %edx
imull %r8d, %edx
movl %edx, %r12d
shrl $0x1f, %r12d
addl %edx, %r12d
sarl %r12d
addl %esi, %r12d
cmpl %r8d, %esi
cmovael %eax, %r12d
xorl %ebp, %ebp
movq %r8, 0x38(%rsp)
testl %ebx, %ebx
movq 0x28(%rsp), %r11
movq 0x8(%rsp), %r13
jle 0x66bc
xorl %r15d, %r15d
movq 0x18(%rsp), %rax
movl 0x4(%rax), %eax
imull %ebx, %eax
cmpl %r8d, %esi
movl %ebp, %edx
cmovbl %r15d, %edx
movl %r15d, %esi
cmovbl %ebp, %esi
movl %ebx, %r8d
imull %r12d, %r8d
addl %edx, %r8d
imull %ebx, %r8d
addl %esi, %r8d
addl %eax, %r8d
movslq %r8d, %rax
xorps %xmm0, %xmm0
cvtsd2ss (%r11,%rax,8), %xmm0
movss %xmm0, 0x4(%rsp)
movl $0x4, %esi
movl $0x1, %edx
movq %r14, %rdi
movq %r13, %rcx
movq %r11, %rbx
callq 0x1210
movq 0x18(%rsp), %rax
movq %rbx, %r11
movq 0x38(%rsp), %r8
movq 0x30(%rsp), %rsi
incl %r15d
movl 0x8(%rax), %ebx
cmpl %ebx, %r15d
jl 0x6647
incl %ebp
cmpl %ebx, %ebp
jl 0x6636
movq 0x18(%rsp), %rax
movl 0x4(%rax), %eax
movq 0x8(%rsp), %r13
incl %r8d
cmpl %eax, %r8d
jl 0x6600
leal -0x1(%rax), %ecx
movl 0x14(%rsp), %edx
cmpl %ecx, %edx
movl %edx, %ecx
movq 0x18(%rsp), %rbx
jl 0x65cc
movq %r13, %rdi
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x10b0
callq 0x1338