// File: /workspace/github_cpp_makefile_star2_O2/sjain12[P]CliqueCounting/tests/test_cliques_turan_shadow.cpp
// Function: main
int main(int argc, char *argv[])
{
    if(argc < 13) {
        usage();
        exit(1);
    }

    std::ofstream of; // output file
    std::vector<std::string> graphs; // input files
	srand (time(NULL));
    int min_clique_size = 0, max_clique_size = 0, runs = 0, i = 0;
    float start_threshold = 0.0, end_threshold = 0.0, threshold_interval = 0.0;
	int num_samples=0, full=0;
    char c;
    printf("*****************************\n");
    while ((c = getopt(argc, argv, "i:m:M:n:r:f:")) != -1) {
        switch (c) {
            case 'i': {
                // multiple input files
                char *token = std::strtok(optarg, ",");
                printf("Input Files: ");
                while (token != NULL) {
                    graphs.push_back(std::string(token));
                    printf("%s,",token);
                    token = std::strtok(NULL, ",");
                }
                printf("\n");
            }
            break;

            case 'm':
                min_clique_size = atoi(optarg);
                cout << "Min clique size: " << min_clique_size << endl;
            break;

            case 'M':
                max_clique_size = atoi(optarg);
                cout << "Max Clique Size:" << max_clique_size << endl;
            break;

            case 'n':
                num_samples = atoi(optarg);
                cout << "num_samples: " << num_samples << endl;
            break;

            case 'r':
                runs = atoi(optarg);
                cout << "Runs: " << runs << endl;
            break;

		}
    }
    printf("*****************************\n\n");
    
    populate_nCr();
    
    for (std::vector<std::string>::iterator it=graphs.begin(); it!=graphs.end(); ++it)
    {
        std::string fname = "../graphs/" + *it;
        std::cout << fname << std::endl;
        Graph g;
        printf("Loading graph\n");
        if (loadGraph(fname.c_str(), g, 1, IOFormat::escape))
            exit(1);

        printf("Converting to CSR\n");
        CGraph cg = makeCSR(g);

        printf("Creating DAG\n");
        CDAG dag = degreeOrdered(&cg);

        cout << "vertices: " << g.nVertices << " edges = " << g.nEdges << std::endl;

        string f = *it;
        char *token = std::strtok(strdup(f.c_str()), ".");
        string gname(token);
        cout << "GNAME = " << gname << endl;
        for(i=min_clique_size; i<=max_clique_size; i++)
        {
            turan_shadow(cg, dag, of, gname, "", runs, num_samples, i);
            of << std::endl;
        }
        of << std::endl;
        delGraph(g);
        delCGraph(cg);
        delCDAG(dag);
    }
    of.close();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x3c8, %rsp            # imm = 0x3C8
movq %rsi, 0x30(%rsp)
movl %edi, 0x3c(%rsp)
cmpl $0xc, %edi
jle 0x5733
leaq 0x1c8(%rsp), %rdi
callq 0x3490
xorps %xmm0, %xmm0
leaq 0x40(%rsp), %rax
movaps %xmm0, (%rax)
andq $0x0, 0x10(%rax)
xorl %edi, %edi
callq 0x3230
movl %eax, %edi
callq 0x3260
leaq 0x61da(%rip), %rdi      # 0xb3fe
callq 0x33e0
leaq 0x5f48(%rip), %r15      # 0xb178
leaq 0xa0(%rsp), %r12
xorl %ebx, %ebx
xorl %ebp, %ebp
xorl %r14d, %r14d
movl $0x0, 0x2c(%rsp)
movl 0x3c(%rsp), %edi
movq 0x30(%rsp), %rsi
leaq 0x6003(%rip), %rdx      # 0xb25a
callq 0x30a0
shll $0x18, %eax
cmpl $0xff000000, %eax       # imm = 0xFF000000
je 0x5401
sarl $0x18, %eax
leal -0x69(%rax), %ecx
cmpl $0x9, %ecx
ja 0x5306
leaq 0x5db0(%rip), %rdx      # 0xb030
movslq (%rdx,%rcx,4), %rax
addq %rdx, %rax
jmpq *%rax
movq 0xbd30(%rip), %rax      # 0x10fc0
movq (%rax), %rdi
movq %r15, %rsi
callq 0x3400
movq %rax, %r13
leaq 0x5fc2(%rip), %rdi      # 0xb267
xorl %eax, %eax
callq 0x3040
testq %r13, %r13
je 0x52f9
movq %r12, %rdi
movq %r13, %rsi
leaq 0xe8(%rsp), %rdx
callq 0x57e0
leaq 0x40(%rsp), %rdi
movq %r12, %rsi
callq 0x6c4e
movq %r12, %rdi
callq 0x3120
leaq 0x5f95(%rip), %rdi      # 0xb275
movq %r13, %rsi
xorl %eax, %eax
callq 0x3040
xorl %edi, %edi
movq %r15, %rsi
callq 0x3400
movq %rax, %r13
jmp 0x52ac
pushq $0xa
popq %rdi
callq 0x3380
jmp 0x5247
cmpl $0x4d, %eax
jne 0x5247
movq 0xbcaa(%rip), %rax      # 0x10fc0
movq (%rax), %rdi
callq 0x33f0
movl %eax, %r14d
movq 0xbca8(%rip), %rdi      # 0x10fd0
leaq 0x5f5c(%rip), %rsi      # 0xb28b
callq 0x3280
movq %rax, %rdi
movl %r14d, %esi
callq 0x34a0
movq %rax, %rdi
callq 0x3140
jmp 0x5247
movq 0xbc6d(%rip), %rax      # 0x10fc0
movq (%rax), %rdi
callq 0x33f0
movl %eax, 0x2c(%rsp)
movq 0xbc6a(%rip), %rdi      # 0x10fd0
leaq 0x5f0c(%rip), %rsi      # 0xb279
callq 0x3280
movq %rax, %rdi
movl 0x2c(%rsp), %esi
callq 0x34a0
movq %rax, %rdi
callq 0x3140
jmp 0x5247
movq 0xbc2e(%rip), %rax      # 0x10fc0
movq (%rax), %rdi
callq 0x33f0
movl %eax, %ebx
movq 0xbc2d(%rip), %rdi      # 0x10fd0
leaq 0x5ef2(%rip), %rsi      # 0xb29c
callq 0x3280
movq %rax, %rdi
movl %ebx, %esi
callq 0x34a0
movq %rax, %rdi
callq 0x3140
jmp 0x5247
movq 0xbbf3(%rip), %rax      # 0x10fc0
movq (%rax), %rdi
callq 0x33f0
movl %eax, %ebp
movq 0xbbf2(%rip), %rdi      # 0x10fd0
leaq 0x5ec5(%rip), %rsi      # 0xb2aa
callq 0x3280
movq %rax, %rdi
movl %ebp, %esi
callq 0x34a0
movq %rax, %rdi
callq 0x3140
jmp 0x5247
leaq 0x6014(%rip), %rdi      # 0xb41c
callq 0x33e0
callq 0x3849
movq 0x40(%rsp), %rdx
leaq 0x1a8(%rsp), %r15
leaq 0x188(%rsp), %r13
cmpq 0x48(%rsp), %rdx
je 0x56fb
leaq 0x168(%rsp), %r12
movq %r12, %rdi
leaq 0x5e6d(%rip), %rsi      # 0xb2b1
movq %rdx, 0x30(%rsp)
callq 0x5996
movq 0xbb7b(%rip), %rdi      # 0x10fd0
movq %r12, %rsi
callq 0x3220
movq %rax, %rdi
callq 0x3140
leaq 0x5fcf(%rip), %rdi      # 0xb43b
callq 0x33e0
movq 0x168(%rsp), %rdi
leaq 0x60(%rsp), %rsi
pushq $0x1
popq %rcx
movl %ecx, %edx
callq 0x9978
testl %eax, %eax
jne 0x5738
leaq 0x5fb2(%rip), %rdi      # 0xb449
callq 0x33e0
movups 0x60(%rsp), %xmm0
movups 0x70(%rsp), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
leaq 0x148(%rsp), %r12
movq %r12, %rdi
xorl %esi, %esi
callq 0x73d4
leaq 0x5f93(%rip), %rdi      # 0xb45b
callq 0x33e0
leaq 0xe8(%rsp), %rdi
movq %r12, %rsi
callq 0x3695
movq 0xbaec(%rip), %rdi      # 0x10fd0
leaq 0x5dd1(%rip), %rsi      # 0xb2bc
callq 0x3280
movq 0x60(%rsp), %rsi
movq %rax, %rdi
callq 0x3250
movq %rax, %rdi
leaq 0x5dc0(%rip), %rsi      # 0xb2c7
callq 0x3280
movq 0x68(%rsp), %rsi
movq %rax, %rdi
callq 0x3250
movq %rax, %rdi
callq 0x3140
leaq 0x128(%rsp), %rdi
movq 0x30(%rsp), %rsi
callq 0x3360
movq 0x128(%rsp), %rdi
callq 0x34e0
movq %rax, %rdi
leaq 0x5b89(%rip), %rsi      # 0xb0d3
callq 0x3400
leaq 0x80(%rsp), %rdi
movq %rax, %rsi
leaq 0xa0(%rsp), %rdx
callq 0x57e0
movq 0xba62(%rip), %rdi      # 0x10fd0
leaq 0x5d5c(%rip), %rsi      # 0xb2d1
callq 0x3280
movq %rax, %rdi
leaq 0x80(%rsp), %rsi
callq 0x3220
movq %rax, %rdi
callq 0x3140
movl 0x2c(%rsp), %r12d
cmpl %r14d, %r12d
jg 0x5608
movq %r15, %rdi
leaq 0x80(%rsp), %rsi
callq 0x3360
movq %r13, %rdi
leaq 0x6079(%rip), %rsi      # 0xb62f
leaq 0xa0(%rsp), %rdx
callq 0x57e0
movl %r12d, 0x8(%rsp)
movl %ebx, (%rsp)
leaq 0x148(%rsp), %rdi
leaq 0xe8(%rsp), %rsi
movq %r15, %rcx
movl %ebp, %r9d
callq 0x3f4e
movq %r13, %rdi
callq 0x3120
movq %r15, %rdi
callq 0x3120
leaq 0x1c8(%rsp), %rdi
callq 0x3140
incl %r12d
jmp 0x5597
leaq 0x1c8(%rsp), %rdi
callq 0x3140
movups 0x60(%rsp), %xmm0
movups 0x70(%rsp), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
callq 0x6f71
movups 0x148(%rsp), %xmm0
movups 0x158(%rsp), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
callq 0x70ed
movups 0xe8(%rsp), %xmm0
movups 0xf8(%rsp), %xmm1
movups 0x108(%rsp), %xmm2
movups 0x118(%rsp), %xmm3
movaps %xmm3, 0xd0(%rsp)
movaps %xmm2, 0xc0(%rsp)
movaps %xmm1, 0xb0(%rsp)
movaps %xmm0, 0xa0(%rsp)
movups 0xe8(%rsp), %xmm0
movups 0xf8(%rsp), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
callq 0x70ed
leaq 0xc0(%rsp), %rax
movups (%rax), %xmm0
movups 0x10(%rax), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
callq 0x70ed
leaq 0x80(%rsp), %rdi
callq 0x3120
leaq 0x128(%rsp), %rdi
callq 0x3120
leaq 0x168(%rsp), %rdi
callq 0x3120
movq 0x30(%rsp), %rdx
addq $0x20, %rdx
jmp 0x5427
leaq 0x1c8(%rsp), %rdi
callq 0x3390
leaq 0x40(%rsp), %rdi
callq 0x5a74
leaq 0x1c8(%rsp), %rdi
callq 0x33c0
xorl %eax, %eax
addq $0x3c8, %rsp            # imm = 0x3C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x51c3
pushq $0x1
popq %rdi
callq 0x3310
jmp 0x5760
jmp 0x5760
jmp 0x5760
jmp 0x5760
jmp 0x5760
jmp 0x5760
jmp 0x5759
jmp 0x5759
jmp 0x5759
movq %rax, %rbx
jmp 0x57a6
jmp 0x5759
movq %rax, %rbx
jmp 0x57b3
jmp 0x5796
movq %rax, %rbx
jmp 0x57c0
movq %rax, %rbx
leaq 0xa0(%rsp), %rdi
jmp 0x57bb
movq %rax, %rbx
jmp 0x5787
movq %rax, %rbx
leaq 0x188(%rsp), %rdi
callq 0x3120
leaq 0x1a8(%rsp), %rdi
callq 0x3120
jmp 0x5799
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
callq 0x3120
leaq 0x128(%rsp), %rdi
callq 0x3120
leaq 0x168(%rsp), %rdi
callq 0x3120
leaq 0x40(%rsp), %rdi
callq 0x5a74
leaq 0x1c8(%rsp), %rdi
callq 0x33c0
movq %rbx, %rdi
callq 0x34b0
nop