// File: /workspace/github_cpp_makefile_star2_O3/JenTus[P]TCEM/src_TCEM/allocator.cc
// Function: Cide::allocator::allocator(AnyOption*)
allocator::allocator(AnyOption* opt1) {
        
        opt = opt1;
        probGraphFile = opt->getValue("x");
        compareFile = opt->getValue("p"); // it can be empty

        //delim = " \t";
        delim = " ";

        readGraphNodes(); // assign n and m

        sfmt_init_gen_rand(&sfmtSeed , 95082);

        if (compareFile == NULL) {
            cout << "Red k_r and k_b" << endl;
            k_r = strToInt(opt->getValue("r"));
            k_b = strToInt(opt->getValue("b"));
            cout << "kr is " << k_r << " " << "kb is " << k_b << endl;
        } else{
            std::string cF(compareFile);
            int beginIdx = cF.rfind('/');
            compareFileShort = cF.substr(beginIdx + 1);
            for (int j = 0; j < 4; ++j) {
                compareFileShort.pop_back();
            }
            readCompareNodes();
        }

        tao = ceil((double)k_b/(double)k_r);

//        P = Permutation(n, k_r*(tao + 1)) / (double) (pow(fact(tao), k_r) * fact(k_r));

        nrItems = 2;
        epsilon = strToDouble(opt->getValue("epsilon"));
        ell = strToDouble(opt->getValue("ell"));
        outFolderName = opt->getValue("outputFolder");
    
        nrPairs = n * nrItems; // multiple items

        nodeDegree.resize(n);
        
        for(int i = 0; i < n; i++)
            graphT.emplace_back(vector<int>());

        prevSize = 0; // when sample the first node
        //for(int i = 0; i < nrPairs; i++)
        //    hyperG.emplace_back(std::vector<int>());

        // create new pairs-related functions
        hyper_degreepairs = std::vector<double>(n*n, 0);
        for (int i = 0; i < n*n; ++i) {
           hyperGpairs.emplace_back(std::vector<int>());
        }

        rcList = new itemGraphList();
        //item-specific probT is aligned with graphT for each item
        for(int i = 0; i < nrItems; i++) {
            //_Cide::itemGraph *ig = new _Cide::itemGraph(n);
            auto *ig = new _Cide::itemGraph(n);
            for (int j = 0; j < n; j++)
                ig->probT.emplace_back(std::vector< double>());
            rcList->push_back(ig);
        }

        //nodeDegree = std::vector<double>(n,0.0);
        
        cout << "nr items " << nrItems << endl;
        //cout << "assignment size " << k << endl;

        readTICGraph();

        cout << "successfully read everything " << endl;

        arrangeOutputFiles();
        cout << "starting assignment for tcem" << endl;
        tdem();
        
// comment out below to run the baselines
        degreeVersionOne(theta);
        degreeVersionTwo(theta);
        mni(theta);
        if(compareFile!=NULL){
            compareGivenNodes(theta);
        }
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x258, %rsp            # imm = 0x258
movq %rsi, %rbx
movq %rdi, %r15
leaq 0x20(%rdi), %rax
movq %rax, 0x60(%rsp)
leaq 0x30(%rdi), %rax
movq %rax, 0x88(%rsp)
movq %rax, 0x20(%rdi)
xorl %eax, %eax
movq %rax, 0x28(%rdi)
movb %al, 0x30(%rdi)
leaq 0x48(%rdi), %rcx
movq %rcx, 0x20(%rsp)
leaq 0x58(%rdi), %rcx
movq %rcx, 0x80(%rsp)
movq %rcx, 0x48(%rdi)
movq %rax, 0x50(%rdi)
movb %al, 0x58(%rdi)
leaq 0xd8(%rdi), %rcx
movq %rcx, 0x50(%rsp)
leaq 0xb40(%rdi), %r13
leaq 0xb78(%rdi), %rcx
movq %rcx, 0x58(%rsp)
leaq 0xb88(%rdi), %rcx
xorpd %xmm0, %xmm0
movupd %xmm0, 0xa8(%rdi)
movupd %xmm0, 0xb8(%rdi)
movupd %xmm0, 0xc8(%rdi)
movupd %xmm0, 0xd8(%rdi)
movupd %xmm0, 0xe8(%rdi)
movupd %xmm0, 0xf8(%rdi)
movupd %xmm0, 0x108(%rdi)
movq %rax, 0x118(%rdi)
movupd %xmm0, 0xaf0(%rdi)
movupd %xmm0, 0xb00(%rdi)
movupd %xmm0, 0xb10(%rdi)
movupd %xmm0, 0xb28(%rdi)
movupd %xmm0, 0xb38(%rdi)
movupd %xmm0, 0xb48(%rdi)
movupd %xmm0, 0xb58(%rdi)
movq %rax, 0xb68(%rdi)
movq %rcx, 0x10(%rsp)
movq %rcx, 0xb78(%rdi)
movq %rax, 0xb80(%rdi)
movb %al, 0xb88(%rdi)
addq $0xb98, %rdi            # imm = 0xB98
movq %rdi, 0x78(%rsp)
callq 0x3570
leaq 0xd98(%r15), %rax
movq %rax, 0x48(%rsp)
leaq 0xda8(%r15), %rax
movq %rax, 0x70(%rsp)
movq %rax, 0xd98(%r15)
xorl %eax, %eax
movq %rax, 0xda0(%r15)
movb %al, 0xda8(%r15)
leaq 0xdc8(%r15), %rcx
movq %rcx, 0x68(%rsp)
movq %rcx, 0xdb8(%r15)
movq %rax, 0xdc0(%r15)
movb %al, 0xdc8(%r15)
movq %rbx, 0x18(%r15)
leaq 0xe309(%rip), %rsi      # 0x120bf
movq %rbx, %rdi
callq 0xfa94
movq %rax, %rbx
movq 0x28(%r15), %r12
movq %rax, %rdi
callq 0x3130
movq 0x60(%rsp), %rdi
xorl %esi, %esi
movq %r12, %rdx
movq %rbx, %rcx
movq %rax, %r8
callq 0x34c0
movq 0x18(%r15), %rdi
leaq 0xe2d0(%rip), %rsi      # 0x120bd
callq 0xfa94
movq %rax, 0x40(%r15)
movq 0xb80(%r15), %rdx
leaq 0xe46b(%rip), %rcx      # 0x1226f
movl $0x1, %r8d
movq 0x58(%rsp), %rdi
xorl %esi, %esi
callq 0x34c0
movq %r15, %rdi
callq 0x4716
leaq 0x120(%r15), %rdi
movl $0x1736a, %esi          # imm = 0x1736A
callq 0x10d6d
movq 0x40(%r15), %rsi
testq %rsi, %rsi
je 0x3ee4
leaq 0xd0(%rsp), %rdi
leaq 0x28(%rsp), %rdx
callq 0x3110
leaq 0xd0(%rsp), %rbx
movq %rbx, %rdi
movl $0x2f, %esi
movq $-0x1, %rdx
callq 0x3630
incl %eax
movslq %eax, %rdx
leaq 0x28(%rsp), %rdi
movq %rbx, %rsi
movq $-0x1, %rcx
callq 0x3300
leaq 0x28(%rsp), %rbx
movq 0x20(%rsp), %rdi
movq %rbx, %rsi
callq 0x33b0
movq (%rbx), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x3ea7
callq 0x32c0
movl $0x4, %ebx
movq 0x20(%rsp), %r14
movq %r14, %rdi
callq 0x33a0
decl %ebx
jne 0x3eb1
movq %r15, %rdi
callq 0x4a38
leaq 0xe0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3feb
callq 0x32c0
jmp 0x3feb
movq 0x140ed(%rip), %rbx     # 0x17fd8
leaq 0xe2a6(%rip), %rsi      # 0x12198
movl $0xf, %edx
movq %rbx, %rdi
callq 0x3340
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x32d0
movsbl %al, %esi
movq 0x140bb(%rip), %rdi     # 0x17fd8
callq 0x3030
movq %rax, %rdi
callq 0x31e0
movq 0x18(%r15), %rdi
leaq 0xe177(%rip), %rsi      # 0x120ac
callq 0xfa94
movq %rax, %rdi
callq 0xa933
movl %eax, 0x78(%r15)
movq 0x18(%r15), %rdi
leaq 0xe255(%rip), %rsi      # 0x121a6
callq 0xfa94
movq %rax, %rdi
callq 0xa933
movl %eax, 0x7c(%r15)
movq 0x1406f(%rip), %rdi     # 0x17fd8
leaq 0xe238(%rip), %rsi      # 0x121a8
movl $0x6, %edx
callq 0x3340
movl 0x78(%r15), %esi
movq 0x14053(%rip), %rdi     # 0x17fd8
callq 0x3580
movq %rax, %rbx
leaq 0xe2db(%rip), %rsi      # 0x1226f
movl $0x1, %edx
movq %rax, %rdi
callq 0x3340
leaq 0xe207(%rip), %rsi      # 0x121af
movl $0x6, %edx
movq %rbx, %rdi
callq 0x3340
movl 0x7c(%r15), %esi
movq %rbx, %rdi
callq 0x3580
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x32d0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x31e0
cvtsi2sdl 0x7c(%r15), %xmm0
cvtsi2sdl 0x78(%r15), %xmm1
divsd %xmm1, %xmm0
callq 0x3080
cvttsd2si %xmm0, %eax
movl %eax, 0x80(%r15)
movl $0x2, 0x70(%r15)
movq 0x18(%r15), %rdi
leaq 0xe090(%rip), %rsi      # 0x120ae
callq 0xfa94
leaq 0xb0(%rsp), %rdi
leaq 0xf(%rsp), %rdx
movq %rax, %rsi
callq 0x3110
movq $0x0, 0x28(%rsp)
leaq 0xd0(%rsp), %rdi
callq 0x3200
leaq 0xe0(%rsp), %rdi
movq 0xb0(%rsp), %rsi
movq 0xb8(%rsp), %rdx
callq 0x3340
leaq 0xd0(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x31c0
movsd 0x28(%rsp), %xmm0
movsd %xmm0, 0x18(%rsp)
movq 0x13f18(%rip), %rsi     # 0x17fa8
leaq 0xd0(%rsp), %rdi
callq 0x3220
leaq 0x150(%rsp), %rdi
callq 0x30e0
movsd 0x18(%rsp), %xmm0
movsd %xmm0, 0x90(%r15)
leaq 0xc0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x40cf
callq 0x32c0
movq 0x18(%r15), %rdi
leaq 0xdfdc(%rip), %rsi      # 0x120b6
callq 0xfa94
leaq 0x90(%rsp), %rdi
leaq 0xf(%rsp), %rdx
movq %rax, %rsi
callq 0x3110
movq $0x0, 0x28(%rsp)
leaq 0xd0(%rsp), %rdi
callq 0x3200
leaq 0xe0(%rsp), %rdi
movq 0x90(%rsp), %rsi
movq 0x98(%rsp), %rdx
callq 0x3340
leaq 0xd0(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x31c0
movsd 0x28(%rsp), %xmm0
movsd %xmm0, 0x18(%rsp)
movq 0x13e5c(%rip), %rsi     # 0x17fa8
leaq 0xd0(%rsp), %rdi
callq 0x3220
leaq 0x150(%rsp), %rdi
callq 0x30e0
movsd 0x18(%rsp), %xmm0
movsd %xmm0, 0xa0(%r15)
leaq 0xa0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x418b
callq 0x32c0
movq 0x18(%r15), %rdi
leaq 0xdf0b(%rip), %rsi      # 0x120a1
callq 0xfa94
movq %rax, %rbx
movq 0xda0(%r15), %r12
movq %rax, %rdi
callq 0x3130
movq 0x48(%rsp), %rdi
xorl %esi, %esi
movq %r12, %rdx
movq %rbx, %rcx
movq %rax, %r8
callq 0x34c0
movslq 0x68(%r15), %rsi
movl 0x70(%r15), %eax
imull %esi, %eax
movl %eax, 0x74(%r15)
movq 0x50(%rsp), %rdi
callq 0xaab2
movl 0x68(%r15), %esi
testl %esi, %esi
jle 0x4237
xorl %r14d, %r14d
leaq 0x1415b(%rip), %rbx     # 0x18348
leaq 0xd0(%rsp), %rbp
xorpd %xmm0, %xmm0
movapd %xmm0, 0xd0(%rsp)
movq $0x0, 0xe0(%rsp)
movq %rbx, %rdi
movq %rbp, %rsi
callq 0xaae4
movq 0xd0(%rsp), %rdi
testq %rdi, %rdi
je 0x422b
callq 0x32c0
incl %r14d
movl 0x68(%r15), %esi
cmpl %esi, %r14d
jl 0x41f5
xorl %eax, %eax
movq %rax, 0xb20(%r15)
imull %esi, %esi
leaq 0x28(%rsp), %rdx
movq %rax, (%rdx)
leaq 0xd0(%rsp), %rdi
leaq 0xf(%rsp), %rcx
callq 0xab26
movq 0xb58(%r15), %rdi
movapd 0xd0(%rsp), %xmm0
movupd %xmm0, 0xb58(%r15)
movq 0xe0(%rsp), %rax
movq %rax, 0xb68(%r15)
xorpd %xmm0, %xmm0
movapd %xmm0, 0xd0(%rsp)
movq $0x0, 0xe0(%rsp)
testq %rdi, %rdi
je 0x42ba
callq 0x32c0
movq 0xd0(%rsp), %rdi
testq %rdi, %rdi
je 0x42ba
callq 0x32c0
cmpl $0x0, 0x68(%r15)
je 0x430e
xorl %ebp, %ebp
leaq 0xd0(%rsp), %rbx
xorpd %xmm0, %xmm0
movapd %xmm0, 0xd0(%rsp)
movq $0x0, 0xe0(%rsp)
movq %r13, %rdi
movq %rbx, %rsi
callq 0xaae4
movq 0xd0(%rsp), %rdi
testq %rdi, %rdi
je 0x4301
callq 0x32c0
incl %ebp
movl 0x68(%r15), %eax
imull %eax, %eax
cmpl %eax, %ebp
jb 0x42cb
movl $0x18, %edi
callq 0x32f0
xorpd %xmm0, %xmm0
movupd %xmm0, (%rax)
movq $0x0, 0x10(%rax)
movq %rax, 0xae8(%r15)
cmpl $0x0, 0x70(%r15)
jle 0x43e8
xorl %r14d, %r14d
leaq 0xd0(%rsp), %rbp
leaq 0x28(%rsp), %rbx
movl $0xa88, %edi            # imm = 0xA88
callq 0x32f0
movq %rax, %r12
movl 0x68(%r15), %esi
movq %rax, %rdi
callq 0xdda8
movq %r12, 0x28(%rsp)
cmpl $0x0, 0x68(%r15)
jle 0x43b3
xorl %r12d, %r12d
movq 0x28(%rsp), %rdi
xorpd %xmm0, %xmm0
movapd %xmm0, 0xd0(%rsp)
movq $0x0, 0xe0(%rsp)
movq %rbp, %rsi
callq 0xac56
movq 0xd0(%rsp), %rdi
testq %rdi, %rdi
je 0x43aa
callq 0x32c0
incl %r12d
cmpl 0x68(%r15), %r12d
jl 0x4372
movq 0xae8(%r15), %rdi
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0x43d3
movq 0x28(%rsp), %rax
movq %rax, (%rsi)
addq $0x8, 0x8(%rdi)
jmp 0x43db
movq %rbx, %rdx
callq 0xbc2a
incl %r14d
cmpl 0x70(%r15), %r14d
jl 0x434a
movq 0x13be9(%rip), %rdi     # 0x17fd8
leaq 0xddc0(%rip), %rsi      # 0x121b6
movl $0x9, %edx
callq 0x3340
movl 0x70(%r15), %esi
movq 0x13bcd(%rip), %rdi     # 0x17fd8
callq 0x3580
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x32d0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x31e0
movq %r15, %rdi
callq 0x504c
movq 0x13b8f(%rip), %rbx     # 0x17fd8
leaq 0xdd70(%rip), %rsi      # 0x121c0
movl $0x1d, %edx
movq %rbx, %rdi
callq 0x3340
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x32d0
movsbl %al, %esi
movq 0x13b5d(%rip), %rdi     # 0x17fd8
callq 0x3030
movq %rax, %rdi
callq 0x31e0
movq %r15, %rdi
callq 0x5714
movq 0x13b41(%rip), %rbx     # 0x17fd8
leaq 0xdd40(%rip), %rsi      # 0x121de
movl $0x1c, %edx
movq %rbx, %rdi
callq 0x3340
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x32d0
movsbl %al, %esi
movq 0x13b0f(%rip), %rdi     # 0x17fd8
callq 0x3030
movq %rax, %rdi
callq 0x31e0
movq %r15, %rdi
callq 0x618e
movq 0x10(%r15), %rsi
movq %r15, %rdi
callq 0x6488
movq 0x10(%r15), %rsi
movq %r15, %rdi
callq 0x6ce2
movq 0x10(%r15), %rsi
movq %r15, %rdi
callq 0x7592
cmpq $0x0, 0x40(%r15)
je 0x4515
movq 0x10(%r15), %rsi
movq %r15, %rdi
callq 0x8804
addq $0x258, %rsp            # imm = 0x258
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x4529
movq %rax, %rbp
leaq 0xe0(%rsp), %rax
jmp 0x45be
jmp 0x45d7
jmp 0x45d7
movq %rax, %rbp
jmp 0x4588
jmp 0x45d7
movq %rax, %rbp
jmp 0x45b6
jmp 0x45d7
movq %rax, %rbp
movq 0x10(%rsp), %rbx
jmp 0x4627
movq %rax, %rbp
movq 0x13a3a(%rip), %rsi     # 0x17fa8
leaq 0xd0(%rsp), %rdi
callq 0x3220
leaq 0x150(%rsp), %rdi
callq 0x30e0
leaq 0xa0(%rsp), %rax
jmp 0x45be
movq %rax, %rbp
movq 0x13a0c(%rip), %rsi     # 0x17fa8
leaq 0xd0(%rsp), %rdi
callq 0x3220
leaq 0x150(%rsp), %rdi
callq 0x30e0
leaq 0xc0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
jne 0x45ec
jmp 0x45f1
movq %rax, %rbp
movq %r12, %rdi
jmp 0x45ec
jmp 0x45dc
jmp 0x45dc
jmp 0x45d7
movq %rax, %rbp
jmp 0x45f1
movq %rax, %rbp
movq 0xd0(%rsp), %rdi
testq %rdi, %rdi
je 0x45f1
callq 0x32c0
movq 0x10(%rsp), %rbx
movq 0xdb8(%r15), %rdi
cmpq 0x68(%rsp), %rdi
je 0x4609
callq 0x32c0
movq 0x48(%rsp), %rax
movq (%rax), %rdi
cmpq 0x70(%rsp), %rdi
je 0x461d
callq 0x32c0
movq 0x78(%rsp), %rdi
callq 0x3480
movq 0x58(%rsp), %rax
movq (%rax), %rdi
cmpq %rbx, %rdi
je 0x4639
callq 0x32c0
leaq 0xb28(%r15), %rbx
movq 0xb58(%r15), %rdi
testq %rdi, %rdi
je 0x4651
callq 0x32c0
leaq 0xaf0(%r15), %r14
movq %r13, %rdi
callq 0xac8a
movq %rbx, %rdi
callq 0xac8a
movq 0xb08(%r15), %rdi
testq %rdi, %rdi
je 0x4679
callq 0x32c0
movq (%r14), %rdi
testq %rdi, %rdi
movq 0x20(%rsp), %rbx
je 0x468b
callq 0x32c0
movq 0x108(%r15), %rdi
testq %rdi, %rdi
je 0x469c
callq 0x32c0
movq 0xf0(%r15), %rdi
testq %rdi, %rdi
je 0x46ad
callq 0x32c0
movq 0x50(%rsp), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x46bf
callq 0x32c0
movq 0xc0(%r15), %rdi
addq $0xa8, %r15
testq %rdi, %rdi
je 0x46d7
callq 0x32c0
movq (%r15), %rdi
testq %rdi, %rdi
je 0x46e4
callq 0x32c0
movq (%rbx), %rdi
cmpq 0x80(%rsp), %rdi
je 0x46f6
callq 0x32c0
movq 0x60(%rsp), %rax
movq (%rax), %rdi
cmpq 0x88(%rsp), %rdi
je 0x470d
callq 0x32c0
movq %rbp, %rdi
callq 0x35c0
nop