// File: /workspace/github_cpp_makefile_star2_O3/SNUCSE-CTA[P]GI/src/refine.cpp
// Function: Refinement::refine(Coloring*, Graph*, Graph*)
bool Refinement::refine(Coloring* coloring, Graph* aG1, Graph* aG2)
{
	#ifdef DEBUG
	cout << __PRETTY_FUNCTION__ << endl;
	#endif

	auto deg = [aG1, aG2](const int32_t& u) -> int32_t {
		return (u < aG1->numNode) ? aG1->d[u] : aG2->d[u - aG1->numNode];
	};

	auto adj = [aG1, aG2](const int32_t& u, const int32_t& i) -> int32_t {
		return (u < aG1->numNode) ? aG1->e[u][i] : (aG2->e[u - aG1->numNode][i] + aG1->numNode);
	};

	const int32_t numNode = aG1->numNode + aG2->numNode;

	int32_t* inStack = global_memory->getLLArray(numNode);
	int32_t* stackCand = global_memory->getLLArray(numNode);

	memset(inStack, 0, sizeof(int32_t) * numNode);
	memset(stackCand, 0, sizeof(int32_t) * numNode);

	int32_t numStackCand = 0;
	int32_t numVisitCell = 0;
	int32_t numSplitCell = 0;
	int32_t numSplitCount = 0;

	// Push all cells of the coloring into the stack.
	stackSize = 0;
	for (int32_t i = 0; i < numNode; i += coloring->cellSize[i]) {
		cellStack[stackSize] = i;
		++stackSize;
		inStack[i] = 1;
	}

	while (stackSize > 0) {
		if (coloring->numCell == numNode)
			break;

		if (global_mark > INFINITY) {
			memset(markCell, 0, sizeof(int32_t) * numNode);
			memset(markNode, 0, sizeof(int32_t) * numNode);
			global_mark = 0;
		}
		++global_mark;

		int32_t weightend = 0;
		int32_t idx = selectFromStack(coloring);
		int32_t currCell = cellStack[idx];
		int32_t currEnd = currCell + coloring->cellSize[currCell];

		cellStack[idx] = cellStack[stackSize - 1];
		--stackSize;
		inStack[currCell] = 0;

		// The first node.
		int32_t currNode = coloring->perm[currCell];
		int32_t currDegree = deg(currNode);
		do {
			int32_t start = currCell;
			int32_t end = currEnd;
			weightend = deg(currNode);

			if (coloring->cellSize[start] == 1) {
				return false;
			} else if (coloring->cellSize[start] == 2) {
				bool u_in_G1 = (coloring->perm[start] < aG1->numNode);
				bool v_in_G1 = (coloring->perm[start+1] < aG1->numNode);
				if ((u_in_G1 && v_in_G1) || (!u_in_G1 && !v_in_G1)) {
					return false;
				}

				numVisitCell = 0;
				for (int32_t i = 0; i < 2; ++i) {
					currNode = coloring->perm[start+i];
					for (int32_t j = 0; j < deg(currNode); ++j) {
						int32_t neigh = adj(currNode, j);
						int32_t c = coloring->color[coloring->inv[neigh]];
						if (coloring->cellSize[c] > 1) {
							if (markCell[c] != global_mark) {
								visitCell[numVisitCell++] = c;
								markCell[c] = global_mark;
								visitNode[c] = neigh;
								numVisitNode[c] = 1;
							} else {
								visitNode[c + numVisitNode[c]] = neigh;
								++numVisitNode[c];
							}
						}
					}
				}
				++global_mark;

				// Find cells that needs to be split.
				numSplitCell = 0;
				for (int32_t idx = 0; idx < numVisitCell; ++idx) {
					int32_t c = visitCell[idx];
					if (numVisitNode[c] < coloring->cellSize[c]) {
						splitCell[numSplitCell++] = c;
					}
				}

				if (numSplitCell > 0) {
					sort(splitCell, splitCell+numSplitCell);

					for (int32_t idx = 0; idx < numSplitCell; ++idx) {
						int32_t sc = splitCell[idx];

						coloring->cellSize[sc] -= numVisitNode[sc];

						int32_t newCell = sc + coloring->cellSize[sc];
						coloring->cellSize[newCell] = numVisitNode[sc];

						++coloring->numCell;

						if (inStack[sc] == 1) {
							cellStack[stackSize] = newCell;
							++stackSize;
							inStack[newCell] = 1;
						} else {
							if (coloring->cellSize[newCell] < coloring->cellSize[sc]) {
								cellStack[stackSize] = newCell;
								++stackSize;
								inStack[newCell] = 1;
							} else {
								cellStack[stackSize] = sc;
								++stackSize;
								inStack[sc] = 1;
							}
						}

						for (int32_t i = 0; i < numVisitNode[sc]; ++i) {
							int32_t node = visitNode[sc+i];

							int32_t newPos = newCell + i;
							int32_t oldPos = coloring->inv[node];

							coloring->perm[oldPos] = coloring->perm[newPos];
							coloring->perm[newPos] = node;
							coloring->inv[node] = newPos;
							coloring->inv[coloring->perm[oldPos]] = oldPos;
							coloring->color[newPos] = newCell;
						}
					}
				}
			} else { // if cellSize[start] > 2
				if (coloring->cellSize[start] != numNode) {
					numVisitCell = 0;
					for (int32_t i = start; i < end; ++i) {
						currNode = coloring->perm[i];
						for (int32_t j = 0; j < deg(currNode); ++j) {
							int32_t neigh = adj(currNode, j);

							if (markNode[neigh] == global_mark) {
								++neighCount[neigh];
							} else {
								int32_t c = coloring->color[coloring->inv[neigh]];
								if (coloring->cellSize[c] > 1) {
									markNode[neigh] = global_mark;
									neighCount[neigh] = 1;

									if (markCell[c] != global_mark) {
										visitCell[numVisitCell++] = c;
										markCell[c] = global_mark;
										visitNode[c] = neigh;
										numVisitNode[c] = 1;
									} else {
										visitNode[c + numVisitNode[c]++] = neigh;
									}
								} //if (cellSize[c] > 1)
							} //if-else (markNode[neigh])
						} //for (j)
					} //for (i)
				} //if
				++global_mark;

				// Find cells that need to be split.
				numSplitCell = 0;
				for (int32_t idx = 0; idx < numVisitCell; ++idx) {
					int32_t c = visitCell[idx];

					if (numVisitNode[c] < coloring->cellSize[c]) {
						splitCell[numSplitCell++] = c;
					} else {
						int32_t count = neighCount[coloring->perm[c]];
						for (int32_t i = c+1; i < c+coloring->cellSize[c]; ++i) {
							if (neighCount[coloring->perm[i]] != count) {
								splitCell[numSplitCell++] = c;
								break;
							}
						}
					}
				}

				if (numSplitCell > 0) {
					sort(splitCell, splitCell+numSplitCell);

					for (int32_t idx = 0; idx < numSplitCell; ++idx) {
						int32_t sc = splitCell[idx];

						int32_t scEnd = sc + coloring->cellSize[sc];
						numSplitCount = 0;
						if (numVisitNode[sc] < coloring->cellSize[sc]) {
							splitCount[numSplitCount] = 0;
							++numSplitCount;
							splitPos[0] = coloring->cellSize[sc] - numVisitNode[sc];
						}

						int32_t thisEnd = sc + numVisitNode[sc];
						for (int32_t i = sc; i < thisEnd; ++i) {
							int32_t count = neighCount[visitNode[i]];

							if (markCell[count] != global_mark) {
								markCell[count] = global_mark;
								splitCount[numSplitCount] = count;
								++numSplitCount;
								splitPos[count] = 1;
							} else {
								++splitPos[count];
							}
						}
						++global_mark;

						sort(splitCount, splitCount+numSplitCount);

						stackCand[0] = sc;
						numStackCand = 1;

						int32_t newCell = sc;
						for (int32_t k = 0; k < numSplitCount; ++k) {
							int32_t size = splitPos[splitCount[k]];
							coloring->cellSize[newCell] = size;
							splitPos[splitCount[k]] = newCell;

							newCell += size;
							if (newCell < scEnd) {
								// Push new cells into the stack.
								// Note that the first new cell is not pushed.
								stackCand[numStackCand] = newCell;
								++numStackCand;
								++coloring->numCell;
							}
						}

						if (inStack[sc]) {
							for (int32_t k = 1; k < numStackCand; ++k) {
								cellStack[stackSize] = stackCand[k];
								inStack[stackCand[k]] = 1;
								++stackSize;
							}
						} else {
							int32_t maxCell = sc;
							int32_t maxCellSize = coloring->cellSize[sc];
							for (int32_t k = 1; k < numStackCand; ++k) {
								if (coloring->cellSize[stackCand[k]] > maxCellSize) {
									maxCell = stackCand[k];
									maxCellSize = coloring->cellSize[maxCell];
								}
							}

							for (int32_t k = 0; k < numStackCand; ++k) {
								if (stackCand[k] != maxCell) {
									cellStack[stackSize] = stackCand[k];
									inStack[stackCand[k]] = 1;
									++stackSize;
								}
							}
						}

						for (int32_t i = sc; i < thisEnd; ++i) {
							int32_t node = visitNode[i];

							int32_t newPos = splitPos[neighCount[node]]++;
							int32_t oldPos = coloring->inv[node];

							coloring->perm[oldPos] = coloring->perm[newPos];
							coloring->perm[newPos] = node;
							coloring->inv[node] = newPos;
							coloring->inv[coloring->perm[oldPos]] = oldPos;
							neighCount[node] = 0;
						}

						newCell = scEnd - numVisitNode[sc];
						int32_t nc = newCell;
						int32_t ncEnd = newCell + coloring->cellSize[newCell] - 1;
						do {
							coloring->color[nc] = newCell;
							if (nc == ncEnd) {
								newCell = nc + 1;
								if (newCell < numNode) {
									ncEnd = newCell + coloring->cellSize[newCell] - 1;
								}
							}
							++nc;
						} while (nc < scEnd);
					}
				}
			} //if-else (cellSize[start])
		} while (weightend < currDegree);
	}

	return checkColoring(coloring);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %rcx, %r12
movq %rdx, %r15
movq %rsi, %rbx
movq %rdi, %r14
movq %rdi, 0x8(%rsp)
movslq 0xc(%rdx), %rax
movslq 0xc(%rcx), %r13
addq %rax, %r13
movq 0x68(%rdi), %rdi
movl %r13d, %esi
callq 0x4aba
movq %rax, 0x50(%rsp)
movq 0x68(%r14), %rdi
movl %r13d, %esi
callq 0x4aba
movq %rax, 0x68(%rsp)
leaq (,%r13,4), %r14
xorl %ebp, %ebp
movq 0x50(%rsp), %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x20e0
movq 0x68(%rsp), %rdi
xorl %esi, %esi
movq %r14, 0x80(%rsp)
movq %r14, %rdx
callq 0x20e0
movq 0x8(%rsp), %rdi
movl $0x0, 0x28(%rdi)
movq %r13, 0x38(%rsp)
testl %r13d, %r13d
jle 0xab53
movq 0x20(%rdi), %rax
movq 0x20(%rbx), %rcx
movq 0x38(%rsp), %rsi
movq 0x50(%rsp), %r8
movslq 0x28(%rdi), %rdx
movl %ebp, (%rax,%rdx,4)
incl 0x28(%rdi)
movslq %ebp, %rdx
movl $0x1, (%r8,%rdx,4)
movl (%rcx,%rdx,4), %ebp
addl %edx, %ebp
cmpl %esi, %ebp
jl 0xa117
movl 0x28(%rdi), %ebp
testl %ebp, %ebp
jle 0xab53
movl $0x0, 0x14(%rsp)
movq %r12, 0x90(%rsp)
movq 0x38(%rsp), %rax
cmpl %eax, 0x4(%rbx)
je 0xab53
movl 0x80(%rdi), %r14d
cmpl $0x77359401, %r14d      # imm = 0x77359401
jl 0xa1a2
movq 0x70(%rdi), %rdi
xorl %r14d, %r14d
xorl %esi, %esi
movq 0x80(%rsp), %r13
movq %r13, %rdx
callq 0x20e0
movq 0x8(%rsp), %rax
movq 0x78(%rax), %rdi
xorl %esi, %esi
movq %r13, %rdx
callq 0x20e0
movq 0x8(%rsp), %rdi
movl 0x28(%rdi), %ebp
incl %r14d
movl %r14d, 0x80(%rdi)
movq %rbx, %rsi
callq 0xabf0
movq 0x8(%rsp), %rcx
movq 0x20(%rcx), %rcx
movslq %eax, %rdx
movq 0x8(%rsp), %rdi
movslq (%rcx,%rdx,4), %r8
movq 0x20(%rbx), %rax
movq %rax, 0x28(%rsp)
movslq (%rax,%r8,4), %rsi
movq %rsi, %rax
movq %rsi, 0x88(%rsp)
movslq %ebp, %rsi
movl -0x4(%rcx,%rsi,4), %esi
movl %esi, (%rcx,%rdx,4)
decl 0x28(%rdi)
addq %r8, %rax
movq %rax, 0xa0(%rsp)
movq 0x50(%rsp), %rax
xorl %edx, %edx
movl %edx, (%rax,%r8,4)
movq 0x10(%rbx), %rcx
movl (%rcx,%r8,4), %esi
movl 0xc(%r15), %ecx
cmpl %esi, %ecx
cmovgl %edx, %ecx
movq %r12, %rdx
cmovgq %r15, %rdx
movl %esi, 0x34(%rsp)
subl %ecx, %esi
movq 0x20(%rdx), %rcx
movslq %esi, %rdx
movl (%rcx,%rdx,4), %eax
movl %eax, 0x7c(%rsp)
movq 0x38(%rsp), %r14
movq %r8, 0x40(%rsp)
movl 0xc(%r15), %ecx
movl 0x34(%rsp), %r9d
cmpl %r9d, %ecx
movl %ecx, %edx
movl $0x0, %eax
cmovgl %eax, %edx
movq %r12, %rsi
cmovgq %r15, %rsi
movl %r9d, %eax
subl %edx, %eax
movq 0x20(%rsi), %rdx
movslq %eax, %rsi
movl (%rdx,%rsi,4), %r9d
movq 0x28(%rsp), %rax
movl (%rax,%r8,4), %edx
cmpl $0x2, %edx
movl %r9d, 0x24(%rsp)
je 0xa845
cmpl $0x1, %edx
je 0xab6c
cmpl %r14d, %edx
movl $0x0, %eax
movl 0x14(%rsp), %edx
cmovnel %eax, %edx
movl %edx, 0x14(%rsp)
je 0xa40b
cmpl $0x0, 0x88(%rsp)
jle 0xa40b
movq 0x10(%rbx), %rax
movq %rax, 0x48(%rsp)
movl $0x0, 0x14(%rsp)
movq 0x40(%rsp), %rdx
movq 0x48(%rsp), %rax
movq %rdx, 0x58(%rsp)
movl (%rax,%rdx,4), %eax
movl %eax, 0x34(%rsp)
movslq %eax, %r14
movq 0x78(%rdi), %r8
movq 0x30(%rdi), %r9
movq 0x38(%rdi), %rax
movq %rax, 0x60(%rsp)
movq 0x70(%rdi), %r11
movq 0x40(%rdi), %rax
movq %rax, 0x18(%rsp)
movq 0x48(%rdi), %r13
xorl %ebp, %ebp
movl 0x14(%rsp), %edi
movl 0x34(%rsp), %edx
subl %ecx, %edx
jge 0xa326
movq 0x20(%r15), %rax
movslq (%rax,%r14,4), %rax
cmpq %rax, %rbp
jge 0xa3ec
movq 0x38(%r15), %rax
movq (%rax,%r14,8), %rax
movl (%rax,%rbp,4), %ecx
jmp 0xa347
movq 0x20(%r12), %rax
movslq %edx, %rdx
movslq (%rax,%rdx,4), %rax
cmpq %rax, %rbp
jge 0xa3ec
movq 0x38(%r12), %rax
movq (%rax,%rdx,8), %rax
addl (%rax,%rbp,4), %ecx
movslq %ecx, %r10
movq 0x8(%rsp), %rax
movl 0x80(%rax), %esi
cmpl %esi, (%r8,%r10,4)
jne 0xa361
incl (%r9,%r10,4)
jmp 0xa3e0
movq 0x8(%rbx), %rax
movq 0x18(%rbx), %rdx
movslq (%rdx,%r10,4), %rdx
movl (%rax,%rdx,4), %eax
movslq %eax, %rdx
movq 0x28(%rsp), %rax
cmpl $0x2, (%rax,%rdx,4)
jl 0xa3e0
movl %esi, (%r8,%r10,4)
movl $0x1, (%r9,%r10,4)
movl (%r11,%rdx,4), %eax
movq 0x8(%rsp), %rsi
cmpl 0x80(%rsi), %eax
jne 0xa3b7
movl (%r13,%rdx,4), %eax
leal 0x1(%rax), %esi
movl %esi, (%r13,%rdx,4)
addl %eax, %edx
movslq %edx, %rax
movq 0x18(%rsp), %rdx
movl %ecx, (%rdx,%rax,4)
jmp 0xa3e0
movslq %edi, %rax
incl %edi
movq 0x60(%rsp), %r10
movl %edx, (%r10,%rax,4)
movl 0x80(%rsi), %eax
movl %eax, (%r11,%rdx,4)
movq 0x18(%rsp), %rax
movl %ecx, (%rax,%rdx,4)
movl $0x1, (%r13,%rdx,4)
incq %rbp
movl 0xc(%r15), %ecx
jmp 0xa300
movl %edi, 0x14(%rsp)
movq 0x58(%rsp), %rdx
incq %rdx
cmpq 0xa0(%rsp), %rdx
movq 0x8(%rsp), %rdi
jl 0xa2c4
incl 0x80(%rdi)
movl 0x14(%rsp), %eax
testl %eax, %eax
jle 0xab30
movq 0x30(%rdi), %rcx
movq 0x38(%rdi), %rdx
movq 0x48(%rdi), %rsi
movq 0x50(%rdi), %rdi
movq %rdi, 0x18(%rsp)
movl %eax, %r8d
xorl %r10d, %r10d
xorl %r9d, %r9d
movl (%rdx,%r10,4), %r11d
movslq %r11d, %r14
movq 0x28(%rsp), %rax
movl (%rax,%r14,4), %edi
cmpl %edi, (%rsi,%r14,4)
jl 0xa478
movq 0x10(%rbx), %r13
movslq (%r13,%r14,4), %rax
movl (%rcx,%rax,4), %ebp
addl %r11d, %edi
movslq %edi, %rdi
incq %r14
cmpq %rdi, %r14
jge 0xa487
movslq (%r13,%r14,4), %rax
incq %r14
cmpl %ebp, (%rcx,%rax,4)
je 0xa466
movslq %r9d, %rax
incl %r9d
movq 0x18(%rsp), %rdi
movl %r11d, (%rdi,%rax,4)
movq 0x8(%rsp), %rdi
incq %r10
cmpq %r8, %r10
jne 0xa43b
testl %r9d, %r9d
jle 0xab30
movl %r9d, %eax
movq 0x50(%rdi), %r14
leaq (%r14,%rax,4), %r13
movq %rax, 0x98(%rsp)
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
movq %r14, %rdi
movq %r13, %rsi
callq 0x89b7
movq %r14, %rdi
movq %r13, %rsi
callq 0x8a92
movq 0x8(%rsp), %rdi
movq 0x20(%rbx), %rax
movq %rax, 0x28(%rsp)
xorl %edx, %edx
movq 0x48(%rdi), %rcx
movq 0x50(%rdi), %rax
movq %rdx, 0x60(%rsp)
movl (%rax,%rdx,4), %ebp
movslq %ebp, %rax
movq 0x28(%rsp), %rsi
movl (%rsi,%rax,4), %r13d
movq %rax, 0x18(%rsp)
movl (%rcx,%rax,4), %edx
xorl %r14d, %r14d
cmpl %r13d, %edx
jge 0xa538
movq 0x8(%rsp), %rdx
movq 0x58(%rdx), %rax
movl $0x0, (%rax)
movq 0x18(%rsp), %rdi
movl (%rsi,%rdi,4), %eax
subl (%rcx,%rdi,4), %eax
movq 0x60(%rdx), %rdx
movl %eax, (%rdx)
movl (%rcx,%rdi,4), %edx
movl $0x1, %r14d
leal (%rdx,%rbp), %eax
movslq %eax, %r11
movq %rdx, 0x58(%rsp)
testl %edx, %edx
jle 0xa5a6
movq 0x8(%rsp), %rdi
movq 0x30(%rdi), %rax
movq 0x40(%rdi), %rcx
movq 0x70(%rdi), %rdx
movq 0x58(%rdi), %rsi
movq 0x60(%rdi), %rdi
movq 0x18(%rsp), %r8
movslq (%rcx,%r8,4), %r9
movl (%rax,%r9,4), %r9d
movslq %r9d, %r9
movq 0x8(%rsp), %r10
movl 0x80(%r10), %r10d
cmpl %r10d, (%rdx,%r9,4)
jne 0xa588
incl (%rdi,%r9,4)
jmp 0xa59e
movl %r10d, (%rdx,%r9,4)
movslq %r14d, %r14
movl %r9d, (%rsi,%r14,4)
incl %r14d
movl $0x1, (%rdi,%r9,4)
incq %r8
cmpq %r11, %r8
jl 0xa565
movq %r11, 0x28(%rsp)
addl %ebp, %r13d
movq 0x8(%rsp), %rcx
incl 0x80(%rcx)
testl %r14d, %r14d
je 0xa66c
movslq %r14d, %rax
movq 0x58(%rcx), %rcx
leaq (%rcx,%rax,4), %rsi
movq %rsi, 0x48(%rsp)
movq %rcx, %rdi
movq %rcx, 0x70(%rsp)
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
callq 0x89b7
movq 0x70(%rsp), %rdi
movq 0x48(%rsp), %rsi
callq 0x8a92
movq 0x68(%rsp), %r10
movl %ebp, (%r10)
testl %r14d, %r14d
jle 0xa674
movq 0x8(%rsp), %rax
movq 0x58(%rax), %rcx
movq 0x60(%rax), %rdx
movq 0x20(%rbx), %rsi
movl %r14d, %edi
movl $0x1, %eax
xorl %r8d, %r8d
movl %ebp, %r9d
movq 0x50(%rsp), %r14
movslq (%rcx,%r8,4), %r10
movslq %r9d, %r11
movl (%rdx,%r10,4), %r9d
movl %r9d, (%rsi,%r11,4)
movslq (%rcx,%r8,4), %r10
movl %r11d, (%rdx,%r10,4)
addl %r11d, %r9d
cmpl %r13d, %r9d
jge 0xa65d
cltq
movq 0x68(%rsp), %r10
movl %r9d, (%r10,%rax,4)
incl %eax
incl 0x4(%rbx)
jmp 0xa662
movq 0x68(%rsp), %r10
incq %r8
cmpq %r8, %rdi
jne 0xa62c
jmp 0xa67e
movq 0x68(%rsp), %r10
movl %ebp, (%r10)
movl $0x1, %eax
movq 0x50(%rsp), %r14
movq 0x18(%rsp), %rcx
cmpl $0x0, (%r14,%rcx,4)
je 0xa6cf
cmpl $0x2, %eax
jl 0xa73f
movq 0x8(%rsp), %rdx
movq 0x20(%rdx), %rcx
movl %eax, %eax
movl 0x28(%rdx), %esi
movl $0x1, %edx
movslq (%r10,%rdx,4), %rdi
movslq %esi, %rsi
movl %edi, (%rcx,%rsi,4)
movl $0x1, (%r14,%rdi,4)
movq 0x8(%rsp), %rdi
movl 0x28(%rdi), %esi
incl %esi
movl %esi, 0x28(%rdi)
incq %rdx
cmpq %rdx, %rax
jne 0xa6a6
jmp 0xa73f
cmpl $0x2, %eax
jl 0xa702
movq 0x20(%rbx), %rcx
movq 0x18(%rsp), %rdx
movl (%rcx,%rdx,4), %edx
movl %eax, %esi
movl $0x1, %edi
movslq (%r10,%rdi,4), %r8
movl (%rcx,%r8,4), %r9d
cmpl %edx, %r9d
cmovgl %r8d, %ebp
cmovgl %r9d, %edx
incq %rdi
cmpq %rdi, %rsi
jne 0xa6e7
testl %eax, %eax
jle 0xa73f
movq 0x8(%rsp), %rcx
movq 0x20(%rcx), %rcx
movl %eax, %eax
xorl %edx, %edx
movl (%r10,%rdx,4), %esi
cmpl %ebp, %esi
je 0xa737
movq 0x8(%rsp), %r8
movslq 0x28(%r8), %rdi
movl %esi, (%rcx,%rdi,4)
movslq (%r10,%rdx,4), %rsi
movl $0x1, (%r14,%rsi,4)
incl 0x28(%r8)
incq %rdx
cmpq %rdx, %rax
jne 0xa713
cmpl $0x0, 0x58(%rsp)
movq 0x28(%rsp), %r14
jle 0xa7a9
movq 0x8(%rsp), %rdx
movq 0x30(%rdx), %rax
movq 0x40(%rdx), %rcx
movq 0x60(%rdx), %rdx
movq 0x10(%rbx), %rsi
movq 0x18(%rbx), %rdi
movq 0x18(%rsp), %r8
movslq (%rcx,%r8,4), %r9
movslq (%rax,%r9,4), %r10
movslq (%rdx,%r10,4), %r11
leal 0x1(%r11), %ebp
movl %ebp, (%rdx,%r10,4)
movslq (%rdi,%r9,4), %r10
movl (%rsi,%r11,4), %ebp
movl %ebp, (%rsi,%r10,4)
movl %r9d, (%rsi,%r11,4)
movl %r11d, (%rdi,%r9,4)
movslq (%rsi,%r10,4), %r11
movl %r10d, (%rdi,%r11,4)
movl $0x0, (%rax,%r9,4)
incq %r8
cmpq %r14, %r8
jl 0xa769
movq 0x8(%rsp), %rax
movq 0x48(%rax), %rax
movq 0x18(%rsp), %rcx
movslq (%rax,%rcx,4), %rax
movslq %r13d, %rcx
subl %eax, %r13d
movq 0x20(%rbx), %r8
movslq %r13d, %rdx
movl (%r8,%rdx,4), %esi
addl %edx, %esi
decl %esi
leaq (,%rcx,4), %rdi
shlq $0x2, %rax
subq %rax, %rdi
movq %r8, 0x28(%rsp)
addq %rdi, %r8
addq $0x4, %r8
addq 0x8(%rbx), %rdi
xorl %r9d, %r9d
movl %r13d, %r10d
movq 0x38(%rsp), %r14
movl %r10d, (%rdi,%r9,4)
leal (%r9,%r13), %eax
leaq (%rdx,%r9), %r11
incq %r11
cmpl %esi, %eax
jne 0xa81d
leaq (%r9,%r13), %r10
incq %r10
cmpq %r14, %r11
jge 0xa81d
addl (%r8,%r9,4), %esi
incq %r9
cmpq %rcx, %r11
jl 0xa7fa
movq 0x60(%rsp), %rdx
incq %rdx
cmpq 0x98(%rsp), %rdx
movq 0x8(%rsp), %rdi
jne 0xa4e3
jmp 0xab35
movq 0x10(%rbx), %rdx
cmpl %ecx, (%rdx,%r8,4)
setl %sil
cmpl %ecx, 0x4(%rdx,%r8,4)
setl %al
cmpb %al, %sil
je 0xab6c
leaq (%rdx,%r8,4), %rax
movq %rax, 0x18(%rsp)
xorl %eax, %eax
movb $0x1, %sil
movl $0x0, 0x14(%rsp)
movq 0x18(%rsp), %rdx
movl (%rdx,%rax,4), %eax
movl %eax, 0x34(%rsp)
cltq
movq 0x70(%rdi), %r8
movq 0x38(%rdi), %r9
movq 0x40(%rdi), %r10
movq 0x48(%rdi), %r11
xorl %r14d, %r14d
movl 0x34(%rsp), %ebp
subl %ecx, %ebp
jge 0xa8c1
movq 0x20(%r15), %r13
movslq (%r13,%rax,4), %r13
cmpq %r13, %r14
jge 0xa956
movq 0x38(%r15), %rcx
movq (%rcx,%rax,8), %rcx
movl (%rcx,%r14,4), %ecx
jmp 0xa8e3
movq 0x20(%r12), %rdx
movslq %ebp, %r13
movslq (%rdx,%r13,4), %rdx
cmpq %rdx, %r14
jge 0xa956
movq 0x38(%r12), %rdx
movq (%rdx,%r13,8), %rdx
addl (%rdx,%r14,4), %ecx
movq 0x8(%rbx), %rdx
movq 0x18(%rbx), %r13
movslq %ecx, %rbp
movslq (%r13,%rbp,4), %r13
movl (%rdx,%r13,4), %edx
movslq %edx, %r13
movq 0x28(%rsp), %rdx
cmpl $0x2, (%rdx,%r13,4)
jl 0xa94a
movl (%r8,%r13,4), %edx
cmpl 0x80(%rdi), %edx
jne 0xa923
movslq (%r11,%r13,4), %rdx
addq %r13, %rdx
movl %ecx, (%r10,%rdx,4)
incl (%r11,%r13,4)
jmp 0xa94a
movl 0x14(%rsp), %ebp
movslq %ebp, %rdx
incl %ebp
movl %ebp, 0x14(%rsp)
movl %r13d, (%r9,%rdx,4)
movl 0x80(%rdi), %edx
movl %edx, (%r8,%r13,4)
movl %ecx, (%r10,%r13,4)
movl $0x1, (%r11,%r13,4)
incq %r14
movl 0xc(%r15), %ecx
jmp 0xa899
movl $0x1, %eax
testb $0x1, %sil
movl $0x0, %esi
jne 0xa878
incl 0x80(%rdi)
movl 0x14(%rsp), %eax
testl %eax, %eax
jle 0xab30
movq 0x38(%rdi), %rcx
movq 0x48(%rdi), %rdx
movq 0x50(%rdi), %rsi
movl %eax, %eax
xorl %r9d, %r9d
xorl %r8d, %r8d
movq 0x38(%rsp), %r14
movslq (%rcx,%r9,4), %r10
movl (%rdx,%r10,4), %r11d
movq 0x28(%rsp), %r13
cmpl (%r13,%r10,4), %r11d
jge 0xa9b3
movslq %r8d, %r11
incl %r8d
movl %r10d, (%rsi,%r11,4)
incq %r9
cmpq %r9, %rax
jne 0xa995
testl %r8d, %r8d
jle 0xab35
movl %r8d, %eax
movq 0x50(%rdi), %r14
leaq (%r14,%rax,4), %r12
movq %rax, 0x60(%rsp)
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
movq %r14, %rdi
movq %r12, %rsi
callq 0x89b7
movq %r14, %rdi
movq %r12, %rsi
callq 0x8a92
movq 0x8(%rsp), %rdi
movq 0x50(%rdi), %rax
movq %rax, 0x58(%rsp)
movq 0x48(%rdi), %rdx
movq 0x20(%rbx), %rax
movq %rax, 0x28(%rsp)
movq 0x20(%rdi), %rax
movq %rax, 0x48(%rsp)
movq 0x40(%rdi), %rax
movq %rax, 0x70(%rsp)
xorl %ecx, %ecx
movq 0x58(%rsp), %rax
movq %rcx, 0x18(%rsp)
movl (%rax,%rcx,4), %ecx
movslq %ecx, %r9
movl (%rdx,%r9,4), %ebp
movq 0x28(%rsp), %r8
movl (%r8,%r9,4), %r10d
movl %r10d, %ecx
subl %ebp, %ecx
movl %ecx, (%r8,%r9,4)
leal (%r9,%rcx), %r11d
movl (%rdx,%r9,4), %ecx
movslq %r11d, %r13
movl %ecx, (%r8,%r13,4)
incl 0x4(%rbx)
movq 0x50(%rsp), %rax
cmpl $0x1, (%rax,%r9,4)
jne 0xaa79
movslq 0x28(%rdi), %rcx
movq 0x48(%rsp), %rsi
movl %r13d, (%rsi,%rcx,4)
jmp 0xaa90
movl (%r8,%r13,4), %ecx
movslq 0x28(%rdi), %rsi
cmpl (%r8,%r9,4), %ecx
jge 0xaa99
movq 0x48(%rsp), %rcx
movl %r13d, (%rcx,%rsi,4)
incl 0x28(%rdi)
leaq (%rax,%r13,4), %rcx
jmp 0xaaa9
leaq (%rax,%r9,4), %rcx
movq 0x48(%rsp), %rax
movl %r9d, (%rax,%rsi,4)
incl 0x28(%rdi)
movl $0x1, (%rcx)
cmpl $0x0, (%rdx,%r9,4)
jle 0xab10
movq 0x10(%rbx), %rdi
movq 0x18(%rbx), %r14
leaq (%rdi,%r13,4), %rcx
shlq $0x2, %r13
addq 0x8(%rbx), %r13
movq 0x70(%rsp), %rax
leaq (%rax,%r9,4), %rsi
addl %r9d, %r10d
subl %ebp, %r10d
xorl %ebp, %ebp
movslq (%rsi,%rbp,4), %r8
movslq (%r14,%r8,4), %rax
movl (%rcx,%rbp,4), %r12d
movl %r12d, (%rdi,%rax,4)
movl %r8d, (%rcx,%rbp,4)
leal (%r10,%rbp), %r12d
movl %r12d, (%r14,%r8,4)
movslq (%rdi,%rax,4), %r8
movl %eax, (%r14,%r8,4)
movl %r11d, (%r13,%rbp,4)
incq %rbp
movslq (%rdx,%r9,4), %rax
cmpq %rax, %rbp
jl 0xaadb
movq 0x18(%rsp), %rcx
incq %rcx
cmpq 0x60(%rsp), %rcx
movq 0x90(%rsp), %r12
movq 0x8(%rsp), %rdi
jne 0xaa26
movq 0x38(%rsp), %r14
movq 0x40(%rsp), %r8
movl 0x24(%rsp), %eax
cmpl 0x7c(%rsp), %eax
jl 0xa23a
movl 0x28(%rdi), %ebp
testl %ebp, %ebp
jg 0xa150
movq %rbx, %rsi
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xab92
xorl %eax, %eax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq