// File: /workspace/github_cpp_makefile_star2_O3/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 0x9141
movq %rax, 0x10(%rbx)
jmp 0x9333
movq %rsi, %r14
movslq %eax, %rcx
cmpq %rsi, %rcx
jge 0x91c6
leaq 0x120(%rbx), %r15
leaq 0xb08(%rbx), %r12
movslq %eax, %rbp
leaq 0x4(%rsp), %r13
movl 0xae0(%rbx), %eax
cmpl $0x270, %eax            # imm = 0x270
jl 0x9179
movq %r15, %rdi
callq 0x104e4
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 0xb10(%rbx), %rsi
cmpq 0xb18(%rbx), %rsi
je 0x91b3
movl %edx, (%rsi)
addq $0x4, %rsi
movq %rsi, 0xb10(%rbx)
jmp 0x91be
movq %r12, %rdi
movq %r13, %rdx
callq 0xbd60
incq %rbp
cmpq %r14, %rbp
jl 0x9162
cmpl $0x0, 0x70(%rbx)
jle 0x9216
leaq 0xb08(%rbx), %r12
xorl %r15d, %r15d
movq 0xae8(%rbx), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
cmpq %r15, %rdx
jbe 0x9342
movq (%rax,%r15,8), %rdi
movq 0xb20(%rbx), %rdx
movq %r12, %rsi
movq %r14, %rcx
callq 0xdf40
incq %r15
movslq 0x70(%rbx), %rax
cmpq %rax, %r15
jl 0x91d6
movslq 0xb20(%rbx), %rax
cmpq %r14, %rax
jge 0x9255
movq 0xae8(%rbx), %rcx
movq 0x8(%rcx), %rsi
movq (%rcx), %rcx
movq %rsi, %rdx
subq %rcx, %rdx
sarq $0x3, %rdx
cmpq %rcx, %rsi
je 0x9361
cmpq $0x1, %rdx
jbe 0x934e
incq %rax
cmpq %r14, %rax
jl 0x9243
movq %rbx, %rdi
movq %r14, %rsi
callq 0xa25a
movq 0xb20(%rbx), %rax
movl %eax, (%rsp)
movslq %eax, %rcx
cmpq %r14, %rcx
jge 0x932c
movq %rsp, %r15
movsd 0x8ecf(%rip), %xmm1     # 0x12150
movq 0xb28(%rbx), %rdx
leaq (%rcx,%rcx,2), %rcx
movq 0x8(%rdx,%rcx,8), %r12
subq (%rdx,%rcx,8), %r12
shrq $0x2, %r12
testl %r12d, %r12d
jle 0x931b
andl $0x7fffffff, %r12d      # imm = 0x7FFFFFFF
xorl %r13d, %r13d
movslq (%rsp), %rax
leaq (%rax,%rax,2), %rcx
movq 0xb28(%rbx), %rdx
movq 0xb40(%rbx), %rsi
movq (%rdx,%rcx,8), %rcx
movslq (%rcx,%r13,4), %rbp
leaq (,%rbp,2), %rcx
addq %rbp, %rcx
leaq (%rsi,%rcx,8), %rdi
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0x92eb
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rdi)
jmp 0x92fb
movq %r15, %rdx
callq 0xbd60
movsd 0x8e55(%rip), %xmm1     # 0x12150
movq 0xb58(%rbx), %rax
movsd (%rax,%rbp,8), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rax,%rbp,8)
incq %r13
cmpq %r13, %r12
jne 0x92a8
movl (%rsp), %eax
incl %eax
movl %eax, (%rsp)
movslq %eax, %rcx
cmpq %r14, %rcx
jl 0x9281
movq %r14, 0xb20(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x9246(%rip), %rdi      # 0x1258f
movq %r15, %rsi
jmp 0x935a
leaq 0x923a(%rip), %rdi      # 0x1258f
movl $0x1, %esi
xorl %eax, %eax
callq 0x3490
leaq 0x9227(%rip), %rdi      # 0x1258f
xorl %esi, %esi
jmp 0x935a