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

    std::vector<std::string> graphs; // input files

    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);
                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 '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++)
        {
			string outfile(gname + "_" + to_string(i) + "_" + to_string(runs) + "_bf");
			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_brute_force(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, 0x24(%rsp)
cmpl $0x8, %edi
jle 0x4899
xorps %xmm0, %xmm0
leaq 0x80(%rsp), %r14
movaps %xmm0, (%r14)
andq $0x0, 0x10(%r14)
leaq 0x5023(%rip), %rdi      # 0x921d
callq 0x33b0
leaq 0x4ecb(%rip), %r15      # 0x90d1
leaq 0x240(%rsp), %r13
leaq 0xc0(%rsp), %r12
leaq 0x4eb2(%rip), %rbx      # 0x90cf
movl $0x0, 0x20(%rsp)
movl $0x0, 0x28(%rsp)
movl $0x0, 0x30(%rsp)
movl 0x24(%rsp), %edi
movq 0x38(%rsp), %rsi
leaq 0x4e73(%rip), %rdx      # 0x90b8
callq 0x30a0
shll $0x18, %eax
cmpl $0xff000000, %eax       # imm = 0xFF000000
je 0x43a3
sarl $0x18, %eax
cmpl $0x69, %eax
je 0x42b3
cmpl $0x4d, %eax
je 0x4325
cmpl $0x6d, %eax
je 0x4364
cmpl $0x72, %eax
jne 0x4235
movq 0x9d42(%rip), %rax      # 0xdfc0
movq (%rax), %rdi
callq 0x33c0
movl %eax, 0x20(%rsp)
movq 0x9d3f(%rip), %rdi      # 0xdfd0
leaq 0x4e5f(%rip), %rsi      # 0x90f7
callq 0x3260
movq %rax, %rdi
movl 0x20(%rsp), %esi
callq 0x3470
movq %rax, %rdi
callq 0x3140
jmp 0x4235
movq 0x9d06(%rip), %rax      # 0xdfc0
movq (%rax), %rdi
movq %r15, %rsi
callq 0x33d0
movq %rax, %rbp
leaq 0x4df2(%rip), %rdi      # 0x90c1
xorl %eax, %eax
callq 0x3040
testq %rbp, %rbp
je 0x4318
movq %r13, %rdi
movq %rbp, %rsi
movq %r12, %rdx
callq 0x49e6
movq %r14, %rdi
movq %r13, %rsi
callq 0x53ca
movq %r13, %rdi
callq 0x3120
movq %rbx, %rdi
movq %rbp, %rsi
xorl %eax, %eax
callq 0x3040
xorl %edi, %edi
movq %r15, %rsi
callq 0x33d0
movq %rax, %rbp
jmp 0x42d6
pushq $0xa
popq %rdi
callq 0x3350
jmp 0x4235
movq 0x9c94(%rip), %rax      # 0xdfc0
movq (%rax), %rdi
callq 0x33c0
movl %eax, 0x28(%rsp)
movq 0x9c91(%rip), %rdi      # 0xdfd0
leaq 0x4d9f(%rip), %rsi      # 0x90e5
callq 0x3260
movq %rax, %rdi
movl 0x28(%rsp), %esi
callq 0x3470
movq %rax, %rdi
callq 0x3140
jmp 0x4235
movq 0x9c55(%rip), %rax      # 0xdfc0
movq (%rax), %rdi
callq 0x33c0
movl %eax, 0x30(%rsp)
movq 0x9c52(%rip), %rdi      # 0xdfd0
leaq 0x4d4e(%rip), %rsi      # 0x90d3
callq 0x3260
movq %rax, %rdi
movl 0x30(%rsp), %esi
callq 0x3470
movq %rax, %rdi
callq 0x3140
jmp 0x4235
leaq 0x4e91(%rip), %rdi      # 0x923b
callq 0x33b0
callq 0x3809
movq 0x80(%rsp), %rdx
movl 0x20(%rsp), %eax
testl %eax, %eax
movl $0x0, %ecx
cmovgl %eax, %ecx
movl %ecx, 0x24(%rsp)
movslq 0x30(%rsp), %rax
movq %rax, 0x30(%rsp)
movslq 0x28(%rsp), %rax
movq %rax, 0x38(%rsp)
leaq 0x240(%rsp), %r15
leaq 0x220(%rsp), %rbp
leaq 0x200(%rsp), %r13
cmpq 0x88(%rsp), %rdx
je 0x4855
leaq 0x180(%rsp), %r14
movq %r14, %rdi
leaq 0x4ce4(%rip), %rsi      # 0x90fe
movq %rdx, 0x28(%rsp)
callq 0x4a21
movq 0x9ba5(%rip), %rdi      # 0xdfd0
movq %r14, %rsi
callq 0x3220
movq %rax, %rdi
callq 0x3140
leaq 0x4e18(%rip), %rdi      # 0x925a
callq 0x33b0
movq 0x180(%rsp), %rdi
leaq 0x60(%rsp), %rsi
pushq $0x1
popq %rcx
movl %ecx, %edx
callq 0x80f4
testl %eax, %eax
jne 0x4891
leaq 0x4dfb(%rip), %rdi      # 0x9268
callq 0x33b0
movups 0x60(%rsp), %xmm0
movups 0x70(%rsp), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
leaq 0x160(%rsp), %r14
movq %r14, %rdi
xorl %esi, %esi
callq 0x5b50
leaq 0x4ddc(%rip), %rdi      # 0x927a
callq 0x33b0
leaq 0xc0(%rsp), %rdi
movq %r14, %rsi
callq 0x3655
movq 0x9b16(%rip), %rdi      # 0xdfd0
leaq 0x4c48(%rip), %rsi      # 0x9109
callq 0x3260
movq 0x60(%rsp), %rsi
movq %rax, %rdi
callq 0x3240
movq %rax, %rdi
leaq 0x4c37(%rip), %rsi      # 0x9114
callq 0x3260
movq 0x68(%rsp), %rsi
movq %rax, %rdi
callq 0x3240
movq %rax, %rdi
callq 0x3140
leaq 0x140(%rsp), %rdi
movq 0x28(%rsp), %rsi
callq 0x3330
movq 0x140(%rsp), %rdi
callq 0x34a0
movq %rax, %rdi
leaq 0x4b43(%rip), %rsi      # 0x9063
callq 0x33d0
leaq 0xa0(%rsp), %rdi
movq %rax, %rsi
movq %r15, %rdx
callq 0x49e6
movq 0x9a91(%rip), %rdi      # 0xdfd0
leaq 0x4bd8(%rip), %rsi      # 0x911e
callq 0x3260
movq %rax, %rdi
leaq 0xa0(%rsp), %rsi
callq 0x3220
movq %rax, %rdi
callq 0x3140
movq 0x30(%rsp), %r12
cmpq 0x38(%rsp), %r12
jg 0x476e
leaq 0x100(%rsp), %rdi
leaq 0xa0(%rsp), %rsi
leaq 0x4b9d(%rip), %rdx      # 0x9127
callq 0x4b1d
leaq 0x1c0(%rsp), %r14
movq %r14, %rdi
movl %r12d, %esi
callq 0x4b55
leaq 0x120(%rsp), %rbx
movq %rbx, %rdi
leaq 0x100(%rsp), %rsi
movq %r14, %rdx
callq 0x4ab6
leaq 0x40(%rsp), %rdi
movq %rbx, %rsi
leaq 0x4b5b(%rip), %rdx      # 0x9127
callq 0x4a97
leaq 0x1a0(%rsp), %r14
movq %r14, %rdi
movl 0x20(%rsp), %esi
callq 0x4b55
movq %r15, %rdi
leaq 0x40(%rsp), %rsi
movq %r14, %rdx
callq 0x4ab6
leaq 0x1e0(%rsp), %rbx
movq %rbx, %rdi
movq %r15, %rsi
leaq 0x4b1f(%rip), %rdx      # 0x9129
callq 0x4a97
movq %r15, %rdi
callq 0x3120
leaq 0x1a0(%rsp), %rdi
callq 0x3120
leaq 0x40(%rsp), %r14
movq %r14, %rdi
callq 0x3120
leaq 0x120(%rsp), %rdi
callq 0x3120
leaq 0x1c0(%rsp), %rdi
callq 0x3120
leaq 0x100(%rsp), %rdi
callq 0x3120
movq %r14, %rdi
leaq 0x4acb(%rip), %rsi      # 0x912d
movq %rbx, %rdx
callq 0x4a21
movq 0x995f(%rip), %rdi      # 0xdfd0
movq %r14, %rsi
callq 0x3220
movq %rax, %rdi
callq 0x3140
movq %r15, %rdi
callq 0x3460
movq %r15, %rdi
leaq 0x40(%rsp), %rsi
pushq $0x10
popq %rdx
callq 0x3130
leaq 0x2b0(%rsp), %rdi
callq 0x30b0
testb %al, %al
je 0x4876
movq 0x40(%rsp), %rsi
leaq 0x4a87(%rip), %rdi      # 0x9141
xorl %eax, %eax
callq 0x3040
movq %r15, %rdi
leaq 0x4a87(%rip), %rsi      # 0x9152
callq 0x3260
movq %rax, %rdi
callq 0x3140
movl 0x24(%rsp), %r14d
subl $0x1, %r14d
jb 0x473f
movq %rbp, %rdi
leaq 0xa0(%rsp), %rsi
callq 0x3330
movq %r13, %rdi
leaq 0x4da2(%rip), %rsi      # 0x949f
leaq 0x120(%rsp), %rdx
callq 0x49e6
leaq 0x160(%rsp), %rdi
leaq 0xc0(%rsp), %rsi
movq %r15, %rdx
movq %r12, %r9
callq 0x3d5e
movq %r13, %rdi
callq 0x3120
movq %rbp, %rdi
callq 0x3120
movq %r15, %rdi
callq 0x3140
jmp 0x46dd
movq %r15, %rdi
callq 0x3360
movq %r15, %rdi
callq 0x3390
leaq 0x40(%rsp), %rdi
callq 0x3120
leaq 0x1e0(%rsp), %rdi
callq 0x3120
incq %r12
jmp 0x4568
movups 0x60(%rsp), %xmm0
movups 0x70(%rsp), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
callq 0x56ed
movups 0x160(%rsp), %xmm0
movups 0x170(%rsp), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
callq 0x5869
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 0x5869
leaq 0x2b0(%rsp), %rax
movups -0x50(%rax), %xmm0
movups -0x40(%rax), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
callq 0x5869
leaq 0xa0(%rsp), %rdi
callq 0x3120
leaq 0x140(%rsp), %rdi
callq 0x3120
leaq 0x180(%rsp), %rdi
callq 0x3120
movq 0x28(%rsp), %rdx
addq $0x20, %rdx
jmp 0x43fa
leaq 0x80(%rsp), %rdi
callq 0x4bae
xorl %eax, %eax
addq $0x448, %rsp            # imm = 0x448
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x9753(%rip), %rdi      # 0xdfd0
leaq 0x47c5(%rip), %rsi      # 0x9049
callq 0x3260
movq %rax, %rdi
callq 0x3140
pushq $0x1
popq %rdi
callq 0x32e0
callq 0x41b0
jmp 0x4891
jmp 0x48c4
jmp 0x48c4
jmp 0x48c4
jmp 0x48c4
movq %rax, %rbx
jmp 0x49b6
jmp 0x48ba
jmp 0x48ba
jmp 0x48c4
jmp 0x48ba
jmp 0x48ba
movq %rax, %rbx
jmp 0x49c3
jmp 0x48e9
movq %rax, %rbx
jmp 0x49d0
movq %rax, %rbx
leaq 0x240(%rsp), %rdi
jmp 0x49cb
jmp 0x4982
movq %rax, %rbx
jmp 0x499c
movq %rax, %rbx
jmp 0x49a9
movq %rax, %rbx
jmp 0x494d
movq %rax, %rbx
jmp 0x4940
jmp 0x4957
movq %rax, %rbx
jmp 0x4933
movq %rax, %rbx
jmp 0x4929
movq %rax, %rbx
jmp 0x491c
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 0x49a4
movq %rax, %rbx
jmp 0x4992
jmp 0x4982
movq %rax, %rbx
jmp 0x4973
movq %rax, %rbx
leaq 0x200(%rsp), %rdi
callq 0x3120
leaq 0x220(%rsp), %rdi
callq 0x3120
jmp 0x4985
movq %rax, %rbx
leaq 0x240(%rsp), %rdi
callq 0x3390
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 0x4bae
movq %rbx, %rdi
callq 0x3480
nop