// File: /workspace/github_c_makefile_star2_O3/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 $0x18, %rsp
movq %rdx, %rbx
movq %rsi, %r14
leaq 0x6551(%rip), %rsi      # 0xd430
callq 0x11d0
testq %rax, %rax
je 0x70cc
movq %rax, %r15
leaq 0x4(%rbx), %r12
movl $0x4, %esi
movl $0x1, %edx
movq %r12, %rdi
movq %rax, %rcx
callq 0x1210
cmpl $0x0, 0x38(%rbx)
movl 0x4(%rbx), %eax
movq %r14, 0x10(%rsp)
js 0x6f54
testl %eax, %eax
jle 0x6fe5
xorl %r13d, %r13d
movq 0x10(%rbx), %rcx
movq 0x20(%rbx), %rdx
movslq 0x38(%rbx), %rsi
cltq
imulq %rsi, %rax
addq %r13, %rax
movslq (%rdx,%rax,4), %rax
movsbl (%rcx,%rax), %edi
movq %r15, %rsi
callq 0x1140
movl 0x4(%rbx), %eax
incq %r13
cmpl %eax, %r13d
jl 0x6f22
jmp 0x6f7c
testl %eax, %eax
jle 0x6fe5
movq 0x10(%rbx), %rax
movsbl (%rax), %ebp
xorl %r14d, %r14d
movl %ebp, %edi
movq %r15, %rsi
callq 0x1140
incl %r14d
movl (%r12), %eax
cmpl %eax, %r14d
jl 0x6f66
cmpl $0x0, 0x38(%rbx)
js 0x6fba
testl %eax, %eax
jle 0x6fe5
xorl %r14d, %r14d
movq %rsp, %r13
movq 0x40(%rbx), %rax
movl (%rax,%r14,4), %eax
movl %eax, (%rsp)
movl $0x4, %esi
movl $0x1, %edx
movq %r13, %rdi
movq %r15, %rcx
callq 0x1210
incq %r14
movslq 0x4(%rbx), %rax
cmpq %rax, %r14
jl 0x6f8c
jmp 0x6fe5
testl %eax, %eax
jle 0x6fe5
xorl %ebp, %ebp
movq %rsp, %r13
incl %ebp
movl %ebp, (%rsp)
movl $0x4, %esi
movl $0x1, %edx
movq %r13, %rdi
movq %r15, %rcx
callq 0x1210
movl (%r12), %eax
cmpl %eax, %ebp
jl 0x6fc3
movb $0x1, %cl
movq %rsp, %r13
movl %ecx, 0x4(%rsp)
testl %eax, %eax
jle 0x7045
movl 0x8(%rbx), %ecx
xorl %ebp, %ebp
testl %ecx, %ecx
jle 0x703f
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, (%rsp)
movl $0x4, %esi
movl $0x1, %edx
movq %r13, %rdi
movq %r15, %rcx
callq 0x1210
incl %r14d
movl 0x8(%rbx), %ecx
cmpl %ecx, %r14d
jl 0x6ffe
movl (%r12), %eax
incl %ebp
cmpl %eax, %ebp
jl 0x6ff7
testb $0x1, 0x4(%rsp)
movl $0x0, %ecx
jne 0x6fea
testl %eax, %eax
jle 0x70b6
movl 0x8(%rbx), %ecx
xorl %ebp, %ebp
movq %rsp, %r13
movq %r12, 0x8(%rsp)
testl %ecx, %ecx
jle 0x70b0
xorl %r14d, %r14d
movq 0x10(%rsp), %r12
movl 0x4(%rbx), %eax
imull %r14d, %eax
addl %ebp, %eax
cltq
xorps %xmm0, %xmm0
cvtsd2ss (%r12,%rax,8), %xmm0
movss %xmm0, (%rsp)
movl $0x4, %esi
movl $0x1, %edx
movq %r13, %rdi
movq %r15, %rcx
callq 0x1210
incl %r14d
movl 0x8(%rbx), %ecx
cmpl %ecx, %r14d
jl 0x706e
movq 0x8(%rsp), %r12
movl (%r12), %eax
incl %ebp
cmpl %eax, %ebp
jl 0x7062
movq %r15, %rdi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x10b0
callq 0x1382
nopl (%rax)