// File: JenTus[P]TCEM/src_TCEM/allocator.cc
// Function: Cide::allocator::generateRCSets(long long)
void allocator::generateRCSets(int64 newSize) {
        
        if(newSize < prevSize){
            theta = prevSize; //
            return;
        }

        // sample target nodes
        for (int i = prevSize; i < newSize; i++) {
            int randTarget = sfmt_genrand_uint32(&sfmtSeed) % n;
            targetNodes.push_back(randTarget);
        }
        
        // expand coordinated RR sets samples of items
        for(int itemID = 0; itemID < nrItems; itemID++) {
            rcList->at(itemID)->generateRRSample(targetNodes, prevSize, newSize);
        }

        for (int rcID = prevSize; rcID < newSize; ++rcID) {
            int tprsize = rcList->at(0)->hyperGT[rcID].size();
            for (int j = 0; j < tprsize; ++j) {
                int y = rcList->at(0)->hyperGT[rcID][j];
                //cout << y << " ";
            }
            int tpbsize = rcList->at(1)->hyperGT[rcID].size();
            for (int j = 0; j < tpbsize; ++j) {
                int y = rcList->at(1)->hyperGT[rcID][j];
                //cout << y << " ";
            }
            //cout << endl;
        }

        // rcList -> itemID -> hyperGT[rcID]: store a list of the nodes.
        double tmpsize = createhyperGTPairs(newSize);
//        cout << "current size is " << newSize <<  " size of hyPerGTPairs is " << tmpsize << endl;

        for (int rcID = prevSize; rcID < newSize; ++rcID) {
            int tpsize = hyperGTpairs[rcID].size();
            for (int i = 0; i < tpsize; ++i) {
                int x = hyperGTpairs[rcID][i]; // because x is too large.
                hyperGpairs[x].push_back(rcID);
                hyper_degreepairs[x] += 1;
            }
            //int tprsize = rcList->at(0)->hyperGT[rcID].size();
            //for (int j = 0; j < tprsize; ++j) {
            //    int y = rcList->at(0)->hyperGT[rcID][j];
            //    //cout << y << " ";
            //    hyperG[y].push_back(rcID); // careful about the repetition
            //}
            //int tpbsize = rcList->at(1)->hyperGT[rcID].size();
            //for (int j = 0; j < tpbsize; ++j) {
            //    int y = rcList->at(1)->hyperGT[rcID][j];
            //    //cout << y << " ";
            //    hyperG[y+n].push_back(rcID); // careful about the repeatation
            //}
            //cout << endl;
        }

        prevSize = newSize;
        
    }

