// File: /workspace/github_cpp_makefile_star2_O2/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 %rsi, %rbx
movq %rdi, %r12
movq %rdx, 0x98(%rsp)
movq %rcx, 0xa0(%rsp)
movq %rdx, 0x10(%rsp)
movslq 0xc(%rdx), %rax
movq %rcx, 0x60(%rsp)
movslq 0xc(%rcx), %r15
addq %rax, %r15
movq 0x68(%rdi), %rdi
movl %r15d, %esi
callq 0x3f1a
movq %rax, 0x40(%rsp)
movq 0x68(%r12), %rdi
movl %r15d, %esi
callq 0x3f1a
movq %rax, %r13
leaq (,%r15,4), %r14
xorl %ebp, %ebp
movq 0x40(%rsp), %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x2100
movq %r13, 0x90(%rsp)
movq %r13, %rdi
xorl %esi, %esi
movq %r14, 0x80(%rsp)
movq %r14, %rdx
callq 0x2100
andl $0x0, 0x28(%r12)
movq 0x20(%r12), %rax
cmpl %r15d, %ebp
jge 0x8fca
movslq 0x28(%r12), %rcx
movl %ebp, (%rax,%rcx,4)
incl 0x28(%r12)
movslq %ebp, %rcx
movq 0x40(%rsp), %rdx
movl $0x1, (%rdx,%rcx,4)
movq 0x20(%rbx), %rdx
addl (%rdx,%rcx,4), %ebp
jmp 0x8fa0
movl $0x0, 0xc(%rsp)
movq %r15, 0x58(%rsp)
movl 0x28(%r12), %ebp
testl %ebp, %ebp
jle 0x9908
cmpl %r15d, 0x4(%rbx)
je 0x9908
movl 0x80(%r12), %r14d
cmpl $0x77359401, %r14d      # imm = 0x77359401
jl 0x902d
movq 0x70(%r12), %rdi
xorl %r14d, %r14d
xorl %esi, %esi
movq 0x80(%rsp), %r13
movq %r13, %rdx
callq 0x2100
movq 0x78(%r12), %rdi
xorl %esi, %esi
movq %r13, %rdx
callq 0x2100
movl 0x28(%r12), %ebp
incl %r14d
movl %r14d, 0x80(%r12)
movq %r12, %rdi
movq %rbx, %rsi
callq 0x9988
movq 0x20(%r12), %rcx
cltq
movslq (%rcx,%rax,4), %rsi
movq 0x20(%rbx), %rdx
movslq (%rdx,%rsi,4), %rdi
movslq %ebp, %rdx
movl -0x4(%rcx,%rdx,4), %edx
movl %edx, (%rcx,%rax,4)
decl 0x28(%r12)
movq 0x40(%rsp), %rax
andl $0x0, (%rax,%rsi,4)
addq %rsi, %rdi
movq %rdi, 0x88(%rsp)
movq 0x10(%rbx), %rax
movq %rsi, 0x68(%rsp)
movl (%rax,%rsi,4), %edx
movl %edx, 0x34(%rsp)
movq 0x10(%rsp), %rdi
movl 0xc(%rdi), %eax
cmpl %eax, %edx
movl $0x0, %ecx
cmovll %ecx, %eax
movq 0x60(%rsp), %rcx
cmovlq %rdi, %rcx
movl %edx, 0x1c(%rsp)
subl %eax, %edx
movq 0x20(%rcx), %rax
movslq %edx, %rcx
movl (%rax,%rcx,4), %eax
movl %eax, 0x78(%rsp)
movl 0xc(%rdi), %eax
movl 0x1c(%rsp), %esi
cmpl %eax, %esi
movl %eax, %ecx
movl $0x0, %edx
cmovll %edx, %ecx
movq 0x60(%rsp), %rdx
cmovlq %rdi, %rdx
subl %ecx, %esi
movq 0x20(%rdx), %rcx
movslq %esi, %rdx
movl (%rcx,%rdx,4), %ecx
movl %ecx, 0x7c(%rsp)
movq 0x20(%rbx), %rcx
movq 0x68(%rsp), %rsi
movq %rcx, 0x28(%rsp)
movl (%rcx,%rsi,4), %ecx
cmpl $0x2, %ecx
je 0x919d
cmpl $0x1, %ecx
je 0x98f4
cmpl %r15d, %ecx
jne 0x9781
incl 0x80(%r12)
movq 0x30(%r12), %rax
movq 0x38(%r12), %rcx
movq 0x48(%r12), %rdx
movq 0x50(%r12), %rsi
xorl %edi, %edi
movl 0xc(%rsp), %r8d
testl %r8d, %r8d
movl $0x0, %r9d
cmovgl %r8d, %r9d
xorl %r8d, %r8d
cmpq %r9, %rdi
je 0x92e1
movl (%rcx,%rdi,4), %r10d
movslq %r10d, %r11
movq 0x28(%rsp), %r14
movl (%r14,%r11,4), %r15d
cmpl %r15d, (%rdx,%r11,4)
jl 0x9189
movq 0x10(%rbx), %r14
movslq (%r14,%r11,4), %r13
movl (%rax,%r13,4), %ebp
addl %r10d, %r15d
movslq %r15d, %r15
incq %r11
cmpq %r15, %r11
jge 0x9193
movslq (%r14,%r11,4), %r13
incq %r11
cmpl %ebp, (%rax,%r13,4)
je 0x9177
movslq %r8d, %r11
incl %r8d
movl %r10d, (%rsi,%r11,4)
incq %rdi
movq 0x58(%rsp), %r15
jmp 0x9143
movq 0x10(%rbx), %rcx
cmpl %eax, (%rcx,%rsi,4)
setl %dl
cmpl %eax, 0x4(%rcx,%rsi,4)
setl %sil
cmpb %sil, %dl
je 0x98f4
movq 0x68(%rsp), %rdx
leaq (%rcx,%rdx,4), %rcx
movq %rcx, 0x50(%rsp)
xorl %edx, %edx
movl $0x0, 0xc(%rsp)
cmpq $0x2, %rdx
je 0x95c2
movq 0x50(%rsp), %rcx
movq %rdx, 0x20(%rsp)
movl (%rcx,%rdx,4), %ecx
movl %ecx, 0x1c(%rsp)
movl %ecx, 0x34(%rsp)
movq 0x70(%r12), %rbp
movq 0x38(%r12), %rcx
movq %rcx, 0x38(%rsp)
movq 0x40(%r12), %r15
movq 0x48(%r12), %r14
xorl %r13d, %r13d
movl %r13d, 0x4c(%rsp)
movl 0x1c(%rsp), %esi
cmpl %eax, %esi
movl %eax, %ecx
movl $0x0, %edx
cmovll %edx, %ecx
movq 0x60(%rsp), %rdx
cmovlq %rdi, %rdx
subl %ecx, %esi
movq 0x20(%rdx), %rcx
movslq %esi, %rdx
cmpl (%rcx,%rdx,4), %r13d
jge 0x92cf
leaq 0x98(%rsp), %rdi
leaq 0x34(%rsp), %rsi
leaq 0x4c(%rsp), %rdx
callq 0x99e4
movq 0x8(%rbx), %rcx
movq 0x18(%rbx), %rdx
movslq %eax, %rsi
movslq (%rdx,%rsi,4), %rdx
movl (%rcx,%rdx,4), %ecx
movslq %ecx, %rcx
movq 0x28(%rsp), %rdx
cmpl $0x2, (%rdx,%rcx,4)
jl 0x92bf
movl (%rbp,%rcx,4), %edx
cmpl 0x80(%r12), %edx
jne 0x9292
movslq (%r14,%rcx,4), %rdx
addq %rcx, %rdx
movl %eax, (%r15,%rdx,4)
incl (%r14,%rcx,4)
jmp 0x92bf
movl 0xc(%rsp), %esi
movslq %esi, %rdx
incl %esi
movl %esi, 0xc(%rsp)
movq 0x38(%rsp), %rsi
movl %ecx, (%rsi,%rdx,4)
movl 0x80(%r12), %edx
movl %edx, (%rbp,%rcx,4)
movl %eax, (%r15,%rcx,4)
movl $0x1, (%r14,%rcx,4)
movq 0x10(%rsp), %rdi
incl %r13d
movl 0xc(%rdi), %eax
jmp 0x920b
movq 0x20(%rsp), %rdx
incq %rdx
movq 0x58(%rsp), %r15
jmp 0x91d0
testl %r8d, %r8d
jle 0x975d
movq 0x50(%r12), %rdi
movl %r8d, %eax
movq %rax, 0x20(%rsp)
leaq (%rdi,%rax,4), %rsi
callq 0x7839
xorl %edx, %edx
cmpq 0x20(%rsp), %rdx
movq 0x10(%rsp), %rdi
je 0x976e
movq 0x48(%r12), %rcx
movq 0x50(%r12), %rax
movq %rdx, 0x38(%rsp)
movl (%rax,%rdx,4), %r15d
movq 0x20(%rbx), %rdx
movslq %r15d, %r10
movl (%rdx,%r10,4), %r13d
movl (%rcx,%r10,4), %r9d
xorl %eax, %eax
cmpl %r13d, %r9d
jge 0x9359
movq 0x58(%r12), %rax
andl $0x0, (%rax)
movl (%rdx,%r10,4), %eax
subl (%rcx,%r10,4), %eax
movq 0x60(%r12), %rdx
movl %eax, (%rdx)
movl (%rcx,%r10,4), %r9d
pushq $0x1
popq %rax
addl %r15d, %r13d
addl %r15d, %r9d
movq 0x30(%r12), %rcx
movq 0x40(%r12), %rdx
movq 0x70(%r12), %rsi
movq 0x58(%r12), %rdi
movq 0x60(%r12), %r8
movslq %r9d, %r14
movq %r10, %r9
movq %r10, 0x28(%rsp)
movslq %eax, %rbp
cmpq %r14, %r9
jge 0x93c3
movslq (%rdx,%r9,4), %r10
movl (%rcx,%r10,4), %r10d
movslq %r10d, %r10
movl 0x80(%r12), %r11d
cmpl %r11d, (%rsi,%r10,4)
jne 0x93aa
incl (%r8,%r10,4)
jmp 0x93be
movl %r11d, (%rsi,%r10,4)
movl %r10d, (%rdi,%rbp,4)
incl %ebp
movl $0x1, (%r8,%r10,4)
movl %ebp, %eax
incq %r9
jmp 0x9383
incl 0x80(%r12)
movq 0x58(%r12), %rdi
leaq (%rdi,%rbp,4), %rsi
callq 0x7839
movq 0x90(%rsp), %r11
movl %r15d, (%r11)
movq 0x58(%r12), %rdx
testl %ebp, %ebp
movl $0x0, %eax
cmovlel %eax, %ebp
movq 0x60(%r12), %rsi
xorl %edi, %edi
movl %r15d, %r8d
pushq $0x1
popq %rax
movslq %eax, %rcx
cmpq %rdi, %rbp
je 0x943b
movslq (%rdx,%rdi,4), %r9
movslq %r8d, %r10
movl (%rsi,%r9,4), %r8d
movq 0x20(%rbx), %r9
movl %r8d, (%r9,%r10,4)
movslq (%rdx,%rdi,4), %r9
movl %r10d, (%rsi,%r9,4)
addl %r10d, %r8d
cmpl %r13d, %r8d
jge 0x9436
movl %r8d, (%r11,%rcx,4)
incl %ecx
incl 0x4(%rbx)
movl %ecx, %eax
incq %rdi
jmp 0x9400
movq 0x40(%rsp), %rdx
movq 0x28(%rsp), %rsi
cmpl $0x0, (%rdx,%rsi,4)
je 0x947e
movq 0x20(%r12), %rax
pushq $0x1
popq %rdx
cmpq %rcx, %rdx
jge 0x94e6
movslq (%r11,%rdx,4), %rsi
movslq 0x28(%r12), %rdi
movl %esi, (%rax,%rdi,4)
movq 0x40(%rsp), %rdi
movl $0x1, (%rdi,%rsi,4)
incl 0x28(%r12)
incq %rdx
jmp 0x9453
movq 0x20(%rbx), %rdx
movl (%rdx,%rsi,4), %esi
pushq $0x1
popq %rdi
cmpq %rcx, %rdi
jge 0x94a5
movslq (%r11,%rdi,4), %r8
movl (%rdx,%r8,4), %r9d
cmpl %esi, %r9d
cmovgl %r8d, %r15d
cmovgl %r9d, %esi
incq %rdi
jmp 0x9488
movq 0x20(%r12), %rcx
testl %eax, %eax
movl $0x0, %edx
cmovlel %edx, %eax
xorl %edx, %edx
cmpq %rdx, %rax
je 0x94e6
movl (%r11,%rdx,4), %esi
cmpl %r15d, %esi
je 0x94e1
movslq 0x28(%r12), %rdi
movl %esi, (%rcx,%rdi,4)
movslq (%r11,%rdx,4), %rsi
movq 0x40(%rsp), %rdi
movl $0x1, (%rdi,%rsi,4)
incl 0x28(%r12)
incq %rdx
jmp 0x94b6
movq 0x30(%r12), %rax
movq 0x40(%r12), %rcx
movq 0x60(%r12), %rdx
movq 0x28(%rsp), %rsi
movq 0x58(%rsp), %r15
cmpq %r14, %rsi
jge 0x9545
movslq (%rcx,%rsi,4), %rdi
movslq (%rax,%rdi,4), %r8
movslq (%rdx,%r8,4), %r9
leal 0x1(%r9), %r10d
movl %r10d, (%rdx,%r8,4)
movq 0x10(%rbx), %r8
movq 0x18(%rbx), %r10
movslq (%r10,%rdi,4), %r11
movl (%r8,%r9,4), %ebp
movl %ebp, (%r8,%r11,4)
movl %edi, (%r8,%r9,4)
movl %r9d, (%r10,%rdi,4)
movslq (%r8,%r11,4), %r8
movl %r11d, (%r10,%r8,4)
andl $0x0, (%rax,%rdi,4)
incq %rsi
jmp 0x94ff
movq 0x48(%r12), %rax
movq 0x28(%rsp), %rcx
movslq (%rax,%rcx,4), %rdi
movslq %r13d, %rax
subl %edi, %r13d
movq 0x20(%rbx), %r8
movslq %r13d, %rcx
movl (%r8,%rcx,4), %edx
addl %ecx, %edx
decl %edx
leaq (,%rax,4), %rsi
shlq $0x2, %rdi
subq %rdi, %rsi
leaq (%r8,%rsi), %rdi
addq $0x4, %rdi
addq 0x8(%rbx), %rsi
xorl %r8d, %r8d
movl %r13d, %r9d
movl %r9d, (%rsi,%r8,4)
leal (%r8,%r13), %r11d
leaq (%rcx,%r8), %r10
incq %r10
cmpl %edx, %r11d
jne 0x95ad
leaq (%r8,%r13), %r9
incq %r9
cmpq %r15, %r10
jge 0x95ad
addl (%rdi,%r8,4), %edx
incq %r8
cmpq %rax, %r10
jl 0x9589
movq 0x38(%rsp), %rdx
incq %rdx
jmp 0x9302
incl 0x80(%r12)
movq 0x38(%r12), %rax
movq 0x48(%r12), %rcx
movq 0x50(%r12), %rdx
xorl %esi, %esi
movl 0xc(%rsp), %r8d
testl %r8d, %r8d
movl $0x0, %edi
cmovgl %r8d, %edi
xorl %r8d, %r8d
cmpq %rsi, %rdi
je 0x9616
movslq (%rax,%rsi,4), %r9
movl (%rcx,%r9,4), %r10d
movq 0x28(%rsp), %r11
cmpl (%r11,%r9,4), %r10d
jge 0x9611
movslq %r8d, %r10
incl %r8d
movl %r9d, (%rdx,%r10,4)
incq %rsi
jmp 0x95ef
testl %r8d, %r8d
jle 0x975d
movq 0x50(%r12), %rdi
movl %r8d, %eax
movq %rax, 0x38(%rsp)
leaq (%rdi,%rax,4), %rsi
callq 0x7839
movq 0x50(%r12), %rax
movq %rax, 0x50(%rsp)
movq 0x20(%r12), %rax
movq %rax, 0x20(%rsp)
movq 0x48(%r12), %rdx
movq 0x20(%rbx), %rcx
xorl %esi, %esi
movq %rcx, 0x70(%rsp)
cmpq 0x38(%rsp), %rsi
je 0x9764
movq 0x50(%rsp), %rax
movq %rsi, 0x28(%rsp)
movl (%rax,%rsi,4), %r8d
movslq %r8d, %r8
movl (%rdx,%r8,4), %ebp
movl (%rcx,%r8,4), %r9d
movl %r9d, %r10d
subl %ebp, %r10d
movl %r10d, (%rcx,%r8,4)
addl %r8d, %r10d
movl (%rdx,%r8,4), %r15d
movslq %r10d, %r11
movl %r15d, (%rcx,%r11,4)
incl 0x4(%rbx)
movq 0x40(%rsp), %rax
cmpl $0x1, (%rax,%r8,4)
leaq (%rax,%r11,4), %r15
jne 0x96af
movslq 0x28(%r12), %r13
jmp 0x96be
movl (%rcx,%r11,4), %eax
movslq 0x28(%r12), %r13
cmpl (%rcx,%r8,4), %eax
jge 0x96c9
movq 0x20(%rsp), %rax
movl %r10d, (%rax,%r13,4)
jmp 0x96db
movq 0x40(%rsp), %rax
leaq (%rax,%r8,4), %r15
movq 0x20(%rsp), %rax
movl %r8d, (%rax,%r13,4)
incl 0x28(%r12)
movl $0x1, (%r15)
leaq (,%r8,4), %r15
addq 0x40(%r12), %r15
shlq $0x2, %r11
addl %r8d, %r9d
subl %ebp, %r9d
xorl %r13d, %r13d
movslq (%rdx,%r8,4), %rax
cmpq %rax, %r13
jge 0x974b
movslq (%r15,%r13,4), %rax
movq 0x10(%rbx), %rbp
movq 0x18(%rbx), %r14
movslq (%r14,%rax,4), %rcx
leaq (%r11,%rbp), %rsi
movl (%rsi,%r13,4), %edi
movl %edi, (%rbp,%rcx,4)
movl %eax, (%rsi,%r13,4)
leal (%r9,%r13), %esi
movl %esi, (%r14,%rax,4)
movslq (%rbp,%rcx,4), %rax
movl %ecx, (%r14,%rax,4)
movq 0x8(%rbx), %rax
addq %r11, %rax
movl %r10d, (%rax,%r13,4)
incq %r13
jmp 0x9701
movq 0x28(%rsp), %rsi
incq %rsi
movq 0x70(%rsp), %rcx
jmp 0x9659
movq 0x10(%rsp), %rdi
jmp 0x976e
movq 0x10(%rsp), %rdi
movq 0x58(%rsp), %r15
movl 0x7c(%rsp), %eax
cmpl 0x78(%rsp), %eax
jl 0x90b8
jmp 0x8fd7
movl $0x0, 0xc(%rsp)
movq 0x68(%rsp), %rdx
cmpq 0x88(%rsp), %rdx
jge 0x9110
movq 0x10(%rbx), %rcx
movq %rdx, 0x70(%rsp)
movl (%rcx,%rdx,4), %ecx
movl %ecx, 0x1c(%rsp)
movl %ecx, 0x34(%rsp)
movq 0x78(%r12), %r15
movq 0x30(%r12), %rbp
movq 0x38(%r12), %rcx
movq %rcx, 0x50(%rsp)
movq 0x70(%r12), %r13
movq 0x40(%r12), %rcx
movq %rcx, 0x38(%rsp)
movq 0x48(%r12), %rcx
movq %rcx, 0x20(%rsp)
xorl %r14d, %r14d
movl %r14d, 0x4c(%rsp)
movl 0x1c(%rsp), %esi
cmpl %eax, %esi
movl %eax, %ecx
movl $0x0, %edx
cmovll %edx, %ecx
movq 0x60(%rsp), %rdx
cmovlq %rdi, %rdx
subl %ecx, %esi
movq 0x20(%rdx), %rcx
movslq %esi, %rdx
cmpl (%rcx,%rdx,4), %r14d
jge 0x98e2
leaq 0x98(%rsp), %rdi
leaq 0x34(%rsp), %rsi
leaq 0x4c(%rsp), %rdx
callq 0x99e4
cltq
movl 0x80(%r12), %edx
cmpl %edx, (%r15,%rax,4)
jne 0x983e
incl (%rbp,%rax,4)
jmp 0x989a
movq 0x8(%rbx), %rcx
movq 0x18(%rbx), %rsi
movslq (%rsi,%rax,4), %rsi
movl (%rcx,%rsi,4), %ecx
movslq %ecx, %rcx
movq 0x28(%rsp), %rsi
cmpl $0x2, (%rsi,%rcx,4)
jl 0x989a
movl %edx, (%r15,%rax,4)
movl $0x1, (%rbp,%rax,4)
movl (%r13,%rcx,4), %edx
cmpl 0x80(%r12), %edx
movq 0x10(%rsp), %rdi
jne 0x98aa
movq 0x20(%rsp), %r9
movl (%r9,%rcx,4), %edx
leal 0x1(%rdx), %esi
movl %esi, (%r9,%rcx,4)
addl %edx, %ecx
movslq %ecx, %rcx
movq 0x38(%rsp), %rdx
movl %eax, (%rdx,%rcx,4)
jmp 0x989f
movq 0x10(%rsp), %rdi
incl %r14d
movl 0xc(%rdi), %eax
jmp 0x97e0
movl 0xc(%rsp), %esi
movslq %esi, %rdx
incl %esi
movl %esi, 0xc(%rsp)
movq 0x50(%rsp), %rsi
movl %ecx, (%rsi,%rdx,4)
movl 0x80(%r12), %edx
movl %edx, (%r13,%rcx,4)
movq 0x38(%rsp), %rdx
movl %eax, (%rdx,%rcx,4)
movq 0x20(%rsp), %rax
movl $0x1, (%rax,%rcx,4)
jmp 0x989f
movq 0x70(%rsp), %rdx
incq %rdx
movq 0x58(%rsp), %r15
jmp 0x978e
xorl %eax, %eax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r12, %rdi
movq %rbx, %rsi
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x9932