// File: /workspace/github_c_makefile_star2_O2/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 $0xc8, %rsp
movq %r9, 0x28(%rsp)
movl %r8d, %r14d
movq %rcx, 0x30(%rsp)
movl %edi, 0xc(%rsp)
movl 0x100(%rsp), %ecx
leal (%rdx,%rdx), %eax
movl %eax, 0x8(%rsp)
leal 0x1(%rdx,%rdx), %r12d
leal 0x2(%rdx,%rdx), %eax
leal 0x1(%rax,%rdx,2), %r8d
movl 0x40008(%rsi), %edi
movq %rsi, 0x78(%rsp)
movl 0x4000c(%rsi), %r15d
movslq %r14d, %r13
movslq %ecx, %rbx
cmpl $0x0, 0x108(%rsp)
movq %rdx, 0x40(%rsp)
movl %edi, 0x24(%rsp)
jns 0x15e02
movq 0x30(%rsp), %rdi
movq %r13, %rsi
movl %r8d, %ebp
callq 0x1c3c3
movq 0x28(%rsp), %rdi
movq %rbx, %rsi
callq 0x1c3c3
movl %ebp, %r8d
movl 0x24(%rsp), %edi
movq 0x40(%rsp), %rdx
movq %rbx, 0xa0(%rsp)
movq 0x120(%rsp), %rax
movq %rax, 0x68(%rsp)
leal 0x1(%rdx), %eax
movq %rax, 0x70(%rsp)
movl %edi, %eax
negl %eax
movl %eax, 0x1c(%rsp)
imull $-0x64, %edi, %eax
movl %eax, 0x18(%rsp)
movq %r13, 0x80(%rsp)
leaq (,%r13,4), %rbp
movslq %r12d, %r13
leaq (,%r13,8), %rbx
movl %r14d, 0x38(%rsp)
imull %r13d, %r14d
addl %ebx, %r14d
addl %ebp, %r14d
movslq %r8d, %r12
imull $0x18, %r12d, %edi
addl %r14d, %edi
movl %r15d, %eax
imull %edx, %eax
movl %eax, 0x14(%rsp)
callq 0x26f00
movq %rax, %r14
movq %rax, 0xc0(%rsp)
movq %rax, %rdi
movq %rbp, %rsi
callq 0x26ff4
movq %rax, 0x88(%rsp)
movq %r14, %rdi
movq %rbx, %rsi
callq 0x26ff4
movq %rax, 0x48(%rsp)
xorl %ebx, %ebx
movl 0x8(%rsp), %eax
movl %eax, %ebp
orl $0x1, %ebp
cmovlel %ebx, %ebp
cmpq %rbx, %rbp
je 0x15ed0
movq %r14, %rdi
movq 0x80(%rsp), %rsi
callq 0x26ff4
movq 0x48(%rsp), %rcx
movq %rax, (%rcx,%rbx,8)
incq %rbx
jmp 0x15ead
imulq $0xc, %r12, %rbp
movq %r14, %rdi
movq %rbp, %rsi
callq 0x26ff4
movq %rax, %rbx
movq %r14, %rdi
movq %rbp, %rsi
callq 0x26ff4
pushq $0x8
popq %rcx
xorl %edx, %edx
movq 0x40(%rsp), %r9
movl 0x8(%rsp), %esi
movl 0x18(%rsp), %edi
cmpq %r12, %rdx
jge 0x15f23
movl %edi, (%rbx,%rcx)
movl %edi, -0x4(%rbx,%rcx)
movl %edi, -0x8(%rbx,%rcx)
movl %edi, (%rax,%rcx)
movl %edi, -0x4(%rax,%rcx)
movl %edi, -0x8(%rax,%rcx)
incq %rdx
addq $0xc, %rcx
jmp 0x15eff
imulq $0xc, %r13, %rcx
andl $0x0, (%rax,%rcx)
xorl %ecx, %ecx
testl %r9d, %r9d
movl $0x0, %edx
cmovgl %r9d, %edx
imulq $0xc, %rdx, %rdx
movslq %esi, %rsi
imulq $0xc, %rsi, %rsi
addq %rax, %rsi
addq $0x10, %rsi
movl 0x1c(%rsp), %edi
cmpq %rcx, %rdx
je 0x15f60
movl %edi, (%rsi,%rcx)
subl %r15d, %edi
addq $0xc, %rcx
jmp 0x15f4f
movl %r15d, 0x3c(%rsp)
addq $0x8, 0x78(%rsp)
movl 0x14(%rsp), %ecx
addl 0x24(%rsp), %ecx
movl %ecx, 0x14(%rsp)
movslq 0x70(%rsp), %rcx
movslq %r9d, %rdx
movq %rdx, 0xb0(%rsp)
xorl %r10d, %r10d
movl 0x38(%rsp), %edx
testl %edx, %edx
movl $0x0, %esi
cmovgl %edx, %esi
movq %rsi, 0xb8(%rsp)
shlq $0x3, %rcx
movq 0x48(%rsp), %rdx
subq %rcx, %rdx
movq %rdx, 0xa8(%rsp)
pushq $-0x1
popq %rcx
pushq $0x1
popq %rbp
xorl %edx, %edx
movl %ecx, %r11d
movl %ecx, 0x10(%rsp)
xorl %esi, %esi
cmpq 0xb8(%rsp), %r10
movl %r11d, 0x20(%rsp)
je 0x1620f
movq %rax, %r12
movl %esi, 0x64(%rsp)
movl %edx, %r8d
subl %r9d, %r8d
testl %r8d, %r8d
movl $0x0, %esi
cmovgl %r8d, %esi
movq 0x70(%rsp), %rdi
movq %rdx, 0x98(%rsp)
leal (%rdx,%rdi), %ecx
movl 0x100(%rsp), %eax
cmpl %eax, %ecx
cmovgel %eax, %ecx
movq 0x30(%rsp), %rax
movsbq (%rax,%r10), %r15
subl %r8d, %edi
leal (%rdi,%rsi), %r8d
decl %r8d
movslq %r8d, %r8
imulq $0xc, %r8, %r8
addq %rbx, %r8
addq $0x4, %r8
cmpq 0xb0(%rsp), %r10
movq %rbx, 0x50(%rsp)
movq %r10, 0x58(%rsp)
jge 0x16059
movl 0x1c(%rsp), %edx
movl %edx, (%r8)
subl 0x3c(%rsp), %edx
movl %edx, 0x1c(%rsp)
movl 0x18(%rsp), %r14d
jmp 0x16061
movl 0x18(%rsp), %r14d
movl %r14d, (%r8)
shlq $0xa, %r15
addq 0x78(%rsp), %r15
addl %esi, %edi
movslq %edi, %r10
movl %ebp, 0x60(%rsp)
addl %ebp, %edi
movslq %edi, %r8
movl %esi, %edi
movslq %ecx, %rcx
imulq $0xc, %r8, %rsi
movq %r12, 0x90(%rsp)
addq %r12, %rsi
movq 0xa8(%rsp), %rax
leaq (%rax,%r10,8), %r8
imulq $0xc, %r10, %r10
addq 0x50(%rsp), %r10
xorl %r12d, %r12d
pushq $-0x1
popq %r11
cmpq %rcx, %rdi
jge 0x1617b
movl -0xc(%rsi,%r12), %r9d
movl -0x8(%rsi,%r12), %ebx
movl -0x4(%rsi,%r12), %ebp
cmpl %ebp, %r9d
setl %dl
cmpl %ebx, %r9d
setl %r13b
orb %dl, %r13b
cmpl %ebx, %ebp
cmovgl %ebp, %ebx
setg %dl
orb $0x2, %dl
movzbl %dl, %ebp
testb %r13b, %r13b
pushq $0x1
popq %rax
cmovel %eax, %ebp
cmovel %r9d, %ebx
movq 0x28(%rsp), %rdx
movsbq (%rdx,%rdi), %rdx
addl (%r15,%rdx,4), %ebx
cmpl %r14d, %ebx
cmovgl %ebx, %r14d
cmovgl %edi, %r11d
movl %ebx, (%r10,%r12)
movl (%rsi,%r12), %edx
movl 0x8(%rsi,%r12), %r9d
movl 0x3c(%rsp), %eax
subl %eax, %r9d
movl 0x24(%rsp), %r13d
subl %r13d, %edx
cmpl %edx, %r9d
cmovgl %r9d, %edx
leal 0x8(%rbp), %r9d
movzbl %r9b, %r9d
cmovll %ebp, %r9d
movl %edx, 0x8(%r10,%r12)
movl -0xc(%r10,%r12), %edx
movl -0x8(%r10,%r12), %ebx
subl %eax, %ebx
subl %r13d, %edx
movl %r9d, %ebp
orb $0x4, %bpl
cmpl %edx, %ebx
cmovgl %ebx, %edx
movzbl %bpl, %ebx
cmovll %r9d, %ebx
movl %edx, 0x4(%r10,%r12)
movq (%r8), %rdx
movq 0x58(%rsp), %rax
movb %bl, (%rdx,%rax)
incq %rdi
addq $0xc, %r12
addq $0x8, %r8
jmp 0x160a8
movl 0x64(%rsp), %esi
cmpl %r14d, %esi
movq 0x40(%rsp), %r9
jge 0x161b1
movl %r11d, %ebp
movq 0x98(%rsp), %rdx
subl %edx, %ebp
incl %ebp
movq 0x58(%rsp), %r10
movl %r10d, 0x10(%rsp)
movq 0x50(%rsp), %rcx
movq 0x90(%rsp), %rbx
jmp 0x161f3
movl %esi, %eax
subl 0x14(%rsp), %eax
cmpl %eax, %r14d
movq 0x50(%rsp), %rcx
movq 0x58(%rsp), %r10
movq 0x98(%rsp), %rdx
movq 0x90(%rsp), %rbx
jge 0x161e8
cmpl $0x0, 0xc(%rsp)
movl 0x20(%rsp), %r11d
movl 0x60(%rsp), %ebp
jne 0x161f0
jmp 0x1620f
pushq $0x1
popq %rbp
movl 0x20(%rsp), %r11d
movl %esi, %r14d
movq 0x88(%rsp), %rax
movl %edx, (%rax,%r10,4)
addl %ebp, %edx
incq %r10
movl %r14d, %esi
movq %rcx, %rax
jmp 0x15fc5
cmpl $0x0, 0xc(%rsp)
jne 0x1622f
testl %esi, %esi
jg 0x1622f
movq 0x128(%rsp), %rax
movb $0x0, (%rax)
xorl %r12d, %r12d
xorl %ebp, %ebp
jmp 0x16488
movl 0x38(%rsp), %eax
decl %eax
movl 0x100(%rsp), %r8d
decl %r8d
cmpl $0x0, 0xc(%rsp)
cmovel %r11d, %r8d
cmovel 0x10(%rsp), %eax
xorl %r14d, %r14d
xorl %r12d, %r12d
xorl %ebp, %ebp
xorl %r15d, %r15d
movl 0x8(%rsp), %edi
movl %eax, %r13d
movslq %eax, %rdx
leal (%r8,%r9), %eax
movq 0x88(%rsp), %rcx
subl (%rcx,%rdx,4), %eax
testl %eax, %eax
cmovlel %r14d, %eax
cmpl %edi, %eax
jg 0x1637c
movl %eax, %eax
movq 0x48(%rsp), %rcx
movq (%rcx,%rax,8), %rax
movzbl (%rax,%rdx), %eax
movslq %r8d, %rcx
testl %ebp, %ebp
je 0x162c3
movq 0x120(%rsp), %rdx
movb $0x2d, (%rdx,%r12)
movq 0x28(%rsp), %rdx
movb (%rdx,%rcx), %dl
movq 0x128(%rsp), %rsi
movb %dl, (%rsi,%r12)
decl %ecx
andl $0x4, %eax
movl %ecx, %r8d
movl %eax, %ebp
jmp 0x162f4
movq 0x30(%rsp), %rsi
movb (%rsi,%rdx), %dl
movq 0x120(%rsp), %rsi
movb %dl, (%rsi,%r12)
testl %r15d, %r15d
je 0x16335
movq 0x128(%rsp), %rcx
movb $0x2d, (%rcx,%r12)
decl %r13d
andl $0x8, %eax
xorl %ebp, %ebp
movl %eax, %r15d
leal 0x1(%r12), %eax
cmpl 0x110(%rsp), %eax
jl 0x1631f
leaq 0x673b5(%rip), %rdi     # 0x7d6be
xorl %eax, %eax
movq %r8, %rbx
callq 0x223fb
movl 0x8(%rsp), %edi
movq 0x40(%rsp), %r9
movq %rbx, %r8
incq %r12
movl %r13d, %eax
testl %r13d, %r13d
js 0x163a8
testl %r8d, %r8d
jns 0x1625d
jmp 0x163a8
movq 0x28(%rsp), %rdx
movb (%rdx,%rcx), %dl
movq 0x128(%rsp), %rsi
movb %dl, (%rsi,%r12)
decl %r13d
movl %ecx, %r8d
decl %r8d
movl %eax, %ecx
andb $0x3, %cl
cmpb $0x2, %cl
je 0x1636c
andl $0x3, %eax
xorl %ebp, %ebp
cmpl $0x3, %eax
jne 0x16374
pushq $0x1
popq %r15
jmp 0x162f4
xorl %r15d, %r15d
pushq $0x1
popq %rbp
jmp 0x162f4
xorl %r15d, %r15d
jmp 0x162f4
xorl %ebp, %ebp
cmpl $0x0, 0xc(%rsp)
jne 0x164fc
leaq 0x6729c(%rip), %rdi     # 0x7d62c
leaq 0x6729c(%rip), %rsi     # 0x7d633
leaq 0x672a8(%rip), %rcx     # 0x7d646
movl $0x159, %edx            # imm = 0x159
callq 0x6460
leaq 0x6730f(%rip), %r13     # 0x7d6be
movq 0x120(%rsp), %rbx
movq 0x128(%rsp), %r14
testl %eax, %eax
js 0x163ff
movl %eax, %ebp
movl %eax, %eax
movq 0x30(%rsp), %rcx
movb (%rcx,%rax), %al
movb %al, (%rbx,%r12)
movb $0x2d, (%r14,%r12)
leal 0x1(%r12), %eax
cmpl 0x110(%rsp), %eax
jl 0x163f6
movq %r13, %rdi
xorl %eax, %eax
movq %r8, %r15
callq 0x223fb
movq %r15, %r8
movl %ebp, %eax
decl %eax
incq %r12
jmp 0x163bf
leaq 0x672b8(%rip), %r15     # 0x7d6be
testl %r8d, %r8d
js 0x1644d
movb $0x2d, (%rbx,%r12)
movl %r8d, %eax
movq 0x28(%rsp), %rcx
movb (%rcx,%rax), %al
movq 0x128(%rsp), %rcx
movb %al, (%rcx,%r12)
leal 0x1(%r12), %eax
cmpl 0x110(%rsp), %eax
jl 0x16445
movq %r15, %rdi
xorl %eax, %eax
movq %r8, %r14
callq 0x223fb
movq %r14, %r8
decl %r8d
incq %r12
jmp 0x16406
movl %r12d, %r15d
cmpl $0x0, 0x108(%rsp)
movq 0x128(%rsp), %r14
jle 0x16478
movq %rbx, %rdi
movq %r15, %rsi
callq 0x1c3c3
movq %r14, %rdi
movq %r15, %rsi
callq 0x1c3c3
movb $0x0, (%rbx,%r15)
addq %r15, %r14
pushq $0x1
popq %rbp
movq %r14, 0x68(%rsp)
movq 0x68(%rsp), %rax
movb $0x0, (%rax)
cmpl $0x0, 0x108(%rsp)
jns 0x164be
movq 0x30(%rsp), %rdi
movq 0x80(%rsp), %rsi
callq 0x1c3c3
movq 0x28(%rsp), %rdi
movq 0xa0(%rsp), %rsi
callq 0x1c3c3
leaq 0xc0(%rsp), %rdi
callq 0x26fa2
movq 0x130(%rsp), %rax
testq %rax, %rax
je 0x164de
movl 0x10(%rsp), %ecx
movl %ecx, (%rax)
movq 0x138(%rsp), %rax
testq %rax, %rax
je 0x164f1
movl 0x20(%rsp), %ecx
movl %ecx, (%rax)
movq 0x118(%rsp), %rax
movl %r12d, (%rax)
movl %ebp, %eax
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq