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

	Graph* g1 = aG1;
	Graph* g2 = aG2;

	int32_t n = g1->numNode;
	int32_t* d1 = g1->d;
	char* one1 = g1->one;
	int32_t** neigh1 = g1->e;
	int32_t* d2 = g2->d;
	char* one2 = g2->one;
	int32_t** neigh2 = g2->e;
	int32_t numNode = aColoring->numNode;
	int32_t* perm = aColoring->perm;
	int32_t* inv = aColoring->inv;
	int32_t* cellSize = aColoring->cellSize;
	int32_t* color = aColoring->color;

	int32_t i, j, k, sc, ind, currCell, cellEnd, visitCellInd;
	int32_t u, du, v, adj, cell, splitInd, splitCountInd, count, size, endIdx, newCell;
	int32_t numDeleted = 0;

	//check if there are coreness-1 vertices.
	bool hasDegreeOne = false;
	for(i = 0; i < n; ++i) {
		if( d1[i] == 1 ){
			hasDegreeOne = true;
			break;
		}
	}
	if( hasDegreeOne == false )
		return 0;

	//now there is at least one degree one vertex

	//push cells having degree one vertices to cellStack
	stackSize = 0;
	for( i = 0; i < numNode; i += cellSize[i] ) {
		u = perm[i];
		du = (u < n) ? d1[u] : d2[u - n];
		if( du == 1 ) {
			cellStack[stackSize] = i;
			++stackSize;
		}
	}

	ind = 0;
	while( ind < stackSize ) {
		if( global_mark > INFINITY ) {
			memset(markCell, 0, sizeof(int32_t) * n);
			memset(markNode, 0, sizeof(int32_t) * n);
			global_mark = 0;
		}
		++global_mark;

		//Step 1. select a cell from cellStack and count the cell
		currCell = cellStack[ind];
		++ind;

		cellEnd = currCell + cellSize[currCell];
		visitCellInd = 0;
		for(i = currCell; i < cellEnd; ++i) {
			u = perm[i];
			if(u < n) { //g1
				adj = *(neigh1[u]); //the only neighbor of u
				if( d1[adj] != 1 ) {
					d1[u] = -1;
					one1[u] = 1;
				}

				if( markNode[adj] == global_mark ) {
					++(neighCount[adj]);
				}
				else { //adj is visited first time
					cell = color[ inv[adj] ];
					markNode[adj] = global_mark;
					neighCount[adj] = 1;
					if( markCell[cell] != global_mark ) { //cell is visited first time
						visitCell[visitCellInd] = cell;
						++visitCellInd;
						markCell[cell] = global_mark;
						visitNode[cell] = adj;
						numVisitNode[cell] = 1;
					}
					else {
						visitNode[cell + numVisitNode[cell]] = adj;
						++(numVisitNode[cell]);
					}
				}
			}
			else { //g2
				adj = *(neigh2[u - n]); //the only neighbor of u
				if( d2[adj] != 1 ) {
					d2[u - n] = -1;
					one2[u - n] = 1;
				}

				if( markNode[adj + n] == global_mark ) {
					++(neighCount[adj + n]);
				}
				else { //adj is visited first time
					cell = color[ inv[adj + n] ];
					markNode[adj + n] = global_mark;
					neighCount[adj + n] = 1;
					if( markCell[cell] != global_mark ) { //cell is visited first time
						visitCell[visitCellInd] = cell;
						++visitCellInd;
						markCell[cell] = global_mark;
						visitNode[cell] = adj + n;
						numVisitNode[cell] = 1;
					}
					else {
						visitNode[cell + numVisitNode[cell]] = adj + n;
						++(numVisitNode[cell]);
					}
				}
			} //if-else ( u < n )
		} //for (i)
		++global_mark;

		//Step 2. find out cells to split & delete edges whose degree not 1
		sort(visitCell, visitCell+visitCellInd);
		splitInd = 0;
		splitCell[0] = numNode;
		for(j = 0; j < visitCellInd; ++j) {
			cell = visitCell[j]; //for each visited cell
			//TODO: I think we have always (numVisitNode[cell] > 0).
			if( numVisitNode[cell] > 0 && numVisitNode[cell] < cellSize[cell] ) {
				splitCell[splitInd] = cell;
				++splitInd;
			}
			else {
				cellEnd = cell + cellSize[cell];
				count = neighCount[ perm[cell] ];
				for(i = cell + 1; i < cellEnd; ++i) {
					if( neighCount[ perm[i] ] != count ) {
						splitCell[splitInd] = cell;
						++splitInd;
						break;
					}
				}
				if( i == cellEnd ) { //cell does not split
					u = perm[cell];
					du = (u < n) ? d1[u] : d2[u - n];
					if( du != 1 ) {
						for(k = cell; k < cellEnd; ++k) {
							v = perm[k]; //each vertex in this cell
							deleteEdge(v, neighCount[v], g1, g2);
							numDeleted += neighCount[v];
						}
						//if degree becomes 1 after deleting edges
						du = (u < n) ? d1[u] : d2[u - n];
						if( du == 1 ) {
							cellStack[stackSize] = cell;
							++stackSize;
						}
					} //if (du != 1)
				} //if (i == cellEnd)
			} //if-else (numVisitNode[cell] < cellSize[cell])
		} //for (j)

		//Step 3. split the cells in splitCell
		if( splitInd > 0 ) {
			for(sc = 0; sc < splitInd; ++sc) { //for each cell to split
				cell = splitCell[sc];
				cellEnd = cell + cellSize[cell];

				//Step 3-1. count #vertices of each new cell
				splitCountInd = 0;
				if( numVisitNode[cell] < cellSize[cell] ) {
					splitCount[splitCountInd] = 0;
					++splitCountInd;
					splitPos[0] = cellSize[cell] - numVisitNode[cell];
				}
				endIdx = cell + numVisitNode[cell];
				for(i = cell; i < endIdx; ++i) {
					count = neighCount[ visitNode[i] ];
					//Note that markCell marks 'count' in below.
					if( markCell[count] != global_mark ) {
						markCell[count] = global_mark;
						splitCount[splitCountInd] = count;
						++splitCountInd;
						splitPos[count] = 1;
					}
					else {
						++(splitPos[count]);
					}
				} //for (i)
				++global_mark;

				sort(splitCount, splitCount + splitCountInd);
				aColoring->numCell += (splitCountInd - 1);

				//Step 3-2. compute start position of each new cell
				i = cell;
				for(k = 0; k < splitCountInd; ++k) {
					size = splitPos[ splitCount[k] ];
					cellSize[i] = size;
					splitPos[ splitCount[k] ] = i;
					i += size;
				}

				//Step 3-3. move vertices to its appropriate new cells
				endIdx = cell + numVisitNode[cell];
				for(i = cell; i < endIdx; ++i) {
					u = visitNode[i];
					deleteEdge(u, neighCount[u], g1, g2);
					numDeleted += neighCount[u];
					j = splitPos[ neighCount[u] ]; //where u goes
					++(splitPos[ neighCount[u] ]);
					k = inv[u]; //where u was

					perm[k] = perm[j];
					perm[j] = u;
					inv[u] = j;
					inv[ perm[k] ] = k;
					neighCount[u] = 0;
				}

				//Step 3-4. recolor the vertices in new cells
				newCell = cellEnd - numVisitNode[cell];
				i = newCell;
				endIdx = newCell + cellSize[newCell] - 1;
				do {
					color[i] = newCell;
					if( i == endIdx ) {
						newCell = i + 1;
						if( newCell < numNode )
							endIdx = newCell + cellSize[newCell] - 1;
					}
				} while( ++i < cellEnd );

				//Step 3-5. push the new cells to the stack
				for(i = cell, k = 0; k < splitCountInd; i += cellSize[i], ++k) {
					if( k > 0 || splitCount[0] > 0 ) {
						u = perm[i];
						du = (u < n) ? d1[u] : d2[u - n];
						if( du == 1 ) {
							cellStack[stackSize] = i;
							++stackSize;
						}
					}
				}
			} //for (sc)
		} //if( splitInd > 0 )
	} //while (ind < stackSize)

	return numDeleted;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x110, %rsp            # imm = 0x110
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0xf8(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x30(%rbp), %rax
movl 0xc(%rax), %eax
movl %eax, -0x3c(%rbp)
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x30(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0x50(%rbp)
movq -0x30(%rbp), %rax
movq 0x38(%rax), %rax
movq %rax, -0x58(%rbp)
movq -0x38(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x60(%rbp)
movq -0x38(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0x68(%rbp)
movq -0x38(%rbp), %rax
movq 0x38(%rax), %rax
movq %rax, -0x70(%rbp)
movq -0x18(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x74(%rbp)
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x80(%rbp)
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x88(%rbp)
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x90(%rbp)
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x98(%rbp)
movl $0x0, -0xe8(%rbp)
movb $0x0, -0xe9(%rbp)
movl $0x0, -0x9c(%rbp)
movl -0x9c(%rbp), %eax
cmpl -0x3c(%rbp), %eax
jge 0x1444d
movq -0x48(%rbp), %rax
movslq -0x9c(%rbp), %rcx
cmpl $0x1, (%rax,%rcx,4)
jne 0x1443a
movb $0x1, -0xe9(%rbp)
jmp 0x1444d
jmp 0x1443c
movl -0x9c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x9c(%rbp)
jmp 0x14415
movb -0xe9(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x14469
movl $0x0, -0x4(%rbp)
jmp 0x15314
movq -0xf8(%rbp), %rax
movl $0x0, 0x28(%rax)
movl $0x0, -0x9c(%rbp)
movl -0x9c(%rbp), %eax
cmpl -0x74(%rbp), %eax
jge 0x14538
movq -0x80(%rbp), %rax
movslq -0x9c(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0xbc(%rbp)
movl -0xbc(%rbp), %eax
cmpl -0x3c(%rbp), %eax
jge 0x144c5
movq -0x48(%rbp), %rax
movslq -0xbc(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0xfc(%rbp)
jmp 0x144de
movq -0x60(%rbp), %rax
movl -0xbc(%rbp), %ecx
subl -0x3c(%rbp), %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0xfc(%rbp)
movl -0xfc(%rbp), %eax
movl %eax, -0xc0(%rbp)
cmpl $0x1, -0xc0(%rbp)
jne 0x14514
movq -0xf8(%rbp), %rax
movl -0x9c(%rbp), %esi
movq 0x20(%rax), %rcx
movslq 0x28(%rax), %rdx
movl %esi, (%rcx,%rdx,4)
movl 0x28(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x28(%rax)
jmp 0x14516
movq -0x90(%rbp), %rax
movslq -0x9c(%rbp), %rcx
movl (%rax,%rcx,4), %eax
addl -0x9c(%rbp), %eax
movl %eax, -0x9c(%rbp)
jmp 0x14481
movl $0x0, -0xac(%rbp)
movq -0xf8(%rbp), %rcx
movl -0xac(%rbp), %eax
cmpl 0x28(%rcx), %eax
jge 0x1530b
movq -0xf8(%rbp), %rax
cmpl $0x77359400, 0x80(%rax) # imm = 0x77359400
jle 0x145b0
movq -0xf8(%rbp), %rax
movq 0x70(%rax), %rdi
movslq -0x3c(%rbp), %rdx
shlq $0x2, %rdx
xorl %esi, %esi
callq 0x3110
movq -0xf8(%rbp), %rax
movq 0x78(%rax), %rdi
movslq -0x3c(%rbp), %rdx
shlq $0x2, %rdx
xorl %esi, %esi
callq 0x3110
movq -0xf8(%rbp), %rax
movl $0x0, 0x80(%rax)
movq -0xf8(%rbp), %rax
movl 0x80(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x80(%rax)
movq 0x20(%rax), %rax
movslq -0xac(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0xb0(%rbp)
movl -0xac(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xac(%rbp)
movl -0xb0(%rbp), %eax
movq -0x90(%rbp), %rcx
movslq -0xb0(%rbp), %rdx
addl (%rcx,%rdx,4), %eax
movl %eax, -0xb4(%rbp)
movl $0x0, -0xb8(%rbp)
movl -0xb0(%rbp), %eax
movl %eax, -0x9c(%rbp)
movl -0x9c(%rbp), %eax
cmpl -0xb4(%rbp), %eax
jge 0x149c2
movq -0x80(%rbp), %rax
movslq -0x9c(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0xbc(%rbp)
movl -0xbc(%rbp), %eax
cmpl -0x3c(%rbp), %eax
jge 0x147e9
movq -0x58(%rbp), %rax
movslq -0xbc(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl (%rax), %eax
movl %eax, -0xc8(%rbp)
movq -0x48(%rbp), %rax
movslq -0xc8(%rbp), %rcx
cmpl $0x1, (%rax,%rcx,4)
je 0x1469a
movq -0x48(%rbp), %rax
movslq -0xbc(%rbp), %rcx
movl $0xffffffff, (%rax,%rcx,4) # imm = 0xFFFFFFFF
movq -0x50(%rbp), %rax
movslq -0xbc(%rbp), %rcx
movb $0x1, (%rax,%rcx)
movq -0xf8(%rbp), %rcx
movq 0x78(%rcx), %rax
movslq -0xc8(%rbp), %rdx
movl (%rax,%rdx,4), %eax
cmpl 0x80(%rcx), %eax
jne 0x146d7
movq -0xf8(%rbp), %rax
movq 0x30(%rax), %rax
movslq -0xc8(%rbp), %rcx
movl (%rax,%rcx,4), %edx
addl $0x1, %edx
movl %edx, (%rax,%rcx,4)
jmp 0x147e4
movq -0xf8(%rbp), %rcx
movq -0x98(%rbp), %rax
movq -0x88(%rbp), %rdx
movslq -0xc8(%rbp), %rsi
movslq (%rdx,%rsi,4), %rdx
movl (%rax,%rdx,4), %eax
movl %eax, -0xcc(%rbp)
movl 0x80(%rcx), %esi
movq 0x78(%rcx), %rax
movslq -0xc8(%rbp), %rdx
movl %esi, (%rax,%rdx,4)
movq 0x30(%rcx), %rax
movslq -0xc8(%rbp), %rdx
movl $0x1, (%rax,%rdx,4)
movq 0x70(%rcx), %rax
movslq -0xcc(%rbp), %rdx
movl (%rax,%rdx,4), %eax
cmpl 0x80(%rcx), %eax
je 0x147a2
movq -0xf8(%rbp), %rax
movl -0xcc(%rbp), %esi
movq 0x38(%rax), %rcx
movslq -0xb8(%rbp), %rdx
movl %esi, (%rcx,%rdx,4)
movl -0xb8(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, -0xb8(%rbp)
movl 0x80(%rax), %esi
movq 0x70(%rax), %rcx
movslq -0xcc(%rbp), %rdx
movl %esi, (%rcx,%rdx,4)
movl -0xc8(%rbp), %esi
movq 0x40(%rax), %rcx
movslq -0xcc(%rbp), %rdx
movl %esi, (%rcx,%rdx,4)
movq 0x48(%rax), %rax
movslq -0xcc(%rbp), %rcx
movl $0x1, (%rax,%rcx,4)
jmp 0x147e2
movq -0xf8(%rbp), %rax
movl -0xc8(%rbp), %esi
movq 0x40(%rax), %rcx
movl -0xcc(%rbp), %edx
movq 0x48(%rax), %rdi
movslq -0xcc(%rbp), %r8
addl (%rdi,%r8,4), %edx
movslq %edx, %rdx
movl %esi, (%rcx,%rdx,4)
movq 0x48(%rax), %rax
movslq -0xcc(%rbp), %rcx
movl (%rax,%rcx,4), %edx
addl $0x1, %edx
movl %edx, (%rax,%rcx,4)
jmp 0x147e4
jmp 0x149ac
movq -0x70(%rbp), %rax
movl -0xbc(%rbp), %ecx
subl -0x3c(%rbp), %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movl (%rax), %eax
movl %eax, -0xc8(%rbp)
movq -0x60(%rbp), %rax
movslq -0xc8(%rbp), %rcx
cmpl $0x1, (%rax,%rcx,4)
je 0x14841
movq -0x60(%rbp), %rax
movl -0xbc(%rbp), %ecx
subl -0x3c(%rbp), %ecx
movslq %ecx, %rcx
movl $0xffffffff, (%rax,%rcx,4) # imm = 0xFFFFFFFF
movq -0x68(%rbp), %rax
movl -0xbc(%rbp), %ecx
subl -0x3c(%rbp), %ecx
movslq %ecx, %rcx
movb $0x1, (%rax,%rcx)
movq -0xf8(%rbp), %rcx
movq 0x78(%rcx), %rax
movl -0xc8(%rbp), %edx
addl -0x3c(%rbp), %edx
movslq %edx, %rdx
movl (%rax,%rdx,4), %eax
cmpl 0x80(%rcx), %eax
jne 0x14888
movq -0xf8(%rbp), %rax
movq 0x30(%rax), %rax
movl -0xc8(%rbp), %ecx
addl -0x3c(%rbp), %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %edx
addl $0x1, %edx
movl %edx, (%rax,%rcx,4)
jmp 0x149aa
movq -0xf8(%rbp), %rcx
movq -0x98(%rbp), %rax
movq -0x88(%rbp), %rdx
movl -0xc8(%rbp), %esi
addl -0x3c(%rbp), %esi
movslq %esi, %rsi
movslq (%rdx,%rsi,4), %rdx
movl (%rax,%rdx,4), %eax
movl %eax, -0xcc(%rbp)
movl 0x80(%rcx), %esi
movq 0x78(%rcx), %rax
movl -0xc8(%rbp), %edx
addl -0x3c(%rbp), %edx
movslq %edx, %rdx
movl %esi, (%rax,%rdx,4)
movq 0x30(%rcx), %rax
movl -0xc8(%rbp), %edx
addl -0x3c(%rbp), %edx
movslq %edx, %rdx
movl $0x1, (%rax,%rdx,4)
movq 0x70(%rcx), %rax
movslq -0xcc(%rbp), %rdx
movl (%rax,%rdx,4), %eax
cmpl 0x80(%rcx), %eax
je 0x14965
movq -0xf8(%rbp), %rax
movl -0xcc(%rbp), %esi
movq 0x38(%rax), %rcx
movslq -0xb8(%rbp), %rdx
movl %esi, (%rcx,%rdx,4)
movl -0xb8(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, -0xb8(%rbp)
movl 0x80(%rax), %esi
movq 0x70(%rax), %rcx
movslq -0xcc(%rbp), %rdx
movl %esi, (%rcx,%rdx,4)
movl -0xc8(%rbp), %esi
addl -0x3c(%rbp), %esi
movq 0x40(%rax), %rcx
movslq -0xcc(%rbp), %rdx
movl %esi, (%rcx,%rdx,4)
movq 0x48(%rax), %rax
movslq -0xcc(%rbp), %rcx
movl $0x1, (%rax,%rcx,4)
jmp 0x149a8
movq -0xf8(%rbp), %rax
movl -0xc8(%rbp), %esi
addl -0x3c(%rbp), %esi
movq 0x40(%rax), %rcx
movl -0xcc(%rbp), %edx
movq 0x48(%rax), %rdi
movslq -0xcc(%rbp), %r8
addl (%rdi,%r8,4), %edx
movslq %edx, %rdx
movl %esi, (%rcx,%rdx,4)
movq 0x48(%rax), %rax
movslq -0xcc(%rbp), %rcx
movl (%rax,%rcx,4), %edx
addl $0x1, %edx
movl %edx, (%rax,%rcx,4)
jmp 0x149aa
jmp 0x149ac
jmp 0x149ae
movl -0x9c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x9c(%rbp)
jmp 0x1461c
movq -0xf8(%rbp), %rax
movl 0x80(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x80(%rax)
movq 0x38(%rax), %rdi
movq 0x38(%rax), %rsi
movslq -0xb8(%rbp), %rax
shlq $0x2, %rax
addq %rax, %rsi
callq 0x10940
movq -0xf8(%rbp), %rax
movl $0x0, -0xd0(%rbp)
movl -0x74(%rbp), %ecx
movq 0x50(%rax), %rax
movl %ecx, (%rax)
movl $0x0, -0xa0(%rbp)
movl -0xa0(%rbp), %eax
cmpl -0xb8(%rbp), %eax
jge 0x14cfa
movq -0xf8(%rbp), %rax
movq 0x38(%rax), %rcx
movslq -0xa0(%rbp), %rdx
movl (%rcx,%rdx,4), %ecx
movl %ecx, -0xcc(%rbp)
movq 0x48(%rax), %rax
movslq -0xcc(%rbp), %rcx
cmpl $0x0, (%rax,%rcx,4)
jle 0x14aac
movq -0xf8(%rbp), %rax
movq 0x48(%rax), %rax
movslq -0xcc(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movq -0x90(%rbp), %rcx
movslq -0xcc(%rbp), %rdx
cmpl (%rcx,%rdx,4), %eax
jge 0x14aac
movq -0xf8(%rbp), %rax
movl -0xcc(%rbp), %edx
movq 0x50(%rax), %rax
movslq -0xd0(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0xd0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xd0(%rbp)
jmp 0x14ce4
movq -0xf8(%rbp), %rax
movl -0xcc(%rbp), %ecx
movq -0x90(%rbp), %rdx
movslq -0xcc(%rbp), %rsi
addl (%rdx,%rsi,4), %ecx
movl %ecx, -0xb4(%rbp)
movq 0x30(%rax), %rax
movq -0x80(%rbp), %rcx
movslq -0xcc(%rbp), %rdx
movslq (%rcx,%rdx,4), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0xd8(%rbp)
movl -0xcc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x9c(%rbp)
movl -0x9c(%rbp), %eax
cmpl -0xb4(%rbp), %eax
jge 0x14b6d
movq -0xf8(%rbp), %rax
movq 0x30(%rax), %rax
movq -0x80(%rbp), %rcx
movslq -0x9c(%rbp), %rdx
movslq (%rcx,%rdx,4), %rcx
movl (%rax,%rcx,4), %eax
cmpl -0xd8(%rbp), %eax
je 0x14b5a
movq -0xf8(%rbp), %rax
movl -0xcc(%rbp), %edx
movq 0x50(%rax), %rax
movslq -0xd0(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0xd0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xd0(%rbp)
jmp 0x14b6d
jmp 0x14b5c
movl -0x9c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x9c(%rbp)
jmp 0x14afb
movl -0x9c(%rbp), %eax
cmpl -0xb4(%rbp), %eax
jne 0x14ce2
movq -0x80(%rbp), %rax
movslq -0xcc(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0xbc(%rbp)
movl -0xbc(%rbp), %eax
cmpl -0x3c(%rbp), %eax
jge 0x14bb4
movq -0x48(%rbp), %rax
movslq -0xbc(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x100(%rbp)
jmp 0x14bcd
movq -0x60(%rbp), %rax
movl -0xbc(%rbp), %ecx
subl -0x3c(%rbp), %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x100(%rbp)
movl -0x100(%rbp), %eax
movl %eax, -0xc0(%rbp)
cmpl $0x1, -0xc0(%rbp)
je 0x14ce0
movl -0xcc(%rbp), %eax
movl %eax, -0xa4(%rbp)
movl -0xa4(%rbp), %eax
cmpl -0xb4(%rbp), %eax
jge 0x14c6e
movq -0xf8(%rbp), %rdi
movq -0x80(%rbp), %rax
movslq -0xa4(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0xc4(%rbp)
movl -0xc4(%rbp), %esi
movq 0x30(%rdi), %rax
movslq -0xc4(%rbp), %rcx
movl (%rax,%rcx,4), %edx
movq -0x30(%rbp), %rcx
movq -0x38(%rbp), %r8
callq 0x16910
movq -0xf8(%rbp), %rax
movq 0x30(%rax), %rax
movslq -0xc4(%rbp), %rcx
movl (%rax,%rcx,4), %eax
addl -0xe8(%rbp), %eax
movl %eax, -0xe8(%rbp)
movl -0xa4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa4(%rbp)
jmp 0x14bf2
movl -0xbc(%rbp), %eax
cmpl -0x3c(%rbp), %eax
jge 0x14c8f
movq -0x48(%rbp), %rax
movslq -0xbc(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x104(%rbp)
jmp 0x14ca8
movq -0x60(%rbp), %rax
movl -0xbc(%rbp), %ecx
subl -0x3c(%rbp), %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x104(%rbp)
movl -0x104(%rbp), %eax
movl %eax, -0xc0(%rbp)
cmpl $0x1, -0xc0(%rbp)
jne 0x14cde
movq -0xf8(%rbp), %rax
movl -0xcc(%rbp), %esi
movq 0x20(%rax), %rcx
movslq 0x28(%rax), %rdx
movl %esi, (%rcx,%rdx,4)
movl 0x28(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x28(%rax)
jmp 0x14ce0
jmp 0x14ce2
jmp 0x14ce4
jmp 0x14ce6
movl -0xa0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa0(%rbp)
jmp 0x14a17
cmpl $0x0, -0xd0(%rbp)
jle 0x15306
movl $0x0, -0xa8(%rbp)
movl -0xa8(%rbp), %eax
cmpl -0xd0(%rbp), %eax
jge 0x15304
movq -0xf8(%rbp), %rax
movq 0x50(%rax), %rcx
movslq -0xa8(%rbp), %rdx
movl (%rcx,%rdx,4), %ecx
movl %ecx, -0xcc(%rbp)
movl -0xcc(%rbp), %ecx
movq -0x90(%rbp), %rdx
movslq -0xcc(%rbp), %rsi
addl (%rdx,%rsi,4), %ecx
movl %ecx, -0xb4(%rbp)
movl $0x0, -0xd4(%rbp)
movq 0x48(%rax), %rax
movslq -0xcc(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movq -0x90(%rbp), %rcx
movslq -0xcc(%rbp), %rdx
cmpl (%rcx,%rdx,4), %eax
jge 0x14dd3
movq -0xf8(%rbp), %rax
movq 0x58(%rax), %rcx
movslq -0xd4(%rbp), %rdx
movl $0x0, (%rcx,%rdx,4)
movl -0xd4(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, -0xd4(%rbp)
movq -0x90(%rbp), %rcx
movslq -0xcc(%rbp), %rdx
movl (%rcx,%rdx,4), %ecx
movq 0x48(%rax), %rdx
movslq -0xcc(%rbp), %rsi
subl (%rdx,%rsi,4), %ecx
movq 0x60(%rax), %rax
movl %ecx, (%rax)
movq -0xf8(%rbp), %rcx
movl -0xcc(%rbp), %eax
movq 0x48(%rcx), %rcx
movslq -0xcc(%rbp), %rdx
addl (%rcx,%rdx,4), %eax
movl %eax, -0xe0(%rbp)
movl -0xcc(%rbp), %eax
movl %eax, -0x9c(%rbp)
movl -0x9c(%rbp), %eax
cmpl -0xe0(%rbp), %eax
jge 0x14ece
movq -0xf8(%rbp), %rcx
movq 0x30(%rcx), %rax
movq 0x40(%rcx), %rdx
movslq -0x9c(%rbp), %rsi
movslq (%rdx,%rsi,4), %rdx
movl (%rax,%rdx,4), %eax
movl %eax, -0xd8(%rbp)
movq 0x70(%rcx), %rax
movslq -0xd8(%rbp), %rdx
movl (%rax,%rdx,4), %eax
cmpl 0x80(%rcx), %eax
je 0x14e9d
movq -0xf8(%rbp), %rax
movl 0x80(%rax), %esi
movq 0x70(%rax), %rcx
movslq -0xd8(%rbp), %rdx
movl %esi, (%rcx,%rdx,4)
movl -0xd8(%rbp), %esi
movq 0x58(%rax), %rcx
movslq -0xd4(%rbp), %rdx
movl %esi, (%rcx,%rdx,4)
movl -0xd4(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, -0xd4(%rbp)
movq 0x60(%rax), %rax
movslq -0xd8(%rbp), %rcx
movl $0x1, (%rax,%rcx,4)
jmp 0x14eb8
movq -0xf8(%rbp), %rax
movq 0x60(%rax), %rax
movslq -0xd8(%rbp), %rcx
movl (%rax,%rcx,4), %edx
addl $0x1, %edx
movl %edx, (%rax,%rcx,4)
jmp 0x14eba
movl -0x9c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x9c(%rbp)
jmp 0x14e00
movq -0xf8(%rbp), %rax
movl 0x80(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x80(%rax)
movq 0x58(%rax), %rdi
movq 0x58(%rax), %rsi
movslq -0xd4(%rbp), %rax
shlq $0x2, %rax
addq %rax, %rsi
callq 0x10940
movl -0xd4(%rbp), %ecx
subl $0x1, %ecx
movq -0x18(%rbp), %rax
addl 0x4(%rax), %ecx
movl %ecx, 0x4(%rax)
movl -0xcc(%rbp), %eax
movl %eax, -0x9c(%rbp)
movl $0x0, -0xa4(%rbp)
movl -0xa4(%rbp), %eax
cmpl -0xd4(%rbp), %eax
jge 0x14fb2
movq -0xf8(%rbp), %rcx
movq 0x60(%rcx), %rax
movq 0x58(%rcx), %rdx
movslq -0xa4(%rbp), %rsi
movslq (%rdx,%rsi,4), %rdx
movl (%rax,%rdx,4), %eax
movl %eax, -0xdc(%rbp)
movl -0xdc(%rbp), %esi
movq -0x90(%rbp), %rax
movslq -0x9c(%rbp), %rdx
movl %esi, (%rax,%rdx,4)
movl -0x9c(%rbp), %edx
movq 0x60(%rcx), %rax
movq 0x58(%rcx), %rcx
movslq -0xa4(%rbp), %rsi
movslq (%rcx,%rsi,4), %rcx
movl %edx, (%rax,%rcx,4)
movl -0xdc(%rbp), %eax
addl -0x9c(%rbp), %eax
movl %eax, -0x9c(%rbp)
movl -0xa4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa4(%rbp)
jmp 0x14f28
movq -0xf8(%rbp), %rcx
movl -0xcc(%rbp), %eax
movq 0x48(%rcx), %rcx
movslq -0xcc(%rbp), %rdx
addl (%rcx,%rdx,4), %eax
movl %eax, -0xe0(%rbp)
movl -0xcc(%rbp), %eax
movl %eax, -0x9c(%rbp)
movl -0x9c(%rbp), %eax
cmpl -0xe0(%rbp), %eax
jge 0x15129
movq -0xf8(%rbp), %rdi
movq 0x40(%rdi), %rax
movslq -0x9c(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0xbc(%rbp)
movl -0xbc(%rbp), %esi
movq 0x30(%rdi), %rax
movslq -0xbc(%rbp), %rcx
movl (%rax,%rcx,4), %edx
movq -0x30(%rbp), %rcx
movq -0x38(%rbp), %r8
callq 0x16910
movq -0xf8(%rbp), %rax
movq 0x30(%rax), %rcx
movslq -0xbc(%rbp), %rdx
movl (%rcx,%rdx,4), %ecx
addl -0xe8(%rbp), %ecx
movl %ecx, -0xe8(%rbp)
movq 0x60(%rax), %rcx
movq 0x30(%rax), %rdx
movslq -0xbc(%rbp), %rsi
movslq (%rdx,%rsi,4), %rdx
movl (%rcx,%rdx,4), %ecx
movl %ecx, -0xa0(%rbp)
movq 0x60(%rax), %rcx
movq 0x30(%rax), %rdx
movslq -0xbc(%rbp), %rsi
movslq (%rdx,%rsi,4), %rdx
movl (%rcx,%rdx,4), %esi
addl $0x1, %esi
movl %esi, (%rcx,%rdx,4)
movq -0x88(%rbp), %rcx
movslq -0xbc(%rbp), %rdx
movl (%rcx,%rdx,4), %ecx
movl %ecx, -0xa4(%rbp)
movq -0x80(%rbp), %rcx
movslq -0xa0(%rbp), %rdx
movl (%rcx,%rdx,4), %esi
movq -0x80(%rbp), %rcx
movslq -0xa4(%rbp), %rdx
movl %esi, (%rcx,%rdx,4)
movl -0xbc(%rbp), %esi
movq -0x80(%rbp), %rcx
movslq -0xa0(%rbp), %rdx
movl %esi, (%rcx,%rdx,4)
movl -0xa0(%rbp), %esi
movq -0x88(%rbp), %rcx
movslq -0xbc(%rbp), %rdx
movl %esi, (%rcx,%rdx,4)
movl -0xa4(%rbp), %esi
movq -0x88(%rbp), %rcx
movq -0x80(%rbp), %rdx
movslq -0xa4(%rbp), %rdi
movslq (%rdx,%rdi,4), %rdx
movl %esi, (%rcx,%rdx,4)
movq 0x30(%rax), %rax
movslq -0xbc(%rbp), %rcx
movl $0x0, (%rax,%rcx,4)
movl -0x9c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x9c(%rbp)
jmp 0x14fdf
movq -0xf8(%rbp), %rcx
movl -0xb4(%rbp), %eax
movq 0x48(%rcx), %rcx
movslq -0xcc(%rbp), %rdx
subl (%rcx,%rdx,4), %eax
movl %eax, -0xe4(%rbp)
movl -0xe4(%rbp), %eax
movl %eax, -0x9c(%rbp)
movl -0xe4(%rbp), %eax
movq -0x90(%rbp), %rcx
movslq -0xe4(%rbp), %rdx
addl (%rcx,%rdx,4), %eax
subl $0x1, %eax
movl %eax, -0xe0(%rbp)
movl -0xe4(%rbp), %edx
movq -0x98(%rbp), %rax
movslq -0x9c(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x9c(%rbp), %eax
cmpl -0xe0(%rbp), %eax
jne 0x151d7
movl -0x9c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xe4(%rbp)
movl -0xe4(%rbp), %eax
cmpl -0x74(%rbp), %eax
jge 0x151d5
movl -0xe4(%rbp), %eax
movq -0x90(%rbp), %rcx
movslq -0xe4(%rbp), %rdx
addl (%rcx,%rdx,4), %eax
subl $0x1, %eax
movl %eax, -0xe0(%rbp)
jmp 0x151d7
jmp 0x151d9
movl -0x9c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x9c(%rbp)
cmpl -0xb4(%rbp), %eax
jl 0x15176
movl -0xcc(%rbp), %eax
movl %eax, -0x9c(%rbp)
movl $0x0, -0xa4(%rbp)
movl -0xa4(%rbp), %eax
cmpl -0xd4(%rbp), %eax
jge 0x152ee
cmpl $0x0, -0xa4(%rbp)
jg 0x15235
movq -0xf8(%rbp), %rax
movq 0x58(%rax), %rax
cmpl $0x0, (%rax)
jle 0x152bb
movq -0x80(%rbp), %rax
movslq -0x9c(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0xbc(%rbp)
movl -0xbc(%rbp), %eax
cmpl -0x3c(%rbp), %eax
jge 0x1526a
movq -0x48(%rbp), %rax
movslq -0xbc(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x108(%rbp)
jmp 0x15283
movq -0x60(%rbp), %rax
movl -0xbc(%rbp), %ecx
subl -0x3c(%rbp), %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x108(%rbp)
movl -0x108(%rbp), %eax
movl %eax, -0xc0(%rbp)
cmpl $0x1, -0xc0(%rbp)
jne 0x152b9
movq -0xf8(%rbp), %rax
movl -0x9c(%rbp), %esi
movq 0x20(%rax), %rcx
movslq 0x28(%rax), %rdx
movl %esi, (%rcx,%rdx,4)
movl 0x28(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x28(%rax)
jmp 0x152bb
jmp 0x152bd
movq -0x90(%rbp), %rax
movslq -0x9c(%rbp), %rcx
movl (%rax,%rcx,4), %eax
addl -0x9c(%rbp), %eax
movl %eax, -0x9c(%rbp)
movl -0xa4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa4(%rbp)
jmp 0x15206
jmp 0x152f0
movl -0xa8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa8(%rbp)
jmp 0x14d11
jmp 0x15306
jmp 0x14542
movl -0xe8(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x110, %rsp            # imm = 0x110
popq %rbp
retq