// File: /workspace/github_cpp_makefile_star2_O2/datourat[P]IP-label-for-graph-reachability/Graph.cpp
// Function: Graph::HugeNodeListUnion(std::vector<int, std::allocator<int>>&, std::vector<int, std::allocator<int>> const&)
void Graph::HugeNodeListUnion(vector<int>& v1, const vector<int>& v2){
	int v1size=v1.size(), v2size=v2.size();

	if(v1size==0){
		v1=v2;
		return;
	}

	if(vl[v1[v1size-1]].outdegree > vl[v2[0]].outdegree){
		if(v1size==HUGENODENUM)
			return ;
		else{
			if(v2.begin()+HUGENODENUM-v1size < v2.end())
				v1.insert(v1.end(), v2.begin(), v2.begin()+HUGENODENUM-v1size);
			else
				v1.insert(v1.end(), v2.begin(), v2.end());
			return ;
		}
	}

/*
	if(v1size==1){
		int i=0;
		for(; i<v2size; i++){
			if(vl[v2[i]].outdegree <= vl[v1[0]].outdegree){
				break;
			}
		}
		if(i<HUGENODENUM)
			v1.insert(v1.begin(), v2.begin(), v2.begin()+i);
		else{
			v1=v2;
			return ;
		}
		while(i<v2size && vl[v2[i]].outdegree==vl[v1[0]].outdegree){
			i++;
		}
		if(i<v2size)
			if(v2size==HUGENODENUM)
				v1.insert(v1.end(), v2.begin()+i, v2.begin()+HUGENODENUM-1);
			else
				v1.insert(v1.end(), v2.begin()+i, v2.end());
		return ;
	}
*/

	int k=0;
	int i=0, j=0;
	static vector<int> v(HUGENODENUM);
	v.clear();

	while(k<HUGENODENUM && i<v1size && j<v2size){
		if(vl[v1[i]].outdegree==vl[v2[j]].outdegree){
			if(v1[i]==v2[j]){
				v.push_back(v1[i]);
				i++;
				j++;
				k++;
			}else if(v1[i]<v2[j]){
				v.push_back(v1[i]);
				i++;
				k++;
			}else{
				v.push_back(v2[j]);
				j++;
				k++;
			}
		}else if(vl[v1[i]].outdegree>vl[v2[j]].outdegree){
			v.push_back(v1[i]);
			k++;
			i++;
		}else{
			v.push_back(v2[j]);
			k++;
			j++;
		}
	}

	if(k==HUGENODENUM){
		v1=v;
		return;
	}else{
		if(k==HUGENODENUM+1){
			cout << "bug..." << endl;
			v.pop_back();
			v1=v;
			return ;
		}else if(k>HUGENODENUM+1){
			cout << "bug..." << endl;
			return ;
		}
	}

	if(i!=v1size){
		if(v1.end() < v1.begin()+i+HUGENODENUM-v.size())
			v.insert(v.end(), v1.begin()+i, v1.end());
		else
			v.insert(v.end(), v1.begin()+i, v1.begin()+i+HUGENODENUM-v.size());
	}
	if(j!=v2size){
		if(v2.end() < v2.begin()+j+HUGENODENUM-v.size())
			v.insert(v.end(), v2.begin()+j, v2.end());
		else
			v.insert(v.end(), v2.begin()+j, v2.begin()+j+HUGENODENUM-v.size());
	}

	v1=v;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdx, %r10
movq %rsi, %r9
movq (%rsi), %rcx
movq 0x8(%rsi), %rsi
movq %rsi, %rax
subq %rcx, %rax
movq %rax, %r13
shrq $0x2, %r13
testl %r13d, %r13d
je 0x8a6e
movq %rdi, %r15
movq (%r10), %rbp
movq 0x8(%r10), %r8
shlq $0x1e, %rax
movabsq $-0x100000000, %rdx     # imm = 0xFFFFFFFF00000000
addq %rax, %rdx
sarq $0x1e, %rdx
movslq (%rcx,%rdx), %rcx
movq 0x30(%rdi), %rdx
shlq $0x4, %rcx
movl 0xc(%rdx,%rcx), %ecx
movslq (%rbp), %rdi
shlq $0x4, %rdi
cmpl 0xc(%rdx,%rdi), %ecx
jle 0x8a87
movslq 0x4(%r15), %rcx
cmpl %r13d, %ecx
je 0x8bc1
leaq (,%rcx,4), %rcx
addq %rbp, %rcx
sarq $0x1e, %rax
subq %rax, %rcx
movq %r9, %rdi
movq %rbp, %rdx
cmpq %r8, %rcx
jb 0x8a5b
movq %r8, %rcx
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x9f34
movq %r9, %rdi
movq %r10, %rsi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x98ce
movb 0xc903(%rip), %al       # 0x15390
testb %al, %al
movq %r9, 0x10(%rsp)
movq %r10, 0x18(%rsp)
je 0x8c90
subq %rbp, %r8
shrq $0x2, %r8
movq 0xc8cb(%rip), %rax      # 0x15378
cmpq %rax, 0xc8cc(%rip)      # 0x15380
je 0x8abd
movq %rax, 0xc8c3(%rip)      # 0x15380
xorl %ebx, %ebx
xorl %r12d, %r12d
xorl %r14d, %r14d
movq %r8, 0x20(%rsp)
movslq 0x4(%r15), %rax
movslq %r12d, %rdx
movslq %ebx, %rbp
cmpl %eax, %r14d
jge 0x8b73
cmpl %r13d, %r12d
jge 0x8b73
cmpl %r8d, %ebx
jge 0x8b73
movq (%r9), %rax
leaq (%rax,%rdx,4), %rsi
movslq (%rsi), %rcx
movq 0x30(%r15), %rdi
movq %rcx, %r8
shlq $0x4, %r8
movq (%r10), %rax
leaq (%rax,%rbp,4), %rax
movslq (%rax), %rdx
movq %rdx, %r9
shlq $0x4, %r9
movl 0xc(%rdi,%r9), %r9d
cmpl %r9d, 0xc(%rdi,%r8)
jne 0x8b36
cmpl %edx, %ecx
jne 0x8b49
leaq 0xc84c(%rip), %rdi      # 0x15378
callq 0x9a0e
incl %r12d
jmp 0x8b5a
jle 0x8b4b
leaq 0xc839(%rip), %rdi      # 0x15378
callq 0x9a0e
incl %r12d
jmp 0x8b5c
jl 0x8b38
leaq 0xc826(%rip), %rdi      # 0x15378
movq %rax, %rsi
callq 0x9a0e
incl %ebx
incl %r14d
movq 0x10(%rsp), %r9
movq 0x18(%rsp), %r10
movq 0x20(%rsp), %r8
jmp 0x8aca
cmpl %eax, %r14d
jne 0x8b84
leaq 0xc7f9(%rip), %rsi      # 0x15378
movq %r9, %rdi
jmp 0x8bbc
leal 0x1(%rax), %ecx
cmpl %ecx, %r14d
jne 0x8bd0
movq 0xc445(%rip), %rdi      # 0x14fd8
leaq 0x59e7(%rip), %rsi      # 0xe581
movq %r9, %rbx
callq 0x3270
movq %rax, %rdi
callq 0x3140
leaq 0xc7c7(%rip), %rsi      # 0x15378
addq $-0x4, 0xc7c7(%rip)     # 0x15380
movq %rbx, %rdi
callq 0x98ce
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jle 0x8bef
movq 0xc3ff(%rip), %rdi      # 0x14fd8
leaq 0x59a1(%rip), %rsi      # 0xe581
callq 0x3270
movq %rax, %rdi
callq 0x3140
jmp 0x8bc1
cmpl %r13d, %r12d
je 0x8c39
movq 0x8(%r9), %r8
shlq $0x2, %rdx
addq (%r9), %rdx
leaq (%rdx,%rax,4), %rax
leaq 0xc76e(%rip), %rdi      # 0x15378
movq 0xc76f(%rip), %rsi      # 0x15380
movq 0xc760(%rip), %rcx      # 0x15378
subq %rsi, %rcx
addq %rax, %rcx
cmpq %rcx, %r8
cmovbq %r8, %rcx
callq 0x9f54
movq 0x20(%rsp), %r8
movq 0x18(%rsp), %r10
movq 0x10(%rsp), %r9
cmpl %r8d, %ebx
je 0x8b78
movq 0x8(%r10), %rax
shlq $0x2, %rbp
addq (%r10), %rbp
movslq 0x4(%r15), %rcx
leaq (,%rcx,4), %rdx
addq %rbp, %rdx
leaq 0xc715(%rip), %rdi      # 0x15378
movq 0xc716(%rip), %rsi      # 0x15380
movq 0xc707(%rip), %rcx      # 0x15378
subq %rsi, %rcx
addq %rdx, %rcx
cmpq %rcx, %rax
cmovbq %rax, %rcx
movq %rbp, %rdx
callq 0x9f34
movq 0x10(%rsp), %r9
jmp 0x8b78
leaq 0xc6f9(%rip), %rdi      # 0x15390
movq %r8, %rbx
callq 0x3440
movq %rbx, %r8
movq 0x18(%rsp), %r10
movq 0x10(%rsp), %r9
testl %eax, %eax
je 0x8a9f
movslq 0x4(%r15), %rsi
leaq 0xc6b9(%rip), %rdi      # 0x15378
leaq 0xf(%rsp), %rdx
callq 0x9a92
leaq 0x94a(%rip), %rdi       # 0x961a
leaq 0xc6a1(%rip), %rsi      # 0x15378
leaq 0xc58a(%rip), %rdx      # 0x15268
callq 0x3210
leaq 0xc6a6(%rip), %rdi      # 0x15390
callq 0x31b0
movq 0x10(%rsp), %r9
movq 0x18(%rsp), %r10
movq %rbx, %r8
jmp 0x8a9f
movq %rax, %rbx
leaq 0xc685(%rip), %rdi      # 0x15390
callq 0x31a0
movq %rbx, %rdi
callq 0x3430