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

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdx, %rcx
movq %rsi, %rax
movq (%rsi), %rsi
movq %rax, 0x8(%rsp)
movq 0x8(%rax), %rax
movq %rax, %rbx
subq %rsi, %rbx
sarq $0x2, %rbx
movq (%rdx), %rdx
movq %rcx, 0x20(%rsp)
movq 0x8(%rcx), %r15
leal -0x1(%rbx), %ecx
movl (%rsi,%rcx,4), %ecx
cmpl (%rdx), %ecx
jge 0x74be
movslq (%rdi), %rcx
cmpl %ebx, %ecx
je 0x7638
leaq (%rdx,%rcx,4), %rcx
movl %ebx, %esi
shlq $0x2, %rsi
subq %rsi, %rcx
cmpq %r15, %rcx
jae 0x768c
movq 0x8(%rsp), %rdi
movq %rax, %rsi
jmp 0x76f8
subq %rdx, %r15
shrq $0x2, %r15
cmpl $0x1, %ebx
movq %rdi, 0x18(%rsp)
jne 0x74ed
movl %r15d, %r14d
xorl %ebx, %ebx
cmpq %rbx, %r14
je 0x7647
movl (%rdx,%rbx,4), %eax
cmpl (%rsi), %eax
jge 0x764a
incq %rbx
jmp 0x74d4
movb 0xddbd(%rip), %al       # 0x152b0
testb %al, %al
je 0x770b
movq 0xdd96(%rip), %rax      # 0x15298
cmpq %rax, 0xdd97(%rip)      # 0x152a0
je 0x7512
movq %rax, 0xdd8e(%rip)      # 0x152a0
xorl %r12d, %r12d
xorl %r14d, %r14d
xorl %ebp, %ebp
movslq (%rdi), %rax
movl %r14d, %edx
movl %r12d, %r13d
cmpl %eax, %ebp
jge 0x758d
cmpl %ebx, %r14d
jae 0x758d
cmpl %r15d, %r12d
jae 0x758d
movq 0x8(%rsp), %rax
movq (%rax), %rax
leaq (%rax,%rdx,4), %rsi
movq 0x20(%rsp), %rax
movq (%rax), %rax
movl (%rax,%r13,4), %ecx
cmpl %ecx, (%rsi)
jne 0x755e
leaq 0xdd44(%rip), %rdi      # 0x15298
callq 0x9a0e
incl %r14d
jmp 0x7581
jge 0x7571
leaq 0xdd31(%rip), %rdi      # 0x15298
callq 0x9a0e
incl %r14d
jmp 0x7584
leaq (%rax,%r13,4), %rsi
leaq 0xdd1c(%rip), %rdi      # 0x15298
callq 0x9a0e
incl %r12d
incl %ebp
movq 0x18(%rsp), %rdi
jmp 0x751a
cmpl %eax, %ebp
jge 0x7627
cmpl %ebx, %r14d
je 0x75da
movq 0x8(%rsp), %rcx
movq 0x8(%rcx), %r8
shlq $0x2, %rdx
addq (%rcx), %rdx
leaq (%rdx,%rax,4), %rax
leaq 0xdce3(%rip), %rdi      # 0x15298
movq 0xdce4(%rip), %rsi      # 0x152a0
movq 0xdcd5(%rip), %rcx      # 0x15298
subq %rsi, %rcx
addq %rax, %rcx
cmpq %rcx, %r8
cmovbq %r8, %rcx
callq 0x9f54
movq 0x18(%rsp), %rdi
cmpl %r15d, %r12d
je 0x7627
movq 0x20(%rsp), %rcx
movq 0x8(%rcx), %rax
shlq $0x2, %r13
addq (%rcx), %r13
movslq (%rdi), %rcx
leaq (,%rcx,4), %rdx
addq %r13, %rdx
leaq 0xdc94(%rip), %rdi      # 0x15298
movq 0xdc95(%rip), %rsi      # 0x152a0
movq 0xdc86(%rip), %rcx      # 0x15298
subq %rsi, %rcx
addq %rdx, %rcx
cmpq %rcx, %rax
cmovbq %rax, %rcx
movq %r13, %rdx
callq 0x9f34
leaq 0xdc6a(%rip), %rsi      # 0x15298
movq 0x8(%rsp), %rdi
callq 0x98ce
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %r15d, %ebx
cmpl (%rdi), %ebx
jge 0x7699
movl %ebx, %r12d
leaq (%rdx,%r12,4), %rcx
movq 0x8(%rsp), %r13
movq %r13, %rdi
callq 0x9f34
movq 0x18(%rsp), %rsi
movq 0x20(%rsp), %rax
movq (%rax), %rax
movq (%r13), %rcx
cmpl %r15d, %ebx
cmovbel %r15d, %ebx
cmpq %r14, %r12
jae 0x76e0
movl (%rax,%r12,4), %edx
cmpl (%rcx), %edx
jne 0x76b6
incq %r12
jmp 0x767a
movq 0x8(%rsp), %rdi
movq %rax, %rsi
movq %r15, %rcx
jmp 0x76f8
movq 0x8(%rsp), %rdi
movq 0x20(%rsp), %rsi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x98ce
cmpq %r14, %r12
jae 0x76dd
cmpl %r15d, (%rsi)
jne 0x76dd
movq 0x8(%rsp), %rdi
movq 0x8(%rdi), %rsi
movl %r12d, %ecx
leaq (%rax,%rcx,4), %rdx
movslq %r15d, %rcx
leaq (%rax,%rcx,4), %rcx
addq $-0x4, %rcx
jmp 0x76f8
movl %r12d, %ebx
movq 0x8(%rsp), %rdi
movq 0x8(%rdi), %rsi
movl %ebx, %ecx
leaq (%rax,%rcx,4), %rdx
movq 0x20(%rsp), %rax
movq 0x8(%rax), %rcx
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x9f34
leaq 0xdb9e(%rip), %rdi      # 0x152b0
callq 0x3440
movq 0x18(%rsp), %rdi
testl %eax, %eax
je 0x74fb
movslq (%rdi), %rsi
leaq 0xdb6a(%rip), %rdi      # 0x15298
leaq 0x17(%rsp), %rdx
callq 0x9a92
leaq 0x1edb(%rip), %rdi      # 0x961a
leaq 0xdb52(%rip), %rsi      # 0x15298
leaq 0xdb1b(%rip), %rdx      # 0x15268
callq 0x3210
leaq 0xdb57(%rip), %rdi      # 0x152b0
callq 0x31b0
movq 0x18(%rsp), %rdi
jmp 0x74fb
movq %rax, %rbx
leaq 0xdb3e(%rip), %rdi      # 0x152b0
callq 0x31a0
movq %rbx, %rdi
callq 0x3430
nop