// File: /workspace/github_cpp_makefile_star2_O1/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 0xfcb2
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 0xfcb2
movq %rax, 0x40(%r15)
movq 0xb80(%r15), %rdx
leaq 0xe473(%rip), %rcx      # 0x12277
movl $0x1, %r8d
movq 0x58(%rsp), %rdi
xorl %esi, %esi
callq 0x34c0
movq %r15, %rdi
callq 0x4730
leaq 0x120(%r15), %rdi
movl $0x1736a, %esi          # imm = 0x1736A
callq 0x110e4
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 0x4a52
leaq 0xe0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3feb
callq 0x32c0
jmp 0x3feb
movq 0x140ed(%rip), %rbx     # 0x17fd8
leaq 0xe2ae(%rip), %rsi      # 0x121a0
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 0xfcb2
movq %rax, %rdi
callq 0xa9a5
movl %eax, 0x78(%r15)
movq 0x18(%r15), %rdi
leaq 0xe25d(%rip), %rsi      # 0x121ae
callq 0xfcb2
movq %rax, %rdi
callq 0xa9a5
movl %eax, 0x7c(%r15)
movq 0x1406f(%rip), %rdi     # 0x17fd8
leaq 0xe240(%rip), %rsi      # 0x121b0
movl $0x6, %edx
callq 0x3340
movl 0x78(%r15), %esi
movq 0x14053(%rip), %rdi     # 0x17fd8
callq 0x3580
movq %rax, %rbx
leaq 0xe2e3(%rip), %rsi      # 0x12277
movl $0x1, %edx
movq %rax, %rdi
callq 0x3340
leaq 0xe20f(%rip), %rsi      # 0x121b7
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 0xfcb2
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 0xfcb2
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 0xfcb2
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 0xab24
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 0xab56
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 0xab98
movq 0xb58(%r15), %rdi
movapd 0xd0(%rsp), %xmm0
movq 0xe0(%rsp), %rax
movq %rdi, 0xd0(%rsp)
movupd 0xb60(%r15), %xmm1
movupd %xmm0, 0xb58(%r15)
movq %rax, 0xb68(%r15)
movupd %xmm1, 0xd8(%rsp)
xorpd %xmm0, %xmm0
movapd %xmm0, 0xd0(%rsp)
movq $0x0, 0xe0(%rsp)
testq %rdi, %rdi
je 0x42c2
callq 0x32c0
movq 0xd0(%rsp), %rdi
testq %rdi, %rdi
je 0x42d4
callq 0x32c0
cmpl $0x0, 0x68(%r15)
je 0x4328
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 0xab56
movq 0xd0(%rsp), %rdi
testq %rdi, %rdi
je 0x431b
callq 0x32c0
incl %ebp
movl 0x68(%r15), %eax
imull %eax, %eax
cmpl %eax, %ebp
jb 0x42e5
movl $0x18, %edi
callq 0x32f0
xorpd %xmm0, %xmm0
movupd %xmm0, (%rax)
movq $0x0, 0x10(%rax)
movq %rax, 0xae8(%r15)
cmpl $0x0, 0x70(%r15)
jle 0x4402
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 0xde7c
movq %r12, 0x28(%rsp)
cmpl $0x0, 0x68(%r15)
jle 0x43cd
xorl %r12d, %r12d
movq 0x28(%rsp), %rdi
xorpd %xmm0, %xmm0
movapd %xmm0, 0xd0(%rsp)
movq $0x0, 0xe0(%rsp)
movq %rbp, %rsi
callq 0xacbe
movq 0xd0(%rsp), %rdi
testq %rdi, %rdi
je 0x43c4
callq 0x32c0
incl %r12d
cmpl 0x68(%r15), %r12d
jl 0x438c
movq 0xae8(%r15), %rdi
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0x43ed
movq 0x28(%rsp), %rax
movq %rax, (%rsi)
addq $0x8, 0x8(%rdi)
jmp 0x43f5
movq %rbx, %rdx
callq 0xbc74
incl %r14d
cmpl 0x70(%r15), %r14d
jl 0x4364
movq 0x13bcf(%rip), %rdi     # 0x17fd8
leaq 0xddae(%rip), %rsi      # 0x121be
movl $0x9, %edx
callq 0x3340
movl 0x70(%r15), %esi
movq 0x13bb3(%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 0x5064
movq 0x13b75(%rip), %rbx     # 0x17fd8
leaq 0xdd5e(%rip), %rsi      # 0x121c8
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 0x13b43(%rip), %rdi     # 0x17fd8
callq 0x3030
movq %rax, %rdi
callq 0x31e0
movq %r15, %rdi
callq 0x5734
movq 0x13b27(%rip), %rbx     # 0x17fd8
leaq 0xdd2e(%rip), %rsi      # 0x121e6
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 0x13af5(%rip), %rdi     # 0x17fd8
callq 0x3030
movq %rax, %rdi
callq 0x31e0
movq %r15, %rdi
callq 0x61b8
movq 0x10(%r15), %rsi
movq %r15, %rdi
callq 0x64b2
movq 0x10(%r15), %rsi
movq %r15, %rdi
callq 0x6cfe
movq 0x10(%r15), %rsi
movq %r15, %rdi
callq 0x75a0
cmpq $0x0, 0x40(%r15)
je 0x452f
movq 0x10(%r15), %rsi
movq %r15, %rdi
callq 0x885e
addq $0x258, %rsp            # imm = 0x258
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x4543
movq %rax, %rbp
leaq 0xe0(%rsp), %rax
jmp 0x45d8
jmp 0x45f1
jmp 0x45f1
movq %rax, %rbp
jmp 0x45a2
jmp 0x45f1
movq %rax, %rbp
jmp 0x45d0
jmp 0x45f1
movq %rax, %rbp
movq 0x10(%rsp), %rbx
jmp 0x4641
movq %rax, %rbp
movq 0x13a20(%rip), %rsi     # 0x17fa8
leaq 0xd0(%rsp), %rdi
callq 0x3220
leaq 0x150(%rsp), %rdi
callq 0x30e0
leaq 0xa0(%rsp), %rax
jmp 0x45d8
movq %rax, %rbp
movq 0x139f2(%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 0x4606
jmp 0x460b
movq %rax, %rbp
movq %r12, %rdi
jmp 0x4606
jmp 0x45f6
jmp 0x45f6
jmp 0x45f1
movq %rax, %rbp
jmp 0x460b
movq %rax, %rbp
movq 0xd0(%rsp), %rdi
testq %rdi, %rdi
je 0x460b
callq 0x32c0
movq 0x10(%rsp), %rbx
movq 0xdb8(%r15), %rdi
cmpq 0x68(%rsp), %rdi
je 0x4623
callq 0x32c0
movq 0x48(%rsp), %rax
movq (%rax), %rdi
cmpq 0x70(%rsp), %rdi
je 0x4637
callq 0x32c0
movq 0x78(%rsp), %rdi
callq 0x3480
movq 0x58(%rsp), %rax
movq (%rax), %rdi
cmpq %rbx, %rdi
je 0x4653
callq 0x32c0
leaq 0xb28(%r15), %rbx
movq 0xb58(%r15), %rdi
testq %rdi, %rdi
je 0x466b
callq 0x32c0
leaq 0xaf0(%r15), %r14
movq %r13, %rdi
callq 0xacf2
movq %rbx, %rdi
callq 0xacf2
movq 0xb08(%r15), %rdi
testq %rdi, %rdi
je 0x4693
callq 0x32c0
movq (%r14), %rdi
testq %rdi, %rdi
movq 0x20(%rsp), %rbx
je 0x46a5
callq 0x32c0
movq 0x108(%r15), %rdi
testq %rdi, %rdi
je 0x46b6
callq 0x32c0
movq 0xf0(%r15), %rdi
testq %rdi, %rdi
je 0x46c7
callq 0x32c0
movq 0x50(%rsp), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x46d9
callq 0x32c0
movq 0xc0(%r15), %rdi
addq $0xa8, %r15
testq %rdi, %rdi
je 0x46f1
callq 0x32c0
movq (%r15), %rdi
testq %rdi, %rdi
je 0x46fe
callq 0x32c0
movq (%rbx), %rdi
cmpq 0x80(%rsp), %rdi
je 0x4710
callq 0x32c0
movq 0x60(%rsp), %rax
movq (%rax), %rdi
cmpq 0x88(%rsp), %rdi
je 0x4727
callq 0x32c0
movq %rbp, %rdi
callq 0x35c0
nop