// File: /workspace/github_cpp_makefile_star2_O1/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 0x91bf
movq %rax, 0x10(%rbx)
jmp 0x93bf
movq %rsi, %r14
movslq %eax, %rcx
cmpq %rsi, %rcx
jge 0x9254
leaq 0x120(%rbx), %r15
leaq 0xb08(%rbx), %r12
movslq %eax, %rbp
leaq 0x4(%rsp), %r13
cmpl $0x270, 0xae0(%rbx)     # imm = 0x270
jl 0x9202
movq %r15, %rdi
callq 0x1083c
movl $0x0, 0xae0(%rbx)
movslq 0xae0(%rbx), %rax
leal 0x1(%rax), %ecx
movl %ecx, 0xae0(%rbx)
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 0x9241
movl %edx, (%rsi)
addq $0x4, %rsi
movq %rsi, 0xb10(%rbx)
jmp 0x924c
movq %r12, %rdi
movq %r13, %rdx
callq 0xbdaa
incq %rbp
cmpq %r14, %rbp
jl 0x91e4
cmpl $0x0, 0x70(%rbx)
jle 0x92a4
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 0x93ce
movq (%rax,%r15,8), %rdi
movq 0xb20(%rbx), %rdx
movq %r12, %rsi
movq %r14, %rcx
callq 0xe038
incq %r15
movslq 0x70(%rbx), %rax
cmpq %rax, %r15
jl 0x9264
movslq 0xb20(%rbx), %rax
cmpq %r14, %rax
jge 0x92e3
movq 0xae8(%rbx), %rcx
movq 0x8(%rcx), %rsi
movq (%rcx), %rcx
movq %rsi, %rdx
subq %rcx, %rdx
sarq $0x3, %rdx
cmpq %rcx, %rsi
je 0x93ed
cmpq $0x1, %rdx
jbe 0x93da
incq %rax
cmpq %r14, %rax
jl 0x92d1
movq %rbx, %rdi
movq %r14, %rsi
callq 0xa2fe
movq 0xb20(%rbx), %rax
movl %eax, (%rsp)
cltq
cmpq %r14, %rax
jge 0x93b8
movq %rsp, %r15
movsd 0x8e42(%rip), %xmm1     # 0x12150
movq 0xb28(%rbx), %rcx
leaq (%rax,%rax,2), %rax
movq 0x8(%rcx,%rax,8), %r12
subq (%rcx,%rax,8), %r12
shrq $0x2, %r12
testl %r12d, %r12d
jle 0x93a5
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 0x9378
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rdi)
jmp 0x9388
movq %r15, %rdx
callq 0xbdaa
movsd 0x8dc8(%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 0x9335
movslq (%rsp), %rax
incq %rax
movl %eax, (%rsp)
cmpq %r14, %rax
jl 0x930e
movq %r14, 0xb20(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x91c2(%rip), %rdi      # 0x12597
movq %r15, %rsi
jmp 0x93e6
leaq 0x91b6(%rip), %rdi      # 0x12597
movl $0x1, %esi
xorl %eax, %eax
callq 0x3490
leaq 0x91a3(%rip), %rdi      # 0x12597
xorl %esi, %esi
jmp 0x93e6