// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl 0x2b5ea(%rip), %edi     # 0x323d4
callq 0x5670
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x5800
movq -0x20(%rbp), %rdi
movq -0x8(%rbp), %rsi
movq -0x10(%rbp), %rdx
callq 0x6330
movl $0x2, %edi
leaq 0x1d109(%rip), %rsi     # 0x23f26
movb $0x0, %al
callq 0x1adf0
cmpl $0x0, 0x2b80d(%rip)     # 0x32638
je 0x6e54
movq -0x20(%rbp), %rdi
callq 0x60f0
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x28(%rax)
movl $0x2, %edi
leaq 0x1d0ff(%rip), %rsi     # 0x23f4c
movb $0x0, %al
callq 0x1adf0
movq -0x20(%rbp), %rdi
movq -0x8(%rbp), %rdx
movq -0x10(%rbp), %rcx
leaq 0x1d101(%rip), %rsi     # 0x23f68
callq 0x65b0
movq -0x20(%rbp), %rdi
callq 0x6ac0
movq -0x20(%rbp), %rdi
callq 0x5dc0
movl $0x2, %edi
leaq 0x1d0e0(%rip), %rsi     # 0x23f6a
movb $0x0, %al
callq 0x1adf0
movq -0x20(%rbp), %rdi
callq 0x60f0
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x20(%rax)
movl $0x2, %edi
leaq 0x1d0ed(%rip), %rsi     # 0x23f9e
movb $0x0, %al
callq 0x1adf0
movl 0x2b51a(%rip), %eax     # 0x323d8
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl 0x2b97e(%rip), %eax     # 0x32848
jg 0x6fc7
movq -0x20(%rbp), %rdi
movl -0x2c(%rbp), %esi
callq 0x6b60
movq %rax, -0x28(%rbp)
movl -0x2c(%rbp), %eax
movl %eax, -0x34(%rbp)
movq -0x28(%rbp), %rdi
callq 0xecd0
movl %eax, %ecx
movl -0x34(%rbp), %eax
cmpl %ecx, %eax
jne 0x6efa
jmp 0x6f19
leaq 0x1d0b1(%rip), %rdi     # 0x23fb2
leaq 0x1c79f(%rip), %rsi     # 0x236a7
movl $0x6fc, %edx            # imm = 0x6FC
leaq 0x1d0b5(%rip), %rcx     # 0x23fc9
callq 0x32d0
movq -0x28(%rbp), %rdi
movq -0x20(%rbp), %rax
movq (%rax), %rsi
callq 0x6cf0
movl %eax, -0x30(%rbp)
movl -0x30(%rbp), %eax
cmpl 0x2b6fb(%rip), %eax     # 0x32630
jg 0x6f3c
jmp 0x6fc7
movl -0x2c(%rbp), %eax
cmpl 0x2b903(%rip), %eax     # 0x32848
jne 0x6f66
movl -0x30(%rbp), %esi
movl 0x2b8f8(%rip), %edx     # 0x32848
movl 0x2b6da(%rip), %ecx     # 0x32630
leaq 0x1d093(%rip), %rdi     # 0x23ff0
movb $0x0, %al
callq 0xfd50
jmp 0x6fc7
leaq -0x28(%rbp), %rdi
callq 0xe860
cvtsi2sdl -0x2c(%rbp), %xmm0
movsd 0x1c09c(%rip), %xmm1    # 0x23018
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl 0x2b8b8(%rip), %eax     # 0x32848
jle 0x6f9b
movl 0x2b8b0(%rip), %eax     # 0x32848
movl %eax, -0x2c(%rbp)
movl -0x30(%rbp), %edx
movl -0x2c(%rbp), %ecx
movl 0x2b430(%rip), %r8d     # 0x323d8
movl 0x2b899(%rip), %r9d     # 0x32848
movl $0x1, %edi
leaq 0x1d0aa(%rip), %rsi     # 0x24065
movb $0x0, %al
callq 0x1adf0
jmp 0x6ec1
movq -0x20(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x28(%rbp), %rdx
callq 0x7000
movl $0x2, %edi
leaq 0x1d0ce(%rip), %rsi     # 0x240b2
movb $0x0, %al
callq 0x1adf0
leaq -0x28(%rbp), %rdi
callq 0xe860
addq $0x40, %rsp
popq %rbp
retq
nopw (%rax,%rax)