// File: /workspace/github_c_makefile_star2_O2/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, %r15
leaq 0x6d32(%rip), %rsi      # 0xc380
callq 0x11c0
testq %rax, %rax
je 0x584c
movq %rax, %r12
leaq 0x4(%rbx), %rdi
pushq $0x4
popq %rsi
pushq $0x1
popq %rdx
movq %rdi, 0x8(%rsp)
movq %rax, %rcx
callq 0x1200
cmpl $0x0, 0x38(%rbx)
js 0x56b5
xorl %r14d, %r14d
movq 0x8(%rsp), %rax
movl (%rax), %eax
cmpl %eax, %r14d
jge 0x56da
cltq
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 %r12, %rsi
callq 0x1130
incq %r14
jmp 0x567f
movq 0x10(%rbx), %rax
movsbl (%rax), %ebp
xorl %r14d, %r14d
movq 0x8(%rsp), %rax
movl (%rax), %eax
cmpl %eax, %r14d
jge 0x56da
movl %ebp, %edi
movq %r12, %rsi
callq 0x1130
incl %r14d
jmp 0x56bf
movq %r12, 0x10(%rsp)
movq %r15, 0x20(%rsp)
cmpl $0x0, 0x38(%rbx)
js 0x5728
xorl %r12d, %r12d
leaq 0x4(%rsp), %r14
pushq $0x4
popq %r13
pushq $0x1
popq %rbp
movslq %eax, %rcx
cmpq %rcx, %r12
jge 0x5765
movq 0x40(%rbx), %rax
movl (%rax,%r12,4), %eax
movl %eax, 0x4(%rsp)
movq %r14, %rdi
movq %r13, %rsi
movq %rbp, %rdx
movq 0x10(%rsp), %rcx
callq 0x1200
incq %r12
movl 0x4(%rbx), %eax
jmp 0x56f9
pushq $0x1
popq %r12
leaq 0x4(%rsp), %r14
pushq $0x4
popq %r13
pushq $0x1
popq %rbp
leal -0x1(%r12), %ecx
cmpl %eax, %ecx
jge 0x5765
movl %r12d, 0x4(%rsp)
movq %r14, %rdi
movq %r13, %rsi
movq %rbp, %rdx
movq 0x10(%rsp), %rcx
callq 0x1200
movq 0x8(%rsp), %rax
movl (%rax), %eax
incl %r12d
jmp 0x5738
xorl %ecx, %ecx
leaq 0x4(%rsp), %r13
pushq $0x4
popq %rbp
pushq $0x1
popq %r14
cmpl $0x2, %ecx
je 0x57d5
movl %ecx, 0x1c(%rsp)
xorl %r12d, %r12d
cmpl %eax, %r12d
jge 0x57cd
xorl %r15d, %r15d
cmpl 0x8(%rbx), %r15d
jge 0x57c1
movq 0x58(%rbx), %rax
movl 0x4(%rbx), %ecx
imull %r15d, %ecx
addl %r12d, %ecx
movslq %ecx, %rcx
cvtsd2ss (%rax,%rcx,8), %xmm0
movss %xmm0, 0x4(%rsp)
movq %r13, %rdi
movq %rbp, %rsi
movq %r14, %rdx
movq 0x10(%rsp), %rcx
callq 0x1200
incl %r15d
jmp 0x5787
incl %r12d
movq 0x8(%rsp), %rax
movl (%rax), %eax
jmp 0x577f
movl 0x1c(%rsp), %ecx
incl %ecx
jmp 0x5773
xorl %r14d, %r14d
pushq $0x4
popq %r13
pushq $0x1
popq %rbp
movq 0x20(%rsp), %r12
cmpl %eax, %r14d
jge 0x5834
xorl %r15d, %r15d
cmpl 0x8(%rbx), %r15d
jge 0x5828
movq 0x8(%rsp), %rax
movl (%rax), %eax
imull %r15d, %eax
addl %r14d, %eax
cltq
cvtsd2ss (%r12,%rax,8), %xmm0
movss %xmm0, 0x4(%rsp)
leaq 0x4(%rsp), %rdi
movq %r13, %rsi
movq %rbp, %rdx
movq 0x10(%rsp), %rcx
callq 0x1200
incl %r15d
jmp 0x57ec
incl %r14d
movq 0x8(%rsp), %rax
movl (%rax), %eax
jmp 0x57e4
movq 0x10(%rsp), %rdi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x10b0
movq 0xa7a5(%rip), %rax      # 0xfff8
movq (%rax), %rcx
leaq 0x6b25(%rip), %rdi      # 0xc382
pushq $0x19
popq %rsi
pushq $0x1
popq %rdx
callq 0x1200
pushq $0x1
popq %rdi
callq 0x11f0