// File: 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
movq %rsp, %rbp
subq $0x660, %rsp            # imm = 0x660
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpl $0x9, -0x8(%rbp)
jge 0x508e
callq 0x5040
movl $0x1, %edi
callq 0x33c0
leaq -0x28(%rbp), %rdi
callq 0x60f0
xorl %eax, %eax
movl %eax, -0x584(%rbp)
movl %eax, %edi
callq 0x32b0
movl %eax, %edi
callq 0x32d0
movl -0x584(%rbp), %eax
movl $0x0, -0x2c(%rbp)
movl $0x0, -0x30(%rbp)
movl $0x0, -0x34(%rbp)
movl $0x0, -0x38(%rbp)
movl $0x0, -0x3c(%rbp)
movl $0x0, -0x40(%rbp)
movl $0x0, -0x44(%rbp)
movl $0x0, -0x48(%rbp)
movl $0x0, -0x4c(%rbp)
leaq 0xf0d6(%rip), %rdi      # 0x141cf
callq 0x3050
jmp 0x5100
jmp 0x5102
movl -0x8(%rbp), %edi
movq -0x10(%rbp), %rsi
leaq 0xf0de(%rip), %rdx      # 0x141ee
callq 0x30c0
movb %al, -0x4d(%rbp)
movsbl %al, %eax
cmpl $-0x1, %eax
je 0x52f0
movsbl -0x4d(%rbp), %eax
addl $-0x4d, %eax
movl %eax, %ecx
movq %rcx, -0x590(%rbp)
subl $0x25, %eax
ja 0x52eb
movq -0x590(%rbp), %rax
leaq 0xeec5(%rip), %rcx      # 0x14010
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x5bd8
movq 0x17e54(%rip), %rax     # 0x1cfc0
movq (%rax), %rdi
leaq 0xf091(%rip), %rsi      # 0x14207
callq 0x3480
movq %rax, -0x68(%rbp)
leaq 0xf071(%rip), %rdi      # 0x141f7
xorl %eax, %eax
callq 0x3050
jmp 0x518f
jmp 0x5191
cmpq $0x0, -0x68(%rbp)
je 0x5264
movq -0x68(%rbp), %rax
movq %rax, -0x5a0(%rbp)
leaq -0x89(%rbp), %rdi
movq %rdi, -0x598(%rbp)
callq 0x3570
movq -0x5a0(%rbp), %rsi
movq -0x598(%rbp), %rdx
leaq -0x88(%rbp), %rdi
callq 0x5c60
jmp 0x51d6
leaq -0x28(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x6110
jmp 0x51e8
leaq -0x88(%rbp), %rdi
callq 0x31c0
leaq -0x89(%rbp), %rdi
callq 0x3360
movq -0x68(%rbp), %rsi
leaq 0xeffa(%rip), %rdi      # 0x14205
xorl %eax, %eax
callq 0x3050
jmp 0x5214
xorl %eax, %eax
movl %eax, %edi
leaq 0xefe8(%rip), %rsi      # 0x14207
callq 0x3480
movq %rax, -0x68(%rbp)
jmp 0x5191
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x5253
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x88(%rbp), %rdi
callq 0x31c0
leaq -0x89(%rbp), %rdi
callq 0x3360
jmp 0x5bd8
leaq 0xeff0(%rip), %rdi      # 0x1425b
xorl %eax, %eax
callq 0x3050
jmp 0x5274
jmp 0x52eb
movq 0x17d43(%rip), %rax     # 0x1cfc0
movq (%rax), %rdi
callq 0x3470
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %esi
leaq 0xef77(%rip), %rdi      # 0x14209
xorl %eax, %eax
callq 0x3050
jmp 0x529b
jmp 0x52eb
movq 0x17d1c(%rip), %rax     # 0x1cfc0
movq (%rax), %rdi
callq 0x3470
movl %eax, -0x30(%rbp)
movl -0x30(%rbp), %esi
leaq 0xef65(%rip), %rdi      # 0x1421e
xorl %eax, %eax
callq 0x3050
jmp 0x52c2
jmp 0x52eb
movq 0x17cf5(%rip), %rax     # 0x1cfc0
movq (%rax), %rdi
callq 0x3470
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %esi
leaq 0xef53(%rip), %rdi      # 0x14233
xorl %eax, %eax
callq 0x3050
jmp 0x52e9
jmp 0x52eb
jmp 0x5102
leaq 0xef46(%rip), %rdi      # 0x1423d
xorl %eax, %eax
callq 0x3050
jmp 0x5300
callq 0x3ba0
jmp 0x5307
leaq -0x28(%rbp), %rdi
callq 0x6140
movq %rax, -0x98(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x61b0
movq %rax, -0xa0(%rbp)
leaq -0x98(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x6170
testb $0x1, %al
jne 0x5343
jmp 0x5bc3
leaq -0x98(%rbp), %rdi
callq 0x62f0
movq %rax, %rdx
leaq 0xef04(%rip), %rsi      # 0x1425d
leaq -0xc0(%rbp), %rdi
callq 0x61e0
jmp 0x5367
movq 0x17c62(%rip), %rdi     # 0x1cfd0
leaq -0xc0(%rbp), %rsi
callq 0x32a0
movq %rax, -0x5a8(%rbp)
jmp 0x5383
movq -0x5a8(%rbp), %rdi
movq 0x17c27(%rip), %rsi     # 0x1cfb8
callq 0x3340
jmp 0x5398
leaq 0xeec9(%rip), %rdi      # 0x14268
xorl %eax, %eax
callq 0x3050
jmp 0x53a8
leaq -0xc0(%rbp), %rdi
callq 0x3130
movq %rax, %rdi
leaq -0xe0(%rbp), %rsi
movl $0x1, %ecx
movl %ecx, %edx
callq 0x131e0
movl %eax, -0x5ac(%rbp)
jmp 0x53d2
movl -0x5ac(%rbp), %eax
cmpl $0x0, %eax
je 0x53f8
movl $0x1, %edi
callq 0x33c0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x5bb5
leaq 0xee78(%rip), %rdi      # 0x14277
xorl %eax, %eax
callq 0x3050
jmp 0x5408
movups -0xe0(%rbp), %xmm0
movups -0xd0(%rbp), %xmm1
movaps %xmm1, -0x110(%rbp)
movaps %xmm0, -0x120(%rbp)
movaps -0x120(%rbp), %xmm0
movaps -0x110(%rbp), %xmm1
movq %rsp, %rax
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
leaq -0x100(%rbp), %rdi
xorl %esi, %esi
callq 0xa520
jmp 0x544c
leaq 0xee37(%rip), %rdi      # 0x1428a
xorl %eax, %eax
callq 0x3050
jmp 0x545c
leaq -0x160(%rbp), %rdi
leaq -0x100(%rbp), %rsi
callq 0x3800
jmp 0x5471
movq 0x17b58(%rip), %rdi     # 0x1cfd0
leaq 0xee19(%rip), %rsi      # 0x14298
callq 0x32f0
movq %rax, -0x5b8(%rbp)
jmp 0x548d
movq -0x5b8(%rbp), %rdi
movq -0xe0(%rbp), %rsi
callq 0x3590
movq %rax, -0x5c0(%rbp)
jmp 0x54a9
movq -0x5c0(%rbp), %rdi
leaq 0xedec(%rip), %rsi      # 0x142a3
callq 0x32f0
movq %rax, -0x5c8(%rbp)
jmp 0x54c5
movq -0x5c8(%rbp), %rdi
movq -0xd8(%rbp), %rsi
callq 0x3590
movq %rax, -0x5d0(%rbp)
jmp 0x54e1
movq -0x5d0(%rbp), %rdi
movq 0x17ac9(%rip), %rsi     # 0x1cfb8
callq 0x3340
jmp 0x54f6
leaq -0x98(%rbp), %rdi
callq 0x62f0
movq %rax, %rsi
leaq -0x180(%rbp), %rdi
callq 0x3140
jmp 0x5513
leaq -0x180(%rbp), %rdi
callq 0x3130
movq %rax, %rdi
callq 0x35a0
movq %rax, %rdi
leaq 0xebca(%rip), %rsi      # 0x140fb
callq 0x3480
movq %rax, -0x188(%rbp)
movq -0x188(%rbp), %rax
movq %rax, -0x5e0(%rbp)
leaq -0x1a9(%rbp), %rdi
movq %rdi, -0x5d8(%rbp)
callq 0x3570
movq -0x5e0(%rbp), %rsi
movq -0x5d8(%rbp), %rdx
leaq -0x1a8(%rbp), %rdi
callq 0x5c60
jmp 0x557a
leaq -0x1a9(%rbp), %rdi
callq 0x3360
movq 0x17a43(%rip), %rdi     # 0x1cfd0
leaq 0xed19(%rip), %rsi      # 0x142ad
callq 0x32f0
movq %rax, -0x5e8(%rbp)
jmp 0x55a2
movq -0x5e8(%rbp), %rdi
leaq -0x1a8(%rbp), %rsi
callq 0x32a0
movq %rax, -0x5f0(%rbp)
jmp 0x55be
movq -0x5f0(%rbp), %rdi
movq 0x179ec(%rip), %rsi     # 0x1cfb8
callq 0x3340
jmp 0x55d3
movl -0x2c(%rbp), %eax
movl %eax, -0x38(%rbp)
movl -0x38(%rbp), %eax
cmpl -0x30(%rbp), %eax
jg 0x5a85
leaq 0xecca(%rip), %rdx      # 0x142b6
leaq -0x250(%rbp), %rdi
leaq -0x1a8(%rbp), %rsi
callq 0x6430
jmp 0x5601
movl -0x38(%rbp), %esi
leaq -0x270(%rbp), %rdi
callq 0x64b0
jmp 0x5612
leaq -0x230(%rbp), %rdi
leaq -0x250(%rbp), %rsi
leaq -0x270(%rbp), %rdx
callq 0x6360
jmp 0x562e
leaq 0xec81(%rip), %rdx      # 0x142b6
leaq -0x210(%rbp), %rdi
leaq -0x230(%rbp), %rsi
callq 0x6310
jmp 0x564a
movl -0x34(%rbp), %esi
leaq -0x290(%rbp), %rdi
callq 0x64b0
jmp 0x565b
leaq -0x1f0(%rbp), %rdi
leaq -0x210(%rbp), %rsi
leaq -0x290(%rbp), %rdx
callq 0x6360
jmp 0x5677
leaq 0xec3a(%rip), %rdx      # 0x142b8
leaq -0x1d0(%rbp), %rdi
leaq -0x1f0(%rbp), %rsi
callq 0x6310
jmp 0x5693
leaq -0x1f0(%rbp), %rdi
callq 0x31c0
leaq -0x290(%rbp), %rdi
callq 0x31c0
leaq -0x210(%rbp), %rdi
callq 0x31c0
leaq -0x230(%rbp), %rdi
callq 0x31c0
leaq -0x270(%rbp), %rdi
callq 0x31c0
leaq -0x250(%rbp), %rdi
callq 0x31c0
leaq 0xebda(%rip), %rsi      # 0x142bc
leaq -0x2b0(%rbp), %rdi
leaq -0x1d0(%rbp), %rdx
callq 0x61e0
jmp 0x56f7
movq 0x178d2(%rip), %rdi     # 0x1cfd0
leaq -0x2b0(%rbp), %rsi
callq 0x32a0
movq %rax, -0x5f8(%rbp)
jmp 0x5713
movq -0x5f8(%rbp), %rdi
movq 0x17897(%rip), %rsi     # 0x1cfb8
callq 0x3340
jmp 0x5728
leaq -0x4b0(%rbp), %rdi
callq 0x3520
jmp 0x5736
leaq -0x4b0(%rbp), %rdi
leaq -0x2b0(%rbp), %rsi
movl $0x10, %edx
callq 0x3160
jmp 0x5750
leaq -0x4b0(%rbp), %rdi
callq 0x3230
movb %al, -0x5f9(%rbp)
jmp 0x5764
movb -0x5f9(%rbp), %al
testb $0x1, %al
jne 0x58b2
jmp 0x5774
movq 0x17855(%rip), %rdi     # 0x1cfd0
leaq 0xe95f(%rip), %rsi      # 0x140e1
callq 0x32f0
movq %rax, -0x608(%rbp)
jmp 0x5790
movq -0x608(%rbp), %rdi
movq 0x1781a(%rip), %rsi     # 0x1cfb8
callq 0x3340
jmp 0x57a5
movl $0x1, %edi
callq 0x33c0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x1a9(%rbp), %rdi
callq 0x3360
jmp 0x5ba9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x5b9d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x586e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x5862
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x5856
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x584a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x583e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x1f0(%rbp), %rdi
callq 0x31c0
leaq -0x290(%rbp), %rdi
callq 0x31c0
leaq -0x210(%rbp), %rdi
callq 0x31c0
leaq -0x230(%rbp), %rdi
callq 0x31c0
leaq -0x270(%rbp), %rdi
callq 0x31c0
leaq -0x250(%rbp), %rdi
callq 0x31c0
jmp 0x5b9d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x5a74
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x5a68
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x5a5c
leaq -0x2b0(%rbp), %rdi
callq 0x3130
movq %rax, %rsi
leaq 0xea08(%rip), %rdi      # 0x142d0
xorl %eax, %eax
callq 0x3050
jmp 0x58d1
leaq 0xea09(%rip), %rsi      # 0x142e1
leaq -0x4b0(%rbp), %rdi
callq 0x32f0
movq %rax, -0x610(%rbp)
jmp 0x58ed
movq -0x610(%rbp), %rdi
movq 0x176bd(%rip), %rsi     # 0x1cfb8
callq 0x3340
jmp 0x5902
movl $0x0, -0x4b4(%rbp)
movl -0x4b4(%rbp), %eax
cmpl -0x34(%rbp), %eax
jge 0x5a1c
leaq -0x4d8(%rbp), %rdi
leaq -0x1a8(%rbp), %rsi
callq 0x3140
jmp 0x5930
leaq -0x4f9(%rbp), %rdi
movq %rdi, -0x618(%rbp)
callq 0x3570
movq -0x618(%rbp), %rdx
leaq 0xe90b(%rip), %rsi      # 0x1425c
leaq -0x4f8(%rbp), %rdi
callq 0x5c60
jmp 0x595f
movl -0x38(%rbp), %r9d
leaq -0x100(%rbp), %rdi
leaq -0x160(%rbp), %rsi
leaq -0x4b0(%rbp), %rdx
leaq -0x4d8(%rbp), %rcx
leaq -0x4f8(%rbp), %r8
callq 0x45a0
jmp 0x598d
leaq -0x4f8(%rbp), %rdi
callq 0x31c0
leaq -0x4f9(%rbp), %rdi
callq 0x3360
leaq -0x4d8(%rbp), %rdi
callq 0x31c0
movq 0x17600(%rip), %rsi     # 0x1cfb8
leaq -0x4b0(%rbp), %rdi
callq 0x3340
jmp 0x59c6
jmp 0x59c8
movl -0x4b4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4b4(%rbp)
jmp 0x590c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x5a02
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x4f8(%rbp), %rdi
callq 0x31c0
leaq -0x4f9(%rbp), %rdi
callq 0x3360
leaq -0x4d8(%rbp), %rdi
callq 0x31c0
jmp 0x5a5c
leaq -0x4b0(%rbp), %rdi
callq 0x3420
jmp 0x5a2a
leaq -0x4b0(%rbp), %rdi
callq 0x3450
leaq -0x2b0(%rbp), %rdi
callq 0x31c0
leaq -0x1d0(%rbp), %rdi
callq 0x31c0
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x55d9
leaq -0x4b0(%rbp), %rdi
callq 0x3450
leaq -0x2b0(%rbp), %rdi
callq 0x31c0
leaq -0x1d0(%rbp), %rdi
callq 0x31c0
jmp 0x5b9d
movups -0xe0(%rbp), %xmm0
movups -0xd0(%rbp), %xmm1
movaps %xmm1, -0x510(%rbp)
movaps %xmm0, -0x520(%rbp)
movaps -0x520(%rbp), %xmm0
movaps -0x510(%rbp), %xmm1
movq %rsp, %rax
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
callq 0x9bc0
jmp 0x5ac0
movups -0x100(%rbp), %xmm0
movups -0xf0(%rbp), %xmm1
movaps %xmm1, -0x530(%rbp)
movaps %xmm0, -0x540(%rbp)
movaps -0x540(%rbp), %xmm0
movaps -0x530(%rbp), %xmm1
movq %rsp, %rax
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
callq 0x9e20
jmp 0x5afb
movups -0x160(%rbp), %xmm0
movups -0x150(%rbp), %xmm1
movups -0x140(%rbp), %xmm2
movups -0x130(%rbp), %xmm3
movaps %xmm3, -0x550(%rbp)
movaps %xmm2, -0x560(%rbp)
movaps %xmm1, -0x570(%rbp)
movaps %xmm0, -0x580(%rbp)
movaps -0x580(%rbp), %xmm0
movaps -0x570(%rbp), %xmm1
movaps -0x560(%rbp), %xmm2
movaps -0x550(%rbp), %xmm3
movq %rsp, %rax
movups %xmm3, 0x30(%rax)
movups %xmm2, 0x20(%rax)
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
callq 0x3750
jmp 0x5b68
leaq -0x1a8(%rbp), %rdi
callq 0x31c0
leaq -0x180(%rbp), %rdi
callq 0x31c0
leaq -0xc0(%rbp), %rdi
callq 0x31c0
leaq -0x98(%rbp), %rdi
callq 0x65d0
jmp 0x5317
leaq -0x1a8(%rbp), %rdi
callq 0x31c0
leaq -0x180(%rbp), %rdi
callq 0x31c0
leaq -0xc0(%rbp), %rdi
callq 0x31c0
jmp 0x5bd8
leaq -0x28(%rbp), %rdi
callq 0x65f0
movl -0x4(%rbp), %eax
addq $0x660, %rsp            # imm = 0x660
popq %rbp
retq
leaq -0x28(%rbp), %rdi
callq 0x65f0
movq -0x58(%rbp), %rdi
callq 0x3560
nopw (%rax,%rax)