// File: /workspace/github_c_makefile_star2_O1/sc932[P]ALE/src/ALEhelpers.c
// Function: writeToOutput
void writeToOutput(assemblyT *theAssembly, int fullOut, FILE *out){
    int i, j;
    printf("Set minLogLike to: %0.1f\n", getMinLogLike());
    //printf("Writing statistics to output file.\n");
    fprintf(out, "# ALE_score: %lf\n", theAssembly->totalScore);
    fprintf(out, "# numContigs: %d\n", theAssembly->numContigs);
    fprintf(out, "# totalAssemLen: %ld\n", theAssembly->totalAssemLen);
    fprintf(out, "# placeAvg: %lf\n", theAssembly->placeAvgSum/theAssembly->placeAvgNorm);
    fprintf(out, "# insertAvg: %lf\n", theAssembly->insertAvgSum/theAssembly->insertAvgNorm);
    fprintf(out, "# kmerAvg: %lf\n", theAssembly->kmerAvgSum/theAssembly->kmerAvgNorm);
    fprintf(out, "# depthScoreAvg: %lf\n", theAssembly->depthScoreAvgSum/theAssembly->depthScoreAvgNorm);
    fprintf(out, "# depthAvg: %lf\n", theAssembly->depthAvgSum/theAssembly->depthAvgNorm);
    fprintf(out, "# totalReads: %ld\n", theAssembly->totalReads);
    fprintf(out, "# totalMappedReads: %ld\n", theAssembly->totalMappedReads);
    fprintf(out, "# totalUnmappedReads: %ld\n", theAssembly->totalUnmappedReads);
    fprintf(out, "# totalPlacedReads: %ld\n", theAssembly->totalPlacedReads);
    fprintf(out, "# readAvgLen: %lf\n", theAssembly->avgReadSize);
    fprintf(out, "# avgReadOverlap: %lf\n", theAssembly->overlapAvgSum/theAssembly->overlapAvgNorm);
    
    if(fullOut == 1){
        for(i = 0; i < theAssembly->numContigs; i++){
            contig_t *contig = theAssembly->contigs[i];
            fprintf(out, "# Reference: %s %i %lf\n# contig position depth ln(depthLike) ln(placeLike) ln(insertLike) ln(kmerLike)\n", contig->name, contig->seqLen, getContigAvgDepth(contig));
            for(j = 0; j < contig->seqLen; j++){
                fprintf(out, "%d %d %0.3f %0.3f %0.3f %0.3f %0.3f\n", i, j, contig->depth[j], contig->depthLogLikelihood[j], contig->matchLogLikelihood[j], contig->insertLogLikelihood[j], contig->kmerLogLikelihood[j]);
            }
        }
    }
    printf("Total ALE Score: %lf\n", theAssembly->totalScore);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %rbx
movl %esi, %ebp
movq %rdi, %r14
movsd 0x207e4(%rip), %xmm0    # 0x2c4e0
leaq 0x113b3(%rip), %rdi     # 0x1d0b6
movb $0x1, %al
callq 0x3210
movsd 0x10(%r14), %xmm0
leaq 0x18134(%rip), %rsi     # 0x23e4b
movq %rbx, %rdi
movb $0x1, %al
callq 0x3350
movl (%r14), %edx
leaq 0x18132(%rip), %rsi     # 0x23e5d
movq %rbx, %rdi
xorl %eax, %eax
callq 0x3350
movq 0x8(%r14), %rdx
leaq 0x1812f(%rip), %rsi     # 0x23e6f
movq %rbx, %rdi
xorl %eax, %eax
callq 0x3350
movsd 0x28(%r14), %xmm0
divsd 0x30(%r14), %xmm0
leaq 0x18128(%rip), %rsi     # 0x23e85
movq %rbx, %rdi
movb $0x1, %al
callq 0x3350
movsd 0x38(%r14), %xmm0
divsd 0x40(%r14), %xmm0
leaq 0x1811c(%rip), %rsi     # 0x23e96
movq %rbx, %rdi
movb $0x1, %al
callq 0x3350
movsd 0x18(%r14), %xmm0
divsd 0x20(%r14), %xmm0
leaq 0x18111(%rip), %rsi     # 0x23ea8
movq %rbx, %rdi
movb $0x1, %al
callq 0x3350
movsd 0x48(%r14), %xmm0
divsd 0x50(%r14), %xmm0
leaq 0x18104(%rip), %rsi     # 0x23eb8
movq %rbx, %rdi
movb $0x1, %al
callq 0x3350
movsd 0x58(%r14), %xmm0
divsd 0x60(%r14), %xmm0
leaq 0x180fd(%rip), %rsi     # 0x23ece
movq %rbx, %rdi
movb $0x1, %al
callq 0x3350
movq 0x78(%r14), %rdx
leaq 0x180f9(%rip), %rsi     # 0x23edf
movq %rbx, %rdi
xorl %eax, %eax
callq 0x3350
movq 0x88(%r14), %rdx
leaq 0x180f4(%rip), %rsi     # 0x23ef2
movq %rbx, %rdi
xorl %eax, %eax
callq 0x3350
movq 0x80(%r14), %rdx
leaq 0x180f5(%rip), %rsi     # 0x23f0b
movq %rbx, %rdi
xorl %eax, %eax
callq 0x3350
movq 0x90(%r14), %rdx
leaq 0x180f8(%rip), %rsi     # 0x23f26
movq %rbx, %rdi
xorl %eax, %eax
callq 0x3350
movsd 0x98(%r14), %xmm0
leaq 0x180f7(%rip), %rsi     # 0x23f3f
movq %rbx, %rdi
movb $0x1, %al
callq 0x3350
movsd 0x68(%r14), %xmm0
divsd 0x70(%r14), %xmm0
leaq 0x180ed(%rip), %rsi     # 0x23f52
movq %rbx, %rdi
movb $0x1, %al
callq 0x3350
cmpl $0x1, %ebp
jne 0xbf5f
cmpl $0x0, (%r14)
jle 0xbf5f
xorl %r15d, %r15d
leaq 0x18145(%rip), %r13     # 0x23fd1
movq 0xa0(%r14), %rax
movq (%rax,%r15,8), %r12
movslq 0x8(%r12), %rcx
testq %rcx, %rcx
jle 0xbec2
movq 0x30(%r12), %rax
xorpd %xmm0, %xmm0
xorl %edx, %edx
xorps %xmm1, %xmm1
cvtss2sd (%rax,%rdx,4), %xmm1
addsd %xmm1, %xmm0
incq %rdx
cmpq %rdx, %rcx
jne 0xbeac
jmp 0xbec6
xorpd %xmm0, %xmm0
movq (%r12), %rdx
xorps %xmm1, %xmm1
cvtsi2sd %ecx, %xmm1
divsd %xmm1, %xmm0
movq %rbx, %rdi
leaq 0x1808a(%rip), %rsi     # 0x23f69
movb $0x1, %al
callq 0x3350
cmpl $0x0, 0x8(%r12)
jle 0xbf50
xorl %ebp, %ebp
movq 0x30(%r12), %rax
movq 0x38(%r12), %rcx
xorps %xmm0, %xmm0
cvtss2sd (%rax,%rbp,4), %xmm0
movq 0x48(%r12), %rax
xorps %xmm1, %xmm1
cvtss2sd (%rax,%rbp,4), %xmm1
xorps %xmm2, %xmm2
cvtss2sd (%rcx,%rbp,4), %xmm2
movq 0x40(%r12), %rax
xorps %xmm3, %xmm3
cvtss2sd (%rax,%rbp,4), %xmm3
movq 0x50(%r12), %rax
xorps %xmm4, %xmm4
cvtss2sd (%rax,%rbp,4), %xmm4
movq %rbx, %rdi
movq %r13, %rsi
movl %r15d, %edx
movl %ebp, %ecx
movb $0x5, %al
callq 0x3350
incq %rbp
movslq 0x8(%r12), %rax
cmpq %rax, %rbp
jl 0xbef0
incq %r15
movslq (%r14), %rax
cmpq %rax, %r15
jl 0xbe8c
movsd 0x10(%r14), %xmm0
leaq 0x1808a(%rip), %rdi     # 0x23ff6
movb $0x1, %al
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3210