// File: JenTus[P]TCEM/src_TCEM/allocator.cc
// Function: Cide::allocator::degreeVersionTwo(long long)
double allocator::degreeVersionTwo(int64 rcSampleSize) {


        clock_t begin = clock();
        priority_queue<pair<int, double>, vector<pair<int, double>>, CompareBySecond> heap;

        float totalscore = 0;
        int bestNodeID;
//
        for (int i = 0; i < n; i++) {
            double val = (double) nodeDegree[i];
            std::pair<int, double> pairVal(std::make_pair(i, val));
            heap.push(pairVal);
        }

        std::set<int> rednodes, bluenodes;
        seedSet.clear();
        seedScores.clear();
        //std::set<int> rrRed;
        //std::set<int> rrBlue;
        //int testt;

        //rrRed.reserve(n*k_r);
        //rrBlue.reserve(n*k_b);

        while ((int) seedSet.size() < k_r + k_r) {
            pair<int, double> pairVal = heap.top();
            heap.pop();
            bestNodeID = pairVal.first;
           // for (int j = 0; j < hyperG[bestNodeID].size(); ++j) {
           //     int id = hyperG[bestNodeID][j];
           //     rrRed.insert(id);
           // }

            seedSet.push_back(bestNodeID);
            rednodes.insert(bestNodeID);

            pairVal = heap.top();
            heap.pop();
            bestNodeID = pairVal.first;
           // for (int j = 0; j < hyperG[bestNodeID + n].size(); ++j) {
           //     int id = hyperG[bestNodeID + n][j];
           //     rrBlue.insert(id);
           // }

            seedSet.push_back(bestNodeID);
            bluenodes.insert(bestNodeID);
        }

        while ((int) seedSet.size() < k_r + k_b) {
            pair<int, double> pairVal = heap.top();
            heap.pop();
            bestNodeID = pairVal.first;
           // for (int l = 0; l < hyperG[bestNodeID + n].size(); ++l) {
           //     int id = hyperG[bestNodeID + n][l];
           //     rrBlue.insert(id);
           // }
            seedSet.push_back(bestNodeID);
            bluenodes.insert(bestNodeID);
        }

        /*

        vector<int> rrRedV(rrRed.begin(), rrRed.end());
        vector<int> rrBlueV(rrBlue.begin(), rrBlue.end());

        std::sort(rrRedV.begin(), rrRedV.end());
        std::sort(rrBlueV.begin(), rrBlueV.end());

        testt = intersection_size(rrRedV, rrBlueV);
        cout << "intersection is " << testt;
        */

        int redbluecount = 0;

        vector<int> s1(rednodes.begin(), rednodes.end());
        vector<int> s2(bluenodes.begin(), bluenodes.end());
        sort(s1.begin(), s1.end());
        sort(s2.begin(), s2.end());


        for (int i = 0; i < rcSampleSize; ++i) {
            vector<int> RedList = rcList->at(0)->hyperGT[i];
            vector<int> BlueList = rcList->at(1)->hyperGT[i];

            sort(RedList.begin(), RedList.end());
            sort(BlueList.begin(), BlueList.end());

            if(intersection_size(s1, RedList) >= 1){
                if(intersection_size(s2, BlueList) >= 1){
                    redbluecount +=1;
                }
            }
        }


        //cout << " redBluecount is " << redbluecount << endl;

        totalscore = (float) redbluecount / (float) rcSampleSize;

        // end of extra results
        clock_t end = clock();
        totalDuration = double(end - begin) / CLOCKS_PER_SEC + duration_common; // in seconds
        totalMemory = getCurrentMemoryUsage(); // in MB


        cout << "Total score of degree two is " << totalscore*n << endl;
        std::ostringstream streamObj1;
        streamObj1 << std::fixed << std::setprecision(2)<<totalscore*n;

        writeInMasterOutputFile("DegreeVersionTwo", totalDuration,  totalMemory, streamObj1.str(), rednodes, bluenodes);
        return totalscore;
    }

