// File: /workspace/github_c_makefile_star2_O3/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 0x2056f(%rip), %xmm0    # 0x2c4e0
leaq 0x1113e(%rip), %rdi     # 0x1d0b6
movb $0x1, %al
callq 0x3210
movsd 0x10(%r14), %xmm0
leaq 0x17f4f(%rip), %rsi     # 0x23edb
movq %rbx, %rdi
movb $0x1, %al
callq 0x3350
movl (%r14), %edx
leaq 0x17f4d(%rip), %rsi     # 0x23eed
movq %rbx, %rdi
xorl %eax, %eax
callq 0x3350
movq 0x8(%r14), %rdx
leaq 0x17f4a(%rip), %rsi     # 0x23eff
movq %rbx, %rdi
xorl %eax, %eax
callq 0x3350
movsd 0x28(%r14), %xmm0
divsd 0x30(%r14), %xmm0
leaq 0x17f43(%rip), %rsi     # 0x23f15
movq %rbx, %rdi
movb $0x1, %al
callq 0x3350
movsd 0x38(%r14), %xmm0
divsd 0x40(%r14), %xmm0
leaq 0x17f37(%rip), %rsi     # 0x23f26
movq %rbx, %rdi
movb $0x1, %al
callq 0x3350
movsd 0x18(%r14), %xmm0
divsd 0x20(%r14), %xmm0
leaq 0x17f2c(%rip), %rsi     # 0x23f38
movq %rbx, %rdi
movb $0x1, %al
callq 0x3350
movsd 0x48(%r14), %xmm0
divsd 0x50(%r14), %xmm0
leaq 0x17f1f(%rip), %rsi     # 0x23f48
movq %rbx, %rdi
movb $0x1, %al
callq 0x3350
movsd 0x58(%r14), %xmm0
divsd 0x60(%r14), %xmm0
leaq 0x17f18(%rip), %rsi     # 0x23f5e
movq %rbx, %rdi
movb $0x1, %al
callq 0x3350
movq 0x78(%r14), %rdx
leaq 0x17f14(%rip), %rsi     # 0x23f6f
movq %rbx, %rdi
xorl %eax, %eax
callq 0x3350
movq 0x88(%r14), %rdx
leaq 0x17f0f(%rip), %rsi     # 0x23f82
movq %rbx, %rdi
xorl %eax, %eax
callq 0x3350
movq 0x80(%r14), %rdx
leaq 0x17f10(%rip), %rsi     # 0x23f9b
movq %rbx, %rdi
xorl %eax, %eax
callq 0x3350
movq 0x90(%r14), %rdx
leaq 0x17f13(%rip), %rsi     # 0x23fb6
movq %rbx, %rdi
xorl %eax, %eax
callq 0x3350
movsd 0x98(%r14), %xmm0
leaq 0x17f12(%rip), %rsi     # 0x23fcf
movq %rbx, %rdi
movb $0x1, %al
callq 0x3350
movsd 0x68(%r14), %xmm0
divsd 0x70(%r14), %xmm0
leaq 0x17f08(%rip), %rsi     # 0x23fe2
movq %rbx, %rdi
movb $0x1, %al
callq 0x3350
cmpl $0x1, %ebp
jne 0xc1d4
cmpl $0x0, (%r14)
jle 0xc1d4
xorl %r15d, %r15d
leaq 0x17f60(%rip), %r13     # 0x24061
movq 0xa0(%r14), %rax
movq (%rax,%r15,8), %r12
movslq 0x8(%r12), %rcx
testq %rcx, %rcx
jle 0xc137
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 0xc121
jmp 0xc13b
xorpd %xmm0, %xmm0
movq (%r12), %rdx
xorps %xmm1, %xmm1
cvtsi2sd %ecx, %xmm1
divsd %xmm1, %xmm0
movq %rbx, %rdi
leaq 0x17ea5(%rip), %rsi     # 0x23ff9
movb $0x1, %al
callq 0x3350
cmpl $0x0, 0x8(%r12)
jle 0xc1c5
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 0xc165
incq %r15
movslq (%r14), %rax
cmpq %rax, %r15
jl 0xc101
movsd 0x10(%r14), %xmm0
leaq 0x17ea5(%rip), %rdi     # 0x24086
movb $0x1, %al
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3210