// File: /workspace/github_c_makefile_star2_O3/JimKent[P]linearSat/linearSat/linearSat.c
// Function: linearSat
void linearSat(char *readsFile, char *monomerOrderFile, char *outFile)
/* linearSat - assemble alpha repeat regions such as centromeres from reads that have
 * been parsed into various repeat monomer variants.  Cycles of these variants tend to
 * form higher order repeats. */
{
/* This routine reads in the input,  and then calls a routine that produces the
 * output for a given size.  If not all monomers are included in the output, then it
 * will try to find the minimum output size needed to include all monomers. */

/* Read in inputs, and put in "store" */
struct alphaStore *store = alphaStoreNew(maxChainSize);
alphaReadListFromFile(readsFile, store);
alphaStoreLoadMonomerOrder(store, readsFile, monomerOrderFile);
verbose(2, "Loaded input reads and monomer order\n");

if (betweens)
    {
    store->markovChainsNoOrphans = makeMarkovChains(store);
    verbose(2, "Made initial markov chains\n");
    }

/* Do some cross checking and filling out a bit for missing data. */
crossCheckMonomerOrderAndReads(store, "m", readsFile, monomerOrderFile);
fillInTypes(store);
integrateOrphans(store);
verbose(2, "Filled in missing types and integrated orphan ends\n");

/* Make the main markov chains out of the reads. */
store->markovChains = makeMarkovChains(store);
verbose(2, "Made Markov Chains\n");

/* Loop gradually increasing size of output we make until get to maxOutSize or until
 * we generate output that includes all input monomers. */
struct dlList *ll;
int outSize = initialOutSize;
while (outSize <= maxOutSize)
    {
    ll = linearSatOneSize(store, outSize);
    assert(outSize == dlCount(ll));
    int missing = countMissingMonomers(ll, store->monomerList);
    if (missing <= maxToMiss)
        break;
    if (outSize == maxOutSize)
	{
	errAbort("Could not include all monomers. Missing %d.\n"
	         "consider increasing maxOutSize (now %d) or increasing maxToMiss (now %d)",
	         missing, maxOutSize, maxToMiss);
        break;
	}
    dlListFree(&ll);
    outSize *= 1.1;	/* Grow by 10% */
    if (outSize > maxOutSize)
        outSize = maxOutSize;
    verbose(1, "%d missing. Trying again with outSize=%d (initialOutSize %d, maxOutSize %d)\n",
	missing, outSize, initialOutSize, maxOutSize);
    }
writeMonomerListAndBetweens(store, outFile, ll);
verbose(2, "Wrote primary output\n");
dlListFree(&ll);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %r12
movl 0x21436(%rip), %edi     # 0x273f4
callq 0x4df2
movq %rax, %rbx
movq %r12, %rdi
movq %rax, %rsi
callq 0x4ed7
movq %rbx, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x575f
leaq 0x12f50(%rip), %rsi     # 0x18f36
movl $0x2, %edi
xorl %eax, %eax
callq 0x12a31
cmpl $0x0, 0x2161f(%rip)     # 0x27618
je 0x601a
movq %rbx, %rdi
callq 0x559d
movq %rax, 0x28(%rbx)
leaq 0x12f4e(%rip), %rsi     # 0x18f5c
movl $0x2, %edi
xorl %eax, %eax
callq 0x12a31
leaq 0x12f57(%rip), %rsi     # 0x18f78
movq %rbx, %rdi
movq %r12, %rdx
movq %r15, %rcx
callq 0x5980
movq %rbx, %rdi
callq 0x5d0f
movq %rbx, %rdi
callq 0x5397
leaq 0x12f34(%rip), %rsi     # 0x18f7a
movl $0x2, %edi
xorl %eax, %eax
callq 0x12a31
movq %rbx, %rdi
callq 0x559d
movq %rax, 0x20(%rbx)
leaq 0x12f49(%rip), %rsi     # 0x18fae
movl $0x2, %edi
xorl %eax, %eax
callq 0x12a31
movl 0x21381(%rip), %ebp     # 0x273f8
cmpl 0x217ab(%rip), %ebp     # 0x27828
jg 0x6135
leaq 0x10(%rsp), %r15
leaq 0x12fe6(%rip), %r12     # 0x19075
movq %rbx, %rdi
movl %ebp, %esi
callq 0x5d62
movq %rax, 0x10(%rsp)
movq %rax, %rdi
callq 0xab81
cmpl %eax, %ebp
jne 0x6240
movq 0x10(%rsp), %rdi
movq (%rbx), %rsi
callq 0x5f53
movl 0x2154f(%rip), %ecx     # 0x27610
cmpl %ecx, %eax
jle 0x6135
movl %eax, %r13d
cmpl 0x2175a(%rip), %ebp     # 0x27828
je 0x6122
movq %r15, %rdi
callq 0xa959
xorps %xmm0, %xmm0
cvtsi2sd %ebp, %xmm0
mulsd 0x11f31(%rip), %xmm0    # 0x18018
cvttsd2si %xmm0, %ebp
movl 0x21736(%rip), %r9d     # 0x27828
cmpl %ebp, %r9d
cmovll %r9d, %ebp
movl 0x212f8(%rip), %r8d     # 0x273f8
movl $0x1, %edi
movq %r12, %rsi
movl %r13d, %edx
movl %ebp, %ecx
xorl %eax, %eax
callq 0x12a31
cmpl 0x2170e(%rip), %ebp     # 0x27828
jle 0x608f
jmp 0x6135
leaq 0x12ed7(%rip), %rdi     # 0x19000
movl %r13d, %esi
movl %ebp, %edx
xorl %eax, %eax
callq 0xb6c8
movq 0x10(%rsp), %r15
leaq 0x138f2(%rip), %rsi     # 0x19a33
movq %r14, %rdi
callq 0x932b
movq %rax, 0x18(%rsp)
movq (%r15), %r15
cmpq $0x0, (%r15)
je 0x620a
movq %rax, %r14
movq 0x28(%rbx), %rbx
leaq 0x20(%rsp), %rbp
movq 0x10(%r15), %r12
cmpl $0x0, 0x214a6(%rip)     # 0x27618
je 0x61e7
xorl %r13d, %r13d
movl %r13d, 0xc(%rsp)
movl %r13d, 0x8(%rsp)
movq %rbx, %rdi
movq %r15, %rsi
leaq 0xc(%rsp), %rdx
leaq 0x8(%rsp), %rcx
callq 0x3bef
movq 0x8(%rbx), %rax
testq %rax, %rax
je 0x61ae
cmpq %r12, 0x18(%rax)
je 0x61aa
movq (%rax), %rax
jmp 0x619a
movl 0x20(%rax), %r13d
movl 0xc(%rsp), %ecx
addl $-0x2, %ecx
movl 0x8(%rsp), %r8d
movq %rbp, %rdi
movl $0x18, %esi
leaq 0x12ffc(%rip), %rdx     # 0x191c5
movl %r13d, %r9d
xorl %eax, %eax
callq 0xa0ca
movq %r14, %rdi
leaq 0x12ff3(%rip), %rsi     # 0x191d0
movq %rbp, %rdx
xorl %eax, %eax
callq 0x3470
movq 0x8(%r12), %rdx
movq %r14, %rdi
leaq 0x13a58(%rip), %rsi     # 0x19c4e
xorl %eax, %eax
callq 0x3470
movq (%r15), %r15
cmpq $0x0, (%r15)
jne 0x6167
leaq 0x18(%rsp), %rdi
callq 0x99bb
leaq 0x12ea7(%rip), %rsi     # 0x190c2
movl $0x2, %edi
xorl %eax, %eax
callq 0x12a31
leaq 0x10(%rsp), %rdi
callq 0xa959
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x12d7b(%rip), %rdi     # 0x18fc2
leaq 0x12469(%rip), %rsi     # 0x186b7
leaq 0x12d84(%rip), %rcx     # 0x18fd9
movl $0x6fc, %edx            # imm = 0x6FC
callq 0x32e0