// File: /workspace/github_cpp_makefile_star2_O3/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 0xaed6
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 0xaeef
movslq 0x4(%r15), %rcx
cmpl %ebp, %ecx
je 0xb0e3
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 0xaec3
movq %r11, %rcx
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xee5a
movq %r10, %rdi
movq %r14, %rsi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xc1f2
movb 0xb4ab(%rip), %al       # 0x163a0
testb %al, %al
movq %r10, (%rsp)
je 0xb1cf
subq %r13, %r11
shrq $0x2, %r11
movq 0xb479(%rip), %rax      # 0x16388
cmpq %rax, 0xb47a(%rip)      # 0x16390
je 0xaf1f
movq %rax, 0xb471(%rip)      # 0x16390
movl 0x4(%r15), %eax
xorl %r13d, %r13d
testl %eax, %eax
movq %r11, 0x10(%rsp)
jle 0xb069
testl %ebp, %ebp
jle 0xb069
movl $0x0, %ebx
movl $0x0, %r12d
testl %r11d, %r11d
jle 0xb06e
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 0xafb9
cmpl %edi, %ecx
jne 0xafdd
movq 0xb3f6(%rip), %rsi      # 0x16390
cmpq 0xb3f7(%rip), %rsi      # 0x16398
je 0xb034
movl %ecx, (%rsi)
addq $0x4, %rsi
movq %rsi, 0xb3dc(%rip)      # 0x16390
jmp 0xb049
movq 0xb3d0(%rip), %rsi      # 0x16390
movq 0xb3d1(%rip), %r8       # 0x16398
jle 0xafed
cmpq %r8, %rsi
je 0xb001
movl %ecx, (%rsi)
addq $0x4, %rsi
movq %rsi, 0xb3b5(%rip)      # 0x16390
jmp 0xb016
movq 0xb3ac(%rip), %rsi      # 0x16390
movq 0xb3ad(%rip), %r8       # 0x16398
jl 0xafc9
cmpq %r8, %rsi
je 0xb01a
movl %edi, (%rsi)
addq $0x4, %rsi
movq %rsi, 0xb391(%rip)      # 0x16390
jmp 0xb04b
leaq 0xb380(%rip), %rdi      # 0x16388
callq 0xdd36
movq 0x10(%rsp), %r11
movq (%rsp), %r10
incl %ebx
jmp 0xb04e
leaq 0xb367(%rip), %rdi      # 0x16388
movq %rax, %rdx
callq 0xdd36
movq 0x10(%rsp), %r11
movq (%rsp), %r10
jmp 0xb04b
leaq 0xb34d(%rip), %rdi      # 0x16388
callq 0xdd36
movq 0x10(%rsp), %r11
movq (%rsp), %r10
incl %ebx
incl %r13d
incl %r12d
movl 0x4(%r15), %eax
cmpl %eax, %r12d
jge 0xb06e
cmpl %ebp, %ebx
jge 0xb06e
cmpl %r11d, %r13d
jl 0xaf57
jmp 0xb06e
xorl %ebx, %ebx
xorl %r12d, %r12d
cmpl %eax, %r12d
jne 0xb07f
leaq 0xb30e(%rip), %rsi      # 0x16388
movq %r10, %rdi
jmp 0xb0de
leal 0x1(%rax), %ecx
cmpl %ecx, %r12d
jne 0xb0f2
movq 0xaf4a(%rip), %r14      # 0x15fd8
leaq 0x554c(%rip), %rsi      # 0x105e1
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 0xb2b5(%rip), %rsi      # 0x16388
addq $-0x4, 0xb2b5(%rip)     # 0x16390
movq %rbx, %rdi
callq 0xc1f2
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jle 0xb138
movq 0xaedd(%rip), %rbx      # 0x15fd8
leaq 0x54df(%rip), %rsi      # 0x105e1
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 0xb0e3
cmpl %ebp, %ebx
je 0xb180
movq 0x8(%r10), %r8
movslq %ebx, %rdx
shlq $0x2, %rdx
addq (%r10), %rdx
cltq
leaq (%rdx,%rax,4), %rax
leaq 0xb231(%rip), %rdi      # 0x16388
movq 0xb232(%rip), %rsi      # 0x16390
movq 0xb223(%rip), %rcx      # 0x16388
subq %rsi, %rcx
addq %rax, %rcx
cmpq %rcx, %r8
cmovbq %r8, %rcx
callq 0xf00e
movq 0x10(%rsp), %r11
movq (%rsp), %r10
cmpl %r11d, %r13d
je 0xb073
movq 0x8(%r14), %rax
movslq %r13d, %rdx
shlq $0x2, %rdx
addq (%r14), %rdx
movslq 0x4(%r15), %rcx
leaq (%rdx,%rcx,4), %r8
leaq 0xb1e2(%rip), %rdi      # 0x16388
movq 0xb1e3(%rip), %rsi      # 0x16390
movq 0xb1d4(%rip), %rcx      # 0x16388
subq %rsi, %rcx
addq %r8, %rcx
cmpq %rcx, %rax
cmovbq %rax, %rcx
callq 0xee5a
movq (%rsp), %r10
jmp 0xb073
leaq 0xb1ca(%rip), %rdi      # 0x163a0
movq %r11, %rbx
callq 0x3480
movq %rbx, %r11
movq (%rsp), %r10
testl %eax, %eax
je 0xaf01
movslq 0x4(%r15), %rsi
leaq 0xb190(%rip), %rdi      # 0x16388
leaq 0xf(%rsp), %rdx
callq 0xc3d2
leaq 0xcc1(%rip), %rdi       # 0xbeca
leaq 0xb178(%rip), %rsi      # 0x16388
leaq 0xb061(%rip), %rdx      # 0x16278
callq 0x3240
leaq 0xb17d(%rip), %rdi      # 0x163a0
callq 0x31a0
movq (%rsp), %r10
movq %rbx, %r11
jmp 0xaf01
movq %rax, %rbx
leaq 0xb162(%rip), %rdi      # 0x163a0
callq 0x3190
movq %rbx, %rdi
callq 0x3460
nop