// File: quancs[P]EAVC/./eavc.h
// Function: init_vertex_greedy_vc(int*, VerticeStatus*, unsigned int&)
void init_vertex_greedy_vc(int *dscore1, VerticeStatus *vInC1, unsigned int &cvSize1) {  //super fast
#ifdef WIN32
    start = clock();
#else
    times(&start);
#endif
    struct ScoreVertex {
        int score;
        unsigned int vertex;
    };

    function<bool(const ScoreVertex &, const ScoreVertex &)> compFunc = [](const ScoreVertex & v1, const ScoreVertex & v2) {
        return v1.score < v2.score;//<:大的在前面，小的在后面
    };

    ScoreVertex *candidates = new ScoreVertex[uvSize];
    unsigned int candSize = 0;
    cvSize1 = 0;
    unsigned int ueSize1 = ueSize;

    unsigned *readdCandVertices = new unsigned[uvSize];
    unsigned racSize = 0;
    unsigned *highScoreVertices = new unsigned[uvSize];
    unsigned hsvSize = 0;
    int highestScore = static_cast<int>(vNum);

    for (unsigned int v = 0; v < vNum; v++) {
        vInC1[v] = vInBest[v];
        dscore1[v] = static_cast<int>(dVDegree[v]);
        if (vInC1[v] != IN_ABS && vInC1[v] != NIN_ABS) {
            vInC1[v] = NIN;
            candidates[candSize].vertex = v;
            candidates[candSize].score = dscore1[v];
            candSize++;
        }
    }

    make_heap(candidates, candidates + uvSize, compFunc);

    for (; candSize > 0 && ueSize1 > 0;) {
        highestScore = candidates[0].score;
        int gainValue;
        unsigned int v;
        //pop all vertices with bigest score value
        while (candSize > 0) {
            gainValue = candidates[0].score;
            v = candidates[0].vertex;
            if (gainValue == highestScore) {
                pop_heap(candidates, candidates + candSize, compFunc);
                candSize--;
                if (gainValue != dscore1[v]) {//readd the vertexes whose gain value has changed
                    if (dscore1[v] > 0) {
                        readdCandVertices[racSize] = v;
                        racSize++;
                    }
                } else {//add to highScoreVertices
                    highScoreVertices[hsvSize] = v;
                    hsvSize++;
                }
            } else {
                break;
            }
        }

        //Randomly select and add
        while (hsvSize > 0) {
            unsigned randomIndex = pcg32_fast() % hsvSize;
            hsvSize--;
            v = highScoreVertices[randomIndex];
            highScoreVertices[randomIndex] = highScoreVertices[hsvSize];

            if (dscore1[v] != highestScore) {
                if (dscore1[v] > 0) {
                    readdCandVertices[racSize] = v;
                    racSize++;
                }
            } else {// Add v to c
                cvSize1++;
                dscore1[v] = dscore1[v] * -1;
                vInC1[v] = IN;

                unsigned int edgeCount = dVDegree[v];
                for (unsigned int i = 0; i < edgeCount; ++i) {
                    unsigned int n = vAdj[v][i];//v's i'th neighbor

                    if (not_in(vInC1, n)) { //this adj isn't in cover set
                        dscore1[n]--;
                        ueSize1--;
                    } else {
                        dscore1[n]++;
                    }
                }
            }
        }

        //readd
        while (racSize > 0) {
            racSize--;
            v = readdCandVertices[racSize];

            candidates[candSize].vertex = v;
            candidates[candSize].score = dscore1[v];
            push_heap(candidates, candidates + candSize, compFunc);
            candSize++;
        }
    }

    for (unsigned i = 0; i < uvSize; i++) {
        unsigned v = uvSet[i];
        if (dscore1[v] == 0 && in(vInC1, v)) {
            cvSize1--;
            // remove v from c
            vInC1[v] = NIN;

            unsigned int edgeCount = dVDegree[v];
            for (unsigned int i = 0; i < edgeCount; ++i) {
                unsigned int n = vAdj[v][i];//v's i'th neighbor
                if (not_in(vInC1, n))
                    dscore1[n]++;
                else
                    dscore1[n]--;
            }
        }
    }
    delete [] readdCandVertices;
    delete [] highScoreVertices;
    delete [] candidates;

#ifdef WIN32
    finish = clock();
    double initTime = (static_cast<double>(finish - start)) / CLOCKS_PER_SEC;
#else
    times(&finish);
    double initTime = double(finish.tms_utime - start.tms_utime + finish.tms_stime - start.tms_stime) / sysconf(_SC_CLK_TCK);
#endif

    initTime = round(initTime * 100) / 100.0;

    cout << "c init vertex_greedy_vc=" << cvSize1 << "/" << uvSize << "/" << (cvSize1 + total_IN_ABS) << " time=" << initTime << endl;
}

