// File: /workspace/github_c_makefile_star2_O1/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 0x869f(%rip), %rsi      # 0xf321
callq 0x11c0
testq %rax, %rax
je 0x72d6
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 0x1200
movl 0x8(%rbx), %eax
leaq 0x60(%rsp), %rdi
movl %eax, (%rdi)
movl $0x4, %esi
movl $0x1, %edx
movq %r12, %rcx
callq 0x1200
movl (%rbx), %eax
leaq 0x5c(%rsp), %rdi
movl %eax, (%rdi)
movl $0x4, %esi
movl $0x1, %edx
movq %r12, %rcx
callq 0x1200
movl 0x28(%rbx), %eax
leaq 0x58(%rsp), %rdi
movl %eax, (%rdi)
movl $0x4, %esi
movl $0x1, %edx
movq %r12, %rcx
callq 0x1200
movl 0x1c(%r15), %eax
leaq 0x54(%rsp), %rdi
movl %eax, (%rdi)
movl $0x4, %esi
movl $0x1, %edx
movq %r12, %rcx
callq 0x1200
cvtsd2ss 0x30(%r15), %xmm0
leaq 0x50(%rsp), %rdi
movss %xmm0, (%rdi)
movl $0x4, %esi
movl $0x1, %edx
movq %r12, %rcx
callq 0x1200
xorps %xmm0, %xmm0
cvtsd2ss 0x40(%r15), %xmm0
leaq 0x4c(%rsp), %rdi
movss %xmm0, (%rdi)
movl $0x4, %esi
movl $0x1, %edx
movq %r12, %rcx
callq 0x1200
xorps %xmm0, %xmm0
cvtsd2ss 0x48(%r15), %xmm0
leaq 0x48(%rsp), %rdi
movss %xmm0, (%rdi)
movl $0x4, %esi
movl $0x1, %edx
movq %r12, %rcx
callq 0x1200
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 0x1200
xorps %xmm0, %xmm0
cvtsd2ss 0x48(%rbx), %xmm0
leaq 0x40(%rsp), %rdi
movss %xmm0, (%rdi)
movl $0x4, %esi
movl $0x1, %edx
movq %r12, %rcx
callq 0x1200
cmpl $0x0, 0x8(%rbx)
movq %rbx, %rdx
movq %rbx, 0x8(%rsp)
jle 0x6e19
xorl %r14d, %r14d
cmpl $0x1, 0x18(%r13)
sete %r14b
xorl %r15d, %r15d
movq 0x10(%rdx), %rax
addq %r14, %rax
movsbl (%r15,%rax), %edi
movq %r12, %rsi
callq 0x1140
movq 0x8(%rsp), %rdx
incq %r15
movslq 0x8(%rdx), %rax
cmpq %rax, %r15
jl 0x6df4
movq %r12, 0x10(%rsp)
movl 0x28(%rdx), %eax
movl (%rdx), %ecx
addl %eax, %ecx
jle 0x6ed0
movq %r13, %r15
xorl %ebp, %ebp
leaq 0x4(%rsp), %r13
xorl %r12d, %r12d
xorl %r14d, %r14d
cmpl %eax, %r14d
jge 0x6e73
movq 0x30(%rdx), %rax
movslq %r14d, %rcx
cmpl (%rax,%rcx,4), %ebp
jne 0x6e73
movl $0x0, 0x4(%rsp)
movl $0x4, %esi
movq %rdx, %rbx
movl $0x1, %edx
movq %r13, %rdi
movq 0x10(%rsp), %rcx
callq 0x1200
incl %r14d
jmp 0x6ebc
movq 0x50(%rdx), %rax
movslq %r12d, %r12
movsd (%rax,%r12,8), %xmm0
mulsd 0x38(%r15), %xmm0
movsd 0x71da(%rip), %xmm1     # 0xe068
divsd %xmm0, %xmm1
xorps %xmm0, %xmm0
cvtsd2ss %xmm1, %xmm0
movss %xmm0, 0x4(%rsp)
movl $0x4, %esi
movq %rdx, %rbx
movl $0x1, %edx
movq %r13, %rdi
movq 0x10(%rsp), %rcx
callq 0x1200
incl %r12d
incl %ebp
movl 0x28(%rbx), %eax
movl (%rbx), %ecx
addl %eax, %ecx
cmpl %ecx, %ebp
movq %rbx, %rdx
jl 0x6e3b
cmpl $0x0, 0x38(%rdx)
movl 0x4(%rdx), %eax
js 0x6f26
testl %eax, %eax
movq 0x10(%rsp), %r13
jle 0x6f51
xorl %r14d, %r14d
movq 0x10(%rdx), %rcx
movq 0x8(%rsp), %rdx
movq 0x20(%rdx), %rdx
movq 0x8(%rsp), %rsi
movslq 0x38(%rsi), %rsi
cltq
imulq %rsi, %rax
addq %r14, %rax
movslq (%rdx,%rax,4), %rax
movsbl (%rcx,%rax), %edi
movq %r13, %rsi
callq 0x1140
movq 0x8(%rsp), %rdx
movl 0x4(%rdx), %eax
incq %r14
cmpl %eax, %r14d
jl 0x6ee5
jmp 0x6f51
testl %eax, %eax
movq 0x10(%rsp), %r13
jle 0x6f51
movq 0x10(%rdx), %rax
movsbl (%rax), %ebp
xorl %r14d, %r14d
movl %ebp, %edi
movq %r13, %rsi
callq 0x1140
movq 0x8(%rsp), %rdx
incl %r14d
cmpl 0x4(%rdx), %r14d
jl 0x6f39
cmpl $0x0, 0x38(%rdx)
movl 0x4(%rdx), %eax
js 0x6f9f
testl %eax, %eax
movq 0x28(%rsp), %r15
jle 0x6fd4
xorl %r14d, %r14d
leaq 0x4(%rsp), %r12
movq 0x40(%rdx), %rax
movl (%rax,%r14,4), %eax
movl %eax, 0x4(%rsp)
movl $0x4, %esi
movl $0x1, %edx
movq %r12, %rdi
movq %r13, %rcx
callq 0x1200
movq 0x8(%rsp), %rdx
incq %r14
movslq 0x4(%rdx), %rax
cmpq %rax, %r14
jl 0x6f6b
jmp 0x6fd4
testl %eax, %eax
movq 0x28(%rsp), %r15
jle 0x6fd4
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 0x1200
movq 0x8(%rsp), %rdx
cmpl 0x4(%rdx), %ebp
jl 0x6faf
cmpl $0x0, 0x4(%rdx)
jle 0x7032
xorl %ebp, %ebp
leaq 0x4(%rsp), %r12
cmpl $0x0, 0x8(%rdx)
jle 0x702b
xorl %r14d, %r14d
movq 0x58(%rdx), %rax
movl 0x4(%rdx), %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 0x1200
movq 0x8(%rsp), %rdx
incl %r14d
cmpl 0x8(%rdx), %r14d
jl 0x6fea
incl %ebp
cmpl 0x4(%rdx), %ebp
jl 0x6fe1
cmpl $0x0, 0x4(%rdx)
jle 0x708c
xorl %ebp, %ebp
leaq 0x4(%rsp), %r12
cmpl $0x0, 0x8(%rdx)
jle 0x7085
xorl %r14d, %r14d
movl 0x4(%rdx), %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 0x1200
movq 0x8(%rsp), %rdx
incl %r14d
cmpl 0x8(%rdx), %r14d
jl 0x7048
incl %ebp
cmpl 0x4(%rdx), %ebp
jl 0x703f
cmpl $0x2, 0x4(%rdx)
jl 0x718f
xorl %eax, %eax
leaq 0x4(%rsp), %r13
movq 0x10(%rsp), %r14
movl %eax, %esi
leal 0x1(%rsi), %eax
movl %eax, 0x20(%rsp)
cmpl 0x4(%rdx), %eax
jge 0x717c
leal -0x1(%rsi), %eax
imull %esi, %eax
movl %eax, %ecx
shrl $0x1f, %ecx
addl %eax, %ecx
sarl %ecx
movq %rcx, 0x30(%rsp)
movl 0x20(%rsp), %eax
movl %eax, %ebp
movq %rsi, 0x38(%rsp)
cmpl $0x0, 0x8(%rdx)
jle 0x7171
movq 0x30(%rsp), %rax
addl %ebp, %eax
leal -0x1(%rbp), %ecx
imull %ebp, %ecx
movl %ecx, %ebx
shrl $0x1f, %ebx
addl %ecx, %ebx
sarl %ebx
addl %esi, %ebx
cmpl %ebp, %esi
cmovael %eax, %ebx
xorl %r15d, %r15d
movl 0x8(%rdx), %eax
testl %eax, %eax
jle 0x7168
xorl %r12d, %r12d
cmpl %ebp, %esi
movq 0x60(%rdx), %r10
movl %r15d, %edx
cmovbl %r12d, %edx
movl %r12d, %esi
cmovbl %r15d, %esi
movl %eax, %r8d
imull %ebx, %r8d
addl %edx, %r8d
imull %eax, %r8d
addl %esi, %r8d
movslq %r8d, %rax
xorps %xmm0, %xmm0
cvtsd2ss (%r10,%rax,8), %xmm0
movss %xmm0, 0x4(%rsp)
movl $0x4, %esi
movl $0x1, %edx
movq %r13, %rdi
movq %r14, %rcx
callq 0x1200
movq 0x38(%rsp), %rsi
movq 0x8(%rsp), %rdx
incl %r12d
movl 0x8(%rdx), %eax
cmpl %eax, %r12d
jl 0x7107
incl %r15d
cmpl 0x8(%rdx), %r15d
jl 0x70fd
incl %ebp
cmpl 0x4(%rdx), %ebp
jl 0x70d3
movl 0x4(%rdx), %eax
decl %eax
movl 0x20(%rsp), %ecx
cmpl %eax, %ecx
movl %ecx, %eax
jl 0x70a2
cmpl $0x2, 0x4(%rdx)
jl 0x72be
xorl %eax, %eax
leaq 0x4(%rsp), %r14
movq 0x10(%rsp), %r13
movl %eax, %esi
leal 0x1(%rsi), %eax
movl %eax, 0x1c(%rsp)
cmpl 0x4(%rdx), %eax
jge 0x72ab
leal -0x1(%rsi), %eax
imull %esi, %eax
movl %eax, %ecx
shrl $0x1f, %ecx
addl %eax, %ecx
sarl %ecx
movq %rcx, 0x20(%rsp)
movl 0x1c(%rsp), %eax
movl %eax, %r8d
movq %rsi, 0x30(%rsp)
cmpl $0x0, 0x8(%rdx)
jle 0x729e
movq 0x20(%rsp), %rax
addl %r8d, %eax
leal -0x1(%r8), %ecx
imull %r8d, %ecx
movl %ecx, %r15d
shrl $0x1f, %r15d
addl %ecx, %r15d
sarl %r15d
addl %esi, %r15d
cmpl %r8d, %esi
cmovael %eax, %r15d
xorl %ebp, %ebp
movq %r8, 0x38(%rsp)
movl 0x8(%rdx), %eax
testl %eax, %eax
movq 0x28(%rsp), %r11
jle 0x7293
xorl %r12d, %r12d
movq 0x8(%rsp), %rdx
movl 0x4(%rdx), %ebx
imull %eax, %ebx
cmpl %r8d, %esi
movl %ebp, %edx
cmovbl %r12d, %edx
movl %r12d, %esi
cmovbl %ebp, %esi
movl %eax, %r8d
imull %r15d, %r8d
addl %edx, %r8d
imull %eax, %r8d
addl %esi, %r8d
addl %ebx, %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 0x1200
movq %rbx, %r11
movq 0x8(%rsp), %rdx
movq 0x38(%rsp), %r8
movq 0x30(%rsp), %rsi
incl %r12d
movl 0x8(%rdx), %eax
cmpl %eax, %r12d
jl 0x721e
incl %ebp
cmpl 0x8(%rdx), %ebp
jl 0x720f
incl %r8d
cmpl 0x4(%rdx), %r8d
jl 0x71d7
movl 0x4(%rdx), %eax
decl %eax
movl 0x1c(%rsp), %ecx
cmpl %eax, %ecx
movl %ecx, %eax
jl 0x71a5
movq 0x10(%rsp), %rdi
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x10b0
callq 0x1328