// File: JenTus[P]TCEM/src_TCEM/allocator.cc
// Function: Cide::allocator::rcGreedy(long long, bool)
double allocator::rcGreedy(int64 rcSampleSize, bool extraResults) {
        // For initialization the k_r and k_b, to delete later.

        double totalExpScore = 0;
        std::vector<double> ExpScore(n*n, 0); // use to store hyper_degreepairs

        int bestPairID = -1, bestRedNodeID = -1, bestBlueNodeID = -1;
        std::vector<int> isValidRed = std::vector<int>(n,tao);
        std::vector<int> isValidBlue = std::vector<int>(n,1);
        std::vector<bool> isCovered = std::vector<bool>(rcSampleSize, false);
        std::set<int> rednodes;
        std::set<int> bluenodes;

        int flag_red = 0;

        clock_t begin = clock();

        for (int i = 0; i < n; i++){
            for (int j = 0; j < n; j++){
                if (i != j){
                    ExpScore[i*n + j] = hyper_degreepairs[i*n + j];
                }
            }
        }

        seedSet.clear();
        seedScores.clear(); // seedScores should be cleared as well.

        while ((int)seedSet.size() < k_b) {

            double tempsum = accumulate(ExpScore.begin(), ExpScore.end(), 0.01);
            if(tempsum < 1){
                break;
            }
            // here I use the vector to store the results, but can use the priority queue.
            //bestPairID = std::max_element(ExpScore.begin(), ExpScore.end()) - ExpScore.begin();
            bestPairID = std::distance(ExpScore.begin(), std::max_element(ExpScore.begin(), ExpScore.end()));
            //cout << "bestPairID is " << bestPairID   <<endl;
            bestRedNodeID = (int) bestPairID / n;
            rednodes.insert(bestRedNodeID);
            bestBlueNodeID = (int) bestPairID % n;
            bluenodes.insert(bestBlueNodeID);

            // if can not select, then just pop out
            if (isValidRed[bestRedNodeID] == 0 || isValidBlue[bestBlueNodeID] == 0) {
                ExpScore[bestPairID] = 0;
                continue;
            }

            // push
            seedSet.push_back(bestPairID); // store
            //cout << "ExpScore is " << ExpScore[bestPairID] << "rc sample size is " <<rcSampleSize << "n is " << n << endl;
            seedScores.push_back(ExpScore[bestPairID]); // store score, dividing later

            // make update
            isValidRed[bestRedNodeID] -= 1;
            isValidRed[bestBlueNodeID] = 0;
            isValidBlue[bestBlueNodeID] = 0;
            isValidBlue[bestRedNodeID] = 0;

            if(isValidRed[bestRedNodeID] <= 0){
                for (int i = 0; i < n; ++i) {
                   ExpScore[bestRedNodeID*n + i] = 0;
                }
            }

            for (int i = 0; i < n; ++i) {
               ExpScore[i*n + bestBlueNodeID]  = 0;
               ExpScore[i*n + bestRedNodeID]  = 0;
               ExpScore[bestBlueNodeID*n + i] = 0;
            }

            // if red nodes reaches k_r
            if(rednodes.size() == k_r && flag_red == 0){
                for (int i = 0; i < n; ++i) {
                    if(rednodes.count(i) == 0){
                        isValidRed[i] = 0;
                        for (int j = 0; j < n; ++j) {
                           ExpScore[i*n + j] = 0;
                        }
                    }
                }
                flag_red = 1;
            }

//            cout << "sum of Expscore is " << accumulate(ExpScore.begin(), ExpScore.end(), 0) << endl;

            // update the ExpScore of the pairs whose marginal gain change due to the best pair selection
            int tmpsize = hyperGpairs[bestPairID].size();
            for (int j = 0; j < tmpsize; j++) {
                int rcID = hyperGpairs[bestPairID][j]; // get the rcID
                if(isCovered[rcID] == false){ // ensure not to repeatedly --
                    int ttmpsize = hyperGTpairs[rcID].size();
                    for (int z = 0; z < ttmpsize; z++) {
                        int pairID = hyperGTpairs[rcID][z];
                        if (ExpScore[pairID] != 0) {
                            ExpScore[pairID]--;
                        }
                    }
                    isCovered[rcID] = true;
                }
           }
        } // end of while k loop

        for (int i1 = 0; i1 < seedScores.size(); ++i1) {
           totalExpScore += seedScores[i1];
        }

        int covercount = 0;
        for (int l = 0; l < isCovered.size(); ++l) {
            if(isCovered[l])
                covercount++;
        }


        ///////////// produce the additional results here
        ////////////  Remember should write the f function results not the g function result.
        if(extraResults) {

        cout << "totalExpScore is: " << totalExpScore << " cover is " << covercount << " sample size is " << rcSampleSize << endl;

            clock_t end = clock();

            //cout << "total tdem time taken (in seconds) " << totalDuration << " total memory (in mb) " << totalMemory << endl;
            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;
                    }
                }
            }

            totalDuration = double(end - begin) / CLOCKS_PER_SEC + duration_common; // in seconds
            totalMemory = getCurrentMemoryUsage(); // in MB

            float totalscore = (float) redbluecount / (float) rcSampleSize;

            cout << "Total score of Greedy is " << totalscore*n << "  g result is " << totalExpScore / (float) rcSampleSize *n  << endl;

            std::ostringstream streamObj1;
            streamObj1 << std::fixed << std::setprecision(2)<<totalscore*n << "(" << totalExpScore/(float) rcSampleSize*n << ")";

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

        } // end of extra results
        
        return totalExpScore / (double)rcSampleSize;
    }

