// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x140, %rsp            # imm = 0x140
movq 0x48(%rbp), %rax
movq 0x40(%rbp), %rax
movq 0x38(%rbp), %rax
movq 0x30(%rbp), %rax
movq 0x28(%rbp), %rax
movl 0x20(%rbp), %eax
movl 0x18(%rbp), %eax
movl 0x10(%rbp), %eax
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq %rcx, -0x20(%rbp)
movl %r8d, -0x24(%rbp)
movq %r9, -0x30(%rbp)
movq $0x0, -0x40(%rbp)
movq $0x0, -0x48(%rbp)
movq $0x0, -0x50(%rbp)
movq $0x0, -0x58(%rbp)
movl -0x14(%rbp), %eax
shll %eax
addl $0x1, %eax
movl %eax, -0x64(%rbp)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x68(%rbp)
movl -0x64(%rbp), %eax
movl -0x68(%rbp), %ecx
shll %ecx
addl %ecx, %eax
movl %eax, -0x6c(%rbp)
movl $0x0, -0x70(%rbp)
movl $0xffffffff, -0x78(%rbp) # imm = 0xFFFFFFFF
movl $0xffffffff, -0x80(%rbp) # imm = 0xFFFFFFFF
movl $0x0, -0x84(%rbp)
movl $0x1, -0x88(%rbp)
movl $0x0, -0x94(%rbp)
movq -0x10(%rbp), %rax
movl 0x40008(%rax), %eax
movl %eax, -0x98(%rbp)
movq -0x10(%rbp), %rax
movl 0x4000c(%rax), %eax
movl %eax, -0x9c(%rbp)
xorl %eax, %eax
subl -0x98(%rbp), %eax
imull $0x64, %eax, %eax
movl %eax, -0xa0(%rbp)
movl -0x98(%rbp), %eax
movl -0x9c(%rbp), %ecx
imull -0x14(%rbp), %ecx
addl %ecx, %eax
movl %eax, -0xa4(%rbp)
movl $0x0, -0xb4(%rbp)
xorl %eax, %eax
subl -0x98(%rbp), %eax
movl %eax, -0xb8(%rbp)
cmpl $0x0, 0x18(%rbp)
jge 0x1fbf3
movq -0x20(%rbp), %rdi
movslq -0x24(%rbp), %rsi
callq 0x2a560
movq -0x30(%rbp), %rdi
movslq 0x10(%rbp), %rsi
callq 0x2a560
movslq -0x24(%rbp), %rax
shlq $0x2, %rax
movslq -0x64(%rbp), %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movslq -0x64(%rbp), %rcx
movslq -0x24(%rbp), %rdx
shlq $0x0, %rdx
imulq %rdx, %rcx
addq %rcx, %rax
movslq -0x6c(%rbp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movslq -0x6c(%rbp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movl %eax, %edi
callq 0x3dc20
movq %rax, -0xb0(%rbp)
movq -0xb0(%rbp), %rdi
movslq -0x24(%rbp), %rsi
shlq $0x2, %rsi
callq 0x3de60
movq %rax, -0x40(%rbp)
movq -0xb0(%rbp), %rdi
movslq -0x64(%rbp), %rsi
shlq $0x3, %rsi
callq 0x3de60
movq %rax, -0x48(%rbp)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x64(%rbp), %eax
jge 0x1fcaa
movq -0xb0(%rbp), %rdi
movslq -0x24(%rbp), %rsi
shlq $0x0, %rsi
callq 0x3de60
movq %rax, %rdx
movq -0x48(%rbp), %rax
movslq -0x34(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x1fc74
movq -0xb0(%rbp), %rdi
movslq -0x6c(%rbp), %rax
imulq $0xc, %rax, %rsi
callq 0x3de60
movq %rax, -0x50(%rbp)
movq -0xb0(%rbp), %rdi
movslq -0x6c(%rbp), %rax
imulq $0xc, %rax, %rsi
callq 0x3de60
movq %rax, -0x58(%rbp)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x6c(%rbp), %eax
jge 0x1fd6d
movq -0x50(%rbp), %rax
movslq -0x34(%rbp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0xc0(%rbp)
movl -0xa0(%rbp), %ecx
movq -0xc0(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0xc0(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0xc0(%rbp), %rax
movl %ecx, (%rax)
movq -0x58(%rbp), %rax
movslq -0x34(%rbp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0xc0(%rbp)
movl -0xa0(%rbp), %ecx
movq -0xc0(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0xc0(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0xc0(%rbp), %rax
movl %ecx, (%rax)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x1fce1
movl -0x14(%rbp), %eax
shll %eax
addl $0x1, %eax
movl %eax, -0xa8(%rbp)
movq -0x58(%rbp), %rax
movslq -0xa8(%rbp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movl $0x0, (%rax)
xorl %eax, %eax
subl -0x98(%rbp), %eax
movl %eax, -0xc4(%rbp)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x1fdef
movl -0xc4(%rbp), %ecx
movq -0x58(%rbp), %rax
movl -0xa8(%rbp), %edx
addl -0x34(%rbp), %edx
movslq %edx, %rdx
imulq $0xc, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x4(%rax)
movl -0x9c(%rbp), %ecx
movl -0xc4(%rbp), %eax
subl %ecx, %eax
movl %eax, -0xc4(%rbp)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x1fda8
movl $0x0, -0x74(%rbp)
movl -0x74(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x2025c
movq -0x20(%rbp), %rax
movslq -0x74(%rbp), %rcx
movb (%rax,%rcx), %al
movb %al, -0xc5(%rbp)
movq -0x10(%rbp), %rax
addq $0x8, %rax
movsbl -0xc5(%rbp), %ecx
movslq %ecx, %rcx
shlq $0xa, %rcx
addq %rcx, %rax
movq %rax, -0xd0(%rbp)
movl -0xa0(%rbp), %eax
movl %eax, -0xd4(%rbp)
movl $0xffffffff, -0xd8(%rbp) # imm = 0xFFFFFFFF
movl -0x84(%rbp), %eax
subl -0x14(%rbp), %eax
movl %eax, -0xdc(%rbp)
movl -0x84(%rbp), %eax
addl -0x68(%rbp), %eax
movl %eax, -0xe0(%rbp)
cmpl $0x0, -0xdc(%rbp)
jge 0x1fe7a
movl $0x0, -0xdc(%rbp)
movl -0xe0(%rbp), %eax
cmpl 0x10(%rbp), %eax
jle 0x1fe8e
movl 0x10(%rbp), %eax
movl %eax, -0xe0(%rbp)
movl -0x68(%rbp), %eax
addl -0xdc(%rbp), %eax
movl -0x84(%rbp), %ecx
subl -0x14(%rbp), %ecx
subl %ecx, %eax
movl %eax, -0x90(%rbp)
movl -0x90(%rbp), %eax
addl -0x88(%rbp), %eax
movl %eax, -0x8c(%rbp)
movl -0x74(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x1fef8
movl -0xb8(%rbp), %ecx
movq -0x50(%rbp), %rax
movl -0x90(%rbp), %edx
subl $0x1, %edx
movslq %edx, %rdx
imulq $0xc, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x4(%rax)
movl -0x9c(%rbp), %ecx
movl -0xb8(%rbp), %eax
subl %ecx, %eax
movl %eax, -0xb8(%rbp)
jmp 0x1ff18
movl -0xa0(%rbp), %ecx
movq -0x50(%rbp), %rax
movl -0x90(%rbp), %edx
subl $0x1, %edx
movslq %edx, %rdx
imulq $0xc, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x4(%rax)
movl -0xdc(%rbp), %eax
movl %eax, -0x7c(%rbp)
movl -0x7c(%rbp), %eax
cmpl -0xe0(%rbp), %eax
jge 0x201b0
movq -0x50(%rbp), %rax
movslq -0x90(%rbp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0xf0(%rbp)
movq -0xd0(%rbp), %rax
movq -0x30(%rbp), %rcx
movslq -0x7c(%rbp), %rdx
movsbl (%rcx,%rdx), %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0xf4(%rbp)
movq -0x58(%rbp), %rax
movl -0x8c(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x100(%rbp)
movq -0x100(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x104(%rbp)
movq -0x100(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x108(%rbp)
movq -0x100(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0x10c(%rbp)
movl -0x104(%rbp), %eax
cmpl -0x108(%rbp), %eax
jl 0x1ffec
movl -0x104(%rbp), %eax
cmpl -0x10c(%rbp), %eax
jl 0x1ffec
movl -0x104(%rbp), %eax
addl -0xf4(%rbp), %eax
movl %eax, -0x110(%rbp)
movb $0x1, -0xe1(%rbp)
jmp 0x20030
movl -0x108(%rbp), %eax
cmpl -0x10c(%rbp), %eax
jle 0x20015
movl -0x108(%rbp), %eax
addl -0xf4(%rbp), %eax
movl %eax, -0x110(%rbp)
movb $0x3, -0xe1(%rbp)
jmp 0x2002e
movl -0x10c(%rbp), %eax
addl -0xf4(%rbp), %eax
movl %eax, -0x110(%rbp)
movb $0x2, -0xe1(%rbp)
jmp 0x20030
movl -0x110(%rbp), %ecx
movq -0xf0(%rbp), %rax
movl %ecx, (%rax)
movl -0x110(%rbp), %eax
cmpl -0xd4(%rbp), %eax
jle 0x20062
movl -0x110(%rbp), %eax
movl %eax, -0xd4(%rbp)
movl -0x7c(%rbp), %eax
movl %eax, -0xd8(%rbp)
movq -0x58(%rbp), %rax
movslq -0x8c(%rbp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x118(%rbp)
movq -0x118(%rbp), %rax
movl 0x8(%rax), %eax
subl -0x9c(%rbp), %eax
movl %eax, -0x11c(%rbp)
movq -0x118(%rbp), %rax
movl (%rax), %eax
subl -0x98(%rbp), %eax
movl %eax, -0x120(%rbp)
movl -0x11c(%rbp), %eax
cmpl -0x120(%rbp), %eax
jl 0x200d6
movzbl -0xe1(%rbp), %eax
orl $0x8, %eax
movb %al, -0xe1(%rbp)
movl -0x11c(%rbp), %ecx
movq -0xf0(%rbp), %rax
movl %ecx, 0x8(%rax)
jmp 0x200e6
movl -0x120(%rbp), %ecx
movq -0xf0(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0xf0(%rbp), %rax
addq $-0xc, %rax
movq %rax, -0x128(%rbp)
movq -0x128(%rbp), %rax
movl 0x4(%rax), %eax
subl -0x9c(%rbp), %eax
movl %eax, -0x12c(%rbp)
movq -0x128(%rbp), %rax
movl (%rax), %eax
subl -0x98(%rbp), %eax
movl %eax, -0x130(%rbp)
movl -0x12c(%rbp), %eax
cmpl -0x130(%rbp), %eax
jl 0x20153
movzbl -0xe1(%rbp), %eax
orl $0x4, %eax
movb %al, -0xe1(%rbp)
movl -0x12c(%rbp), %ecx
movq -0xf0(%rbp), %rax
movl %ecx, 0x4(%rax)
jmp 0x20163
movl -0x130(%rbp), %ecx
movq -0xf0(%rbp), %rax
movl %ecx, 0x4(%rax)
movb -0xe1(%rbp), %dl
movq -0x48(%rbp), %rax
movl -0x90(%rbp), %ecx
subl -0x68(%rbp), %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movslq -0x74(%rbp), %rcx
movb %dl, (%rax,%rcx)
movl -0x90(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x90(%rbp)
movl -0x8c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8c(%rbp)
movl -0x7c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x7c(%rbp)
jmp 0x1ff21
movl -0x70(%rbp), %eax
cmpl -0xd4(%rbp), %eax
jge 0x201ea
movl -0xd4(%rbp), %eax
movl %eax, -0x70(%rbp)
movl -0x74(%rbp), %eax
movl %eax, -0x78(%rbp)
movl -0xd8(%rbp), %eax
movl %eax, -0x80(%rbp)
movl -0xd8(%rbp), %eax
addl $0x1, %eax
subl -0x84(%rbp), %eax
movl %eax, -0x88(%rbp)
jmp 0x20213
movl -0xd4(%rbp), %eax
movl -0x70(%rbp), %ecx
subl -0xa4(%rbp), %ecx
cmpl %ecx, %eax
jge 0x20207
cmpl $0x0, -0x8(%rbp)
jne 0x20205
jmp 0x2025c
jmp 0x20211
movl $0x1, -0x88(%rbp)
jmp 0x20213
movl -0x84(%rbp), %edx
movq -0x40(%rbp), %rax
movslq -0x74(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x88(%rbp), %eax
addl -0x84(%rbp), %eax
movl %eax, -0x84(%rbp)
movq -0x50(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x58(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x60(%rbp), %rax
movq %rax, -0x58(%rbp)
movl -0x74(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x74(%rbp)
jmp 0x1fdf6
cmpl $0x0, -0x8(%rbp)
jne 0x2026c
cmpl $0x0, -0x70(%rbp)
jle 0x20595
movl $0x0, -0x134(%rbp)
movl $0x0, -0x138(%rbp)
movl $0x1, -0xb4(%rbp)
cmpl $0x0, -0x8(%rbp)
je 0x202a4
movl -0x24(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x74(%rbp)
movl 0x10(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x7c(%rbp)
jmp 0x202b0
movl -0x78(%rbp), %eax
movl %eax, -0x74(%rbp)
movl -0x80(%rbp), %eax
movl %eax, -0x7c(%rbp)
jmp 0x202b2
movl -0x7c(%rbp), %eax
movq -0x40(%rbp), %rcx
movslq -0x74(%rbp), %rdx
subl (%rcx,%rdx,4), %eax
addl -0x14(%rbp), %eax
movl %eax, -0x13c(%rbp)
cmpl $0x0, -0x13c(%rbp)
jge 0x202dc
movl $0x0, -0x13c(%rbp)
movl -0x13c(%rbp), %eax
cmpl -0x64(%rbp), %eax
jl 0x2031a
cmpl $0x0, -0x8(%rbp)
je 0x202ef
jmp 0x2030e
leaq 0xb826a(%rip), %rdi     # 0xd8560
leaq 0xb826a(%rip), %rsi     # 0xd8567
movl $0x159, %edx            # imm = 0x159
leaq 0xb8271(%rip), %rcx     # 0xd857a
callq 0x6450
movl $0x0, -0x4(%rbp)
jmp 0x20604
movq -0x48(%rbp), %rax
movslq -0x13c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x74(%rbp), %rcx
movb (%rax,%rcx), %al
movb %al, -0x13d(%rbp)
cmpl $0x0, -0x134(%rbp)
je 0x20385
movq 0x30(%rbp), %rax
movslq -0x94(%rbp), %rcx
movb $0x2d, (%rax,%rcx)
movq -0x30(%rbp), %rax
movslq -0x7c(%rbp), %rcx
movb (%rax,%rcx), %dl
movq 0x38(%rbp), %rax
movslq -0x94(%rbp), %rcx
movb %dl, (%rax,%rcx)
movl -0x7c(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x7c(%rbp)
movzbl -0x13d(%rbp), %eax
andl $0x4, %eax
movl %eax, -0x134(%rbp)
jmp 0x2045c
cmpl $0x0, -0x138(%rbp)
je 0x203d4
movq -0x20(%rbp), %rax
movslq -0x74(%rbp), %rcx
movb (%rax,%rcx), %dl
movq 0x30(%rbp), %rax
movslq -0x94(%rbp), %rcx
movb %dl, (%rax,%rcx)
movq 0x38(%rbp), %rax
movslq -0x94(%rbp), %rcx
movb $0x2d, (%rax,%rcx)
movl -0x74(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x74(%rbp)
movzbl -0x13d(%rbp), %eax
andl $0x8, %eax
movl %eax, -0x138(%rbp)
jmp 0x2045a
movq -0x20(%rbp), %rax
movslq -0x74(%rbp), %rcx
movb (%rax,%rcx), %dl
movq 0x30(%rbp), %rax
movslq -0x94(%rbp), %rcx
movb %dl, (%rax,%rcx)
movq -0x30(%rbp), %rax
movslq -0x7c(%rbp), %rcx
movb (%rax,%rcx), %dl
movq 0x38(%rbp), %rax
movslq -0x94(%rbp), %rcx
movb %dl, (%rax,%rcx)
movl -0x74(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x74(%rbp)
movl -0x7c(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x7c(%rbp)
movzbl -0x13d(%rbp), %eax
andl $0x3, %eax
movb %al, -0x13d(%rbp)
movzbl -0x13d(%rbp), %eax
cmpl $0x2, %eax
jne 0x20440
movl $0x1, -0x134(%rbp)
jmp 0x20458
movzbl -0x13d(%rbp), %eax
cmpl $0x3, %eax
jne 0x20456
movl $0x1, -0x138(%rbp)
jmp 0x20458
jmp 0x2045a
jmp 0x2045c
movl -0x94(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x94(%rbp)
cmpl 0x20(%rbp), %eax
jl 0x2047e
leaq 0xb817b(%rip), %rdi     # 0xd85f2
movb $0x0, %al
callq 0x35d40
cmpl $0x0, -0x74(%rbp)
jl 0x2048e
cmpl $0x0, -0x7c(%rbp)
jge 0x2054a
jmp 0x20490
cmpl $0x0, -0x74(%rbp)
jl 0x204eb
movq -0x20(%rbp), %rax
movslq -0x74(%rbp), %rcx
movb (%rax,%rcx), %dl
movq 0x30(%rbp), %rax
movslq -0x94(%rbp), %rcx
movb %dl, (%rax,%rcx)
movq 0x38(%rbp), %rax
movslq -0x94(%rbp), %rcx
movb $0x2d, (%rax,%rcx)
movl -0x94(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x94(%rbp)
cmpl 0x20(%rbp), %eax
jl 0x204e0
leaq 0xb8119(%rip), %rdi     # 0xd85f2
movb $0x0, %al
callq 0x35d40
movl -0x74(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x74(%rbp)
jmp 0x20490
jmp 0x204ed
cmpl $0x0, -0x7c(%rbp)
jl 0x20548
movq 0x30(%rbp), %rax
movslq -0x94(%rbp), %rcx
movb $0x2d, (%rax,%rcx)
movq -0x30(%rbp), %rax
movslq -0x7c(%rbp), %rcx
movb (%rax,%rcx), %dl
movq 0x38(%rbp), %rax
movslq -0x94(%rbp), %rcx
movb %dl, (%rax,%rcx)
movl -0x94(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x94(%rbp)
cmpl 0x20(%rbp), %eax
jl 0x2053d
leaq 0xb80bc(%rip), %rdi     # 0xd85f2
movb $0x0, %al
callq 0x35d40
movl -0x7c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x7c(%rbp)
jmp 0x204ed
jmp 0x2054f
jmp 0x202b2
cmpl $0x0, 0x18(%rbp)
jle 0x20575
movq 0x30(%rbp), %rdi
movslq -0x94(%rbp), %rsi
callq 0x2a560
movq 0x38(%rbp), %rdi
movslq -0x94(%rbp), %rsi
callq 0x2a560
movq 0x30(%rbp), %rax
movslq -0x94(%rbp), %rcx
movb $0x0, (%rax,%rcx)
movq 0x38(%rbp), %rax
movslq -0x94(%rbp), %rcx
movb $0x0, (%rax,%rcx)
jmp 0x205a3
movq 0x38(%rbp), %rax
movb $0x0, (%rax)
movq 0x30(%rbp), %rax
movb $0x0, (%rax)
cmpl $0x0, 0x18(%rbp)
jge 0x205c3
movq -0x20(%rbp), %rdi
movslq -0x24(%rbp), %rsi
callq 0x2a560
movq -0x30(%rbp), %rdi
movslq 0x10(%rbp), %rsi
callq 0x2a560
leaq -0xb0(%rbp), %rdi
callq 0x3dd90
cmpq $0x0, 0x40(%rbp)
je 0x205df
movl -0x78(%rbp), %ecx
movq 0x40(%rbp), %rax
movl %ecx, (%rax)
cmpq $0x0, 0x48(%rbp)
je 0x205ef
movl -0x80(%rbp), %ecx
movq 0x48(%rbp), %rax
movl %ecx, (%rax)
movl -0x94(%rbp), %ecx
movq 0x28(%rbp), %rax
movl %ecx, (%rax)
movl -0xb4(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x140, %rsp            # imm = 0x140
popq %rbp
retq