// File: /workspace/github_c_makefile_star2_O1/JimKent[P]linearSat/linearSat/linearSat.c
// Function: alphaStoreLoadMonomerOrder
void alphaStoreLoadMonomerOrder(struct alphaStore *store, char *readsFile, char *fileName)
/* Read in a file with one line for each monomer type, where first word is type name,
 * and rest of words are all the actually variants of that type.
 * Requires all variants already be in store.  The readsFile is passed
 * just for nicer error reporting. */
{
/* Stuff for processing file a line at a time. */
struct lineFile *lf = lineFileOpen(fileName, TRUE);
char *line, *word;
struct hash *uniq = hashNew(0);

/* Set up variables we'll put results in in store. */
store->typeList = NULL;

while (lineFileNextReal(lf, &line))
    {
    char *name = nextWord(&line);
    if (hashLookup(uniq, name) != NULL)
        errAbort("Type name '%s' repeated line %d of %s\n", name, lf->lineIx, lf->fileName);
    struct monomerType *type;
    AllocVar(type);
    type->name = cloneString(name);
    slAddHead(&store->typeList, type);
    while ((word = nextWord(&line)) != NULL)
        {
	struct monomer *monomer = hashFindVal(store->monomerHash, word);
	if (monomer == NULL)
	    errAbort("%s is in %s but not %s", word, lf->fileName, readsFile);
	struct monomerRef *ref;
	AllocVar(ref);
	ref->val = monomer;
	slAddHead(&type->list, ref);
	hashAddUnique(store->typeHash, word, type);
	}
    if (type->list == NULL)
        errAbort("Short line %d of %s.  Format should be:\ntype list-of-monomers-of-type\n",
	    lf->lineIx, lf->fileName);
    }
slReverse(&store->typeList);
if (store->typeList == NULL)
    errAbort("%s is empty", lf->fileName);
lineFileClose(&lf);
hashFree(&uniq);
verbose(3, "Added %d types containing %d words from %s\n", 
    slCount(store->typeList), store->typeHash->elCount, fileName);

/* Create type array */
store->typeCount = slCount(store->typeList);
struct monomerType **types = AllocArray(store->typeArray, store->typeCount);
struct monomerType *type;
int i;
for (i=0, type = store->typeList; i<store->typeCount; ++i, type = type->next)
    types[i] = type;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, %r12
movq %rdi, %r14
movq %rdx, 0x10(%rsp)
movq %rdx, %rdi
movl $0x1, %esi
callq 0xd12a
movq %rax, (%rsp)
xorl %edi, %edi
movl $0x1, %esi
callq 0xc3f1
movq %rax, 0x8(%rsp)
leaq 0x38(%r14), %rbx
movq $0x0, 0x38(%r14)
movq (%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0xdbed
testl %eax, %eax
je 0x5939
leaq 0x20(%rsp), %r13
movq %rbx, 0x18(%rsp)
movq %r13, %rdi
callq 0x7371
movq %rax, %r15
movq 0x8(%rsp), %rdi
movq %rax, %rsi
callq 0xbd98
testq %rax, %rax
je 0x5865
movq (%rsp), %rax
movl 0x28(%rax), %edx
movq 0x8(%rax), %rcx
leaq 0x13514(%rip), %rdi     # 0x18d6f
movq %r15, %rsi
xorl %eax, %eax
callq 0xb8d7
movl $0x18, %edi
callq 0xf07d
movq %rax, %rbp
movq %r15, %rdi
callq 0x647e
movq %rax, 0x8(%rbp)
movq (%rbx), %rax
movq %rax, (%rbp)
movq %rbp, (%rbx)
movq %r13, %rdi
callq 0x7371
testq %rax, %rax
je 0x5900
movq %rax, %r15
movq 0x8(%r14), %rdi
movq %r15, %rsi
callq 0xc2ba
movq %rax, %rbx
testq %rax, %rax
jne 0x58c8
movq (%rsp), %rax
movq 0x8(%rax), %rdx
leaq 0x134db(%rip), %rdi     # 0x18d96
movq %r15, %rsi
movq %r12, %rcx
xorl %eax, %eax
callq 0xb8d7
movl $0x10, %edi
callq 0xf07d
movq %rbx, 0x8(%rax)
movq 0x10(%rbp), %rcx
movq %rcx, (%rax)
movq %rax, 0x10(%rbp)
movq 0x40(%r14), %rdi
movq %r15, %rsi
movq %rbp, %rdx
callq 0xc161
movq %r13, %rdi
callq 0x7371
movq %rax, %r15
testq %rax, %rax
jne 0x5898
cmpq $0x0, 0x10(%rbp)
jne 0x5920
movq (%rsp), %rax
movl 0x28(%rax), %esi
movq 0x8(%rax), %rdx
leaq 0x13494(%rip), %rdi     # 0x18dad
xorl %eax, %eax
callq 0xb8d7
movq (%rsp), %rdi
movq %r13, %rsi
callq 0xdbed
testl %eax, %eax
movq 0x18(%rsp), %rbx
jne 0x582c
movq %rbx, %rdi
callq 0x673b
cmpq $0x0, (%rbx)
jne 0x595d
movq (%rsp), %rax
movq 0x8(%rax), %rsi
leaq 0x1349e(%rip), %rdi     # 0x18df4
xorl %eax, %eax
callq 0xb8d7
movq %rsp, %rdi
callq 0xd800
leaq 0x8(%rsp), %rdi
callq 0xc757
movq 0x38(%r14), %rdi
callq 0x6674
movq 0x40(%r14), %rcx
movl 0x28(%rcx), %ecx
leaq 0x1347a(%rip), %rsi     # 0x18e00
movl $0x3, %edi
movl %eax, %edx
movq 0x10(%rsp), %r8
xorl %eax, %eax
callq 0x12c8e
movq 0x38(%r14), %rdi
callq 0x6674
movl %eax, 0x48(%r14)
movslq %eax, %rdi
shlq $0x3, %rdi
callq 0xeeec
movq %rax, 0x50(%r14)
movslq 0x48(%r14), %rcx
testq %rcx, %rcx
jle 0x59d0
xorl %edx, %edx
movq (%rbx), %rbx
movq %rbx, (%rax,%rdx,8)
incq %rdx
cmpq %rdx, %rcx
jne 0x59c1
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq