// File: /workspace/github_c_makefile_star2_O2/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 $0x58, %rsp
movq %rcx, %r15
movq %rdx, %rbx
movq %rsi, 0x28(%rsp)
leaq 0x79bb(%rip), %rsi      # 0xc380
callq 0x11c0
testq %rax, %rax
je 0x4f06
movq %rax, %r12
movl 0x4(%rbx), %eax
leaq 0x54(%rsp), %rdi
movl %eax, (%rdi)
pushq $0x4
popq %r13
pushq $0x1
popq %rbp
movq %r13, %rsi
movq %rbp, %rdx
movq %r12, %rcx
callq 0x1200
movl 0x8(%rbx), %eax
leaq 0x50(%rsp), %rdi
movl %eax, (%rdi)
movq %r13, %rsi
movq %rbp, %rdx
movq %r12, %rcx
callq 0x1200
movl (%rbx), %eax
leaq 0x4c(%rsp), %rdi
movl %eax, (%rdi)
movq %r13, %rsi
movq %rbp, %rdx
movq %r12, %rcx
callq 0x1200
movl 0x28(%rbx), %eax
leaq 0x48(%rsp), %rdi
movl %eax, (%rdi)
movq %r13, %rsi
movq %rbp, %rdx
movq %r12, %rcx
callq 0x1200
movl 0x1c(%r15), %eax
leaq 0x44(%rsp), %rdi
movl %eax, (%rdi)
movq %r13, %rsi
movq %rbp, %rdx
movq %r12, %rcx
callq 0x1200
cvtsd2ss 0x30(%r15), %xmm0
leaq 0x40(%rsp), %rdi
movss %xmm0, (%rdi)
movq %r13, %rsi
movq %rbp, %rdx
movq %r12, %rcx
callq 0x1200
cvtsd2ss 0x40(%r15), %xmm0
leaq 0x3c(%rsp), %rdi
movss %xmm0, (%rdi)
movq %r13, %rsi
movq %rbp, %rdx
movq %r12, %rcx
callq 0x1200
cvtsd2ss 0x48(%r15), %xmm0
leaq 0x38(%rsp), %rdi
movss %xmm0, (%rdi)
movq %r13, %rsi
movq %rbp, %rdx
movq %r12, %rcx
callq 0x1200
cvtsd2ss 0x50(%r15), %xmm0
leaq 0x34(%rsp), %rdi
movss %xmm0, (%rdi)
movq %r13, %rsi
movq %rbp, %rdx
movq %r12, %rcx
callq 0x1200
cvtsd2ss 0x48(%rbx), %xmm0
leaq 0x30(%rsp), %rdi
movss %xmm0, (%rdi)
movq %r13, %rsi
movq %rbp, %rdx
movq %r12, %rcx
callq 0x1200
xorl %r14d, %r14d
movq %r15, %rbp
cmpl $0x1, 0x18(%r15)
sete %r14b
xorl %r15d, %r15d
movslq 0x8(%rbx), %rax
cmpq %rax, %r15
jge 0x4b19
movq 0x10(%rbx), %rax
addq %r14, %rax
movsbl (%r15,%rax), %edi
movq %r12, %rsi
callq 0x1130
incq %r15
jmp 0x4af7
movq %r12, 0x10(%rsp)
xorl %r14d, %r14d
pushq $0x1
popq %r12
xorl %r15d, %r15d
xorl %r13d, %r13d
movl 0x28(%rbx), %eax
movl (%rbx), %ecx
addl %eax, %ecx
cmpl %ecx, %r13d
jge 0x4bb0
cmpl %eax, %r14d
jge 0x4b68
movq 0x30(%rbx), %rax
movslq %r14d, %rcx
cmpl (%rax,%rcx,4), %r13d
jne 0x4b68
andl $0x0, 0xc(%rsp)
leaq 0xc(%rsp), %rdi
pushq $0x4
popq %rsi
movq %r12, %rdx
movq 0x10(%rsp), %rcx
callq 0x1200
incl %r14d
jmp 0x4ba8
movq 0x50(%rbx), %rax
movslq %r15d, %r15
movsd (%rax,%r15,8), %xmm0
mulsd 0x38(%rbp), %xmm0
movsd 0x74e6(%rip), %xmm1     # 0xc068
divsd %xmm0, %xmm1
cvtsd2ss %xmm1, %xmm0
movss %xmm0, 0xc(%rsp)
leaq 0xc(%rsp), %rdi
pushq $0x4
popq %rsi
movq %r12, %rdx
movq 0x10(%rsp), %rcx
callq 0x1200
incl %r15d
incl %r13d
jmp 0x4b2b
cmpl $0x0, 0x38(%rbx)
js 0x4bf1
xorl %r14d, %r14d
movq 0x10(%rsp), %r15
movl 0x4(%rbx), %ecx
cmpl %ecx, %r14d
jge 0x4c17
movslq %ecx, %rax
movq 0x10(%rbx), %rcx
movq 0x20(%rbx), %rdx
movslq 0x38(%rbx), %rsi
imulq %rax, %rsi
addq %r14, %rsi
movslq (%rdx,%rsi,4), %rax
movsbl (%rcx,%rax), %edi
movq %r15, %rsi
callq 0x1130
incq %r14
jmp 0x4bbe
movq 0x10(%rbx), %rax
movsbl (%rax), %ebp
xorl %r14d, %r14d
movq 0x10(%rsp), %r15
movl 0x4(%rbx), %ecx
cmpl %ecx, %r14d
jge 0x4c17
movl %ebp, %edi
movq %r15, %rsi
callq 0x1130
incl %r14d
jmp 0x4c00
cmpl $0x0, 0x38(%rbx)
js 0x4c5c
xorl %r15d, %r15d
leaq 0xc(%rsp), %r14
pushq $0x4
popq %r12
pushq $0x1
popq %r13
movslq %ecx, %rax
cmpq %rax, %r15
jge 0x4c95
movq 0x40(%rbx), %rax
movl (%rax,%r15,4), %eax
movl %eax, 0xc(%rsp)
movq %r14, %rdi
movq %r12, %rsi
movq %r13, %rdx
movq 0x10(%rsp), %rcx
callq 0x1200
incq %r15
movl 0x4(%rbx), %ecx
jmp 0x4c2d
pushq $0x1
popq %r15
leaq 0xc(%rsp), %r14
pushq $0x4
popq %r12
pushq $0x1
popq %r13
leal -0x1(%r15), %eax
cmpl %ecx, %eax
jge 0x4c95
movl %r15d, 0xc(%rsp)
movq %r14, %rdi
movq %r12, %rsi
movq %r13, %rdx
movq 0x10(%rsp), %rcx
callq 0x1200
movl 0x4(%rbx), %ecx
incl %r15d
jmp 0x4c6d
xorl %ebp, %ebp
leaq 0xc(%rsp), %r14
pushq $0x4
popq %r12
pushq $0x1
popq %r13
cmpl %ecx, %ebp
jge 0x4ceb
xorl %r15d, %r15d
cmpl 0x8(%rbx), %r15d
jge 0x4ce4
movq 0x58(%rbx), %rax
movl 0x4(%rbx), %ecx
imull %r15d, %ecx
addl %ebp, %ecx
movslq %ecx, %rcx
cvtsd2ss (%rax,%rcx,8), %xmm0
movss %xmm0, 0xc(%rsp)
movq %r14, %rdi
movq %r12, %rsi
movq %r13, %rdx
movq 0x10(%rsp), %rcx
callq 0x1200
incl %r15d
jmp 0x4cab
incl %ebp
movl 0x4(%rbx), %ecx
jmp 0x4ca4
xorl %ebp, %ebp
leaq 0xc(%rsp), %r14
pushq $0x4
popq %r12
pushq $0x1
popq %r13
cmpl %ecx, %ebp
jge 0x4d41
xorl %r15d, %r15d
cmpl 0x8(%rbx), %r15d
jge 0x4d3a
movl 0x4(%rbx), %eax
imull %r15d, %eax
addl %ebp, %eax
cltq
movq 0x28(%rsp), %rcx
cvtsd2ss (%rcx,%rax,8), %xmm0
movss %xmm0, 0xc(%rsp)
movq %r14, %rdi
movq %r12, %rsi
movq %r13, %rdx
movq 0x10(%rsp), %rcx
callq 0x1200
incl %r15d
jmp 0x4d01
incl %ebp
movl 0x4(%rbx), %ecx
jmp 0x4cfa
xorl %r15d, %r15d
leal -0x1(%rcx), %eax
cmpl %eax, %r15d
jge 0x4e13
leal 0x1(%r15), %edi
leal -0x1(%r15), %eax
imull %r15d, %eax
cltd
pushq $0x2
popq %rsi
idivl %esi
movq %rax, 0x20(%rsp)
movl %edi, 0x1c(%rsp)
movl %edi, %r12d
cmpl %ecx, %r12d
jge 0x4e07
movq 0x20(%rsp), %rax
leal (%r12,%rax), %ecx
leal -0x1(%r12), %eax
imull %r12d, %eax
cltd
pushq $0x2
popq %rsi
idivl %esi
movl %eax, %r14d
addl %r15d, %r14d
cmpl %r12d, %r15d
movl 0x8(%rbx), %eax
cmovael %ecx, %r14d
xorl %r13d, %r13d
cmpl %eax, %r13d
jge 0x4dfc
xorl %ebp, %ebp
cmpl %eax, %ebp
jge 0x4df7
cmpl %r12d, %r15d
movq 0x60(%rbx), %rcx
movl %r13d, %edx
cmovbl %ebp, %edx
movl %ebp, %esi
cmovbl %r13d, %esi
movl %eax, %edi
imull %r14d, %edi
addl %edx, %edi
imull %eax, %edi
addl %esi, %edi
movslq %edi, %rax
cvtsd2ss (%rcx,%rax,8), %xmm0
movss %xmm0, 0xc(%rsp)
leaq 0xc(%rsp), %rdi
pushq $0x4
popq %rsi
pushq $0x1
popq %rdx
movq 0x10(%rsp), %rcx
callq 0x1200
incl %ebp
movl 0x8(%rbx), %eax
jmp 0x4da9
incl %r13d
jmp 0x4da2
incl %r12d
movl 0x4(%rbx), %ecx
jmp 0x4d6e
movl 0x1c(%rsp), %eax
movl %eax, %r15d
jmp 0x4d44
xorl %r15d, %r15d
leal -0x1(%rcx), %eax
cmpl %eax, %r15d
jge 0x4eee
leal 0x1(%r15), %edi
leal -0x1(%r15), %eax
imull %r15d, %eax
cltd
pushq $0x2
popq %rsi
idivl %esi
movq %rax, 0x20(%rsp)
movl %edi, 0x1c(%rsp)
movl %edi, %r12d
cmpl %ecx, %r12d
jge 0x4ee2
movq 0x20(%rsp), %rax
leal (%r12,%rax), %ecx
leal -0x1(%r12), %eax
imull %r12d, %eax
cltd
pushq $0x2
popq %rsi
idivl %esi
movl %eax, %r14d
addl %r15d, %r14d
cmpl %r12d, %r15d
movl 0x8(%rbx), %eax
cmovael %ecx, %r14d
xorl %r13d, %r13d
cmpl %eax, %r13d
jge 0x4ed7
xorl %ebp, %ebp
cmpl %eax, %ebp
jge 0x4ed2
movl 0x4(%rbx), %ecx
imull %eax, %ecx
cmpl %r12d, %r15d
movl %r13d, %edx
cmovbl %ebp, %edx
movl %ebp, %esi
cmovbl %r13d, %esi
movl %eax, %edi
imull %r14d, %edi
addl %edx, %edi
imull %eax, %edi
addl %esi, %edi
addl %ecx, %edi
movslq %edi, %rax
movq 0x28(%rsp), %rcx
cvtsd2ss (%rcx,%rax,8), %xmm0
movss %xmm0, 0xc(%rsp)
leaq 0xc(%rsp), %rdi
pushq $0x4
popq %rsi
pushq $0x1
popq %rdx
movq 0x10(%rsp), %rcx
callq 0x1200
incl %ebp
movl 0x8(%rbx), %eax
jmp 0x4e7b
incl %r13d
jmp 0x4e74
incl %r12d
movl 0x4(%rbx), %ecx
jmp 0x4e40
movl 0x1c(%rsp), %eax
movl %eax, %r15d
jmp 0x4e16
movq 0x10(%rsp), %rdi
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x10b0
movq 0xb0eb(%rip), %rax      # 0xfff8
movq (%rax), %rcx
leaq 0x746b(%rip), %rdi      # 0xc382
pushq $0x19
popq %rsi
pushq $0x1
popq %rdx
callq 0x1200
pushq $0x1
popq %rdi
callq 0x11f0