// File: /workspace/github_c_makefile_star2_O1/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, 0x18(%rsp)
movq %rsi, %r15
movq %rdi, %r12
movl 0x213e6(%rip), %edi     # 0x273f4
callq 0x4e9b
movq %rax, %rbx
movq %r12, %rdi
movq %rax, %rsi
callq 0x4f80
movq %rbx, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x57c5
leaq 0x12ef0(%rip), %rsi     # 0x18f26
movl $0x2, %edi
xorl %eax, %eax
callq 0x12c8e
cmpl $0x0, 0x215cf(%rip)     # 0x27618
je 0x606a
movq %rbx, %rdi
callq 0x5615
movq %rax, 0x28(%rbx)
leaq 0x12eee(%rip), %rsi     # 0x18f4c
movl $0x2, %edi
xorl %eax, %eax
callq 0x12c8e
leaq 0x12ef7(%rip), %rsi     # 0x18f68
movq %rbx, %rdi
movq %r12, %rdx
movq %r15, %rcx
callq 0x59df
movq %rbx, %rdi
callq 0x5d72
movq %rbx, %rdi
callq 0x540f
leaq 0x12ed4(%rip), %rsi     # 0x18f6a
movl $0x2, %edi
xorl %eax, %eax
callq 0x12c8e
movq %rbx, %rdi
callq 0x5615
movq %rax, 0x20(%rbx)
leaq 0x12ee9(%rip), %rsi     # 0x18f9e
movl $0x2, %edi
xorl %eax, %eax
callq 0x12c8e
movl 0x21331(%rip), %ebp     # 0x273f8
leaq 0x8(%rsp), %r12
leaq 0x12f92(%rip), %r13     # 0x19065
cmpl 0x2174f(%rip), %ebp     # 0x27828
jg 0x618d
movq %rbx, %rdi
movl %ebp, %esi
callq 0x5dc2
movq %rax, 0x8(%rsp)
movq %rax, %rdi
callq 0xada5
cmpl %eax, %ebp
jne 0x62bc
movq 0x8(%rsp), %rdi
movq (%rbx), %rsi
callq 0x5fa6
movl 0x214ff(%rip), %ecx     # 0x27610
cmpl %ecx, %eax
jle 0x6138
movl %eax, %r14d
movl 0x2170a(%rip), %edx     # 0x27828
cmpl %edx, %ebp
jne 0x613d
xorl %r15d, %r15d
leaq 0x12ec4(%rip), %rdi     # 0x18ff0
movl %r14d, %esi
xorl %eax, %eax
callq 0xb8d7
jmp 0x6184
xorl %r15d, %r15d
jmp 0x6184
movq %r12, %rdi
callq 0xab7d
xorps %xmm0, %xmm0
cvtsi2sd %ebp, %xmm0
mulsd 0x11ec4(%rip), %xmm0    # 0x18018
cvttsd2si %xmm0, %ebp
movl 0x216c9(%rip), %r9d     # 0x27828
cmpl %ebp, %r9d
cmovll %r9d, %ebp
movl 0x2128b(%rip), %r8d     # 0x273f8
movl $0x1, %edi
movq %r13, %rsi
movl %r14d, %edx
movl %ebp, %ecx
xorl %eax, %eax
callq 0x12c8e
movb $0x1, %r15b
testb %r15b, %r15b
jne 0x60d3
movq 0x8(%rsp), %r14
leaq 0x1388a(%rip), %rsi     # 0x19a23
movq 0x18(%rsp), %rdi
callq 0x9532
movq %rax, 0x10(%rsp)
movq (%r14), %r14
cmpq $0x0, (%r14)
je 0x6286
movq 0x28(%rbx), %rbx
movq 0x10(%r14), %r12
cmpl $0x0, 0x21454(%rip)     # 0x27618
je 0x6261
xorl %r15d, %r15d
movl $0x1, %ebp
movq %r14, %r13
movq %rbx, %rdi
movq %r13, %rsi
movl %ebp, %edx
callq 0x3c00
testl %eax, %eax
je 0x61f9
incl %ebp
movq 0x8(%r13), %r13
cmpq $0x0, 0x8(%r13)
setne %cl
movl %eax, %r15d
jmp 0x61fb
xorl %ecx, %ecx
testb %cl, %cl
jne 0x61d5
movq 0x8(%rbx), %rax
testq %rax, %rax
je 0x621a
movq 0x10(%r14), %rcx
cmpq %rcx, 0x18(%rax)
je 0x621a
movq (%rax), %rax
testq %rax, %rax
jne 0x620c
testq %rax, %rax
je 0x6225
movl 0x20(%rax), %r9d
jmp 0x6228
xorl %r9d, %r9d
addl $-0x2, %ebp
leaq 0x20(%rsp), %r13
movq %r13, %rdi
movl $0x18, %esi
leaq 0x12f76(%rip), %rdx     # 0x191b5
movl %ebp, %ecx
movl %r15d, %r8d
xorl %eax, %eax
callq 0xa2ce
movq 0x10(%rsp), %rdi
leaq 0x12f69(%rip), %rsi     # 0x191c0
movq %r13, %rdx
xorl %eax, %eax
callq 0x3470
movq 0x10(%rsp), %rdi
movq 0x8(%r12), %rdx
leaq 0x139cc(%rip), %rsi     # 0x19c3e
xorl %eax, %eax
callq 0x3470
movq (%r14), %r14
cmpq $0x0, (%r14)
jne 0x61b9
leaq 0x10(%rsp), %rdi
callq 0x9bbc
leaq 0x12e1b(%rip), %rsi     # 0x190b2
movl $0x2, %edi
xorl %eax, %eax
callq 0x12c8e
leaq 0x8(%rsp), %rdi
callq 0xab7d
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x12cef(%rip), %rdi     # 0x18fb2
leaq 0x123dd(%rip), %rsi     # 0x186a7
leaq 0x12cf8(%rip), %rcx     # 0x18fc9
movl $0x6fc, %edx            # imm = 0x6FC
callq 0x32e0