// File: SNUCSE-CTA[P]GI/src/refine.cpp
// Function: Refinement::deleteEdge(int, int, Graph*, Graph*)
void Refinement::deleteEdge(int32_t aVertex, int32_t aNumDegOne, Graph* aG1, Graph* aG2)
{
	Graph* g1 = aG1;
	Graph* g2 = aG2;
	int32_t n = g1->numNode;
	int32_t* d1 = g1->d;
	int32_t* d2 = g2->d;

	int32_t du = (aVertex < n) ? d1[aVertex] : d2[aVertex - n];
	if( du < 2 )
		return;

	int32_t i, newDegree, temp, lastInd;
	int32_t* edge = NULL;
	char* one = NULL;

	newDegree = du - aNumDegOne;
	if( aVertex < n ) {
		lastInd = newDegree;
		edge = g1->e[aVertex];
		one = g1->one;
		for(i = 0; i < newDegree; ++i) {
			if( one[edge[i]] ) {
				while( d1[ edge[lastInd] ] == -1 )
					++lastInd;
				temp = edge[i];
				edge[i] = edge[lastInd];
				edge[lastInd] = temp;
			}
		}
		d1[aVertex] = newDegree;
	}
	else {
		lastInd = newDegree;
		edge = g2->e[aVertex - n];
		one = g2->one;
		for(i = 0; i < newDegree; ++i) {
			if( one[edge[i]] ) {
				while( d2[ edge[lastInd] ] == -1 )
					++lastInd;
				temp = edge[i];
				edge[i] = edge[lastInd];
				edge[lastInd] = temp;
			}
		}
		d2[aVertex - n] = newDegree;
	} //if-else (aVertex < n)
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movq %rcx, -0x18(%rbp)
movq %r8, -0x20(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x28(%rbp), %rax
movl 0xc(%rax), %eax
movl %eax, -0x34(%rbp)
movq -0x28(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x48(%rbp)
movl -0xc(%rbp), %eax
cmpl -0x34(%rbp), %eax
jge 0x16970
movq -0x40(%rbp), %rax
movslq -0xc(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x74(%rbp)
jmp 0x16983
movq -0x48(%rbp), %rax
movl -0xc(%rbp), %ecx
subl -0x34(%rbp), %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x74(%rbp)
movl -0x74(%rbp), %eax
movl %eax, -0x4c(%rbp)
cmpl $0x2, -0x4c(%rbp)
jge 0x16994
jmp 0x16b3e
movq $0x0, -0x68(%rbp)
movq $0x0, -0x70(%rbp)
movl -0x4c(%rbp), %eax
subl -0x10(%rbp), %eax
movl %eax, -0x54(%rbp)
movl -0xc(%rbp), %eax
cmpl -0x34(%rbp), %eax
jge 0x16a79
movl -0x54(%rbp), %eax
movl %eax, -0x5c(%rbp)
movq -0x28(%rbp), %rax
movq 0x38(%rax), %rax
movslq -0xc(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x68(%rbp)
movq -0x28(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0x70(%rbp)
movl $0x0, -0x50(%rbp)
movl -0x50(%rbp), %eax
cmpl -0x54(%rbp), %eax
jge 0x16a66
movq -0x70(%rbp), %rax
movq -0x68(%rbp), %rcx
movslq -0x50(%rbp), %rdx
movslq (%rcx,%rdx,4), %rcx
cmpb $0x0, (%rax,%rcx)
je 0x16a59
jmp 0x16a06
movq -0x40(%rbp), %rax
movq -0x68(%rbp), %rcx
movslq -0x5c(%rbp), %rdx
movslq (%rcx,%rdx,4), %rcx
cmpl $-0x1, (%rax,%rcx,4)
jne 0x16a27
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0x16a06
movq -0x68(%rbp), %rax
movslq -0x50(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x58(%rbp)
movq -0x68(%rbp), %rax
movslq -0x5c(%rbp), %rcx
movl (%rax,%rcx,4), %edx
movq -0x68(%rbp), %rax
movslq -0x50(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x58(%rbp), %edx
movq -0x68(%rbp), %rax
movslq -0x5c(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
jmp 0x16a5b
movl -0x50(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
jmp 0x169e6
movl -0x54(%rbp), %edx
movq -0x40(%rbp), %rax
movslq -0xc(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
jmp 0x16b3e
movl -0x54(%rbp), %eax
movl %eax, -0x5c(%rbp)
movq -0x30(%rbp), %rax
movq 0x38(%rax), %rax
movl -0xc(%rbp), %ecx
subl -0x34(%rbp), %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x68(%rbp)
movq -0x30(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0x70(%rbp)
movl $0x0, -0x50(%rbp)
movl -0x50(%rbp), %eax
cmpl -0x54(%rbp), %eax
jge 0x16b2b
movq -0x70(%rbp), %rax
movq -0x68(%rbp), %rcx
movslq -0x50(%rbp), %rdx
movslq (%rcx,%rdx,4), %rcx
cmpb $0x0, (%rax,%rcx)
je 0x16b1e
jmp 0x16acb
movq -0x48(%rbp), %rax
movq -0x68(%rbp), %rcx
movslq -0x5c(%rbp), %rdx
movslq (%rcx,%rdx,4), %rcx
cmpl $-0x1, (%rax,%rcx,4)
jne 0x16aec
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0x16acb
movq -0x68(%rbp), %rax
movslq -0x50(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x58(%rbp)
movq -0x68(%rbp), %rax
movslq -0x5c(%rbp), %rcx
movl (%rax,%rcx,4), %edx
movq -0x68(%rbp), %rax
movslq -0x50(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x58(%rbp), %edx
movq -0x68(%rbp), %rax
movslq -0x5c(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
jmp 0x16b20
movl -0x50(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
jmp 0x16aab
movl -0x54(%rbp), %edx
movq -0x48(%rbp), %rax
movl -0xc(%rbp), %ecx
subl -0x34(%rbp), %ecx
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
popq %rbp
retq