// File: JenTus[P]TCEM/src_TCEM/allocator.cc
// Function: Cide::allocator::degreeVersionOne(long long)
double allocator::degreeVersionOne(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);
        }

        seedSet.clear();
        seedScores.clear();
        set<int> rednodes;
        set<int> bluenodes;
        int testt;


        while ((int) seedSet.size() < k_r) {
            pair<int, double> pairVal = heap.top();
            heap.pop();
            bestNodeID = pairVal.first;
            seedSet.push_back(bestNodeID);
            rednodes.insert(bestNodeID);
        }


        while ((int) seedSet.size() < k_r + k_b) {
            pair<int, double> pairVal = heap.top();
            heap.pop();
            bestNodeID = pairVal.first;
            seedSet.push_back(bestNodeID);
            bluenodes.insert(bestNodeID);
        }

        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 one is " << totalscore*n << endl;

        std::ostringstream streamObj1;
        streamObj1 << std::fixed << std::setprecision(2)<<totalscore*n;

        writeInMasterOutputFile("DegreeVersionOne", totalDuration,  totalMemory, streamObj1.str(), rednodes, bluenodes);

        return totalscore;
    }

// Assembly:
subq $0x518, %rsp            # imm = 0x518
movq %rdi, 0x510(%rsp)
movq %rsi, 0x508(%rsp)
movq 0x510(%rsp), %rax
movq %rax, 0xe8(%rsp)
callq 0x4230
movq %rax, 0x500(%rsp)
leaq 0x4e0(%rsp), %rdi
callq 0xeb10
xorps %xmm0, %xmm0
movss %xmm0, 0x4dc(%rsp)
movl $0x0, 0x4d4(%rsp)
movq 0xe8(%rsp), %rcx
movl 0x4d4(%rsp), %eax
cmpl 0x68(%rcx), %eax
jge 0x78d8
movq 0xe8(%rsp), %rdi
addq $0xd8, %rdi
movslq 0x4d4(%rsp), %rsi
callq 0xe170
movsd (%rax), %xmm0
movsd %xmm0, 0x4c8(%rsp)
leaq 0x4d4(%rsp), %rdi
leaq 0x4c8(%rsp), %rsi
callq 0xeb40
movsd %xmm0, 0xd8(%rsp)
movl %eax, 0xe4(%rsp)
jmp 0x7870
movsd 0xd8(%rsp), %xmm0
movl 0xe4(%rsp), %eax
movl %eax, 0x4b8(%rsp)
movsd %xmm0, 0x4c0(%rsp)
leaq 0x4e0(%rsp), %rdi
leaq 0x4b8(%rsp), %rsi
callq 0xeb80
jmp 0x78a7
jmp 0x78a9
movl 0x4d4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x4d4(%rsp)
jmp 0x7808
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4b0(%rsp)
movl %eax, 0x4ac(%rsp)
jmp 0x82ef
movq 0xe8(%rsp), %rdi
addq $0xa8, %rdi
callq 0xe300
movq 0xe8(%rsp), %rdi
addq $0xc0, %rdi
callq 0xe320
leaq 0x478(%rsp), %rdi
callq 0xe2f0
leaq 0x448(%rsp), %rdi
callq 0xe2f0
movq 0xe8(%rsp), %rdi
addq $0xa8, %rdi
callq 0xe130
movq 0xe8(%rsp), %rcx
cmpl 0x78(%rcx), %eax
jge 0x7a06
leaq 0x4e0(%rsp), %rdi
callq 0xebe0
movq %rax, 0xd0(%rsp)
jmp 0x7956
movq 0xd0(%rsp), %rax
movups (%rax), %xmm0
movaps %xmm0, 0x430(%rsp)
leaq 0x4e0(%rsp), %rdi
callq 0xebf0
jmp 0x7978
movq 0xe8(%rsp), %rdi
movl 0x430(%rsp), %eax
movl %eax, 0x4d8(%rsp)
addq $0xa8, %rdi
leaq 0x4d8(%rsp), %rsi
callq 0xe060
jmp 0x79a4
leaq 0x478(%rsp), %rdi
leaq 0x4d8(%rsp), %rsi
callq 0xe4a0
movb %dl, 0xc7(%rsp)
movq %rax, 0xc8(%rsp)
jmp 0x79ca
movb 0xc7(%rsp), %al
movq 0xc8(%rsp), %rcx
movq %rcx, 0x420(%rsp)
movb %al, 0x428(%rsp)
jmp 0x791a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4b0(%rsp)
movl %eax, 0x4ac(%rsp)
jmp 0x82d5
jmp 0x7a08
movq 0xe8(%rsp), %rdi
addq $0xa8, %rdi
callq 0xe130
movq 0xe8(%rsp), %rdx
movl 0x78(%rdx), %ecx
addl 0x7c(%rdx), %ecx
cmpl %ecx, %eax
jge 0x7ae0
leaq 0x4e0(%rsp), %rdi
callq 0xebe0
movq %rax, 0xb8(%rsp)
jmp 0x7a49
movq 0xb8(%rsp), %rax
movups (%rax), %xmm0
movaps %xmm0, 0x410(%rsp)
leaq 0x4e0(%rsp), %rdi
callq 0xebf0
jmp 0x7a6b
movq 0xe8(%rsp), %rdi
movl 0x410(%rsp), %eax
movl %eax, 0x4d8(%rsp)
addq $0xa8, %rdi
leaq 0x4d8(%rsp), %rsi
callq 0xe060
jmp 0x7a97
leaq 0x448(%rsp), %rdi
leaq 0x4d8(%rsp), %rsi
callq 0xe4a0
movb %dl, 0xaf(%rsp)
movq %rax, 0xb0(%rsp)
jmp 0x7abd
movb 0xaf(%rsp), %al
movq 0xb0(%rsp), %rcx
movq %rcx, 0x400(%rsp)
movb %al, 0x408(%rsp)
jmp 0x7a08
movl $0x0, 0x3fc(%rsp)
leaq 0x478(%rsp), %rdi
movq %rdi, 0x98(%rsp)
callq 0xe760
movq 0x98(%rsp), %rdi
movq %rax, 0x3d8(%rsp)
callq 0xe790
movq %rax, 0x3d0(%rsp)
leaq 0x3cf(%rsp), %rdi
movq %rdi, 0xa0(%rsp)
callq 0xe1b0
movq 0xa0(%rsp), %rcx
movq 0x3d8(%rsp), %rsi
movq 0x3d0(%rsp), %rdx
leaq 0x3e0(%rsp), %rdi
callq 0xe7c0
jmp 0x7b59
leaq 0x3cf(%rsp), %rdi
callq 0xe240
leaq 0x448(%rsp), %rdi
movq %rdi, 0x88(%rsp)
callq 0xe760
movq 0x88(%rsp), %rdi
movq %rax, 0x3a8(%rsp)
callq 0xe790
movq %rax, 0x3a0(%rsp)
leaq 0x39f(%rsp), %rdi
movq %rdi, 0x90(%rsp)
callq 0xe1b0
movq 0x90(%rsp), %rcx
movq 0x3a8(%rsp), %rsi
movq 0x3a0(%rsp), %rdx
leaq 0x3b0(%rsp), %rdi
callq 0xe7c0
jmp 0x7bd4
leaq 0x39f(%rsp), %rdi
callq 0xe240
leaq 0x3e0(%rsp), %rdi
movq %rdi, 0x80(%rsp)
callq 0xe890
movq 0x80(%rsp), %rdi
movq %rax, 0x390(%rsp)
callq 0xe8c0
movq %rax, 0x388(%rsp)
movq 0x390(%rsp), %rdi
movq 0x388(%rsp), %rsi
callq 0xe850
jmp 0x7c2a
leaq 0x3b0(%rsp), %rdi
movq %rdi, 0x78(%rsp)
callq 0xe890
movq 0x78(%rsp), %rdi
movq %rax, 0x380(%rsp)
callq 0xe8c0
movq %rax, 0x378(%rsp)
movq 0x380(%rsp), %rdi
movq 0x378(%rsp), %rsi
callq 0xe850
jmp 0x7c6d
movl $0x0, 0x374(%rsp)
movslq 0x374(%rsp), %rax
cmpq 0x508(%rsp), %rax
jge 0x7ef7
movq 0xe8(%rsp), %rax
movq 0xae8(%rax), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xe0d0
movq %rax, 0x70(%rsp)
jmp 0x7cad
movq 0x70(%rsp), %rax
movq (%rax), %rdi
addq $0x18, %rdi
movslq 0x374(%rsp), %rsi
callq 0xe110
movq %rax, %rsi
leaq 0x358(%rsp), %rdi
callq 0xe8f0
jmp 0x7cd8
movq 0xe8(%rsp), %rax
movq 0xae8(%rax), %rdi
movl $0x1, %esi
callq 0xe0d0
movq %rax, 0x68(%rsp)
jmp 0x7cf8
movq 0x68(%rsp), %rax
movq (%rax), %rdi
addq $0x18, %rdi
movslq 0x374(%rsp), %rsi
callq 0xe110
movq %rax, %rsi
leaq 0x340(%rsp), %rdi
callq 0xe8f0
jmp 0x7d23
leaq 0x358(%rsp), %rdi
movq %rdi, 0x60(%rsp)
callq 0xe890
movq 0x60(%rsp), %rdi
movq %rax, 0x338(%rsp)
callq 0xe8c0
movq %rax, 0x330(%rsp)
movq 0x338(%rsp), %rdi
movq 0x330(%rsp), %rsi
callq 0xe850
jmp 0x7d66
leaq 0x340(%rsp), %rdi
movq %rdi, 0x58(%rsp)
callq 0xe890
movq 0x58(%rsp), %rdi
movq %rax, 0x328(%rsp)
callq 0xe8c0
movq %rax, 0x320(%rsp)
movq 0x328(%rsp), %rdi
movq 0x320(%rsp), %rsi
callq 0xe850
jmp 0x7da9
leaq 0x3e0(%rsp), %rdi
leaq 0x358(%rsp), %rsi
callq 0xe9f0
movq %rax, 0x50(%rsp)
jmp 0x7dc5
movq 0x50(%rsp), %rax
cmpq $0x1, %rax
jb 0x7eb5
leaq 0x3b0(%rsp), %rdi
leaq 0x340(%rsp), %rsi
callq 0xe9f0
movq %rax, 0x48(%rsp)
jmp 0x7df0
movq 0x48(%rsp), %rax
cmpq $0x1, %rax
jb 0x7eb3
movl 0x3fc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x3fc(%rsp)
jmp 0x7eb3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4b0(%rsp)
movl %eax, 0x4ac(%rsp)
leaq 0x3cf(%rsp), %rdi
callq 0xe240
jmp 0x82d5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4b0(%rsp)
movl %eax, 0x4ac(%rsp)
leaq 0x39f(%rsp), %rdi
callq 0xe240
jmp 0x82c8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4b0(%rsp)
movl %eax, 0x4ac(%rsp)
jmp 0x82bb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4b0(%rsp)
movl %eax, 0x4ac(%rsp)
jmp 0x7ee5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4b0(%rsp)
movl %eax, 0x4ac(%rsp)
leaq 0x340(%rsp), %rdi
callq 0xdbe0
jmp 0x7ee5
jmp 0x7eb5
leaq 0x340(%rsp), %rdi
callq 0xdbe0
leaq 0x358(%rsp), %rdi
callq 0xdbe0
movl 0x374(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x374(%rsp)
jmp 0x7c78
leaq 0x358(%rsp), %rdi
callq 0xdbe0
jmp 0x82bb
cvtsi2ssl 0x3fc(%rsp), %xmm0
cvtsi2ssq 0x508(%rsp), %xmm1
divss %xmm1, %xmm0
movss %xmm0, 0x4dc(%rsp)
callq 0x4230
movq %rax, %rcx
movq 0xe8(%rsp), %rax
movq %rcx, 0x318(%rsp)
movq 0x318(%rsp), %rcx
movq 0x500(%rsp), %rdx
subq %rdx, %rcx
cvtsi2sd %rcx, %xmm0
movsd 0x1c1a9(%rip), %xmm1    # 0x240f8
divsd %xmm1, %xmm0
movsd 0x8(%rax), %xmm1
addsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0xb70(%rax)
callq 0x1be40
movss %xmm0, 0x44(%rsp)
jmp 0x7f75
movq 0xe8(%rsp), %rax
movss 0x44(%rsp), %xmm0
movss %xmm0, 0xb74(%rax)
movq 0x27046(%rip), %rdi     # 0x2efd8
leaq 0x1c2f1(%rip), %rsi     # 0x2428a
callq 0x4370
movq %rax, 0x38(%rsp)
jmp 0x7fa5
movq 0x38(%rsp), %rdi
movq 0xe8(%rsp), %rax
movss 0x4dc(%rsp), %xmm0
cvtsi2ssl 0x68(%rax), %xmm1
mulss %xmm1, %xmm0
callq 0x4270
movq %rax, 0x30(%rsp)
jmp 0x7fd0
movq 0x30(%rsp), %rdi
movq 0x26fec(%rip), %rsi     # 0x2efc8
callq 0x43c0
jmp 0x7fe3
leaq 0x1a0(%rsp), %rdi
callq 0x44c0
jmp 0x7ff2
leaq 0x6a87(%rip), %rsi      # 0xea80
leaq 0x1a0(%rsp), %rdi
callq 0x40f0
movq %rax, 0x28(%rsp)
jmp 0x800d
movl $0x2, %edi
callq 0xeaa0
movl %eax, 0x24(%rsp)
jmp 0x801d
movq 0x28(%rsp), %rdi
movl 0x24(%rsp), %eax
movl %eax, 0x19c(%rsp)
movl 0x19c(%rsp), %esi
callq 0x45a0
movq %rax, 0x18(%rsp)
jmp 0x8040
movq 0x18(%rsp), %rdi
movq 0xe8(%rsp), %rax
movss 0x4dc(%rsp), %xmm0
cvtsi2ssl 0x68(%rax), %xmm1
mulss %xmm1, %xmm0
callq 0x4270
jmp 0x8066
leaq 0x177(%rsp), %rdi
movq %rdi, 0x10(%rsp)
callq 0x4690
movq 0x10(%rsp), %rdx
leaq 0x1c224(%rip), %rsi     # 0x242a8
leaq 0x178(%rsp), %rdi
callq 0x44f0
jmp 0x8093
movq 0xe8(%rsp), %rax
movss 0xb70(%rax), %xmm0
movss %xmm0, 0x8(%rsp)
movss 0xb74(%rax), %xmm0
movss %xmm0, 0xc(%rsp)
leaq 0x150(%rsp), %rdi
leaq 0x1a0(%rsp), %rsi
callq 0x4390
jmp 0x80ce
leaq 0x120(%rsp), %rdi
leaq 0x478(%rsp), %rsi
callq 0xeac0
jmp 0x80e5
leaq 0xf0(%rsp), %rdi
leaq 0x448(%rsp), %rsi
callq 0xeac0
jmp 0x80fc
movss 0xc(%rsp), %xmm1
movss 0x8(%rsp), %xmm0
movq 0xe8(%rsp), %rdi
leaq 0x178(%rsp), %rsi
leaq 0x150(%rsp), %rdx
leaq 0x120(%rsp), %rcx
leaq 0xf0(%rsp), %r8
callq 0xd380
jmp 0x8137
leaq 0xf0(%rsp), %rdi
callq 0xeaf0
leaq 0x120(%rsp), %rdi
callq 0xeaf0
leaq 0x150(%rsp), %rdi
callq 0x41f0
leaq 0x178(%rsp), %rdi
callq 0x41f0
leaq 0x177(%rsp), %rdi
callq 0x43e0
movss 0x4dc(%rsp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, (%rsp)
leaq 0x1a0(%rsp), %rdi
callq 0x40c0
leaq 0x3b0(%rsp), %rdi
callq 0xdbe0
leaq 0x3e0(%rsp), %rdi
callq 0xdbe0
leaq 0x448(%rsp), %rdi
callq 0xeaf0
leaq 0x478(%rsp), %rdi
callq 0xeaf0
leaq 0x4e0(%rsp), %rdi
callq 0xec40
movsd (%rsp), %xmm0
addq $0x518, %rsp            # imm = 0x518
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4b0(%rsp)
movl %eax, 0x4ac(%rsp)
jmp 0x82ae
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4b0(%rsp)
movl %eax, 0x4ac(%rsp)
jmp 0x82a1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4b0(%rsp)
movl %eax, 0x4ac(%rsp)
jmp 0x8294
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4b0(%rsp)
movl %eax, 0x4ac(%rsp)
jmp 0x8287
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4b0(%rsp)
movl %eax, 0x4ac(%rsp)
jmp 0x827a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4b0(%rsp)
movl %eax, 0x4ac(%rsp)
leaq 0xf0(%rsp), %rdi
callq 0xeaf0
leaq 0x120(%rsp), %rdi
callq 0xeaf0
leaq 0x150(%rsp), %rdi
callq 0x41f0
leaq 0x178(%rsp), %rdi
callq 0x41f0
leaq 0x177(%rsp), %rdi
callq 0x43e0
leaq 0x1a0(%rsp), %rdi
callq 0x40c0
leaq 0x3b0(%rsp), %rdi
callq 0xdbe0
leaq 0x3e0(%rsp), %rdi
callq 0xdbe0
leaq 0x448(%rsp), %rdi
callq 0xeaf0
leaq 0x478(%rsp), %rdi
callq 0xeaf0
leaq 0x4e0(%rsp), %rdi
callq 0xec40
movq 0x4b0(%rsp), %rdi
callq 0x4680
nopl (%rax)