// File: /workspace/github_c_makefile_star2_O2/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, 0x10(%rsp)
movq %rsi, %r15
movq %rdi, %r12
movl 0x2092b(%rip), %edi     # 0x263f4
callq 0x4a1f
movq %rax, %r14
movq %r12, %rdi
movq %rax, %rsi
callq 0x4afb
movq %r14, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x52d6
leaq 0x11445(%rip), %rsi     # 0x16f36
pushq $0x2
popq %rdi
xorl %eax, %eax
callq 0x110f9
cmpl $0x0, 0x20b36(%rip)     # 0x26638
je 0x5b21
movq %r14, %rdi
callq 0x5143
movq %rax, 0x28(%r14)
leaq 0x11445(%rip), %rsi     # 0x16f5c
pushq $0x2
popq %rdi
xorl %eax, %eax
callq 0x110f9
leaq 0x11450(%rip), %rsi     # 0x16f78
movq %r14, %rdi
movq %r12, %rdx
movq %r15, %rcx
callq 0x54d9
movq %r14, %rdi
callq 0x5824
movq %r14, %rdi
callq 0x4f38
leaq 0x1142d(%rip), %rsi     # 0x16f7a
pushq $0x2
popq %rbx
movl %ebx, %edi
xorl %eax, %eax
callq 0x110f9
movq %r14, %rdi
callq 0x5143
movq %rax, 0x20(%r14)
leaq 0x11442(%rip), %rsi     # 0x16fae
movl %ebx, %edi
xorl %eax, %eax
callq 0x110f9
movl 0x2087d(%rip), %ebp     # 0x263f8
leaq 0x8(%rsp), %r15
leaq 0x114ee(%rip), %r12     # 0x17075
pushq $0x1
popq %r13
cmpl 0x20cb7(%rip), %ebp     # 0x26848
jg 0x5c2c
movq %r14, %rdi
movl %ebp, %esi
callq 0x5874
movq %rax, 0x8(%rsp)
movq %rax, %rdi
callq 0x9c7b
cmpl %eax, %ebp
jne 0x5d2a
movq 0x8(%rsp), %rdi
movq (%r14), %rsi
callq 0x5a65
movl 0x20a67(%rip), %ecx     # 0x26630
cmpl %ecx, %eax
jle 0x5c2c
movl %eax, %ebx
cmpl 0x20c73(%rip), %ebp     # 0x26848
je 0x5c1a
movq %r15, %rdi
callq 0x9a57
cvtsi2sd %ebp, %xmm0
mulsd 0x1042d(%rip), %xmm0    # 0x16018
cvttsd2si %xmm0, %ebp
movl 0x20c52(%rip), %r9d     # 0x26848
cmpl %ebp, %r9d
cmovll %r9d, %ebp
movl 0x207f4(%rip), %r8d     # 0x263f8
movl %r13d, %edi
movq %r12, %rsi
movl %ebx, %edx
movl %ebp, %ecx
xorl %eax, %eax
callq 0x110f9
jmp 0x5b8b
leaq 0x113df(%rip), %rdi     # 0x17000
movl %ebx, %esi
movl %ebp, %edx
xorl %eax, %eax
callq 0xa61f
movq 0x8(%rsp), %r15
leaq 0x11dfb(%rip), %rsi     # 0x17a33
movq 0x10(%rsp), %rdi
callq 0x8645
movq %rax, %rbx
movq %rax, 0x18(%rsp)
movq 0x28(%r14), %rax
movq %rax, 0x10(%rsp)
movq (%r15), %r15
cmpq $0x0, (%r15)
je 0x5cf6
movq 0x10(%r15), %r13
cmpl $0x0, 0x209cd(%rip)     # 0x26638
je 0x5cdc
andl $0x0, 0x4(%rsp)
andl $0x0, (%rsp)
movq 0x10(%rsp), %r14
movq %r14, %rdi
movq %r15, %rsi
leaq 0x4(%rsp), %rdx
movq %rsp, %rcx
callq 0x3a0a
movl 0x4(%rsp), %ebp
addl $-0x2, %ebp
movl (%rsp), %r12d
movq %r14, %rdi
movq %r15, %rsi
pushq $0x1
popq %rdx
callq 0x39d0
leaq 0x20(%rsp), %r14
movq %r14, %rdi
pushq $0x18
popq %rsi
leaq 0x1150c(%rip), %rdx     # 0x171c5
movl %ebp, %ecx
movl %r12d, %r8d
movl %eax, %r9d
xorl %eax, %eax
callq 0x939d
movq %rbx, %rdi
leaq 0x114fe(%rip), %rsi     # 0x171d0
movq %r14, %rdx
xorl %eax, %eax
callq 0x3470
movq 0x8(%r13), %rdx
movq %rbx, %rdi
leaq 0x11f64(%rip), %rsi     # 0x17c4e
xorl %eax, %eax
callq 0x3470
jmp 0x5c53
leaq 0x18(%rsp), %rdi
callq 0x8c9c
leaq 0x113bb(%rip), %rsi     # 0x170c2
pushq $0x2
popq %rdi
xorl %eax, %eax
callq 0x110f9
leaq 0x8(%rsp), %rdi
callq 0x9a57
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x11291(%rip), %rdi     # 0x16fc2
leaq 0x1097f(%rip), %rsi     # 0x166b7
leaq 0x1129a(%rip), %rcx     # 0x16fd9
movl $0x6fc, %edx            # imm = 0x6FC
callq 0x32e0