// Assembly:
subq $0x58, %rsp
movq %rdi, 0x50(%rsp)
movq %rsi, 0x48(%rsp)
movq 0x50(%rsp), %rcx
movq %rcx, (%rsp)
movq 0x48(%rsp), %rax
cmpq 0xb20(%rcx), %rax
jge 0xb609
movq (%rsp), %rax
movq 0xb20(%rax), %rcx
movq %rcx, 0x10(%rax)
jmp 0xb905
movq (%rsp), %rax
movq 0xb20(%rax), %rax
movl %eax, 0x44(%rsp)
movslq 0x44(%rsp), %rax
cmpq 0x48(%rsp), %rax
jge 0xb65f
movq (%rsp), %rdi
addq $0x120, %rdi            # imm = 0x120
callq 0xd070
movq (%rsp), %rdi
xorl %edx, %edx
divl 0x68(%rdi)
movl %edx, 0x40(%rsp)
addq $0xb08, %rdi            # imm = 0xB08
leaq 0x40(%rsp), %rsi
callq 0xe060
movl 0x44(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x44(%rsp)
jmp 0xb618
movl $0x0, 0x3c(%rsp)
movq (%rsp), %rcx
movl 0x3c(%rsp), %eax
cmpl 0x70(%rcx), %eax
jge 0xb6bb
movq (%rsp), %rax
movq 0xae8(%rax), %rdi
movslq 0x3c(%rsp), %rsi
callq 0xe0d0
movq %rax, %rcx
movq (%rsp), %rax
movq (%rcx), %rdi
movq %rax, %rsi
addq $0xb08, %rsi            # imm = 0xB08
movq 0xb20(%rax), %rdx
movq 0x48(%rsp), %rcx
callq 0x1cf10
movl 0x3c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x3c(%rsp)
jmp 0xb667
movq (%rsp), %rax
movq 0xb20(%rax), %rax
movl %eax, 0x38(%rsp)
movslq 0x38(%rsp), %rax
cmpq 0x48(%rsp), %rax
jge 0xb7fe
movq (%rsp), %rax
movq 0xae8(%rax), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xe0d0
movq (%rax), %rdi
addq $0x18, %rdi
movslq 0x38(%rsp), %rsi
callq 0xe110
movq %rax, %rdi
callq 0xe130
movl %eax, 0x34(%rsp)
movl $0x0, 0x30(%rsp)
movl 0x30(%rsp), %eax
cmpl 0x34(%rsp), %eax
jge 0xb762
movq (%rsp), %rax
movq 0xae8(%rax), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xe0d0
movq (%rax), %rdi
addq $0x18, %rdi
movslq 0x38(%rsp), %rsi
callq 0xe110
movq %rax, %rdi
movslq 0x30(%rsp), %rsi
callq 0xe150
movl (%rax), %eax
movl %eax, 0x2c(%rsp)
movl 0x30(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x30(%rsp)
jmp 0xb713
movq (%rsp), %rax
movq 0xae8(%rax), %rdi
movl $0x1, %esi
callq 0xe0d0
movq (%rax), %rdi
addq $0x18, %rdi
movslq 0x38(%rsp), %rsi
callq 0xe110
movq %rax, %rdi
callq 0xe130
movl %eax, 0x28(%rsp)
movl $0x0, 0x24(%rsp)
movl 0x24(%rsp), %eax
cmpl 0x28(%rsp), %eax
jge 0xb7ec
movq (%rsp), %rax
movq 0xae8(%rax), %rdi
movl $0x1, %esi
callq 0xe0d0
movq (%rax), %rdi
addq $0x18, %rdi
movslq 0x38(%rsp), %rsi
callq 0xe110
movq %rax, %rdi
movslq 0x24(%rsp), %rsi
callq 0xe150
movl (%rax), %eax
movl %eax, 0x20(%rsp)
movl 0x24(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x24(%rsp)
jmp 0xb79c
jmp 0xb7ee
movl 0x38(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x38(%rsp)
jmp 0xb6ca
movq (%rsp), %rdi
movq 0x48(%rsp), %rsi
callq 0xd0e0
movq (%rsp), %rax
movsd %xmm0, 0x18(%rsp)
movq 0xb20(%rax), %rax
movl %eax, 0x14(%rsp)
movslq 0x14(%rsp), %rax
cmpq 0x48(%rsp), %rax
jge 0xb8f5
movq (%rsp), %rdi
addq $0xb28, %rdi            # imm = 0xB28
movslq 0x14(%rsp), %rsi
callq 0xe110
movq %rax, %rdi
callq 0xe130
movl %eax, 0x10(%rsp)
movl $0x0, 0xc(%rsp)
movl 0xc(%rsp), %eax
cmpl 0x10(%rsp), %eax
jge 0xb8e3
movq (%rsp), %rdi
addq $0xb28, %rdi            # imm = 0xB28
movslq 0x14(%rsp), %rsi
callq 0xe110
movq %rax, %rdi
movslq 0xc(%rsp), %rsi
callq 0xe150
movq (%rsp), %rdi
movl (%rax), %eax
movl %eax, 0x8(%rsp)
addq $0xb40, %rdi            # imm = 0xB40
movslq 0x8(%rsp), %rsi
callq 0xe110
movq %rax, %rdi
leaq 0x14(%rsp), %rsi
callq 0xe060
movq (%rsp), %rdi
addq $0xb58, %rdi            # imm = 0xB58
movslq 0x8(%rsp), %rsi
callq 0xe170
movsd 0x18825(%rip), %xmm0    # 0x240f0
addsd (%rax), %xmm0
movsd %xmm0, (%rax)
movl 0xc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xc(%rsp)
jmp 0xb85a
jmp 0xb8e5
movl 0x14(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x14(%rsp)
jmp 0xb821
movq (%rsp), %rax
movq 0x48(%rsp), %rcx
movq %rcx, 0xb20(%rax)
addq $0x58, %rsp
retq
nopw (%rax,%rax)