// Assembly:
subq $0x1e8, %rsp            # imm = 0x1E8
movq %rdi, 0x1e0(%rsp)
movq %rsi, 0x1d8(%rsp)
movq %rdx, 0x1d0(%rsp)
leaq 0x7432(%rip), %rdi      # 0xb1b8
callq 0x21b0
leaq 0x1b0(%rsp), %rdi
leaq 0x1af(%rsp), %rsi
callq 0x54e0
movl 0x7442(%rip), %eax      # 0xb1e8
movl %eax, %edi
shlq $0x3, %rdi
callq 0x2030
movq %rax, 0xc0(%rsp)
jmp 0x3dbb
movq 0xc0(%rsp), %rax
movq %rax, 0x1a0(%rsp)
movl $0x0, 0x190(%rsp)
movq 0x1d0(%rsp), %rax
movl $0x0, (%rax)
movl 0x7402(%rip), %eax      # 0xb1ec
movl %eax, 0x18c(%rsp)
movl 0x73f1(%rip), %eax      # 0xb1e8
movl %eax, %edi
shlq $0x2, %rdi
callq 0x2030
movq %rax, 0xb8(%rsp)
jmp 0x3e0c
movq 0xb8(%rsp), %rax
movq %rax, 0x180(%rsp)
movl $0x0, 0x17c(%rsp)
movl 0x73bb(%rip), %eax      # 0xb1e8
movl %eax, %edi
shlq $0x2, %rdi
callq 0x2030
movq %rax, 0xb0(%rsp)
jmp 0x3e42
movq 0xb0(%rsp), %rax
movq %rax, 0x170(%rsp)
movl $0x0, 0x16c(%rsp)
movl 0x72d9(%rip), %eax      # 0xb13c
movl %eax, 0x168(%rsp)
movl $0x0, 0x164(%rsp)
movl 0x164(%rsp), %eax
cmpl 0x72ba(%rip), %eax      # 0xb13c
jae 0x3f97
movq 0x7319(%rip), %rax      # 0xb1a8
movl 0x164(%rsp), %ecx
movb (%rax,%rcx), %dl
movq 0x1d8(%rsp), %rax
movl 0x164(%rsp), %ecx
movb %dl, (%rax,%rcx)
movq 0x72fe(%rip), %rax      # 0xb1b0
movl 0x164(%rsp), %ecx
movl (%rax,%rcx,4), %edx
movq 0x1e0(%rsp), %rax
movl 0x164(%rsp), %ecx
movl %edx, (%rax,%rcx,4)
movq 0x1d8(%rsp), %rax
movl 0x164(%rsp), %ecx
movzbl (%rax,%rcx), %eax
cmpl $0x4, %eax
je 0x3f7f
movq 0x1d8(%rsp), %rax
movl 0x164(%rsp), %ecx
movzbl (%rax,%rcx), %eax
cmpl $0x1, %eax
je 0x3f7f
movq 0x1d8(%rsp), %rax
movl 0x164(%rsp), %ecx
movb $0x0, (%rax,%rcx)
movl 0x164(%rsp), %edx
movq 0x1a0(%rsp), %rax
movl 0x190(%rsp), %ecx
movl %edx, 0x4(%rax,%rcx,8)
movq 0x1e0(%rsp), %rax
movl 0x164(%rsp), %ecx
movl (%rax,%rcx,4), %edx
movq 0x1a0(%rsp), %rax
movl 0x190(%rsp), %ecx
movl %edx, (%rax,%rcx,8)
movl 0x190(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x190(%rsp)
jmp 0x3f7f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x198(%rsp)
movl %eax, 0x194(%rsp)
jmp 0x4849
jmp 0x3f81
movl 0x164(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x164(%rsp)
jmp 0x3e75
movq 0x1a0(%rsp), %rax
movq %rax, 0xa0(%rsp)
movl 0x723b(%rip), %ecx      # 0xb1e8
leaq (%rax,%rcx,8), %rax
movq %rax, 0xa8(%rsp)
leaq 0x140(%rsp), %rdi
leaq 0x1b0(%rsp), %rsi
callq 0x5620
jmp 0x3fd0
movq 0xa8(%rsp), %rsi
movq 0xa0(%rsp), %rdi
leaq 0x140(%rsp), %rdx
callq 0x5570
jmp 0x3fef
leaq 0x140(%rsp), %rdi
callq 0x56d0
xorl %eax, %eax
cmpl $0x0, 0x190(%rsp)
movb %al, 0x9f(%rsp)
jbe 0x4021
cmpl $0x0, 0x18c(%rsp)
seta %al
movb %al, 0x9f(%rsp)
movb 0x9f(%rsp), %al
testb $0x1, %al
jne 0x4031
jmp 0x44f0
movq 0x1a0(%rsp), %rax
movl (%rax), %eax
movl %eax, 0x168(%rsp)
cmpl $0x0, 0x190(%rsp)
jbe 0x41df
movq 0x1a0(%rsp), %rax
movl (%rax), %eax
movl %eax, 0x13c(%rsp)
movq 0x1a0(%rsp), %rax
movl 0x4(%rax), %eax
movl %eax, 0x138(%rsp)
movl 0x13c(%rsp), %eax
cmpl 0x168(%rsp), %eax
jne 0x41d8
movq 0x1a0(%rsp), %rax
movq %rax, 0x88(%rsp)
movl 0x190(%rsp), %ecx
leaq (%rax,%rcx,8), %rax
movq %rax, 0x90(%rsp)
leaq 0x118(%rsp), %rdi
leaq 0x1b0(%rsp), %rsi
callq 0x5620
jmp 0x40c1
movq 0x90(%rsp), %rsi
movq 0x88(%rsp), %rdi
leaq 0x118(%rsp), %rdx
callq 0x56e0
jmp 0x40e0
leaq 0x118(%rsp), %rdi
callq 0x56d0
movl 0x190(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x190(%rsp)
movl 0x13c(%rsp), %eax
movq 0x1e0(%rsp), %rcx
movl 0x138(%rsp), %edx
cmpl (%rcx,%rdx,4), %eax
je 0x41ac
movq 0x1e0(%rsp), %rax
movl 0x138(%rsp), %ecx
cmpl $0x0, (%rax,%rcx,4)
jle 0x41aa
movl 0x138(%rsp), %edx
movq 0x180(%rsp), %rax
movl 0x17c(%rsp), %ecx
movl %edx, (%rax,%rcx,4)
movl 0x17c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x17c(%rsp)
jmp 0x41aa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x198(%rsp)
movl %eax, 0x194(%rsp)
leaq 0x140(%rsp), %rdi
callq 0x56d0
jmp 0x4849
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x198(%rsp)
movl %eax, 0x194(%rsp)
leaq 0x118(%rsp), %rdi
callq 0x56d0
jmp 0x4849
jmp 0x41d6
movl 0x138(%rsp), %edx
movq 0x170(%rsp), %rax
movl 0x16c(%rsp), %ecx
movl %edx, (%rax,%rcx,4)
movl 0x16c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x16c(%rsp)
jmp 0x41da
jmp 0x41df
jmp 0x4042
jmp 0x41e1
cmpl $0x0, 0x16c(%rsp)
jbe 0x43de
callq 0x2410
xorl %edx, %edx
divl 0x16c(%rsp)
movl %edx, 0x114(%rsp)
movl 0x16c(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x16c(%rsp)
movq 0x170(%rsp), %rax
movl 0x114(%rsp), %ecx
movl (%rax,%rcx,4), %eax
movl %eax, 0x138(%rsp)
movq 0x170(%rsp), %rax
movl 0x16c(%rsp), %ecx
movl (%rax,%rcx,4), %edx
movq 0x170(%rsp), %rax
movl 0x114(%rsp), %ecx
movl %edx, (%rax,%rcx,4)
movq 0x1e0(%rsp), %rax
movl 0x138(%rsp), %ecx
movl (%rax,%rcx,4), %eax
cmpl 0x168(%rsp), %eax
je 0x42b1
movq 0x1e0(%rsp), %rax
movl 0x138(%rsp), %ecx
cmpl $0x0, (%rax,%rcx,4)
jle 0x42ac
movl 0x138(%rsp), %edx
movq 0x180(%rsp), %rax
movl 0x17c(%rsp), %ecx
movl %edx, (%rax,%rcx,4)
movl 0x17c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x17c(%rsp)
jmp 0x43d9
movq 0x1d0(%rsp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
movq 0x1e0(%rsp), %rax
movl 0x138(%rsp), %ecx
imull $-0x1, (%rax,%rcx,4), %edx
movq 0x1e0(%rsp), %rax
movl 0x138(%rsp), %ecx
movl %edx, (%rax,%rcx,4)
movq 0x1d8(%rsp), %rax
movl 0x138(%rsp), %ecx
movb $0x3, (%rax,%rcx)
movq 0x6eb1(%rip), %rax      # 0xb1b0
movl 0x138(%rsp), %ecx
movl (%rax,%rcx,4), %eax
movl %eax, 0x110(%rsp)
movl $0x0, 0x10c(%rsp)
movl 0x10c(%rsp), %eax
cmpl 0x110(%rsp), %eax
jae 0x43d7
movq 0x6e4a(%rip), %rax      # 0xb180
movl 0x138(%rsp), %ecx
movq (%rax,%rcx,8), %rax
movl 0x10c(%rsp), %ecx
movl (%rax,%rcx,4), %eax
movl %eax, 0x108(%rsp)
movq 0x1d8(%rsp), %rdi
movl 0x108(%rsp), %esi
callq 0x72f0
movb %al, 0x87(%rsp)
jmp 0x436f
movb 0x87(%rsp), %al
testb $0x1, %al
jne 0x437c
jmp 0x43a7
movq 0x1e0(%rsp), %rax
movl 0x108(%rsp), %ecx
movl (%rax,%rcx,4), %edx
addl $-0x1, %edx
movl %edx, (%rax,%rcx,4)
movl 0x18c(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x18c(%rsp)
jmp 0x43bf
movq 0x1e0(%rsp), %rax
movl 0x108(%rsp), %ecx
movl (%rax,%rcx,4), %edx
addl $0x1, %edx
movl %edx, (%rax,%rcx,4)
jmp 0x43c1
movl 0x10c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x10c(%rsp)
jmp 0x431b
jmp 0x43d9
jmp 0x41e1
jmp 0x43e0
cmpl $0x0, 0x17c(%rsp)
jbe 0x44eb
movl 0x17c(%rsp), %eax
decl %eax
movl %eax, 0x17c(%rsp)
movq 0x180(%rsp), %rax
movl 0x17c(%rsp), %ecx
movl (%rax,%rcx,4), %eax
movl %eax, 0x138(%rsp)
movl 0x138(%rsp), %edx
movq 0x1a0(%rsp), %rax
movl 0x190(%rsp), %ecx
movl %edx, 0x4(%rax,%rcx,8)
movq 0x1e0(%rsp), %rax
movl 0x138(%rsp), %ecx
movl (%rax,%rcx,4), %edx
movq 0x1a0(%rsp), %rax
movl 0x190(%rsp), %ecx
movl %edx, (%rax,%rcx,8)
movq 0x1a0(%rsp), %rax
movq %rax, 0x70(%rsp)
movl 0x190(%rsp), %ecx
leaq (%rax,%rcx,8), %rax
movq %rax, 0x78(%rsp)
leaq 0xe8(%rsp), %rdi
leaq 0x1b0(%rsp), %rsi
callq 0x5620
jmp 0x4489
movq 0x78(%rsp), %rsi
movq 0x70(%rsp), %rdi
leaq 0xe8(%rsp), %rdx
callq 0x57c0
jmp 0x44a2
leaq 0xe8(%rsp), %rdi
callq 0x56d0
movl 0x190(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x190(%rsp)
jmp 0x43e0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x198(%rsp)
movl %eax, 0x194(%rsp)
leaq 0xe8(%rsp), %rdi
callq 0x56d0
jmp 0x4849
jmp 0x3ffc
movl $0x0, 0xe4(%rsp)
movl 0xe4(%rsp), %eax
cmpl 0x6ce0(%rip), %eax      # 0xb1e8
jae 0x466a
movq 0x6ccb(%rip), %rax      # 0xb1e0
movl 0xe4(%rsp), %ecx
movl (%rax,%rcx,4), %eax
movl %eax, 0xe0(%rsp)
movq 0x1e0(%rsp), %rax
movl 0xe0(%rsp), %ecx
cmpl $0x0, (%rax,%rcx,4)
jne 0x4652
movq 0x1d8(%rsp), %rdi
movl 0xe0(%rsp), %esi
callq 0x72c0
movb %al, 0x6f(%rsp)
jmp 0x4559
movb 0x6f(%rsp), %al
testb $0x1, %al
jne 0x4566
jmp 0x4652
movq 0x1d0(%rsp), %rax
movl (%rax), %ecx
addl $-0x1, %ecx
movl %ecx, (%rax)
movq 0x1d8(%rsp), %rax
movl 0xe0(%rsp), %ecx
movb $0x0, (%rax,%rcx)
movq 0x6c21(%rip), %rax      # 0xb1b0
movl 0xe0(%rsp), %ecx
movl (%rax,%rcx,4), %eax
movl %eax, 0xdc(%rsp)
movl $0x0, 0xd8(%rsp)
movl 0xd8(%rsp), %eax
cmpl 0xdc(%rsp), %eax
jae 0x4650
movq 0x6bba(%rip), %rax      # 0xb180
movl 0xe0(%rsp), %ecx
movq (%rax,%rcx,8), %rax
movl 0xd8(%rsp), %ecx
movl (%rax,%rcx,4), %eax
movl %eax, 0xd4(%rsp)
movq 0x1d8(%rsp), %rdi
movl 0xd4(%rsp), %esi
callq 0x72f0
movb %al, 0x6e(%rsp)
jmp 0x45fc
movb 0x6e(%rsp), %al
testb $0x1, %al
jne 0x4606
jmp 0x4620
movq 0x1e0(%rsp), %rax
movl 0xd4(%rsp), %ecx
movl (%rax,%rcx,4), %edx
addl $0x1, %edx
movl %edx, (%rax,%rcx,4)
jmp 0x4638
movq 0x1e0(%rsp), %rax
movl 0xd4(%rsp), %ecx
movl (%rax,%rcx,4), %edx
addl $-0x1, %edx
movl %edx, (%rax,%rcx,4)
jmp 0x463a
movl 0xd8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xd8(%rsp)
jmp 0x45ab
jmp 0x4652
jmp 0x4654
movl 0xe4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xe4(%rsp)
jmp 0x44fb
movq 0x180(%rsp), %rax
movq %rax, 0x60(%rsp)
cmpq $0x0, %rax
je 0x4687
movq 0x60(%rsp), %rdi
callq 0x2160
movq 0x170(%rsp), %rax
movq %rax, 0x58(%rsp)
cmpq $0x0, %rax
je 0x46a4
movq 0x58(%rsp), %rdi
callq 0x2160
movq 0x1a0(%rsp), %rax
movq %rax, 0x50(%rsp)
cmpq $0x0, %rax
je 0x46c1
movq 0x50(%rsp), %rdi
callq 0x2160
leaq 0x6b38(%rip), %rdi      # 0xb200
callq 0x21b0
movq 0x6b2c(%rip), %rax      # 0xb200
movq 0x6add(%rip), %rcx      # 0xb1b8
subq %rcx, %rax
movq 0x6b23(%rip), %rcx      # 0xb208
addq %rcx, %rax
movq 0x6ad1(%rip), %rcx      # 0xb1c0
subq %rcx, %rax
cvtsi2sd %rax, %xmm0
movsd %xmm0, 0x38(%rsp)
movl $0x2, %edi
callq 0x20d0
movsd 0x38(%rsp), %xmm0
cvtsi2sd %rax, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0xc8(%rsp)
movsd 0xc8(%rsp), %xmm0
movsd 0x38d8(%rip), %xmm1     # 0x8008
movsd %xmm1, 0x40(%rsp)
mulsd %xmm1, %xmm0
callq 0x20b0
movsd 0x40(%rsp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0xc8(%rsp)
movq 0x687f(%rip), %rdi      # 0xafd8
leaq 0x3960(%rip), %rsi      # 0x80c0
callq 0x2130
movq %rax, 0x48(%rsp)
jmp 0x476c
movq 0x48(%rsp), %rdi
movq 0x1d0(%rsp), %rax
movl (%rax), %esi
callq 0x2180
movq %rax, 0x30(%rsp)
jmp 0x4787
movq 0x30(%rsp), %rdi
leaq 0x3946(%rip), %rsi      # 0x80d9
callq 0x2130
movq %rax, 0x28(%rsp)
jmp 0x479f
movq 0x28(%rsp), %rdi
movl 0x6a3e(%rip), %esi      # 0xb1e8
callq 0x2180
movq %rax, 0x20(%rsp)
jmp 0x47b6
movq 0x20(%rsp), %rdi
leaq 0x3917(%rip), %rsi      # 0x80d9
callq 0x2130
movq %rax, 0x18(%rsp)
jmp 0x47ce
movq 0x18(%rsp), %rdi
movq 0x1d0(%rsp), %rax
movl (%rax), %esi
movl 0x6a11(%rip), %eax      # 0xb1f4
addl %eax, %esi
callq 0x2180
movq %rax, 0x10(%rsp)
jmp 0x47f1
movq 0x10(%rsp), %rdi
leaq 0x3897(%rip), %rsi      # 0x8094
callq 0x2130
movq %rax, 0x8(%rsp)
jmp 0x4809
movq 0x8(%rsp), %rdi
movsd 0xc8(%rsp), %xmm0
callq 0x21f0
movq %rax, (%rsp)
jmp 0x4822
movq (%rsp), %rdi
movq 0x679b(%rip), %rsi      # 0xafc8
callq 0x2140
jmp 0x4834
leaq 0x1b0(%rsp), %rdi
callq 0x56d0
addq $0x1e8, %rsp            # imm = 0x1E8
retq
leaq 0x1b0(%rsp), %rdi
callq 0x56d0
movq 0x198(%rsp), %rdi
callq 0x21d0
nopw %cs:(%rax,%rax)