// File: /workspace/github_cpp_makefile_star2_O3/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 $0x18, %rsp
movq %rdx, %r14
movq %rsi, %r10
movq (%rsi), %rsi
movq 0x8(%r10), %rax
subq %rsi, %rax
movq %rax, %rbp
sarq $0x2, %rbp
movq (%rdx), %rdx
movq 0x8(%r14), %r15
leal -0x1(%rbp), %ecx
movl (%rsi,%rcx,4), %ecx
cmpl (%rdx), %ecx
jge 0x914b
movslq (%rdi), %rcx
cmpl %ebp, %ecx
je 0x93d4
leaq (%rdx,%rcx,4), %rcx
movl %ebp, %edi
shlq $0x2, %rdi
subq %rdi, %rcx
addq %rax, %rsi
movq %r10, %rdi
cmpq %r15, %rcx
jb 0x9411
movq %r15, %rcx
jmp 0x9411
subq %rdx, %r15
shrq $0x2, %r15
cmpl $0x1, %ebp
movq %r10, (%rsp)
movq %rdi, 0x8(%rsp)
jne 0x9189
testl %r15d, %r15d
je 0x92c9
movl (%rsi), %eax
movl %r15d, %ecx
xorl %ebx, %ebx
cmpl %eax, (%rdx,%rbx,4)
jge 0x92cb
incq %rbx
cmpq %rbx, %rcx
jne 0x9170
movl %r15d, %ebx
jmp 0x92cb
movb 0xd131(%rip), %al       # 0x162c0
testb %al, %al
je 0x9424
movq 0xd10a(%rip), %rax      # 0x162a8
cmpq %rax, 0xd10b(%rip)      # 0x162b0
je 0x91ae
movq %rax, 0xd102(%rip)      # 0x162b0
movl (%rdi), %eax
xorl %r13d, %r13d
testl %eax, %eax
setg %cl
jle 0x932c
testl %ebp, %ebp
je 0x932c
movl $0x0, %r12d
testl %r15d, %r15d
je 0x932f
xorl %r12d, %r12d
movl $0x1, %ebx
xorl %r13d, %r13d
movl %r12d, %eax
movq (%r10), %rcx
leaq (%rcx,%rax,4), %rdx
movl (%rdx), %eax
movl %r13d, %ecx
movq (%r14), %r11
movl (%r11,%rcx,4), %r8d
cmpl %r8d, %eax
jne 0x921a
movq 0xd0ae(%rip), %rsi      # 0x162b0
cmpq 0xd0af(%rip), %rsi      # 0x162b8
je 0x9253
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0xd098(%rip)      # 0x162b0
jmp 0x9268
movq 0xd08f(%rip), %rsi      # 0x162b0
movq 0xd090(%rip), %r9       # 0x162b8
jge 0x923e
cmpq %r9, %rsi
je 0x9270
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0xd074(%rip)      # 0x162b0
jmp 0x9285
cmpq %r9, %rsi
je 0x92ae
movl %r8d, (%rsi)
addq $0x4, %rsi
movq %rsi, 0xd05f(%rip)      # 0x162b0
jmp 0x926b
leaq 0xd04e(%rip), %rdi      # 0x162a8
callq 0xdd36
movq 0x8(%rsp), %rdi
movq (%rsp), %r10
incl %r12d
incl %r13d
jmp 0x9288
leaq 0xd031(%rip), %rdi      # 0x162a8
callq 0xdd36
movq 0x8(%rsp), %rdi
movq (%rsp), %r10
incl %r12d
movl (%rdi), %eax
cmpl %eax, %ebx
setl %cl
jge 0x932f
cmpl %ebp, %r12d
jae 0x932f
incl %ebx
cmpl %r15d, %r13d
jb 0x91e0
jmp 0x932f
leaq (%r11,%rcx,4), %rdx
leaq 0xcfef(%rip), %rdi      # 0x162a8
callq 0xdd36
movq 0x8(%rsp), %rdi
movq (%rsp), %r10
jmp 0x926b
xorl %ebx, %ebx
cmpl (%rdi), %ebx
jge 0x9313
movl %ebx, %r12d
leaq (%rdx,%r12,4), %rcx
movq %r10, %rdi
callq 0xee5a
movq (%rsp), %rdi
movl %r15d, %ecx
movq (%r14), %rax
subl %ebx, %ecx
jbe 0x9403
movq (%rdi), %rdx
movl (%rdx), %edx
movq 0x8(%rsp), %rsi
cmpl %edx, (%rax,%r12,4)
jne 0x93e3
incq %r12
decl %ecx
jne 0x92fa
movl %r15d, %ebx
jmp 0x9403
movq %r10, %rdi
movq %r14, %rsi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xc1f2
xorl %r12d, %r12d
testb %cl, %cl
je 0x93c5
cmpl %ebp, %r12d
je 0x9380
movq 0x8(%r10), %r8
movl %r12d, %edx
shlq $0x2, %rdx
addq (%r10), %rdx
cltq
leaq (%rdx,%rax,4), %rax
leaq 0xcf51(%rip), %rdi      # 0x162a8
movq 0xcf52(%rip), %rsi      # 0x162b0
movq 0xcf43(%rip), %rcx      # 0x162a8
subq %rsi, %rcx
addq %rax, %rcx
cmpq %rcx, %r8
cmovbq %r8, %rcx
callq 0xf00e
movq 0x8(%rsp), %rdi
movq (%rsp), %r10
cmpl %r15d, %r13d
je 0x93c5
movq 0x8(%r14), %rax
movl %r13d, %edx
shlq $0x2, %rdx
addq (%r14), %rdx
movslq (%rdi), %rcx
leaq (%rdx,%rcx,4), %r8
leaq 0xcf07(%rip), %rdi      # 0x162a8
movq 0xcf08(%rip), %rsi      # 0x162b0
movq 0xcef9(%rip), %rcx      # 0x162a8
subq %rsi, %rcx
addq %r8, %rcx
cmpq %rcx, %rax
cmovbq %rax, %rcx
callq 0xee5a
movq (%rsp), %r10
leaq 0xcedc(%rip), %rsi      # 0x162a8
movq %r10, %rdi
callq 0xc1f2
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl %r15d, (%rsi)
jne 0x9400
movq 0x8(%rdi), %rsi
movl %r12d, %ecx
leaq (%rax,%rcx,4), %rdx
movslq %r15d, %rcx
leaq (%rax,%rcx,4), %rcx
addq $-0x4, %rcx
jmp 0x9411
movl %r12d, %ebx
movq 0x8(%rdi), %rsi
movl %ebx, %ecx
leaq (%rax,%rcx,4), %rdx
movq 0x8(%r14), %rcx
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xee5a
leaq 0xce95(%rip), %rdi      # 0x162c0
callq 0x3480
movq 0x8(%rsp), %rdi
movq (%rsp), %r10
testl %eax, %eax
je 0x9197
movslq (%rdi), %rsi
leaq 0xce5d(%rip), %rdi      # 0x162a8
leaq 0x17(%rsp), %rdx
callq 0xc3d2
leaq 0x2a6e(%rip), %rdi      # 0xbeca
leaq 0xce45(%rip), %rsi      # 0x162a8
leaq 0xce0e(%rip), %rdx      # 0x16278
callq 0x3240
leaq 0xce4a(%rip), %rdi      # 0x162c0
callq 0x31a0
movq (%rsp), %r10
movq 0x8(%rsp), %rdi
jmp 0x9197
movq %rax, %rbx
leaq 0xce2d(%rip), %rdi      # 0x162c0
callq 0x3190
movq %rbx, %rdi
callq 0x3460