// File: /workspace/github_cpp_makefile_star2_O1/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 $0x18, %rsp
movq %rdx, %r14
movq %rsi, %r10
movq (%rsi), %rsi
movq 0x8(%r10), %rax
subq %rsi, %rax
movq %rax, %rbp
shrq $0x2, %rbp
testl %ebp, %ebp
je 0xafa4
movq %rdi, %r15
movq (%r14), %r13
movq 0x8(%r14), %r11
movq %rax, %rdx
shlq $0x1e, %rdx
movabsq $-0x100000000, %rcx     # imm = 0xFFFFFFFF00000000
addq %rdx, %rcx
sarq $0x1e, %rcx
movslq (%rsi,%rcx), %rcx
movq 0x30(%rdi), %rdi
shlq $0x4, %rcx
movl 0xc(%rdi,%rcx), %ecx
movslq (%r13), %r8
shlq $0x4, %r8
cmpl 0xc(%rdi,%r8), %ecx
jle 0xafbd
movslq 0x4(%r15), %rcx
cmpl %ebp, %ecx
je 0xb1b1
leaq (,%rcx,4), %rcx
addq %r13, %rcx
sarq $0x1e, %rdx
subq %rdx, %rcx
addq %rax, %rsi
movq %r10, %rdi
movq %r13, %rdx
cmpq %r11, %rcx
jb 0xaf91
movq %r11, %rcx
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xef18
movq %r10, %rdi
movq %r14, %rsi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xc2b6
movb 0xb3dd(%rip), %al       # 0x163a0
testb %al, %al
movq %r10, (%rsp)
je 0xb29d
subq %r13, %r11
shrq $0x2, %r11
movq 0xb3ab(%rip), %rax      # 0x16388
cmpq %rax, 0xb3ac(%rip)      # 0x16390
je 0xafed
movq %rax, 0xb3a3(%rip)      # 0x16390
movl 0x4(%r15), %eax
xorl %r13d, %r13d
testl %eax, %eax
movq %r11, 0x10(%rsp)
jle 0xb137
testl %ebp, %ebp
jle 0xb137
movl $0x0, %ebx
movl $0x0, %r12d
testl %r11d, %r11d
jle 0xb13c
xorl %r12d, %r12d
xorl %ebx, %ebx
xorl %r13d, %r13d
movslq %ebx, %rax
movq (%r10), %rcx
leaq (%rcx,%rax,4), %rdx
movslq (%rdx), %rcx
movq 0x30(%r15), %rsi
movq %rcx, %r8
shlq $0x4, %r8
movslq %r13d, %rax
movq (%r14), %rdi
leaq (%rdi,%rax,4), %rax
movslq (%rax), %rdi
movq %rdi, %r9
shlq $0x4, %r9
movl 0xc(%rsi,%r9), %r9d
cmpl %r9d, 0xc(%rsi,%r8)
jne 0xb087
cmpl %edi, %ecx
jne 0xb0ab
movq 0xb328(%rip), %rsi      # 0x16390
cmpq 0xb329(%rip), %rsi      # 0x16398
je 0xb102
movl %ecx, (%rsi)
addq $0x4, %rsi
movq %rsi, 0xb30e(%rip)      # 0x16390
jmp 0xb117
movq 0xb302(%rip), %rsi      # 0x16390
movq 0xb303(%rip), %r8       # 0x16398
jle 0xb0bb
cmpq %r8, %rsi
je 0xb0cf
movl %ecx, (%rsi)
addq $0x4, %rsi
movq %rsi, 0xb2e7(%rip)      # 0x16390
jmp 0xb0e4
movq 0xb2de(%rip), %rsi      # 0x16390
movq 0xb2df(%rip), %r8       # 0x16398
jl 0xb097
cmpq %r8, %rsi
je 0xb0e8
movl %edi, (%rsi)
addq $0x4, %rsi
movq %rsi, 0xb2c3(%rip)      # 0x16390
jmp 0xb119
leaq 0xb2b2(%rip), %rdi      # 0x16388
callq 0xdde8
movq 0x10(%rsp), %r11
movq (%rsp), %r10
incl %ebx
jmp 0xb11c
leaq 0xb299(%rip), %rdi      # 0x16388
movq %rax, %rdx
callq 0xdde8
movq 0x10(%rsp), %r11
movq (%rsp), %r10
jmp 0xb119
leaq 0xb27f(%rip), %rdi      # 0x16388
callq 0xdde8
movq 0x10(%rsp), %r11
movq (%rsp), %r10
incl %ebx
incl %r13d
incl %r12d
movl 0x4(%r15), %eax
cmpl %eax, %r12d
jge 0xb13c
cmpl %ebp, %ebx
jge 0xb13c
cmpl %r11d, %r13d
jl 0xb025
jmp 0xb13c
xorl %ebx, %ebx
xorl %r12d, %r12d
cmpl %eax, %r12d
jne 0xb14d
leaq 0xb240(%rip), %rsi      # 0x16388
movq %r10, %rdi
jmp 0xb1ac
leal 0x1(%rax), %ecx
cmpl %ecx, %r12d
jne 0xb1c0
movq 0xae7c(%rip), %r14      # 0x15fd8
leaq 0x548e(%rip), %rsi      # 0x105f1
movl $0x6, %edx
movq %r14, %rdi
movq %r10, %rbx
callq 0x32e0
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x3280
movsbl %al, %esi
movq %r14, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31d0
leaq 0xb1e7(%rip), %rsi      # 0x16388
addq $-0x4, 0xb1e7(%rip)     # 0x16390
movq %rbx, %rdi
callq 0xc2b6
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jle 0xb206
movq 0xae0f(%rip), %rbx      # 0x15fd8
leaq 0x5421(%rip), %rsi      # 0x105f1
movl $0x6, %edx
movq %rbx, %rdi
callq 0x32e0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3280
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31d0
jmp 0xb1b1
cmpl %ebp, %ebx
je 0xb24e
movq 0x8(%r10), %r8
movslq %ebx, %rdx
shlq $0x2, %rdx
addq (%r10), %rdx
cltq
leaq (%rdx,%rax,4), %rax
leaq 0xb163(%rip), %rdi      # 0x16388
movq 0xb164(%rip), %rsi      # 0x16390
movq 0xb155(%rip), %rcx      # 0x16388
subq %rsi, %rcx
addq %rax, %rcx
cmpq %rcx, %r8
cmovbq %r8, %rcx
callq 0xf104
movq 0x10(%rsp), %r11
movq (%rsp), %r10
cmpl %r11d, %r13d
je 0xb141
movq 0x8(%r14), %rax
movslq %r13d, %rdx
shlq $0x2, %rdx
addq (%r14), %rdx
movslq 0x4(%r15), %rcx
leaq (%rdx,%rcx,4), %r8
leaq 0xb114(%rip), %rdi      # 0x16388
movq 0xb115(%rip), %rsi      # 0x16390
movq 0xb106(%rip), %rcx      # 0x16388
subq %rsi, %rcx
addq %r8, %rcx
cmpq %rcx, %rax
cmovbq %rax, %rcx
callq 0xef18
movq (%rsp), %r10
jmp 0xb141
leaq 0xb0fc(%rip), %rdi      # 0x163a0
movq %r11, %rbx
callq 0x3480
movq %rbx, %r11
movq (%rsp), %r10
testl %eax, %eax
je 0xafcf
movslq 0x4(%r15), %rsi
leaq 0xb0c2(%rip), %rdi      # 0x16388
leaq 0xf(%rsp), %rdx
callq 0xc488
leaq 0xccf(%rip), %rdi       # 0xbfa6
leaq 0xb0aa(%rip), %rsi      # 0x16388
leaq 0xaf93(%rip), %rdx      # 0x16278
callq 0x3240
leaq 0xb0af(%rip), %rdi      # 0x163a0
callq 0x31a0
movq (%rsp), %r10
movq %rbx, %r11
jmp 0xafcf
movq %rax, %rbx
leaq 0xb094(%rip), %rdi      # 0x163a0
callq 0x3190
movq %rbx, %rdi
callq 0x3460
nop