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

    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:r:")) != -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);
                printf("Min Clique Size: %d\n", min_clique_size);
            break;

            case 'M':
                max_clique_size = atoi(optarg);
                printf("Max Clique Size: %d\n", max_clique_size);
            break;

            case 'r':
                runs = atoi(optarg);
                printf("Runs: %f\n", runs);
            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++)
        {
			string outfile(gname + "_" + to_string(i) + "_" + to_string(runs) + "_cc");
			std::string ofname = "../results/cliques/" + outfile;
    		std::cout << ofname << std::endl;
    		std::ofstream of;
    		of.open(ofname);
    		if (!of.is_open())
    		{
        		std::cout << "Could not open output file." << std::endl;
        		exit(1);
  			}
    		printf("Output File: %s\n", ofname.c_str());
			of << "csize,estimate,time" << endl;
       	
			for (int run=0; run < runs; run++)
			{	
            	cliques_color_coding(cg, dag, of, gname, "", i);
            	of << std::endl;
			}
			of.close();
        }
        delGraph(g);
        delCGraph(cg);
        delCDAG(dag);
    }
   


}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x448, %rsp            # imm = 0x448
movq %rsi, 0x38(%rsp)
movl %edi, 0x30(%rsp)
cmpl $0x8, %edi
jle 0x49b3
xorps %xmm0, %xmm0
leaq 0x80(%rsp), %r14
movaps %xmm0, (%r14)
andq $0x0, 0x10(%r14)
xorl %edi, %edi
callq 0x3220
movl %eax, %edi
callq 0x3250
leaq 0x4ed4(%rip), %rdi      # 0x9253
callq 0x33c0
leaq 0x4d50(%rip), %r12      # 0x90db
leaq 0x240(%rsp), %r13
leaq 0xc0(%rsp), %r15
leaq 0x4d37(%rip), %rbx      # 0x90d9
movl $0x0, 0x24(%rsp)
movl $0x0, 0x2c(%rsp)
movl $0x0, 0x28(%rsp)
movl 0x30(%rsp), %edi
movq 0x38(%rsp), %rsi
leaq 0x4cf8(%rip), %rdx      # 0x90c2
callq 0x30a0
shll $0x18, %eax
cmpl $0xff000000, %eax       # imm = 0xFF000000
je 0x44d1
sarl $0x18, %eax
cmpl $0x69, %eax
je 0x441b
cmpl $0x4d, %eax
je 0x448d
cmpl $0x6d, %eax
je 0x44a9
cmpl $0x72, %eax
jne 0x43ba
movq 0x9bbd(%rip), %rax      # 0xdfc0
movq (%rax), %rdi
callq 0x33d0
leaq 0x4cf5(%rip), %rdi      # 0x9107
movl %eax, 0x24(%rsp)
jmp 0x44c3
movq 0x9b9e(%rip), %rax      # 0xdfc0
movq (%rax), %rdi
movq %r12, %rsi
callq 0x33e0
movq %rax, %rbp
leaq 0x4c94(%rip), %rdi      # 0x90cb
xorl %eax, %eax
callq 0x3040
testq %rbp, %rbp
je 0x4480
movq %r13, %rdi
movq %rbp, %rsi
movq %r15, %rdx
callq 0x4afa
movq %r14, %rdi
movq %r13, %rsi
callq 0x59e6
movq %r13, %rdi
callq 0x3120
movq %rbx, %rdi
movq %rbp, %rsi
xorl %eax, %eax
callq 0x3040
xorl %edi, %edi
movq %r12, %rsi
callq 0x33e0
movq %rax, %rbp
jmp 0x443e
pushq $0xa
popq %rdi
callq 0x3360
jmp 0x43ba
movq 0x9b2c(%rip), %rax      # 0xdfc0
movq (%rax), %rdi
callq 0x33d0
leaq 0x4c4f(%rip), %rdi      # 0x90f2
movl %eax, 0x2c(%rsp)
jmp 0x44c3
movq 0x9b10(%rip), %rax      # 0xdfc0
movq (%rax), %rdi
callq 0x33d0
leaq 0x4c1e(%rip), %rdi      # 0x90dd
movl %eax, 0x28(%rsp)
movl %eax, %esi
xorl %eax, %eax
callq 0x3040
jmp 0x43ba
leaq 0x4d99(%rip), %rdi      # 0x9271
callq 0x33c0
callq 0x3829
movq 0x80(%rsp), %rdx
movl 0x24(%rsp), %eax
testl %eax, %eax
movl $0x0, %ecx
cmovgl %eax, %ecx
movl %ecx, 0x38(%rsp)
leaq 0x240(%rsp), %r14
leaq 0x220(%rsp), %rbx
leaq 0x200(%rsp), %r15
cmpq 0x88(%rsp), %rdx
je 0x496f
leaq 0x180(%rsp), %r12
movq %r12, %rdi
leaq 0x4bdd(%rip), %rsi      # 0x9111
movq %rdx, 0x30(%rsp)
callq 0x4bd6
movq 0x9a8b(%rip), %rdi      # 0xdfd0
movq %r12, %rsi
callq 0x3210
movq %rax, %rdi
callq 0x3140
leaq 0x4d34(%rip), %rdi      # 0x9290
callq 0x33c0
movq 0x180(%rsp), %rdi
leaq 0x60(%rsp), %rsi
pushq $0x1
popq %rcx
movl %ecx, %edx
callq 0x84f0
testl %eax, %eax
jne 0x49ab
leaq 0x4d17(%rip), %rdi      # 0x929e
callq 0x33c0
movups 0x60(%rsp), %xmm0
movups 0x70(%rsp), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
leaq 0x160(%rsp), %r12
movq %r12, %rdi
xorl %esi, %esi
callq 0x616c
leaq 0x4cf8(%rip), %rdi      # 0x92b0
callq 0x33c0
leaq 0xc0(%rsp), %rdi
movq %r12, %rsi
callq 0x3675
movq 0x99fc(%rip), %rdi      # 0xdfd0
leaq 0x4b41(%rip), %rsi      # 0x911c
callq 0x3270
movq 0x60(%rsp), %rsi
movq %rax, %rdi
callq 0x3240
movq %rax, %rdi
leaq 0x4b30(%rip), %rsi      # 0x9127
callq 0x3270
movq 0x68(%rsp), %rsi
movq %rax, %rdi
callq 0x3240
movq %rax, %rdi
callq 0x3140
leaq 0x140(%rsp), %rdi
movq 0x30(%rsp), %rsi
callq 0x3340
movq 0x140(%rsp), %rdi
callq 0x34c0
movq %rax, %rdi
leaq 0x4a29(%rip), %rsi      # 0x9063
callq 0x33e0
leaq 0xa0(%rsp), %rdi
movq %rax, %rsi
movq %r14, %rdx
callq 0x4afa
movq 0x9977(%rip), %rdi      # 0xdfd0
leaq 0x4ad1(%rip), %rsi      # 0x9131
callq 0x3270
movq %rax, %rdi
leaq 0xa0(%rsp), %rsi
callq 0x3210
movq %rax, %rdi
callq 0x3140
movl 0x28(%rsp), %r13d
cmpl 0x2c(%rsp), %r13d
jg 0x4888
leaq 0x100(%rsp), %rdi
leaq 0xa0(%rsp), %rsi
leaq 0x4a96(%rip), %rdx      # 0x913a
callq 0x4cd2
leaq 0x1c0(%rsp), %r12
movq %r12, %rdi
movl %r13d, %esi
callq 0x4d0a
leaq 0x120(%rsp), %rbp
movq %rbp, %rdi
leaq 0x100(%rsp), %rsi
movq %r12, %rdx
callq 0x4c6b
leaq 0x40(%rsp), %rdi
movq %rbp, %rsi
leaq 0x4a54(%rip), %rdx      # 0x913a
callq 0x4c4c
leaq 0x1a0(%rsp), %r12
movq %r12, %rdi
movl 0x24(%rsp), %esi
callq 0x4d0a
movq %r14, %rdi
leaq 0x40(%rsp), %rsi
movq %r12, %rdx
callq 0x4c6b
leaq 0x1e0(%rsp), %rbp
movq %rbp, %rdi
movq %r14, %rsi
leaq 0x4a18(%rip), %rdx      # 0x913c
callq 0x4c4c
movq %r14, %rdi
callq 0x3120
leaq 0x1a0(%rsp), %rdi
callq 0x3120
leaq 0x40(%rsp), %r12
movq %r12, %rdi
callq 0x3120
leaq 0x120(%rsp), %rdi
callq 0x3120
leaq 0x1c0(%rsp), %rdi
callq 0x3120
leaq 0x100(%rsp), %rdi
callq 0x3120
movq %r12, %rdi
leaq 0x49c4(%rip), %rsi      # 0x9140
movq %rbp, %rdx
callq 0x4bd6
movq 0x9845(%rip), %rdi      # 0xdfd0
movq %r12, %rsi
callq 0x3210
movq %rax, %rdi
callq 0x3140
movq %r14, %rdi
callq 0x3470
movq %r14, %rdi
leaq 0x40(%rsp), %rsi
pushq $0x10
popq %rdx
callq 0x3130
leaq 0x2b0(%rsp), %rdi
callq 0x30b0
testb %al, %al
je 0x4990
movq 0x40(%rsp), %rsi
leaq 0x4980(%rip), %rdi      # 0x9154
xorl %eax, %eax
callq 0x3040
movq %r14, %rdi
leaq 0x4980(%rip), %rsi      # 0x9165
callq 0x3270
movq %rax, %rdi
callq 0x3140
movl 0x38(%rsp), %r12d
subl $0x1, %r12d
jb 0x4859
movq %rbx, %rdi
leaq 0xa0(%rsp), %rsi
callq 0x3340
movq %r15, %rdi
leaq 0x4c98(%rip), %rsi      # 0x94af
leaq 0x120(%rsp), %rdx
callq 0x4afa
leaq 0x160(%rsp), %rdi
leaq 0xc0(%rsp), %rsi
movq %r14, %rdx
movl %r13d, %r9d
callq 0x3d7e
movq %r15, %rdi
callq 0x3120
movq %rbx, %rdi
callq 0x3120
movq %r14, %rdi
callq 0x3140
jmp 0x47f7
movq %r14, %rdi
callq 0x3370
movq %r14, %rdi
callq 0x33a0
leaq 0x40(%rsp), %rdi
callq 0x3120
leaq 0x1e0(%rsp), %rdi
callq 0x3120
incl %r13d
jmp 0x4682
movups 0x60(%rsp), %xmm0
movups 0x70(%rsp), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
callq 0x5d09
movups 0x160(%rsp), %xmm0
movups 0x170(%rsp), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
callq 0x5e85
movups 0xc0(%rsp), %xmm0
movups 0xd0(%rsp), %xmm1
movups 0xe0(%rsp), %xmm2
movups 0xf0(%rsp), %xmm3
movaps %xmm3, 0x270(%rsp)
movaps %xmm2, 0x260(%rsp)
movaps %xmm1, 0x250(%rsp)
movaps %xmm0, 0x240(%rsp)
movups 0xc0(%rsp), %xmm0
movups 0xd0(%rsp), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
callq 0x5e85
leaq 0x2b0(%rsp), %rax
movups -0x50(%rax), %xmm0
movups -0x40(%rax), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
callq 0x5e85
leaq 0xa0(%rsp), %rdi
callq 0x3120
leaq 0x140(%rsp), %rdi
callq 0x3120
leaq 0x180(%rsp), %rdi
callq 0x3120
movq 0x30(%rsp), %rdx
addq $0x20, %rdx
jmp 0x4514
leaq 0x80(%rsp), %rdi
callq 0x4d64
xorl %eax, %eax
addq $0x448, %rsp            # imm = 0x448
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x9639(%rip), %rdi      # 0xdfd0
leaq 0x46ab(%rip), %rsi      # 0x9049
callq 0x3270
movq %rax, %rdi
callq 0x3140
pushq $0x1
popq %rdi
callq 0x32f0
callq 0x4327
jmp 0x49ab
jmp 0x49d8
movq %rax, %rbx
jmp 0x4aca
jmp 0x49ce
jmp 0x49ce
jmp 0x49d8
jmp 0x49ce
jmp 0x49ce
movq %rax, %rbx
jmp 0x4ad7
jmp 0x49fd
movq %rax, %rbx
jmp 0x4ae4
movq %rax, %rbx
leaq 0x240(%rsp), %rdi
jmp 0x4adf
jmp 0x4a96
movq %rax, %rbx
jmp 0x4ab0
movq %rax, %rbx
jmp 0x4abd
movq %rax, %rbx
jmp 0x4a61
movq %rax, %rbx
jmp 0x4a54
jmp 0x4a6b
movq %rax, %rbx
jmp 0x4a47
movq %rax, %rbx
jmp 0x4a3d
movq %rax, %rbx
jmp 0x4a30
movq %rax, %rbx
leaq 0x240(%rsp), %rdi
callq 0x3120
leaq 0x1a0(%rsp), %rdi
callq 0x3120
leaq 0x40(%rsp), %rdi
callq 0x3120
leaq 0x120(%rsp), %rdi
callq 0x3120
leaq 0x1c0(%rsp), %rdi
callq 0x3120
leaq 0x100(%rsp), %rdi
jmp 0x4ab8
movq %rax, %rbx
jmp 0x4aa6
jmp 0x4a96
movq %rax, %rbx
jmp 0x4a87
movq %rax, %rbx
leaq 0x200(%rsp), %rdi
callq 0x3120
leaq 0x220(%rsp), %rdi
callq 0x3120
jmp 0x4a99
movq %rax, %rbx
leaq 0x240(%rsp), %rdi
callq 0x33a0
leaq 0x40(%rsp), %rdi
callq 0x3120
leaq 0x1e0(%rsp), %rdi
callq 0x3120
leaq 0xa0(%rsp), %rdi
callq 0x3120
leaq 0x140(%rsp), %rdi
callq 0x3120
leaq 0x180(%rsp), %rdi
callq 0x3120
leaq 0x80(%rsp), %rdi
callq 0x4d64
movq %rbx, %rdi
callq 0x34a0
nop