// File: /workspace/github_c_makefile_star2_O1/JimKent[P]linearSat/linearSat/linearSat.c
// Function: predictFromPreviousTypes
struct wordTree *predictFromPreviousTypes(struct alphaStore *store, struct dlList *past)
/* Predict next based on general pattern of monomer order. */
{
/* This routine is now a bit more complex than necessary but it still works.  It
 * these days only needs to look back 1 because of the read-based type fill-in. */
int maxToLookBack = 3;
    { /* Debugging block */
    struct dlNode *node = nodesFromTail(past, maxToLookBack);
    verbose(4, "predictFromPreviousTypes(");
    for (; !dlEnd(node); node = node->next)
        {
	struct monomer *monomer = node->val;
	verbose(4, "%s, ", monomer->word);
	}
    verbose(4, ")\n");
    }
int pastDepth;
struct dlNode *node;
for (pastDepth = 1, node = past->tail; pastDepth <= maxToLookBack; ++pastDepth)
    {
    if (dlStart(node))
	{
	verbose(3, "predictFromPreviousTypes with empty past\n");
	return NULL;
	}
    struct monomer *monomer = node->val;
    struct monomerType *prevType = hashFindVal(store->typeHash, monomer->word);
    if (prevType != NULL)
        {
	struct monomerType *curType = typeAfter(store, prevType, pastDepth);
	struct monomer *curInfo = pickRandomFromType(curType);
	struct wordTree *curTree = wordTreeFindInList(store->markovChains->children, curInfo);
	verbose(4, "predictFromPreviousType pastDepth %d, curInfo %s, curTree %p %s\n", 
	    pastDepth, curInfo->word, curTree, curTree->monomer->word);
	return curTree;
	}
    node = node->prev;
    }
verbose(3, "predictFromPreviousTypes past all unknown types\n");
return NULL;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
movq 0x10(%rsi), %r12
movl $0x3, %eax
movq 0x8(%r12), %r12
testq %r12, %r12
je 0x445c
decl %eax
jne 0x444c
jmp 0x445f
movq (%r14), %r12
leaq 0x143f2(%rip), %rsi     # 0x18858
movl $0x4, %edi
xorl %eax, %eax
callq 0x12c8e
cmpq $0x0, (%r12)
je 0x44a3
leaq 0x143f2(%rip), %r15     # 0x18872
movq 0x10(%r12), %rax
movq 0x8(%rax), %rdx
movl $0x4, %edi
movq %r15, %rsi
xorl %eax, %eax
callq 0x12c8e
movq (%r12), %r12
cmpq $0x0, (%r12)
jne 0x4480
leaq 0x14c05(%rip), %rsi     # 0x190af
movl $0x4, %edi
xorl %eax, %eax
callq 0x12c8e
movq 0x10(%r14), %r14
movl $0x1, %ebp
leaq 0x143db(%rip), %r15     # 0x188a1
cmpq $0x0, 0x8(%r14)
je 0x455e
movq 0x10(%r14), %rax
movq 0x40(%rbx), %rdi
movq 0x8(%rax), %rsi
callq 0xc2ba
movq %rax, %r13
testq %rax, %rax
je 0x4541
movl %ebp, %eax
movq %r13, %rdi
movq (%rdi), %rdi
testq %rdi, %rdi
jne 0x44fb
movq 0x38(%rbx), %rdi
decl %eax
jne 0x44ef
callq 0x4185
movq 0x20(%rbx), %rcx
movq 0x8(%rcx), %r12
testq %r12, %r12
je 0x451e
cmpq %rax, 0x18(%r12)
je 0x451e
movq (%r12), %r12
jmp 0x450c
movq 0x8(%rax), %rcx
movq 0x18(%r12), %rax
movq 0x8(%rax), %r9
movl $0x4, %edi
movq %r15, %rsi
movl %ebp, %edx
movq %r12, %r8
xorl %eax, %eax
callq 0x12c8e
jmp 0x4545
movq 0x8(%r14), %r14
testq %r13, %r13
jne 0x4574
incl %ebp
cmpl $0x4, %ebp
jne 0x44c6
leaq 0x14386(%rip), %rsi     # 0x188e2
jmp 0x4565
leaq 0x14312(%rip), %rsi     # 0x18877
xorl %r12d, %r12d
movl $0x3, %edi
xorl %eax, %eax
callq 0x12c8e
movq %r12, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq