// File: /workspace/github_c_makefile_star2_O1/icebert[P]pblat/jkOwnLib/bandExt.c
// Function: bandExt
boolean bandExt(boolean global, struct axtScoreScheme *ss, int maxInsert,
	char *aStart, int aSize, char *bStart, int bSize, int dir,
	int symAlloc, int *retSymCount, char *retSymA, char *retSymB, 
	int *retStartA, int *retStartB)
/* Try to extend an alignment from aStart/bStart onwards.
 * Set maxInsert to the maximum gap size allowed.  3 is often
 * a good choice.  aStart/aSize bStart/bSize describe the
 * sequence to extend through (not including any of the existing
 * alignment. Set dir = 1 for forward extension, dir = -1 for backwards. 
 * retSymA and retSymB should point to arrays of characters of
 * symAlloc size.  symAlloc needs to be aSize*2 or so.  The
 * alignment is returned in the various ret values.  The function
 * overall returns TRUE if an extension occurred, FALSE if not. */
{
int i;			/* A humble index or two. */
int *bOffsets = NULL;	/* Offset of top of band. */
UBYTE **parents = NULL;	/* Array of parent positions. */
struct score *curScores = NULL;	/* Scores for current column. */
struct score *prevScores = NULL;	/* Scores for previous column. */
struct score *swapScores;	/* Helps to swap cur & prev column. */
int bandSize = 2*maxInsert + 1;	 /* Size of band including middle */
int maxIns1 = maxInsert + 1;   	 /* Max insert plus one. */
int bandPlus = bandSize + 2*maxIns1;  /* Band plus sentinels on either end. */
int bestScore = 0;	 	 /* Best score so far. */
int aPos, aBestPos = -1;	 /* Current and best position in a. */
int bPos, bBestPos = -1;	 /* Current and best position in b. */
int bandCenter = 0;	/* b Coordinate of current band center. */
int colShift = 1;	/* Vertical shift between this column and previous. */
int prevScoreOffset;	/* Offset into previous score column. */
int curScoreOffset;	/* Offset into current score column. */
int symCount = 0;	/* Size of alignment and size allocated for it. */
int gapOpen = ss->gapOpen;	 /* First base in gap costs this. */
int gapExtend = ss->gapExtend;	 /* Extra bases in gap cost this. */
int badScore = -gapOpen*100;	 /* A score bad enough no one will want to link with us. */
int maxDrop = gapOpen + gapExtend*maxInsert; /* Max score drop allowed before giving up. */
int midScoreOff;		 /* Offset to middle of scoring array. */
struct lm *lm;			 /* Local memory pool. */
boolean didExt = FALSE;
int initGapScore = -gapOpen;

/* For reverse direction just reverse bytes here and there.  It's
 * a lot easier than the alternative and doesn't cost much time in
 * the global scheme of things. */
if (dir < 0)
    {
    reverseBytes(aStart, aSize);
    reverseBytes(bStart, bSize);
    }
#ifdef DEBUG
uglyf("bandExt: dir %d, aStart %d, aSize %d, symAlloc %d\n", dir,
	aSize, bSize, symAlloc);
mustWrite(uglyOut, aStart, aSize);
uglyf("\n");
mustWrite(uglyOut, bStart, bSize);
uglyf("\n");
#endif /* DEBUG */

/* Make up a local mem structure big enough for everything. 
 * This is just a minor, perhaps misguided speed tweak to
 * avoid multiple mallocs. */
lm = lmInit(
    sizeof(bOffsets[0])*aSize +
    sizeof(parents[0])*bandSize +
    bandSize*(sizeof(parents[0][0])*aSize) +
    sizeof(curScores[0]) * bandPlus +
    sizeof(prevScores[0]) * bandPlus );

/* Allocate data structures out of local memory pool. */
lmAllocArray(lm, bOffsets, aSize);
lmAllocArray(lm, parents, bandSize);
for (i=0; i<bandSize; ++i)
    lmAllocArray(lm, parents[i], aSize);
lmAllocArray(lm, curScores, bandPlus);
lmAllocArray(lm, prevScores, bandPlus);

/* Set up scoring arrays so that stuff outside of the band boundary 
 * looks bad.  There will be maxIns+1 of these sentinel values at
 * the start and at the beginning. */
for (i=0; i<bandPlus; ++i)
    {
    struct score *cs = &curScores[i];
    cs->match = cs->up = cs->left = badScore;
    cs = &prevScores[i];
    cs->match = cs->up = cs->left = badScore;
    }

/* Set up scoring array so that extending without an initial insert
 * looks relatively good. */
midScoreOff = 1 + 2 * maxInsert;
prevScores[midScoreOff].match = 0;

/* Set up scoring array so that initial inserts of up to maxInsert
 * are allowed but penalized appropriately. */
    {
    int score = -gapOpen;
    for (i=0; i<maxInsert; ++i)
	{
	prevScores[midScoreOff+i].up = score;
	score -= gapExtend;
	}
    }

for (aPos=0; aPos < aSize; ++aPos)
    {
    char aBase = aStart[aPos];
    int *matRow = ss->matrix[(int)aBase];
    int bestColScore = badScore;
    int bestColPos = -1;
    int colTop = bandCenter - maxInsert;
    int colBottom = bandCenter + maxIns1;

    if (colTop < 0) colTop = 0;
    if (colBottom > bSize) colBottom = bSize;
    curScoreOffset =  maxIns1 + colTop - (bandCenter - maxInsert);
    prevScoreOffset = curScoreOffset + colShift;
#ifdef DEBUG
    uglyf("curScoreOffset %d, maxIns %d, prevScoreOffset %d\n", curScoreOffset, maxInsert, prevScoreOffset);
#endif /* DEBUG */

    /* At top we deal with possibility of initial insert that
     * comes in at this point, unless the band has wandered off. */
    if (aPos < maxInsert)
	{
	curScores[curScoreOffset-1].up = initGapScore;
	initGapScore -= gapExtend;
	}
    else
	curScores[curScoreOffset-1].up = badScore;

    for (bPos = colTop; bPos < colBottom; ++bPos)
	{
	UBYTE parent;
	struct score *curScore = &curScores[curScoreOffset];

#ifdef DEBUG
	uglyf("aPos %d, bPos %d, %c vs %c\n", aPos, bPos, aBase, bStart[bPos]);
	uglyf("  diag[%d %d %d], left[%d %d %d], up[%d %d %d]\n", 
		prevScores[prevScoreOffset-1].match, 
		prevScores[prevScoreOffset-1].left, 
		prevScores[prevScoreOffset-1].up, 
		prevScores[prevScoreOffset].match, 
		prevScores[prevScoreOffset].left, 
		prevScores[prevScoreOffset].up, 
		curScores[curScoreOffset-1].match, 
		curScores[curScoreOffset-1].left, 
		curScores[curScoreOffset-1].up);
#endif /* DEBUG */

	/* Handle ways into the matching state and record if it's
	 * best score so far. */
	    {
	    int match = matRow[(int)bStart[bPos]];
	    struct score *a = &prevScores[prevScoreOffset-1];
	    int diagScore = a->match;
	    int leftScore = a->left;
	    int upScore = a->up;
	    int score;
	    if (diagScore >= leftScore && diagScore >= upScore)
	        {
		score = diagScore + match;
		parent = mpMatch;
		}
	    else if (leftScore > upScore)
	        {
		score = leftScore + match;
	        parent = mpLeft;
		}
	    else
	        {
	        score = upScore + match;
	        parent = mpUp;
	        }
	    curScore->match = score;
	    if (score > bestColScore)
	        {
		bestColScore = score;
		bestColPos = bPos;
		}
	    }

	/* Handle ways into left gap state. */
	    {
	    struct score *a = &prevScores[prevScoreOffset];
	    int extScore = a->left - gapExtend;
	    int openScore = a->match - gapOpen;
	    if (extScore >= openScore)
	        {
		parent |= lpExt;
		curScore->left = extScore;
		}
	    else
	        {
		curScore->left = openScore;
		}
	    }

	/* Handle ways into up gap state. */
	    {
	    struct score *a = &curScore[-1];
	    int extScore = a->up - gapExtend;
	    int openScore = a->match - gapOpen;
	    if (extScore >= openScore)
	        {
		parent |= upExt;
		curScore->up = extScore;
		}
	    else
	        {
		curScore->up = openScore;
		}
	    }

	parents[curScoreOffset - maxIns1][aPos] = parent;

#ifdef DEBUG
	uglyf(" cur [%d %d %d]\n", 
		curScore->match, 
		curScore->left, 
		curScore->up);
#endif /* DEBUG */
	/* Advance to next row in column. */
	curScoreOffset += 1;
	prevScoreOffset += 1;
	}


    /* If this column's score is best so far make note of
     * it and shift things so that the matching bases at the
     * best score are centered in the band.  This allows the
     * band to wander where appropriate.  Having the band shift
     * to the best column position if it is not the best score
     * so far doesn't work so well though.  */
    if (bestScore < bestColScore)
	{
	bestScore = bestColScore;
	aBestPos = aPos;
	bBestPos = bestColPos;
	colShift = (bestColPos + 1) - bandCenter;
	}
    else if (bestColScore < bestScore - maxDrop)
	{
	if (!global)
	    break;
	}
    else
	{
	colShift = 1;
	}

    /* Keep track of vertical offset of this column, and
     * set up offset of next column. */
    bOffsets[aPos] = bandCenter;
    bandCenter += colShift;

    /* Swap scoring arrays so current becomes next iteration's previous. */
    swapScores = curScores;
    curScores = prevScores;
    prevScores = swapScores;
    }


/* Trace back. */
#ifdef DEBUG
uglyf("traceback: bestScore %d, aBestPos %d, bBestPos %d\n", bestScore, aBestPos, bBestPos);
#endif /* DEBUG */
if (global || bestScore > 0)
    {
    boolean upState = FALSE;
    boolean leftState = FALSE;
    didExt = TRUE;
    if (global)
        {
	aPos = aSize-1;
	bPos = bSize-1;
	}
    else
	{
	aPos = aBestPos;
	bPos = bBestPos;
	}
    for (;;)
	{
	int pOffset;
	UBYTE parent;
	pOffset = bPos - bOffsets[aPos] + maxInsert;
	if (pOffset < 0) pOffset = 0;
	// FIXME: there may be some cases near beginning where
	// pOffset is not right.  Clamping it at 0 prevents a crash
	// and produces correct behavior in many cases.  However
	// I'm thinking a better fix would be to have bOffsets follow
	// colTop rather than bandCenter somehow. Exactly how is
	// beyond me at the moment.
	if (pOffset >= bandSize)
	    {
#ifdef DEBUG
	    uglyf("bPos %d, aPos %d, bOffsets[aPos] %d, maxInsert %d\n", bPos, aPos, bOffsets[aPos], maxInsert);
	    uglyf("pOffset = %d, bandSize = %d\n", pOffset, bandSize);
	    uglyf("aSize %d, bSize %d\n", aSize, bSize);
	    faWriteNext(uglyOut, "uglyA", aStart, aSize);
	    faWriteNext(uglyOut, "uglyB", bStart, bSize);
#endif /* DEBUG */
	    assert(global);
	    return FALSE;
	    }
	parent = parents[pOffset][aPos];
#ifdef DEBUG
	uglyf("aPos %d, bPos %d, parent %d, pMask %d upState %d, leftState %d\n", aPos, bPos, parent, parent & mpMask, upState, leftState);
#endif /* DEBUG */
	if (upState)
	    {
	    retSymA[symCount] = '-';
	    retSymB[symCount] = bStart[bPos];
	    bPos -= 1;
	    upState = (parent&upExt);
	    }
	else if (leftState)
	    {
	    retSymA[symCount] = aStart[aPos];
	    retSymB[symCount] = '-';
	    aPos -= 1;
	    leftState = (parent&lpExt);
	    }
	else
	    {
	    retSymA[symCount] = aStart[aPos];
	    retSymB[symCount] = bStart[bPos];
	    aPos -= 1;
	    bPos -= 1;
	    parent &= mpMask;
	    if (parent == mpUp)
	        upState = TRUE;
	    else if (parent == mpLeft)
	        leftState = TRUE;
	    }
	if (++symCount >= symAlloc)
	    errAbort("unsufficient symAlloc in bandExt");
	if (aPos < 0 || bPos < 0)
	    {
	    while (aPos >= 0)
		{
		retSymA[symCount] = aStart[aPos];
		retSymB[symCount] = '-';
		if (++symCount >= symAlloc)
		    errAbort("unsufficient symAlloc in bandExt");
		--aPos;
		}
	    while (bPos >= 0)
		{
		retSymA[symCount] = '-';
		retSymB[symCount] = bStart[bPos];
		if (++symCount >= symAlloc)
		    errAbort("unsufficient symAlloc in bandExt");
		--bPos;
		}
	    break;
	    }
	}
    if (dir > 0)
	{
	reverseBytes(retSymA, symCount);
	reverseBytes(retSymB, symCount);
	}
    retSymA[symCount] = 0;
    retSymB[symCount] = 0;
    }
else
    {
    retSymA[0] = retSymB[0] = 0;
    }

if (dir < 0)
    {
    reverseBytes(aStart, aSize);
    reverseBytes(bStart, bSize);
    }

/* Clean up, set return values and go home */
lmCleanup(&lm);
if (retStartA != NULL) *retStartA = aBestPos;
if (retStartB != NULL) *retStartB = bBestPos;
*retSymCount = symCount;
return didExt;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movq %r9, %r15
movl %r8d, %r14d
movq %rcx, 0x58(%rsp)
movl %edx, %r12d
movl %edi, 0x2c(%rsp)
leal 0x1(%r12,%r12), %ebx
leal 0x2(%r12,%r12), %eax
leal 0x1(%rax,%r12,2), %edx
movl 0x40008(%rsi), %eax
movl %eax, 0x78(%rsp)
movq %rsi, 0x90(%rsp)
movl 0x4000c(%rsi), %eax
movl %eax, 0x44(%rsp)
movslq %r8d, %r13
cmpl $0x0, 0x118(%rsp)
jns 0x18e9a
movq 0x58(%rsp), %rdi
movq %r13, %rsi
movl %edx, %ebp
callq 0x1fade
movl 0x110(%rsp), %eax
movslq %eax, %rsi
movq %r15, %rdi
callq 0x1fade
movl %ebp, %edx
movq %r15, 0x60(%rsp)
leal (%r12,%r12), %eax
movl %eax, 0x40(%rsp)
leaq (,%r13,4), %rbp
movslq %ebx, %rcx
leaq (,%rcx,8), %r15
movq %rcx, 0x20(%rsp)
movq %r14, 0x10(%rsp)
imull %r14d, %ecx
addl %ebp, %ecx
addl %r15d, %ecx
movl %edx, 0x18(%rsp)
movslq %edx, %rax
leaq (,%rax,4), %rdx
leaq (%rdx,%rdx,2), %rdx
movq %rdx, 0x48(%rsp)
leal (%rax,%rax,2), %eax
leal (%rcx,%rax,8), %edi
callq 0x2bea4
movq %rax, 0x68(%rsp)
movq %rax, %rdi
movq %rbp, %rsi
callq 0x2bfa9
movq %rax, 0x98(%rsp)
movq 0x68(%rsp), %rdi
movq %r15, %rsi
callq 0x2bfa9
movq %rax, %r14
movq %r12, 0x38(%rsp)
testl %r12d, %r12d
js 0x18f50
xorl %ebx, %ebx
movl 0x40(%rsp), %eax
testl %eax, %eax
movl $0x0, %r15d
cmovgl %eax, %r15d
incq %r15
movq 0x68(%rsp), %rdi
movq %r13, %rsi
callq 0x2bfa9
movq %rax, (%r14,%rbx,8)
incq %rbx
cmpq %rbx, %r15
jne 0x18f37
movq %r13, 0xa8(%rsp)
movl 0x78(%rsp), %ebp
imull $-0x64, %ebp, %r15d
movq 0x68(%rsp), %rdi
movq 0x48(%rsp), %rbx
movq %rbx, %rsi
callq 0x2bfa9
movq %rax, %r12
movq 0x68(%rsp), %rdi
movq %rbx, %rsi
callq 0x2bfa9
movq %rax, %r9
cmpl $0x0, 0x18(%rsp)
movq 0x38(%rsp), %rbx
jle 0x18fcb
leal (,%rbx,4), %ecx
leaq (%rcx,%rcx,2), %rcx
leaq 0x24(,%rcx,4), %rcx
xorl %edx, %edx
movl %r15d, 0x8(%r12,%rdx)
movl %r15d, 0x4(%r12,%rdx)
movl %r15d, (%r12,%rdx)
movl %r15d, 0x8(%r9,%rdx)
movl %r15d, 0x4(%r9,%rdx)
movl %r15d, (%r9,%rdx)
addq $0xc, %rdx
cmpq %rdx, %rcx
jne 0x18fa6
movl %ebp, %eax
negl %eax
movq 0x20(%rsp), %rcx
leaq (%rcx,%rcx,2), %rcx
movl $0x0, (%r9,%rcx,4)
testl %ebx, %ebx
movl 0x44(%rsp), %r8d
jle 0x19016
movl %ebx, %edx
movl 0x40(%rsp), %ecx
leaq (%rcx,%rcx,2), %rcx
leaq (%r9,%rcx,4), %rcx
addq $0x10, %rcx
shlq $0x2, %rdx
leaq (%rdx,%rdx,2), %rdx
xorl %esi, %esi
movl %eax, %edi
movl %edi, (%rcx,%rsi)
subl %r8d, %edi
addq $0xc, %rsi
cmpq %rsi, %rdx
jne 0x19007
movl %eax, 0x74(%rsp)
xorl %r10d, %r10d
movq 0x10(%rsp), %rax
testl %eax, %eax
movq %r14, 0x50(%rsp)
jle 0x19354
leal 0x1(%rbx), %ecx
imull %ebx, %r8d
addq $0x8, 0x90(%rsp)
addl %ebp, %r8d
movl %r8d, 0x8c(%rsp)
movq %rcx, 0xc8(%rsp)
movslq %ecx, %rcx
movslq %ebx, %rdx
movq %rdx, 0xc0(%rsp)
movl %eax, %eax
movq %rax, 0xb8(%rsp)
shlq $0x3, %rcx
subq %rcx, %r14
movq %r14, 0xb0(%rsp)
movl $0xffffffff, 0x30(%rsp) # imm = 0xFFFFFFFF
xorl %r11d, %r11d
movl $0xffffffff, 0xc(%rsp)  # imm = 0xFFFFFFFF
xorl %r13d, %r13d
movl $0x1, %eax
movq %rax, 0x80(%rsp)
movl %r15d, 0x34(%rsp)
movl %r13d, %edi
subl %ebx, %edi
testl %edi, %edi
movl $0x0, %ecx
cmovgl %edi, %ecx
movq 0xc8(%rsp), %rsi
leal (%rsi,%r13), %ebx
movl 0x110(%rsp), %eax
cmpl %eax, %ebx
cmovgel %eax, %ebx
movq 0x58(%rsp), %rax
movsbq (%rax,%r11), %rdx
subl %edi, %esi
leal (%rsi,%rcx), %edi
decl %edi
movslq %edi, %rdi
leaq (%rdi,%rdi,2), %rdi
leaq (%r12,%rdi,4), %rdi
addq $0x4, %rdi
cmpq 0xc0(%rsp), %r11
movq %r9, 0x18(%rsp)
movq %r12, 0x48(%rsp)
movq %r10, 0xd0(%rsp)
movq %r13, 0xa0(%rsp)
jge 0x1911c
movl 0x74(%rsp), %eax
movl %eax, (%rdi)
subl 0x44(%rsp), %eax
movl %eax, 0x74(%rsp)
jmp 0x1911f
movl %r15d, (%rdi)
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
movl %r15d, %ebp
cmpl %ebx, %ecx
movl 0x44(%rsp), %r10d
jge 0x1926a
shlq $0xa, %rdx
addq 0x90(%rsp), %rdx
addl %ecx, %esi
movq 0x80(%rsp), %rax
leal (%rsi,%rax), %edi
movl %ecx, %ecx
movslq %edi, %r8
movslq %esi, %rsi
movl %ebx, %eax
movq %rax, 0x20(%rsp)
leaq (%rsi,%rsi,2), %rdi
movq 0x48(%rsp), %rax
leaq (%rax,%rdi,4), %rdi
movq 0xb0(%rsp), %rax
leaq (%rax,%rsi,8), %r9
leaq (%r8,%r8,2), %rsi
movq 0x18(%rsp), %rax
leaq (%rax,%rsi,4), %rsi
addq $-0xc, %rsi
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
movl $0x8, %ebx
movl 0x34(%rsp), %ebp
movq %r11, %r14
movl -0x8(%rsi,%rbx), %r11d
movl -0x4(%rsi,%rbx), %r15d
movl (%rsi,%rbx), %eax
cmpl %eax, %r11d
setl %r13b
cmpl %r15d, %r11d
setl %r12b
orb %r13b, %r12b
movl 0x78(%rsp), %r13d
cmpl %r15d, %eax
cmovgl %eax, %r15d
setg %al
orb $0x2, %al
testb %r12b, %r12b
movq 0x60(%rsp), %r12
movsbq (%r12,%rcx), %r12
cmovel %r11d, %r15d
movzbl %al, %eax
movl $0x1, %r11d
cmovel %r11d, %eax
addl (%rdx,%r12,4), %r15d
cmpl %ebp, %r15d
cmovgl %r15d, %ebp
movl %r15d, -0x8(%rdi,%rbx)
cmovgl %ecx, %r8d
movl 0x4(%rsi,%rbx), %r11d
movl 0xc(%rsi,%rbx), %r15d
subl %r10d, %r15d
subl %r13d, %r11d
cmpl %r11d, %r15d
cmovgl %r15d, %r11d
leal 0x8(%rax), %r15d
movzbl %r15b, %r15d
cmovll %eax, %r15d
movl %r11d, (%rdi,%rbx)
movl -0x14(%rdi,%rbx), %eax
movl -0x10(%rdi,%rbx), %r11d
subl %r10d, %r11d
subl %r13d, %eax
movl %r15d, %r12d
orb $0x4, %r12b
cmpl %eax, %r11d
cmovgl %r11d, %eax
movzbl %r12b, %r11d
cmovll %r15d, %r11d
movl %eax, -0x4(%rdi,%rbx)
movq (%r9), %rax
movb %r11b, (%rax,%r14)
movq %r14, %r11
incq %rcx
addq $0xc, %rbx
addq $0x8, %r9
cmpq %rcx, 0x20(%rsp)
jne 0x19196
movq 0xd0(%rsp), %r10
cmpl %ebp, %r10d
jge 0x192a2
movl %r8d, %ecx
movq 0xa0(%rsp), %r13
subl %r13d, %ecx
incl %ecx
movl %r11d, 0x30(%rsp)
movq 0x38(%rsp), %rbx
movq 0x50(%rsp), %r14
movl 0x34(%rsp), %r15d
movq 0x18(%rsp), %r12
jmp 0x19301
movl %r10d, %eax
subl 0x8c(%rsp), %eax
cmpl %eax, %ebp
movq 0x50(%rsp), %r14
movq 0x18(%rsp), %r12
movq 0xa0(%rsp), %r13
jge 0x192ea
cmpl $0x0, 0x2c(%rsp)
movq 0x38(%rsp), %rbx
movl 0x34(%rsp), %r15d
movq 0x48(%rsp), %rdi
je 0x19341
movl 0xc(%rsp), %r8d
movl %r10d, %ebp
movq 0x80(%rsp), %rcx
jmp 0x19306
movl $0x1, %ecx
movl 0xc(%rsp), %r8d
movl %r10d, %ebp
movq 0x38(%rsp), %rbx
movl 0x34(%rsp), %r15d
movq 0x48(%rsp), %rdi
movq 0x98(%rsp), %rax
movl %r13d, (%rax,%r11,4)
movq %rcx, 0x80(%rsp)
addl %ecx, %r13d
xorl %ecx, %ecx
movl %r8d, 0xc(%rsp)
movl %ebp, %r10d
movq %rdi, %r9
testb %cl, %cl
jne 0x1934b
incq %r11
cmpq 0xb8(%rsp), %r11
jne 0x190a1
jmp 0x1934b
movb $0x1, %cl
movq %r12, %r9
movq %rdi, %r12
jmp 0x1932a
testl %r10d, %r10d
setg %r10b
jmp 0x19364
movl $0xffffffff, 0xc(%rsp)  # imm = 0xFFFFFFFF
movl $0xffffffff, 0x30(%rsp) # imm = 0xFFFFFFFF
movq 0x138(%rsp), %r15
movq 0x130(%rsp), %r13
cmpl $0x0, 0x2c(%rsp)
jne 0x1938e
testb %r10b, %r10b
jne 0x1938e
movb $0x0, (%r15)
xorl %r12d, %r12d
xorl %ebx, %ebx
jmp 0x19638
movq 0x10(%rsp), %rcx
decl %ecx
movl 0x110(%rsp), %eax
decl %eax
cmpl $0x0, 0x2c(%rsp)
cmovel 0xc(%rsp), %eax
cmovel 0x30(%rsp), %ecx
movq %rcx, 0x10(%rsp)
movslq 0x120(%rsp), %rbp
xorl %r12d, %r12d
movl $0x0, 0x20(%rsp)
movl $0x0, 0x18(%rsp)
movslq 0x10(%rsp), %rcx
movq %rax, %rsi
addl %ebx, %eax
movq 0x98(%rsp), %rdx
subl (%rdx,%rcx,4), %eax
testl %eax, %eax
movl $0x0, %edx
cmovlel %edx, %eax
cmpl 0x40(%rsp), %eax
jle 0x1940c
cmpl $0x0, 0x2c(%rsp)
je 0x196cf
movl $0x1, %edx
xorl %ecx, %ecx
movq %rsi, %rax
jmp 0x19580
movl %eax, %eax
movq (%r14,%rax,8), %rax
movzbl (%rax,%rcx), %eax
cmpl $0x0, 0x20(%rsp)
je 0x19440
movslq %r12d, %rcx
movb $0x2d, (%r13,%rcx)
movslq %esi, %rsi
movq 0x60(%rsp), %rdx
movb (%rdx,%rsi), %dl
movb %dl, (%r15,%rcx)
decl %esi
andl $0x4, %eax
movl %eax, 0x20(%rsp)
jmp 0x1947b
movq 0x58(%rsp), %rdx
movb (%rdx,%rcx), %dl
movslq %r12d, %rcx
movb %dl, (%r13,%rcx)
cmpl $0x0, 0x18(%rsp)
je 0x1958a
movb $0x2d, (%r15,%rcx)
movq 0x10(%rsp), %rcx
decl %ecx
movq %rcx, 0x10(%rsp)
andl $0x8, %eax
movl $0x0, 0x20(%rsp)
movl %eax, 0x18(%rsp)
movq %rsi, %rax
leal 0x1(%r12), %r14d
cmpl 0x120(%rsp), %r14d
jl 0x194a6
leaq 0x75232(%rip), %rdi     # 0x8e6c6
movq %rax, %rbx
xorl %eax, %eax
callq 0x26b6f
movq %rbx, %rax
movq 0x38(%rsp), %rbx
cmpl $0x0, 0x10(%rsp)
js 0x194bd
testl %eax, %eax
js 0x194bd
xorl %edx, %edx
movb $0x1, %cl
movl %r14d, %r12d
jmp 0x1957b
movq %rax, 0x78(%rsp)
movq 0x10(%rsp), %rax
testl %eax, %eax
js 0x19513
movl %eax, %ebx
movslq %r14d, %r14
incq %r14
incq %rbx
addl %eax, %r12d
addl $0x2, %r12d
movq 0x58(%rsp), %rax
movb -0x1(%rax,%rbx), %al
movb %al, -0x1(%r13,%r14)
movb $0x2d, -0x1(%r15,%r14)
cmpq %rbp, %r14
jl 0x19504
leaq 0x751c9(%rip), %rdi     # 0x8e6c6
xorl %eax, %eax
callq 0x26b6f
incq %r14
decq %rbx
jg 0x194dd
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x19516
movl %r14d, %r12d
movq %rax, 0x10(%rsp)
movl $0x11, %edx
movq 0x78(%rsp), %rax
testl %eax, %eax
js 0x19574
movl %eax, %ebx
movslq %r12d, %r14
incq %r14
incq %rbx
movb $0x2d, -0x1(%r13,%r14)
movq 0x60(%rsp), %rax
movb -0x1(%rax,%rbx), %al
movb %al, -0x1(%r15,%r14)
cmpq %rbp, %r14
jl 0x19560
leaq 0x75172(%rip), %rdi     # 0x8e6c6
xorl %eax, %eax
callq 0x26b6f
movl $0x11, %edx
incq %r14
incl %r12d
decq %rbx
jg 0x19534
xorl %ecx, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x19576
xorl %ecx, %ecx
movq 0x38(%rsp), %rbx
movq 0x50(%rsp), %r14
testl %edx, %edx
je 0x193cd
jmp 0x195fb
movq %rsi, %rdi
movslq %edi, %rdx
movq 0x60(%rsp), %rsi
movb (%rsi,%rdx), %dl
movb %dl, (%r15,%rcx)
movq 0x10(%rsp), %rcx
decl %ecx
movq %rcx, 0x10(%rsp)
decl %edi
movq %rdi, %rdx
movl %eax, %ecx
andb $0x3, %cl
cmpb $0x2, %cl
je 0x195d1
andl $0x3, %eax
cmpl $0x3, %eax
jne 0x195e3
movl $0x1, 0x18(%rsp)
movl $0x0, 0x20(%rsp)
jmp 0x195f3
movl $0x0, 0x18(%rsp)
movl $0x1, 0x20(%rsp)
jmp 0x195f3
movl $0x0, 0x20(%rsp)
movl $0x0, 0x18(%rsp)
movq %rdx, %rax
jmp 0x1947e
cmpl $0x11, %edx
jne 0x196be
movslq %r12d, %rbp
cmpl $0x0, 0x118(%rsp)
jle 0x19627
movq %r13, %rdi
movq %rbp, %rsi
callq 0x1fade
movq %r15, %rdi
movq %rbp, %rsi
callq 0x1fade
movb $0x0, (%r13,%rbp)
addq %rbp, %r15
movl $0x1, %ebx
movq %r15, %r13
movb $0x0, (%r13)
movq 0x140(%rsp), %r14
cmpl $0x0, 0x118(%rsp)
jns 0x19675
movq 0x58(%rsp), %rdi
movq 0xa8(%rsp), %rsi
callq 0x1fade
movl 0x110(%rsp), %eax
movslq %eax, %rsi
movq 0x60(%rsp), %rdi
callq 0x1fade
movq 0x148(%rsp), %r15
leaq 0x68(%rsp), %rdi
callq 0x2bf4b
testq %r14, %r14
je 0x19693
movl 0x30(%rsp), %eax
movl %eax, (%r14)
movq 0x128(%rsp), %rax
testq %r15, %r15
je 0x196a7
movl 0xc(%rsp), %ecx
movl %ecx, (%r15)
movl %r12d, (%rax)
movl %ebx, %eax
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %eax, %eax
movl $0x1, %ebx
testb %cl, %cl
jne 0x1963d
jmp 0x196ac
leaq 0x74f5e(%rip), %rdi     # 0x8e634
leaq 0x74f5e(%rip), %rsi     # 0x8e63b
leaq 0x74f6a(%rip), %rcx     # 0x8e64e
movl $0x159, %edx            # imm = 0x159
callq 0x6460