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

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

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

        /* 4,5: sitewise marginals fi, twice */
        for (int x = 0; x < 2; x++)
            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);
                }

        /* 6: 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);
            }

        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 $0x28, %rsp
movq %rdx, %rbx
movq %rsi, %r14
leaq 0x779f(%rip), %rsi      # 0xf321
callq 0x11c0
testq %rax, %rax
je 0x7d6d
movq %rax, %r15
movq %r14, 0x18(%rsp)
leaq 0x4(%rbx), %r12
movl $0x4, %esi
movl $0x1, %edx
movq %r12, %rdi
movq %rax, %rcx
callq 0x1200
cmpl $0x0, 0x38(%rbx)
movl 0x4(%rbx), %eax
js 0x7bf3
testl %eax, %eax
jle 0x7c14
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 %r15, %rsi
callq 0x1140
movl 0x4(%rbx), %eax
incq %r14
cmpl %eax, %r14d
jl 0x7bc1
jmp 0x7c14
testl %eax, %eax
jle 0x7c14
movq 0x10(%rbx), %rax
movsbl (%rax), %ebp
xorl %r14d, %r14d
movl %ebp, %edi
movq %r15, %rsi
callq 0x1140
incl %r14d
cmpl (%r12), %r14d
jl 0x7c01
cmpl $0x0, 0x38(%rbx)
movl 0x4(%rbx), %eax
js 0x7c58
testl %eax, %eax
jle 0x7c84
xorl %r14d, %r14d
leaq 0xc(%rsp), %r13
movq 0x40(%rbx), %rax
movl (%rax,%r14,4), %eax
movl %eax, 0xc(%rsp)
movl $0x4, %esi
movl $0x1, %edx
movq %r13, %rdi
movq %r15, %rcx
callq 0x1200
incq %r14
movslq 0x4(%rbx), %rax
cmpq %rax, %r14
jl 0x7c29
jmp 0x7c84
testl %eax, %eax
jle 0x7c84
xorl %ebp, %ebp
leaq 0xc(%rsp), %r13
incl %ebp
movl %ebp, 0xc(%rsp)
movl $0x4, %esi
movl $0x1, %edx
movq %r13, %rdi
movq %r15, %rcx
callq 0x1200
cmpl (%r12), %ebp
jl 0x7c63
xorl %eax, %eax
leaq 0xc(%rsp), %r13
movq %rax, 0x20(%rsp)
cmpl $0x0, (%r12)
jle 0x7ce5
xorl %r14d, %r14d
cmpl $0x0, 0x8(%rbx)
jle 0x7cdc
xorl %ebp, %ebp
movq 0x58(%rbx), %rax
movl 0x4(%rbx), %ecx
imull %ebp, %ecx
addl %r14d, %ecx
movslq %ecx, %rcx
xorps %xmm0, %xmm0
cvtsd2ss (%rax,%rcx,8), %xmm0
movss %xmm0, 0xc(%rsp)
movl $0x4, %esi
movl $0x1, %edx
movq %r13, %rdi
movq %r15, %rcx
callq 0x1200
incl %ebp
cmpl 0x8(%rbx), %ebp
jl 0x7ca2
incl %r14d
cmpl (%r12), %r14d
jl 0x7c9a
movq 0x20(%rsp), %rcx
leal 0x1(%rcx), %eax
testl %ecx, %ecx
je 0x7c8b
cmpl $0x0, (%r12)
jle 0x7d57
xorl %ebp, %ebp
leaq 0xc(%rsp), %r13
movq %r12, 0x10(%rsp)
cmpl $0x0, 0x8(%rbx)
movq 0x18(%rsp), %r12
jle 0x7d4a
xorl %r14d, %r14d
movl 0x4(%rbx), %eax
imull %r14d, %eax
addl %ebp, %eax
cltq
xorps %xmm0, %xmm0
cvtsd2ss (%r12,%rax,8), %xmm0
movss %xmm0, 0xc(%rsp)
movl $0x4, %esi
movl $0x1, %edx
movq %r13, %rdi
movq %r15, %rcx
callq 0x1200
incl %r14d
cmpl 0x8(%rbx), %r14d
jl 0x7d12
incl %ebp
movq 0x10(%rsp), %r12
cmpl (%r12), %ebp
jl 0x7d04
movq %r15, %rdi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x10b0
callq 0x1372
nop