// Assembly:
subq $0x718, %rsp            # imm = 0x718
movb %dl, %al
movq %rdi, 0x710(%rsp)
movq %rsi, 0x708(%rsp)
andb $0x1, %al
movb %al, 0x707(%rsp)
movq 0x710(%rsp), %rax
movq %rax, 0x1d8(%rsp)
movq $0x0, 0x6f8(%rsp)
movl 0x68(%rax), %eax
imull %eax, %eax
movq %rax, 0x1e0(%rsp)
movq $0x0, 0x6d8(%rsp)
leaq 0x6d7(%rsp), %rdi
movq %rdi, 0x1e8(%rsp)
callq 0xdc40
movq 0x1e0(%rsp), %rsi
movq 0x1e8(%rsp), %rcx
leaq 0x6e0(%rsp), %rdi
leaq 0x6d8(%rsp), %rdx
callq 0xdc50
jmp 0xb9a4
leaq 0x6d7(%rsp), %rdi
callq 0xdd70
movq 0x1d8(%rsp), %rax
movl $0xffffffff, 0x6c0(%rsp) # imm = 0xFFFFFFFF
movl $0xffffffff, 0x6bc(%rsp) # imm = 0xFFFFFFFF
movl $0xffffffff, 0x6b8(%rsp) # imm = 0xFFFFFFFF
movslq 0x68(%rax), %rcx
movq %rcx, 0x1c0(%rsp)
subq $-0x80, %rax
movq %rax, 0x1c8(%rsp)
leaq 0x69f(%rsp), %rdi
movq %rdi, 0x1d0(%rsp)
callq 0xe1b0
movq 0x1c0(%rsp), %rsi
movq 0x1c8(%rsp), %rdx
movq 0x1d0(%rsp), %rcx
leaq 0x6a0(%rsp), %rdi
callq 0xe1c0
jmp 0xba2e
leaq 0x69f(%rsp), %rdi
callq 0xe240
movq 0x1d8(%rsp), %rax
movslq 0x68(%rax), %rax
movq %rax, 0x1b0(%rsp)
movl $0x1, 0x67c(%rsp)
leaq 0x67b(%rsp), %rdi
movq %rdi, 0x1b8(%rsp)
callq 0xe1b0
movq 0x1b0(%rsp), %rsi
movq 0x1b8(%rsp), %rcx
leaq 0x680(%rsp), %rdi
leaq 0x67c(%rsp), %rdx
callq 0xe1c0
jmp 0xba96
leaq 0x67b(%rsp), %rdi
callq 0xe240
movq 0x708(%rsp), %rax
movq %rax, 0x1a0(%rsp)
movb $0x0, 0x64f(%rsp)
leaq 0x64e(%rsp), %rdi
movq %rdi, 0x1a8(%rsp)
callq 0xe250
movq 0x1a0(%rsp), %rsi
movq 0x1a8(%rsp), %rcx
leaq 0x650(%rsp), %rdi
leaq 0x64f(%rsp), %rdx
callq 0xe260
jmp 0xbaf7
leaq 0x64e(%rsp), %rdi
callq 0xe2e0
leaq 0x618(%rsp), %rdi
callq 0xe2f0
leaq 0x5e8(%rsp), %rdi
callq 0xe2f0
movl $0x0, 0x5e4(%rsp)
callq 0x4230
movq %rax, 0x5d8(%rsp)
movl $0x0, 0x5d4(%rsp)
movq 0x1d8(%rsp), %rcx
movl 0x5d4(%rsp), %eax
cmpl 0x68(%rcx), %eax
jge 0xbccd
movl $0x0, 0x5d0(%rsp)
movq 0x1d8(%rsp), %rcx
movl 0x5d0(%rsp), %eax
cmpl 0x68(%rcx), %eax
jge 0xbcb5
movl 0x5d4(%rsp), %eax
cmpl 0x5d0(%rsp), %eax
je 0xbc9d
movq 0x1d8(%rsp), %rcx
movq %rcx, %rdi
addq $0xb58, %rdi            # imm = 0xB58
movl 0x5d4(%rsp), %eax
imull 0x68(%rcx), %eax
addl 0x5d0(%rsp), %eax
movslq %eax, %rsi
callq 0xe170
movq 0x1d8(%rsp), %rcx
movsd (%rax), %xmm0
movsd %xmm0, 0x198(%rsp)
movl 0x5d4(%rsp), %eax
imull 0x68(%rcx), %eax
addl 0x5d0(%rsp), %eax
movslq %eax, %rsi
leaq 0x6e0(%rsp), %rdi
callq 0xe170
movsd 0x198(%rsp), %xmm0
movsd %xmm0, (%rax)
jmp 0xbc9d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x6c8(%rsp)
movl %eax, 0x6c4(%rsp)
leaq 0x6d7(%rsp), %rdi
callq 0xdd70
jmp 0xd063
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x6c8(%rsp)
movl %eax, 0x6c4(%rsp)
leaq 0x69f(%rsp), %rdi
callq 0xe240
jmp 0xd056
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x6c8(%rsp)
movl %eax, 0x6c4(%rsp)
leaq 0x67b(%rsp), %rdi
callq 0xe240
jmp 0xd049
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x6c8(%rsp)
movl %eax, 0x6c4(%rsp)
leaq 0x64e(%rsp), %rdi
callq 0xe2e0
jmp 0xd03c
jmp 0xbc9f
movl 0x5d0(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x5d0(%rsp)
jmp 0xbb64
jmp 0xbcb7
movl 0x5d4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x5d4(%rsp)
jmp 0xbb41
movq 0x1d8(%rsp), %rdi
addq $0xa8, %rdi
callq 0xe300
movq 0x1d8(%rsp), %rdi
addq $0xc0, %rdi
callq 0xe320
movq 0x1d8(%rsp), %rdi
addq $0xa8, %rdi
callq 0xe130
movq 0x1d8(%rsp), %rcx
cmpl 0x7c(%rcx), %eax
jge 0xc4e3
leaq 0x6e0(%rsp), %rdi
movq %rdi, 0x188(%rsp)
callq 0xe3b0
movq 0x188(%rsp), %rdi
movq %rax, 0x5c0(%rsp)
callq 0xe3e0
movq %rax, 0x5b8(%rsp)
movq 0x5c0(%rsp), %rdi
movq 0x5b8(%rsp), %rsi
movsd 0x183ac(%rip), %xmm0    # 0x24110
callq 0xe340
movsd %xmm0, 0x190(%rsp)
jmp 0xbd74
movsd 0x190(%rsp), %xmm0
movsd %xmm0, 0x5c8(%rsp)
movsd 0x18362(%rip), %xmm0    # 0x240f0
ucomisd 0x5c8(%rsp), %xmm0
jbe 0xbdb7
jmp 0xc4e3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x6c8(%rsp)
movl %eax, 0x6c4(%rsp)
jmp 0xd015
leaq 0x6e0(%rsp), %rdi
movq %rdi, 0x178(%rsp)
callq 0xe3b0
movq 0x178(%rsp), %rdi
movq %rax, 0x5b0(%rsp)
callq 0xe3b0
movq 0x178(%rsp), %rdi
movq %rax, 0x5a0(%rsp)
callq 0xe3e0
movq %rax, 0x598(%rsp)
movq 0x5a0(%rsp), %rdi
movq 0x598(%rsp), %rsi
callq 0xe450
movq %rax, 0x180(%rsp)
jmp 0xbe1d
movq 0x180(%rsp), %rax
movq %rax, 0x5a8(%rsp)
movq 0x5b0(%rsp), %rdi
movq 0x5a8(%rsp), %rsi
callq 0xe410
movq %rax, 0x170(%rsp)
jmp 0xbe4c
movq 0x1d8(%rsp), %rcx
movq 0x170(%rsp), %rax
movl %eax, 0x6c0(%rsp)
movl 0x6c0(%rsp), %eax
movl 0x68(%rcx), %ecx
cltd
idivl %ecx
movl %eax, 0x6bc(%rsp)
leaq 0x618(%rsp), %rdi
leaq 0x6bc(%rsp), %rsi
callq 0xe4a0
movb %dl, 0x167(%rsp)
movq %rax, 0x168(%rsp)
jmp 0xbe9d
movq 0x1d8(%rsp), %rcx
movb 0x167(%rsp), %al
movq 0x168(%rsp), %rdx
movq %rdx, 0x588(%rsp)
movb %al, 0x590(%rsp)
movl 0x6c0(%rsp), %eax
movl 0x68(%rcx), %ecx
cltd
idivl %ecx
movl %edx, 0x6b8(%rsp)
leaq 0x5e8(%rsp), %rdi
leaq 0x6b8(%rsp), %rsi
callq 0xe4a0
movb %dl, 0x157(%rsp)
movq %rax, 0x158(%rsp)
jmp 0xbefd
movb 0x157(%rsp), %al
movq 0x158(%rsp), %rcx
movq %rcx, 0x578(%rsp)
movb %al, 0x580(%rsp)
movslq 0x6bc(%rsp), %rsi
leaq 0x6a0(%rsp), %rdi
callq 0xe150
cmpl $0x0, (%rax)
je 0xbf4f
movslq 0x6b8(%rsp), %rsi
leaq 0x680(%rsp), %rdi
callq 0xe150
cmpl $0x0, (%rax)
jne 0xbf70
movslq 0x6c0(%rsp), %rsi
leaq 0x6e0(%rsp), %rdi
callq 0xe170
xorps %xmm0, %xmm0
movsd %xmm0, (%rax)
jmp 0xbcf5
movq 0x1d8(%rsp), %rdi
addq $0xa8, %rdi
leaq 0x6c0(%rsp), %rsi
callq 0xe060
jmp 0xbf8e
movq 0x1d8(%rsp), %rax
addq $0xc0, %rax
movq %rax, 0x148(%rsp)
movslq 0x6c0(%rsp), %rsi
leaq 0x6e0(%rsp), %rdi
callq 0xe170
movq 0x148(%rsp), %rdi
movq %rax, %rsi
callq 0xe500
jmp 0xbfcb
movslq 0x6bc(%rsp), %rsi
leaq 0x6a0(%rsp), %rdi
callq 0xe150
movl (%rax), %ecx
subl $0x1, %ecx
movl %ecx, (%rax)
movslq 0x6b8(%rsp), %rsi
leaq 0x6a0(%rsp), %rdi
callq 0xe150
movl $0x0, (%rax)
movslq 0x6b8(%rsp), %rsi
leaq 0x680(%rsp), %rdi
callq 0xe150
movl $0x0, (%rax)
movslq 0x6bc(%rsp), %rsi
leaq 0x680(%rsp), %rdi
callq 0xe150
movl $0x0, (%rax)
movslq 0x6bc(%rsp), %rsi
leaq 0x6a0(%rsp), %rdi
callq 0xe150
cmpl $0x0, (%rax)
jg 0xc0b7
movl $0x0, 0x574(%rsp)
movq 0x1d8(%rsp), %rcx
movl 0x574(%rsp), %eax
cmpl 0x68(%rcx), %eax
jge 0xc0b5
movq 0x1d8(%rsp), %rcx
movl 0x6bc(%rsp), %eax
imull 0x68(%rcx), %eax
addl 0x574(%rsp), %eax
movslq %eax, %rsi
leaq 0x6e0(%rsp), %rdi
callq 0xe170
xorps %xmm0, %xmm0
movsd %xmm0, (%rax)
movl 0x574(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x574(%rsp)
jmp 0xc05d
jmp 0xc0b7
movl $0x0, 0x570(%rsp)
movq 0x1d8(%rsp), %rcx
movl 0x570(%rsp), %eax
cmpl 0x68(%rcx), %eax
jge 0xc183
movq 0x1d8(%rsp), %rcx
movl 0x570(%rsp), %eax
imull 0x68(%rcx), %eax
addl 0x6b8(%rsp), %eax
movslq %eax, %rsi
leaq 0x6e0(%rsp), %rdi
callq 0xe170
movq 0x1d8(%rsp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax)
movl 0x570(%rsp), %eax
imull 0x68(%rcx), %eax
addl 0x6bc(%rsp), %eax
movslq %eax, %rsi
leaq 0x6e0(%rsp), %rdi
callq 0xe170
movq 0x1d8(%rsp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax)
movl 0x6b8(%rsp), %eax
imull 0x68(%rcx), %eax
addl 0x570(%rsp), %eax
movslq %eax, %rsi
leaq 0x6e0(%rsp), %rdi
callq 0xe170
xorps %xmm0, %xmm0
movsd %xmm0, (%rax)
movl 0x570(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x570(%rsp)
jmp 0xc0c2
leaq 0x618(%rsp), %rdi
callq 0xe570
movq 0x1d8(%rsp), %rcx
movslq 0x78(%rcx), %rcx
cmpq %rcx, %rax
jne 0xc2aa
cmpl $0x0, 0x5e4(%rsp)
jne 0xc2aa
movl $0x0, 0x56c(%rsp)
movq 0x1d8(%rsp), %rcx
movl 0x56c(%rsp), %eax
cmpl 0x68(%rcx), %eax
jge 0xc29f
leaq 0x618(%rsp), %rdi
leaq 0x56c(%rsp), %rsi
callq 0xe580
movq %rax, 0x140(%rsp)
jmp 0xc1f5
movq 0x140(%rsp), %rax
cmpq $0x0, %rax
jne 0xc287
movslq 0x56c(%rsp), %rsi
leaq 0x6a0(%rsp), %rdi
callq 0xe150
movl $0x0, (%rax)
movl $0x0, 0x568(%rsp)
movq 0x1d8(%rsp), %rcx
movl 0x568(%rsp), %eax
cmpl 0x68(%rcx), %eax
jge 0xc285
movq 0x1d8(%rsp), %rcx
movl 0x56c(%rsp), %eax
imull 0x68(%rcx), %eax
addl 0x568(%rsp), %eax
movslq %eax, %rsi
leaq 0x6e0(%rsp), %rdi
callq 0xe170
xorps %xmm0, %xmm0
movsd %xmm0, (%rax)
movl 0x568(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x568(%rsp)
jmp 0xc22d
jmp 0xc287
jmp 0xc289
movl 0x56c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x56c(%rsp)
jmp 0xc1be
movl $0x1, 0x5e4(%rsp)
movq 0x1d8(%rsp), %rdi
addq $0xb40, %rdi            # imm = 0xB40
movslq 0x6c0(%rsp), %rsi
callq 0xe110
movq %rax, %rdi
callq 0xe130
movl %eax, 0x564(%rsp)
movl $0x0, 0x560(%rsp)
movl 0x560(%rsp), %eax
cmpl 0x564(%rsp), %eax
jge 0xc4de
movq 0x1d8(%rsp), %rdi
addq $0xb40, %rdi            # imm = 0xB40
movslq 0x6c0(%rsp), %rsi
callq 0xe110
movq %rax, %rdi
movslq 0x560(%rsp), %rsi
callq 0xe150
movl (%rax), %eax
movl %eax, 0x55c(%rsp)
movslq 0x55c(%rsp), %rsi
leaq 0x650(%rsp), %rdi
callq 0xe5e0
movq %rdx, 0x130(%rsp)
movq %rax, 0x138(%rsp)
jmp 0xc350
movq 0x130(%rsp), %rax
movq 0x138(%rsp), %rcx
movq %rcx, 0x548(%rsp)
movq %rax, 0x550(%rsp)
leaq 0x548(%rsp), %rdi
callq 0xe640
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0xc4c6
movq 0x1d8(%rsp), %rdi
addq $0xb28, %rdi            # imm = 0xB28
movslq 0x55c(%rsp), %rsi
callq 0xe110
movq %rax, %rdi
callq 0xe130
movl %eax, 0x544(%rsp)
movl $0x0, 0x540(%rsp)
movl 0x540(%rsp), %eax
cmpl 0x544(%rsp), %eax
jge 0xc46d
movq 0x1d8(%rsp), %rdi
addq $0xb28, %rdi            # imm = 0xB28
movslq 0x55c(%rsp), %rsi
callq 0xe110
movq %rax, %rdi
movslq 0x540(%rsp), %rsi
callq 0xe150
movl (%rax), %eax
movl %eax, 0x53c(%rsp)
movslq 0x53c(%rsp), %rsi
leaq 0x6e0(%rsp), %rdi
callq 0xe170
movsd (%rax), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0xc430
jp 0xc430
jmp 0xc455
movslq 0x53c(%rsp), %rsi
leaq 0x6e0(%rsp), %rdi
callq 0xe170
movsd 0x17cdb(%rip), %xmm0    # 0x24128
addsd (%rax), %xmm0
movsd %xmm0, (%rax)
jmp 0xc457
movl 0x540(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x540(%rsp)
jmp 0xc3c1
movslq 0x55c(%rsp), %rsi
leaq 0x650(%rsp), %rdi
callq 0xe5e0
movq %rdx, 0x120(%rsp)
movq %rax, 0x128(%rsp)
jmp 0xc494
movq 0x120(%rsp), %rax
movq 0x128(%rsp), %rcx
movq %rcx, 0x528(%rsp)
movq %rax, 0x530(%rsp)
leaq 0x528(%rsp), %rdi
movl $0x1, %esi
callq 0xe670
jmp 0xc4c8
movl 0x560(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x560(%rsp)
jmp 0xc2e0
jmp 0xbcf5
movl $0x0, 0x524(%rsp)
movq 0x1d8(%rsp), %rdi
movslq 0x524(%rsp), %rax
movq %rax, 0x118(%rsp)
addq $0xc0, %rdi
callq 0xe6c0
movq %rax, %rcx
movq 0x118(%rsp), %rax
cmpq %rcx, %rax
jae 0xc567
movq 0x1d8(%rsp), %rdi
addq $0xc0, %rdi
movslq 0x524(%rsp), %rsi
callq 0xe170
movsd (%rax), %xmm0
addsd 0x6f8(%rsp), %xmm0
movsd %xmm0, 0x6f8(%rsp)
movl 0x524(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x524(%rsp)
jmp 0xc4ee
movl $0x0, 0x520(%rsp)
movl $0x0, 0x51c(%rsp)
movslq 0x51c(%rsp), %rax
movq %rax, 0x110(%rsp)
leaq 0x650(%rsp), %rdi
callq 0xe6e0
movq %rax, %rcx
movq 0x110(%rsp), %rax
cmpq %rcx, %rax
jae 0xc631
movslq 0x51c(%rsp), %rsi
leaq 0x650(%rsp), %rdi
callq 0xe5e0
movq %rdx, 0x100(%rsp)
movq %rax, 0x108(%rsp)
jmp 0xc5d5
movq 0x100(%rsp), %rax
movq 0x108(%rsp), %rcx
movq %rcx, 0x508(%rsp)
movq %rax, 0x510(%rsp)
leaq 0x508(%rsp), %rdi
callq 0xe640
testb $0x1, %al
jne 0xc608
jmp 0xc619
movl 0x520(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x520(%rsp)
jmp 0xc61b
movl 0x51c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x51c(%rsp)
jmp 0xc57d
testb $0x1, 0x707(%rsp)
je 0xcf9e
movq 0x22992(%rip), %rdi     # 0x2efd8
leaq 0x17bdc(%rip), %rsi     # 0x24229
callq 0x4370
movq %rax, 0xf8(%rsp)
jmp 0xc65c
movq 0xf8(%rsp), %rdi
movsd 0x6f8(%rsp), %xmm0
callq 0x46d0
movq %rax, 0xf0(%rsp)
jmp 0xc67c
movq 0xf0(%rsp), %rdi
leaq 0x17bb1(%rip), %rsi     # 0x2423c
callq 0x4370
movq %rax, 0xe8(%rsp)
jmp 0xc69a
movq 0xe8(%rsp), %rdi
movl 0x520(%rsp), %esi
callq 0x4650
movq %rax, 0xe0(%rsp)
jmp 0xc6b8
movq 0xe0(%rsp), %rdi
leaq 0x17b80(%rip), %rsi     # 0x24247
callq 0x4370
movq %rax, 0xd8(%rsp)
jmp 0xc6d6
movq 0xd8(%rsp), %rdi
movq 0x708(%rsp), %rsi
callq 0x41a0
movq %rax, 0xd0(%rsp)
jmp 0xc6f5
movq 0xd0(%rsp), %rdi
movq 0x228c4(%rip), %rsi     # 0x2efc8
callq 0x43c0
jmp 0xc70b
callq 0x4230
movq %rax, 0x500(%rsp)
movl $0x0, 0x4fc(%rsp)
leaq 0x618(%rsp), %rdi
movq %rdi, 0xc0(%rsp)
callq 0xe760
movq 0xc0(%rsp), %rdi
movq %rax, 0x4d8(%rsp)
callq 0xe790
movq %rax, 0x4d0(%rsp)
leaq 0x4cf(%rsp), %rdi
movq %rdi, 0xc8(%rsp)
callq 0xe1b0
movq 0xc8(%rsp), %rcx
movq 0x4d8(%rsp), %rsi
movq 0x4d0(%rsp), %rdx
leaq 0x4e0(%rsp), %rdi
callq 0xe7c0
jmp 0xc791
leaq 0x4cf(%rsp), %rdi
callq 0xe240
leaq 0x5e8(%rsp), %rdi
movq %rdi, 0xb0(%rsp)
callq 0xe760
movq 0xb0(%rsp), %rdi
movq %rax, 0x4a8(%rsp)
callq 0xe790
movq %rax, 0x4a0(%rsp)
leaq 0x49f(%rsp), %rdi
movq %rdi, 0xb8(%rsp)
callq 0xe1b0
movq 0xb8(%rsp), %rcx
movq 0x4a8(%rsp), %rsi
movq 0x4a0(%rsp), %rdx
leaq 0x4b0(%rsp), %rdi
callq 0xe7c0
jmp 0xc80c
leaq 0x49f(%rsp), %rdi
callq 0xe240
leaq 0x4e0(%rsp), %rdi
movq %rdi, 0xa8(%rsp)
callq 0xe890
movq 0xa8(%rsp), %rdi
movq %rax, 0x490(%rsp)
callq 0xe8c0
movq %rax, 0x488(%rsp)
movq 0x490(%rsp), %rdi
movq 0x488(%rsp), %rsi
callq 0xe850
jmp 0xc862
leaq 0x4b0(%rsp), %rdi
movq %rdi, 0xa0(%rsp)
callq 0xe890
movq 0xa0(%rsp), %rdi
movq %rax, 0x480(%rsp)
callq 0xe8c0
movq %rax, 0x478(%rsp)
movq 0x480(%rsp), %rdi
movq 0x478(%rsp), %rsi
callq 0xe850
jmp 0xc8ab
movl $0x0, 0x474(%rsp)
movslq 0x474(%rsp), %rax
cmpq 0x708(%rsp), %rax
jge 0xcb4d
movq 0x1d8(%rsp), %rax
movq 0xae8(%rax), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xe0d0
movq %rax, 0x98(%rsp)
jmp 0xc8ee
movq 0x98(%rsp), %rax
movq (%rax), %rdi
addq $0x18, %rdi
movslq 0x474(%rsp), %rsi
callq 0xe110
movq %rax, %rsi
leaq 0x458(%rsp), %rdi
callq 0xe8f0
jmp 0xc91c
movq 0x1d8(%rsp), %rax
movq 0xae8(%rax), %rdi
movl $0x1, %esi
callq 0xe0d0
movq %rax, 0x90(%rsp)
jmp 0xc93f
movq 0x90(%rsp), %rax
movq (%rax), %rdi
addq $0x18, %rdi
movslq 0x474(%rsp), %rsi
callq 0xe110
movq %rax, %rsi
leaq 0x440(%rsp), %rdi
callq 0xe8f0
jmp 0xc96d
leaq 0x458(%rsp), %rdi
movq %rdi, 0x88(%rsp)
callq 0xe890
movq 0x88(%rsp), %rdi
movq %rax, 0x438(%rsp)
callq 0xe8c0
movq %rax, 0x430(%rsp)
movq 0x438(%rsp), %rdi
movq 0x430(%rsp), %rsi
callq 0xe850
jmp 0xc9b6
leaq 0x440(%rsp), %rdi
movq %rdi, 0x80(%rsp)
callq 0xe890
movq 0x80(%rsp), %rdi
movq %rax, 0x428(%rsp)
callq 0xe8c0
movq %rax, 0x420(%rsp)
movq 0x428(%rsp), %rdi
movq 0x420(%rsp), %rsi
callq 0xe850
jmp 0xc9ff
leaq 0x4e0(%rsp), %rdi
leaq 0x458(%rsp), %rsi
callq 0xe9f0
movq %rax, 0x78(%rsp)
jmp 0xca1b
movq 0x78(%rsp), %rax
cmpq $0x1, %rax
jb 0xcb0b
leaq 0x4b0(%rsp), %rdi
leaq 0x440(%rsp), %rsi
callq 0xe9f0
movq %rax, 0x70(%rsp)
jmp 0xca46
movq 0x70(%rsp), %rax
cmpq $0x1, %rax
jb 0xcb09
movl 0x4fc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x4fc(%rsp)
jmp 0xcb09
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x6c8(%rsp)
movl %eax, 0x6c4(%rsp)
leaq 0x4cf(%rsp), %rdi
callq 0xe240
jmp 0xd015
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x6c8(%rsp)
movl %eax, 0x6c4(%rsp)
leaq 0x49f(%rsp), %rdi
callq 0xe240
jmp 0xcf8f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x6c8(%rsp)
movl %eax, 0x6c4(%rsp)
jmp 0xcf82
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x6c8(%rsp)
movl %eax, 0x6c4(%rsp)
jmp 0xcb3b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x6c8(%rsp)
movl %eax, 0x6c4(%rsp)
leaq 0x440(%rsp), %rdi
callq 0xdbe0
jmp 0xcb3b
jmp 0xcb0b
leaq 0x440(%rsp), %rdi
callq 0xdbe0
leaq 0x458(%rsp), %rdi
callq 0xdbe0
movl 0x474(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x474(%rsp)
jmp 0xc8b6
leaq 0x458(%rsp), %rdi
callq 0xdbe0
jmp 0xcf82
movq 0x1d8(%rsp), %rax
movq 0x500(%rsp), %rcx
movq 0x5d8(%rsp), %rdx
subq %rdx, %rcx
cvtsi2sd %rcx, %xmm0
movsd 0x17583(%rip), %xmm1    # 0x240f8
divsd %xmm1, %xmm0
movsd 0x8(%rax), %xmm1
addsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0xb70(%rax)
callq 0x1be40
movss %xmm0, 0x6c(%rsp)
jmp 0xcb9b
movq 0x1d8(%rsp), %rax
movss 0x6c(%rsp), %xmm0
movss %xmm0, 0xb74(%rax)
cvtsi2ssl 0x4fc(%rsp), %xmm0
cvtsi2ssq 0x708(%rsp), %xmm1
divss %xmm1, %xmm0
movss %xmm0, 0x41c(%rsp)
movq 0x22400(%rip), %rdi     # 0x2efd8
leaq 0x17679(%rip), %rsi     # 0x24258
callq 0x4370
movq %rax, 0x60(%rsp)
jmp 0xcbeb
movq 0x60(%rsp), %rdi
movq 0x1d8(%rsp), %rax
movss 0x41c(%rsp), %xmm0
cvtsi2ssl 0x68(%rax), %xmm1
mulss %xmm1, %xmm0
callq 0x4270
movq %rax, 0x58(%rsp)
jmp 0xcc16
movq 0x58(%rsp), %rdi
leaq 0x17650(%rip), %rsi     # 0x24272
callq 0x4370
movq %rax, 0x50(%rsp)
jmp 0xcc2e
movq 0x50(%rsp), %rdi
movq 0x1d8(%rsp), %rax
movsd 0x6f8(%rsp), %xmm0
cvtsi2ssq 0x708(%rsp), %xmm1
cvtss2sd %xmm1, %xmm1
divsd %xmm1, %xmm0
cvtsi2sdl 0x68(%rax), %xmm1
mulsd %xmm1, %xmm0
callq 0x46d0
movq %rax, 0x48(%rsp)
jmp 0xcc6b
movq 0x48(%rsp), %rdi
movq 0x22351(%rip), %rsi     # 0x2efc8
callq 0x43c0
jmp 0xcc7e
leaq 0x2a0(%rsp), %rdi
callq 0x44c0
jmp 0xcc8d
leaq 0x1dec(%rip), %rsi      # 0xea80
leaq 0x2a0(%rsp), %rdi
callq 0x40f0
movq %rax, 0x40(%rsp)
jmp 0xcca8
movl $0x2, %edi
callq 0xeaa0
movl %eax, 0x3c(%rsp)
jmp 0xccb8
movq 0x40(%rsp), %rdi
movl 0x3c(%rsp), %eax
movl %eax, 0x29c(%rsp)
movl 0x29c(%rsp), %esi
callq 0x45a0
movq %rax, 0x30(%rsp)
jmp 0xccdb
movq 0x30(%rsp), %rdi
movq 0x1d8(%rsp), %rax
movss 0x41c(%rsp), %xmm0
cvtsi2ssl 0x68(%rax), %xmm1
mulss %xmm1, %xmm0
callq 0x4270
movq %rax, 0x28(%rsp)
jmp 0xcd06
movq 0x28(%rsp), %rdi
leaq 0x1756f(%rip), %rsi     # 0x24281
callq 0x4370
movq %rax, 0x20(%rsp)
jmp 0xcd1e
movq 0x20(%rsp), %rdi
movq 0x1d8(%rsp), %rax
movsd 0x6f8(%rsp), %xmm0
cvtsi2ssq 0x708(%rsp), %xmm1
cvtss2sd %xmm1, %xmm1
divsd %xmm1, %xmm0
cvtsi2sdl 0x68(%rax), %xmm1
mulsd %xmm1, %xmm0
callq 0x46d0
movq %rax, 0x18(%rsp)
jmp 0xcd5b
movq 0x18(%rsp), %rdi
leaq 0x17a1d(%rip), %rsi     # 0x24784
callq 0x4370
jmp 0xcd6e
leaq 0x277(%rsp), %rdi
movq %rdi, 0x10(%rsp)
callq 0x4690
movq 0x10(%rsp), %rdx
leaq 0x174f7(%rip), %rsi     # 0x24283
leaq 0x278(%rsp), %rdi
callq 0x44f0
jmp 0xcd9b
movq 0x1d8(%rsp), %rax
movss 0xb70(%rax), %xmm0
movss %xmm0, 0x8(%rsp)
movss 0xb74(%rax), %xmm0
movss %xmm0, 0xc(%rsp)
leaq 0x250(%rsp), %rdi
leaq 0x2a0(%rsp), %rsi
callq 0x4390
jmp 0xcdd6
leaq 0x220(%rsp), %rdi
leaq 0x618(%rsp), %rsi
callq 0xeac0
jmp 0xcded
leaq 0x1f0(%rsp), %rdi
leaq 0x5e8(%rsp), %rsi
callq 0xeac0
jmp 0xce04
movss 0xc(%rsp), %xmm1
movss 0x8(%rsp), %xmm0
movq 0x1d8(%rsp), %rdi
leaq 0x278(%rsp), %rsi
leaq 0x250(%rsp), %rdx
leaq 0x220(%rsp), %rcx
leaq 0x1f0(%rsp), %r8
callq 0xd380
jmp 0xce3f
leaq 0x1f0(%rsp), %rdi
callq 0xeaf0
leaq 0x220(%rsp), %rdi
callq 0xeaf0
leaq 0x250(%rsp), %rdi
callq 0x41f0
leaq 0x278(%rsp), %rdi
callq 0x41f0
leaq 0x277(%rsp), %rdi
callq 0x43e0
leaq 0x2a0(%rsp), %rdi
callq 0x40c0
leaq 0x4b0(%rsp), %rdi
callq 0xdbe0
leaq 0x4e0(%rsp), %rdi
callq 0xdbe0
jmp 0xcf9e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x6c8(%rsp)
movl %eax, 0x6c4(%rsp)
jmp 0xcf75
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x6c8(%rsp)
movl %eax, 0x6c4(%rsp)
jmp 0xcf68
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x6c8(%rsp)
movl %eax, 0x6c4(%rsp)
jmp 0xcf5b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x6c8(%rsp)
movl %eax, 0x6c4(%rsp)
jmp 0xcf4e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x6c8(%rsp)
movl %eax, 0x6c4(%rsp)
jmp 0xcf41
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x6c8(%rsp)
movl %eax, 0x6c4(%rsp)
leaq 0x1f0(%rsp), %rdi
callq 0xeaf0
leaq 0x220(%rsp), %rdi
callq 0xeaf0
leaq 0x250(%rsp), %rdi
callq 0x41f0
leaq 0x278(%rsp), %rdi
callq 0x41f0
leaq 0x277(%rsp), %rdi
callq 0x43e0
leaq 0x2a0(%rsp), %rdi
callq 0x40c0
leaq 0x4b0(%rsp), %rdi
callq 0xdbe0
leaq 0x4e0(%rsp), %rdi
callq 0xdbe0
jmp 0xd015
movsd 0x6f8(%rsp), %xmm0
cvtsi2sdq 0x708(%rsp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, (%rsp)
leaq 0x5e8(%rsp), %rdi
callq 0xeaf0
leaq 0x618(%rsp), %rdi
callq 0xeaf0
leaq 0x650(%rsp), %rdi
callq 0xeb00
leaq 0x680(%rsp), %rdi
callq 0xdbe0
leaq 0x6a0(%rsp), %rdi
callq 0xdbe0
leaq 0x6e0(%rsp), %rdi
callq 0xdd10
movsd (%rsp), %xmm0
addq $0x718, %rsp            # imm = 0x718
retq
leaq 0x5e8(%rsp), %rdi
callq 0xeaf0
leaq 0x618(%rsp), %rdi
callq 0xeaf0
leaq 0x650(%rsp), %rdi
callq 0xeb00
leaq 0x680(%rsp), %rdi
callq 0xdbe0
leaq 0x6a0(%rsp), %rdi
callq 0xdbe0
leaq 0x6e0(%rsp), %rdi
callq 0xdd10
movq 0x6c8(%rsp), %rdi
callq 0x4680