// Assembly:
subq $0x548, %rsp            # imm = 0x548
movq %rdi, 0x540(%rsp)
movq %rsi, 0x538(%rsp)
movq 0x540(%rsp), %rax
movq %rax, 0x108(%rsp)
callq 0x4230
movq %rax, 0x530(%rsp)
leaq 0x510(%rsp), %rdi
callq 0xeb10
xorps %xmm0, %xmm0
movss %xmm0, 0x50c(%rsp)
movl $0x0, 0x504(%rsp)
movq 0x108(%rsp), %rcx
movl 0x504(%rsp), %eax
cmpl 0x68(%rcx), %eax
jge 0x8438
movq 0x108(%rsp), %rdi
addq $0xd8, %rdi
movslq 0x504(%rsp), %rsi
callq 0xe170
movsd (%rax), %xmm0
movsd %xmm0, 0x4f8(%rsp)
leaq 0x504(%rsp), %rdi
leaq 0x4f8(%rsp), %rsi
callq 0xeb40
movsd %xmm0, 0xf8(%rsp)
movl %eax, 0x104(%rsp)
jmp 0x83d0
movsd 0xf8(%rsp), %xmm0
movl 0x104(%rsp), %eax
movl %eax, 0x4e8(%rsp)
movsd %xmm0, 0x4f0(%rsp)
leaq 0x510(%rsp), %rdi
leaq 0x4e8(%rsp), %rsi
callq 0xeb80
jmp 0x8407
jmp 0x8409
movl 0x504(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x504(%rsp)
jmp 0x8368
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4e0(%rsp)
movl %eax, 0x4dc(%rsp)
jmp 0x8f09
leaq 0x4a8(%rsp), %rdi
callq 0xe2f0
leaq 0x478(%rsp), %rdi
callq 0xe2f0
movq 0x108(%rsp), %rdi
addq $0xa8, %rdi
callq 0xe300
movq 0x108(%rsp), %rdi
addq $0xc0, %rdi
callq 0xe320
movq 0x108(%rsp), %rdi
addq $0xa8, %rdi
callq 0xe130
movq 0x108(%rsp), %rdx
movl 0x78(%rdx), %ecx
addl 0x78(%rdx), %ecx
cmpl %ecx, %eax
jge 0x8618
leaq 0x510(%rsp), %rdi
callq 0xebe0
movq %rax, 0xf0(%rsp)
jmp 0x84bb
movq 0xf0(%rsp), %rax
movups (%rax), %xmm0
movaps %xmm0, 0x460(%rsp)
leaq 0x510(%rsp), %rdi
callq 0xebf0
jmp 0x84dd
movq 0x108(%rsp), %rdi
movl 0x460(%rsp), %eax
movl %eax, 0x508(%rsp)
addq $0xa8, %rdi
leaq 0x508(%rsp), %rsi
callq 0xe060
jmp 0x8509
leaq 0x4a8(%rsp), %rdi
leaq 0x508(%rsp), %rsi
callq 0xe4a0
movb %dl, 0xe7(%rsp)
movq %rax, 0xe8(%rsp)
jmp 0x852f
movb 0xe7(%rsp), %al
movq 0xe8(%rsp), %rcx
movq %rcx, 0x450(%rsp)
movb %al, 0x458(%rsp)
leaq 0x510(%rsp), %rdi
callq 0xebe0
movq %rax, 0xd8(%rsp)
jmp 0x8564
movq 0xd8(%rsp), %rsi
leaq 0x460(%rsp), %rdi
callq 0xec50
jmp 0x857b
leaq 0x510(%rsp), %rdi
callq 0xebf0
jmp 0x858a
movq 0x108(%rsp), %rdi
movl 0x460(%rsp), %eax
movl %eax, 0x508(%rsp)
addq $0xa8, %rdi
leaq 0x508(%rsp), %rsi
callq 0xe060
jmp 0x85b6
leaq 0x478(%rsp), %rdi
leaq 0x508(%rsp), %rsi
callq 0xe4a0
movb %dl, 0xcf(%rsp)
movq %rax, 0xd0(%rsp)
jmp 0x85dc
movb 0xcf(%rsp), %al
movq 0xd0(%rsp), %rcx
movq %rcx, 0x440(%rsp)
movb %al, 0x448(%rsp)
jmp 0x847a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4e0(%rsp)
movl %eax, 0x4dc(%rsp)
jmp 0x8eef
jmp 0x861a
movq 0x108(%rsp), %rdi
addq $0xa8, %rdi
callq 0xe130
movq 0x108(%rsp), %rdx
movl 0x78(%rdx), %ecx
addl 0x7c(%rdx), %ecx
cmpl %ecx, %eax
jge 0x86f2
leaq 0x510(%rsp), %rdi
callq 0xebe0
movq %rax, 0xc0(%rsp)
jmp 0x865b
movq 0xc0(%rsp), %rax
movups (%rax), %xmm0
movaps %xmm0, 0x430(%rsp)
leaq 0x510(%rsp), %rdi
callq 0xebf0
jmp 0x867d
movq 0x108(%rsp), %rdi
movl 0x430(%rsp), %eax
movl %eax, 0x508(%rsp)
addq $0xa8, %rdi
leaq 0x508(%rsp), %rsi
callq 0xe060
jmp 0x86a9
leaq 0x478(%rsp), %rdi
leaq 0x508(%rsp), %rsi
callq 0xe4a0
movb %dl, 0xb7(%rsp)
movq %rax, 0xb8(%rsp)
jmp 0x86cf
movb 0xb7(%rsp), %al
movq 0xb8(%rsp), %rcx
movq %rcx, 0x420(%rsp)
movb %al, 0x428(%rsp)
jmp 0x861a
movl $0x0, 0x41c(%rsp)
leaq 0x4a8(%rsp), %rdi
movq %rdi, 0xa0(%rsp)
callq 0xe760
movq 0xa0(%rsp), %rdi
movq %rax, 0x3f8(%rsp)
callq 0xe790
movq %rax, 0x3f0(%rsp)
leaq 0x3ef(%rsp), %rdi
movq %rdi, 0xa8(%rsp)
callq 0xe1b0
movq 0xa8(%rsp), %rcx
movq 0x3f8(%rsp), %rsi
movq 0x3f0(%rsp), %rdx
leaq 0x400(%rsp), %rdi
callq 0xe7c0
jmp 0x876b
leaq 0x3ef(%rsp), %rdi
callq 0xe240
leaq 0x478(%rsp), %rdi
movq %rdi, 0x90(%rsp)
callq 0xe760
movq 0x90(%rsp), %rdi
movq %rax, 0x3c8(%rsp)
callq 0xe790
movq %rax, 0x3c0(%rsp)
leaq 0x3bf(%rsp), %rdi
movq %rdi, 0x98(%rsp)
callq 0xe1b0
movq 0x98(%rsp), %rcx
movq 0x3c8(%rsp), %rsi
movq 0x3c0(%rsp), %rdx
leaq 0x3d0(%rsp), %rdi
callq 0xe7c0
jmp 0x87e6
leaq 0x3bf(%rsp), %rdi
callq 0xe240
leaq 0x400(%rsp), %rdi
movq %rdi, 0x88(%rsp)
callq 0xe890
movq 0x88(%rsp), %rdi
movq %rax, 0x3b0(%rsp)
callq 0xe8c0
movq %rax, 0x3a8(%rsp)
movq 0x3b0(%rsp), %rdi
movq 0x3a8(%rsp), %rsi
callq 0xe850
jmp 0x883c
leaq 0x3d0(%rsp), %rdi
movq %rdi, 0x80(%rsp)
callq 0xe890
movq 0x80(%rsp), %rdi
movq %rax, 0x3a0(%rsp)
callq 0xe8c0
movq %rax, 0x398(%rsp)
movq 0x3a0(%rsp), %rdi
movq 0x398(%rsp), %rsi
callq 0xe850
jmp 0x8885
movl $0x0, 0x394(%rsp)
movslq 0x394(%rsp), %rax
cmpq 0x538(%rsp), %rax
jge 0x8b0f
movq 0x108(%rsp), %rax
movq 0xae8(%rax), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xe0d0
movq %rax, 0x78(%rsp)
jmp 0x88c5
movq 0x78(%rsp), %rax
movq (%rax), %rdi
addq $0x18, %rdi
movslq 0x394(%rsp), %rsi
callq 0xe110
movq %rax, %rsi
leaq 0x378(%rsp), %rdi
callq 0xe8f0
jmp 0x88f0
movq 0x108(%rsp), %rax
movq 0xae8(%rax), %rdi
movl $0x1, %esi
callq 0xe0d0
movq %rax, 0x70(%rsp)
jmp 0x8910
movq 0x70(%rsp), %rax
movq (%rax), %rdi
addq $0x18, %rdi
movslq 0x394(%rsp), %rsi
callq 0xe110
movq %rax, %rsi
leaq 0x360(%rsp), %rdi
callq 0xe8f0
jmp 0x893b
leaq 0x378(%rsp), %rdi
movq %rdi, 0x68(%rsp)
callq 0xe890
movq 0x68(%rsp), %rdi
movq %rax, 0x358(%rsp)
callq 0xe8c0
movq %rax, 0x350(%rsp)
movq 0x358(%rsp), %rdi
movq 0x350(%rsp), %rsi
callq 0xe850
jmp 0x897e
leaq 0x360(%rsp), %rdi
movq %rdi, 0x60(%rsp)
callq 0xe890
movq 0x60(%rsp), %rdi
movq %rax, 0x348(%rsp)
callq 0xe8c0
movq %rax, 0x340(%rsp)
movq 0x348(%rsp), %rdi
movq 0x340(%rsp), %rsi
callq 0xe850
jmp 0x89c1
leaq 0x400(%rsp), %rdi
leaq 0x378(%rsp), %rsi
callq 0xe9f0
movq %rax, 0x58(%rsp)
jmp 0x89dd
movq 0x58(%rsp), %rax
cmpq $0x1, %rax
jb 0x8acd
leaq 0x3d0(%rsp), %rdi
leaq 0x360(%rsp), %rsi
callq 0xe9f0
movq %rax, 0x50(%rsp)
jmp 0x8a08
movq 0x50(%rsp), %rax
cmpq $0x1, %rax
jb 0x8acb
movl 0x41c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x41c(%rsp)
jmp 0x8acb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4e0(%rsp)
movl %eax, 0x4dc(%rsp)
leaq 0x3ef(%rsp), %rdi
callq 0xe240
jmp 0x8eef
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4e0(%rsp)
movl %eax, 0x4dc(%rsp)
leaq 0x3bf(%rsp), %rdi
callq 0xe240
jmp 0x8ee2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4e0(%rsp)
movl %eax, 0x4dc(%rsp)
jmp 0x8ed5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4e0(%rsp)
movl %eax, 0x4dc(%rsp)
jmp 0x8afd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4e0(%rsp)
movl %eax, 0x4dc(%rsp)
leaq 0x360(%rsp), %rdi
callq 0xdbe0
jmp 0x8afd
jmp 0x8acd
leaq 0x360(%rsp), %rdi
callq 0xdbe0
leaq 0x378(%rsp), %rdi
callq 0xdbe0
movl 0x394(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x394(%rsp)
jmp 0x8890
leaq 0x378(%rsp), %rdi
callq 0xdbe0
jmp 0x8ed5
cvtsi2ssl 0x41c(%rsp), %xmm0
cvtsi2ssq 0x538(%rsp), %xmm1
divss %xmm1, %xmm0
movss %xmm0, 0x50c(%rsp)
callq 0x4230
movq %rax, %rcx
movq 0x108(%rsp), %rax
movq %rcx, 0x338(%rsp)
movq 0x338(%rsp), %rcx
movq 0x530(%rsp), %rdx
subq %rdx, %rcx
cvtsi2sd %rcx, %xmm0
movsd 0x1b591(%rip), %xmm1    # 0x240f8
divsd %xmm1, %xmm0
movsd 0x8(%rax), %xmm1
addsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0xb70(%rax)
callq 0x1be40
movss %xmm0, 0x4c(%rsp)
jmp 0x8b8d
movq 0x108(%rsp), %rax
movss 0x4c(%rsp), %xmm0
movss %xmm0, 0xb74(%rax)
movq 0x2642e(%rip), %rdi     # 0x2efd8
leaq 0x1b708(%rip), %rsi     # 0x242b9
callq 0x4370
movq %rax, 0x40(%rsp)
jmp 0x8bbd
movq 0x40(%rsp), %rdi
movq 0x108(%rsp), %rax
movss 0x50c(%rsp), %xmm0
cvtsi2ssl 0x68(%rax), %xmm1
mulss %xmm1, %xmm0
callq 0x4270
movq %rax, 0x38(%rsp)
jmp 0x8be8
movq 0x38(%rsp), %rdi
movq 0x263d4(%rip), %rsi     # 0x2efc8
callq 0x43c0
jmp 0x8bfb
leaq 0x1c0(%rsp), %rdi
callq 0x44c0
jmp 0x8c0a
leaq 0x5e6f(%rip), %rsi      # 0xea80
leaq 0x1c0(%rsp), %rdi
callq 0x40f0
movq %rax, 0x30(%rsp)
jmp 0x8c25
movl $0x2, %edi
callq 0xeaa0
movl %eax, 0x2c(%rsp)
jmp 0x8c35
movq 0x30(%rsp), %rdi
movl 0x2c(%rsp), %eax
movl %eax, 0x1bc(%rsp)
movl 0x1bc(%rsp), %esi
callq 0x45a0
movq %rax, 0x20(%rsp)
jmp 0x8c58
movq 0x20(%rsp), %rdi
movq 0x108(%rsp), %rax
movss 0x50c(%rsp), %xmm0
cvtsi2ssl 0x68(%rax), %xmm1
mulss %xmm1, %xmm0
callq 0x4270
jmp 0x8c7e
leaq 0x197(%rsp), %rdi
movq %rdi, 0x18(%rsp)
callq 0x4690
movq 0x18(%rsp), %rdx
leaq 0x1b63b(%rip), %rsi     # 0x242d7
leaq 0x198(%rsp), %rdi
callq 0x44f0
jmp 0x8cab
movq 0x108(%rsp), %rax
movss 0xb70(%rax), %xmm0
movss %xmm0, 0x10(%rsp)
movss 0xb74(%rax), %xmm0
movss %xmm0, 0x14(%rsp)
leaq 0x170(%rsp), %rdi
leaq 0x1c0(%rsp), %rsi
callq 0x4390
jmp 0x8ce6
leaq 0x140(%rsp), %rdi
leaq 0x4a8(%rsp), %rsi
callq 0xeac0
jmp 0x8cfd
leaq 0x110(%rsp), %rdi
leaq 0x478(%rsp), %rsi
callq 0xeac0
jmp 0x8d14
movss 0x14(%rsp), %xmm1
movss 0x10(%rsp), %xmm0
movq 0x108(%rsp), %rdi
leaq 0x198(%rsp), %rsi
leaq 0x170(%rsp), %rdx
leaq 0x140(%rsp), %rcx
leaq 0x110(%rsp), %r8
callq 0xd380
jmp 0x8d4f
leaq 0x110(%rsp), %rdi
callq 0xeaf0
leaq 0x140(%rsp), %rdi
callq 0xeaf0
leaq 0x170(%rsp), %rdi
callq 0x41f0
leaq 0x198(%rsp), %rdi
callq 0x41f0
leaq 0x197(%rsp), %rdi
callq 0x43e0
movss 0x50c(%rsp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, 0x8(%rsp)
leaq 0x1c0(%rsp), %rdi
callq 0x40c0
leaq 0x3d0(%rsp), %rdi
callq 0xdbe0
leaq 0x400(%rsp), %rdi
callq 0xdbe0
leaq 0x478(%rsp), %rdi
callq 0xeaf0
leaq 0x4a8(%rsp), %rdi
callq 0xeaf0
leaq 0x510(%rsp), %rdi
callq 0xec40
movsd 0x8(%rsp), %xmm0
addq $0x548, %rsp            # imm = 0x548
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4e0(%rsp)
movl %eax, 0x4dc(%rsp)
jmp 0x8ec8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4e0(%rsp)
movl %eax, 0x4dc(%rsp)
jmp 0x8ebb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4e0(%rsp)
movl %eax, 0x4dc(%rsp)
jmp 0x8eae
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4e0(%rsp)
movl %eax, 0x4dc(%rsp)
jmp 0x8ea1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4e0(%rsp)
movl %eax, 0x4dc(%rsp)
jmp 0x8e94
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4e0(%rsp)
movl %eax, 0x4dc(%rsp)
leaq 0x110(%rsp), %rdi
callq 0xeaf0
leaq 0x140(%rsp), %rdi
callq 0xeaf0
leaq 0x170(%rsp), %rdi
callq 0x41f0
leaq 0x198(%rsp), %rdi
callq 0x41f0
leaq 0x197(%rsp), %rdi
callq 0x43e0
leaq 0x1c0(%rsp), %rdi
callq 0x40c0
leaq 0x3d0(%rsp), %rdi
callq 0xdbe0
leaq 0x400(%rsp), %rdi
callq 0xdbe0
leaq 0x478(%rsp), %rdi
callq 0xeaf0
leaq 0x4a8(%rsp), %rdi
callq 0xeaf0
leaq 0x510(%rsp), %rdi
callq 0xec40
movq 0x4e0(%rsp), %rdi
callq 0x4680
nopw %cs:(%rax,%rax)