// File: /workspace/github_cpp_makefile_star2_O2/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0xb20(%rdi), %rax
cmpq %rsi, %rax
jle 0x7037
movq %rax, 0x10(%rbx)
jmp 0x7210
movq %rsi, %r14
leaq 0x120(%rbx), %r12
leaq 0xb08(%rbx), %r15
movslq %eax, %rbp
leaq 0x4(%rsp), %r13
cmpq %r14, %rbp
jge 0x7097
movl 0xae0(%rbx), %eax
cmpl $0x270, %eax            # imm = 0x270
jl 0x706c
movq %r12, %rdi
callq 0xd710
xorl %eax, %eax
leal 0x1(%rax), %ecx
movl %ecx, 0xae0(%rbx)
cltq
movl 0x120(%rbx,%rax,4), %eax
xorl %edx, %edx
divl 0x68(%rbx)
movl %edx, 0x4(%rsp)
movq %r15, %rdi
movq %r13, %rsi
callq 0x854e
incq %rbp
jmp 0x7050
xorl %r12d, %r12d
movslq 0x70(%rbx), %rax
cmpq %rax, %r12
jge 0x70cc
movq 0xae8(%rbx), %rdi
movq %r12, %rsi
callq 0x856c
movq (%rax), %rdi
movq 0xb20(%rbx), %rdx
movq %r15, %rsi
movq %r14, %rcx
callq 0xb5c2
incq %r12
jmp 0x709a
movslq 0xb20(%rbx), %r12
pushq $0x1
popq %r15
cmpq %r14, %r12
jge 0x716f
movq 0xae8(%rbx), %rdi
xorl %esi, %esi
callq 0x856c
movq (%rax), %rax
movq 0x18(%rax), %rax
imulq $0x18, %r12, %rbp
movq 0x8(%rax,%rbp), %r13
subq (%rax,%rbp), %r13
shrq $0x2, %r13
testl %r13d, %r13d
movl $0x0, %eax
cmovlel %eax, %r13d
movq 0xae8(%rbx), %rdi
subl $0x1, %r13d
jb 0x7128
xorl %esi, %esi
callq 0x856c
jmp 0x7112
movq %r15, %rsi
callq 0x856c
movq (%rax), %rax
movq 0x18(%rax), %rax
movq 0x8(%rax,%rbp), %r13
subq (%rax,%rbp), %r13
shrq $0x2, %r13
testl %r13d, %r13d
movl $0x0, %eax
cmovlel %eax, %r13d
subl $0x1, %r13d
jb 0x7167
movq 0xae8(%rbx), %rdi
movq %r15, %rsi
callq 0x856c
jmp 0x7150
incq %r12
jmp 0x70d7
movq %rbx, %rdi
movq %r14, %rsi
callq 0x7d2c
movl 0xb20(%rbx), %eax
movq %rsp, %r15
movl %eax, (%rsp)
cltq
cmpq %r14, %rax
jge 0x7209
movq 0xb28(%rbx), %rcx
imulq $0x18, %rax, %rax
movq 0x8(%rcx,%rax), %r13
subq (%rcx,%rax), %r13
shrq $0x2, %r13
testl %r13d, %r13d
movl $0x0, %eax
cmovlel %eax, %r13d
xorl %ebp, %ebp
movslq (%rsp), %rax
cmpq %rbp, %r13
je 0x7202
movq 0xb28(%rbx), %rcx
imulq $0x18, %rax, %rax
movq (%rcx,%rax), %rax
movslq (%rax,%rbp,4), %r12
imulq $0x18, %r12, %rdi
addq 0xb40(%rbx), %rdi
movq %r15, %rsi
callq 0x854e
movq 0xb58(%rbx), %rax
movsd (%rax,%r12,8), %xmm0
addsd 0x6f29(%rip), %xmm0     # 0xe120
movsd %xmm0, (%rax,%r12,8)
incq %rbp
jmp 0x71b3
incl %eax
jmp 0x7183
movq %r14, 0xb20(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop