// File: /workspace/github_c_makefile_star2_O2/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 0x1f8d7(%rip), %xmm0    # 0x294e0
leaq 0xf4a6(%rip), %rdi      # 0x190b6
movb $0x1, %al
callq 0x3210
movsd 0x10(%r14), %xmm0
leaq 0x16287(%rip), %rsi     # 0x1feab
movq %rbx, %rdi
movb $0x1, %al
callq 0x3350
movl (%r14), %edx
leaq 0x16285(%rip), %rsi     # 0x1febd
movq %rbx, %rdi
xorl %eax, %eax
callq 0x3350
movq 0x8(%r14), %rdx
leaq 0x16282(%rip), %rsi     # 0x1fecf
movq %rbx, %rdi
xorl %eax, %eax
callq 0x3350
movsd 0x28(%r14), %xmm0
divsd 0x30(%r14), %xmm0
leaq 0x1627b(%rip), %rsi     # 0x1fee5
movq %rbx, %rdi
movb $0x1, %al
callq 0x3350
movsd 0x38(%r14), %xmm0
divsd 0x40(%r14), %xmm0
leaq 0x1626f(%rip), %rsi     # 0x1fef6
movq %rbx, %rdi
movb $0x1, %al
callq 0x3350
movsd 0x18(%r14), %xmm0
divsd 0x20(%r14), %xmm0
leaq 0x16264(%rip), %rsi     # 0x1ff08
movq %rbx, %rdi
movb $0x1, %al
callq 0x3350
movsd 0x48(%r14), %xmm0
divsd 0x50(%r14), %xmm0
leaq 0x16257(%rip), %rsi     # 0x1ff18
movq %rbx, %rdi
movb $0x1, %al
callq 0x3350
movsd 0x58(%r14), %xmm0
divsd 0x60(%r14), %xmm0
leaq 0x16250(%rip), %rsi     # 0x1ff2e
movq %rbx, %rdi
movb $0x1, %al
callq 0x3350
movq 0x78(%r14), %rdx
leaq 0x1624c(%rip), %rsi     # 0x1ff3f
movq %rbx, %rdi
xorl %eax, %eax
callq 0x3350
movq 0x88(%r14), %rdx
leaq 0x16247(%rip), %rsi     # 0x1ff52
movq %rbx, %rdi
xorl %eax, %eax
callq 0x3350
movq 0x80(%r14), %rdx
leaq 0x16248(%rip), %rsi     # 0x1ff6b
movq %rbx, %rdi
xorl %eax, %eax
callq 0x3350
movq 0x90(%r14), %rdx
leaq 0x1624b(%rip), %rsi     # 0x1ff86
movq %rbx, %rdi
xorl %eax, %eax
callq 0x3350
movsd 0x98(%r14), %xmm0
leaq 0x1624a(%rip), %rsi     # 0x1ff9f
movq %rbx, %rdi
movb $0x1, %al
callq 0x3350
movsd 0x68(%r14), %xmm0
divsd 0x70(%r14), %xmm0
leaq 0x16240(%rip), %rsi     # 0x1ffb2
movq %rbx, %rdi
movb $0x1, %al
callq 0x3350
cmpl $0x1, %ebp
jne 0x9e33
xorl %r15d, %r15d
leaq 0x162a2(%rip), %r13     # 0x20031
movq %r14, (%rsp)
movslq (%r14), %rax
cmpq %rax, %r15
jge 0x9e33
movq 0xa0(%r14), %rax
movq (%rax,%r15,8), %rbp
movq (%rbp), %r12
movl 0x8(%rbp), %r14d
movq %rbp, %rdi
callq 0x9953
movq %rbx, %rdi
leaq 0x16205(%rip), %rsi     # 0x1ffc9
movq %r12, %rdx
movl %r14d, %ecx
movb $0x1, %al
callq 0x3350
xorl %r12d, %r12d
movslq 0x8(%rbp), %rax
cmpq %rax, %r12
jge 0x9e27
movq 0x30(%rbp), %rax
movq 0x38(%rbp), %rcx
cvtss2sd (%rax,%r12,4), %xmm0
movq 0x48(%rbp), %rax
cvtss2sd (%rax,%r12,4), %xmm1
cvtss2sd (%rcx,%r12,4), %xmm2
movq 0x40(%rbp), %rax
cvtss2sd (%rax,%r12,4), %xmm3
movq 0x50(%rbp), %rax
cvtss2sd (%rax,%r12,4), %xmm4
movq %rbx, %rdi
movq %r13, %rsi
movl %r15d, %edx
movl %r12d, %ecx
movb $0x5, %al
callq 0x3350
incq %r12
jmp 0x9dd4
incq %r15
movq (%rsp), %r14
jmp 0x9d93
movsd 0x10(%r14), %xmm0
leaq 0x16216(%rip), %rdi     # 0x20056
movb $0x1, %al
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3210