// File: 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
movq %rsp, %rbp
subq $0x580, %rsp            # imm = 0x580
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpl $0xd, -0x8(%rbp)
jge 0x672e
callq 0x66e0
movl $0x1, %edi
callq 0x33e0
leaq -0x210(%rbp), %rdi
callq 0x3540
leaq -0x228(%rbp), %rdi
callq 0x7b80
xorl %eax, %eax
movl %eax, -0x484(%rbp)
movl %eax, %edi
callq 0x32c0
movl %eax, %edi
callq 0x32e0
movl -0x484(%rbp), %eax
movl $0x0, -0x22c(%rbp)
movl $0x0, -0x230(%rbp)
movl $0x0, -0x234(%rbp)
movl $0x0, -0x238(%rbp)
movl $0x0, -0x23c(%rbp)
movl $0x0, -0x240(%rbp)
movl $0x0, -0x244(%rbp)
movl $0x0, -0x248(%rbp)
movl $0x0, -0x24c(%rbp)
leaq 0x12b8d(%rip), %rdi     # 0x19350
callq 0x3050
jmp 0x67ca
jmp 0x67cc
movl -0x8(%rbp), %edi
movq -0x10(%rbp), %rsi
leaq 0x12b95(%rip), %rdx     # 0x1936f
callq 0x30c0
movb %al, -0x24d(%rbp)
movsbl %al, %eax
cmpl $-0x1, %eax
je 0x6b04
movsbl -0x24d(%rbp), %eax
addl $-0x4d, %eax
movl %eax, %ecx
movq %rcx, -0x490(%rbp)
subl $0x25, %eax
ja 0x6aff
movq -0x490(%rbp), %rax
leaq 0x1280d(%rip), %rcx     # 0x19028
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x258(%rbp)
movl %eax, -0x25c(%rbp)
jmp 0x70f7
movq 0x1d77e(%rip), %rax     # 0x23fc0
movq (%rax), %rdi
leaq 0x1299c(%rip), %rsi     # 0x191e8
callq 0x34a0
movq %rax, -0x268(%rbp)
leaq 0x12b1d(%rip), %rdi     # 0x1937c
xorl %eax, %eax
callq 0x3050
jmp 0x6868
jmp 0x686a
cmpq $0x0, -0x268(%rbp)
je 0x6958
movq -0x268(%rbp), %rax
movq %rax, -0x4a0(%rbp)
leaq -0x289(%rbp), %rdi
movq %rdi, -0x498(%rbp)
callq 0x3590
movq -0x4a0(%rbp), %rsi
movq -0x498(%rbp), %rdx
leaq -0x288(%rbp), %rdi
callq 0x7190
jmp 0x68b5
leaq -0x228(%rbp), %rdi
leaq -0x288(%rbp), %rsi
callq 0x7ba0
jmp 0x68ca
leaq -0x288(%rbp), %rdi
callq 0x31c0
leaq -0x289(%rbp), %rdi
callq 0x3370
movq -0x268(%rbp), %rsi
leaq 0x12a9a(%rip), %rdi     # 0x1938a
xorl %eax, %eax
callq 0x3050
jmp 0x68f9
xorl %eax, %eax
movl %eax, %edi
leaq 0x128e4(%rip), %rsi     # 0x191e8
callq 0x34a0
movq %rax, -0x268(%rbp)
jmp 0x686a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x258(%rbp)
movl %eax, -0x25c(%rbp)
jmp 0x6947
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x258(%rbp)
movl %eax, -0x25c(%rbp)
leaq -0x288(%rbp), %rdi
callq 0x31c0
leaq -0x289(%rbp), %rdi
callq 0x3370
jmp 0x70f7
leaq 0x12a85(%rip), %rdi     # 0x193e4
xorl %eax, %eax
callq 0x3050
jmp 0x6968
jmp 0x6aff
movq 0x1d64c(%rip), %rax     # 0x23fc0
movq (%rax), %rdi
callq 0x3490
movl %eax, -0x22c(%rbp)
movq 0x1d647(%rip), %rdi     # 0x23fd0
leaq 0x129fe(%rip), %rsi     # 0x1938e
callq 0x3300
movq %rax, -0x4a8(%rbp)
jmp 0x699e
movq -0x4a8(%rbp), %rdi
movl -0x22c(%rbp), %esi
callq 0x3560
movq %rax, -0x4b0(%rbp)
jmp 0x69b9
movq -0x4b0(%rbp), %rdi
movq 0x1d5f1(%rip), %rsi     # 0x23fb8
callq 0x3350
jmp 0x69ce
jmp 0x6aff
movq 0x1d5e6(%rip), %rax     # 0x23fc0
movq (%rax), %rdi
callq 0x3490
movl %eax, -0x230(%rbp)
movq 0x1d5e1(%rip), %rdi     # 0x23fd0
leaq 0x129aa(%rip), %rsi     # 0x193a0
callq 0x3300
movq %rax, -0x4b8(%rbp)
jmp 0x6a04
movq -0x4b8(%rbp), %rdi
movl -0x230(%rbp), %esi
callq 0x3560
movq %rax, -0x4c0(%rbp)
jmp 0x6a1f
movq -0x4c0(%rbp), %rdi
movq 0x1d58b(%rip), %rsi     # 0x23fb8
callq 0x3350
jmp 0x6a34
jmp 0x6aff
movq 0x1d580(%rip), %rax     # 0x23fc0
movq (%rax), %rdi
callq 0x3490
movl %eax, -0x248(%rbp)
movq 0x1d57b(%rip), %rdi     # 0x23fd0
leaq 0x12955(%rip), %rsi     # 0x193b1
callq 0x3300
movq %rax, -0x4c8(%rbp)
jmp 0x6a6a
movq -0x4c8(%rbp), %rdi
movl -0x248(%rbp), %esi
callq 0x3560
movq %rax, -0x4d0(%rbp)
jmp 0x6a85
movq -0x4d0(%rbp), %rdi
movq 0x1d525(%rip), %rsi     # 0x23fb8
callq 0x3350
jmp 0x6a9a
jmp 0x6aff
movq 0x1d51d(%rip), %rax     # 0x23fc0
movq (%rax), %rdi
callq 0x3490
movl %eax, -0x234(%rbp)
movq 0x1d518(%rip), %rdi     # 0x23fd0
leaq 0x12900(%rip), %rsi     # 0x193bf
callq 0x3300
movq %rax, -0x4d8(%rbp)
jmp 0x6acd
movq -0x4d8(%rbp), %rdi
movl -0x234(%rbp), %esi
callq 0x3560
movq %rax, -0x4e0(%rbp)
jmp 0x6ae8
movq -0x4e0(%rbp), %rdi
movq 0x1d4c2(%rip), %rsi     # 0x23fb8
callq 0x3350
jmp 0x6afd
jmp 0x6aff
jmp 0x67cc
leaq 0x128bb(%rip), %rdi     # 0x193c6
xorl %eax, %eax
callq 0x3050
jmp 0x6b14
callq 0x3bd0
jmp 0x6b1b
leaq -0x228(%rbp), %rdi
callq 0x7bd0
movq %rax, -0x298(%rbp)
leaq -0x228(%rbp), %rdi
callq 0x7c40
movq %rax, -0x2a0(%rbp)
leaq -0x298(%rbp), %rdi
leaq -0x2a0(%rbp), %rsi
callq 0x7c00
testb $0x1, %al
jne 0x6b5d
jmp 0x70c5
leaq -0x298(%rbp), %rdi
callq 0x7c70
movq %rax, %rdx
leaq 0x12873(%rip), %rsi     # 0x193e6
leaq -0x2c0(%rbp), %rdi
callq 0x77d0
jmp 0x6b81
movq 0x1d448(%rip), %rdi     # 0x23fd0
leaq -0x2c0(%rbp), %rsi
callq 0x32b0
movq %rax, -0x4e8(%rbp)
jmp 0x6b9d
movq -0x4e8(%rbp), %rdi
movq 0x1d40d(%rip), %rsi     # 0x23fb8
callq 0x3350
jmp 0x6bb2
leaq 0x12838(%rip), %rdi     # 0x193f1
xorl %eax, %eax
callq 0x3050
jmp 0x6bc2
leaq -0x2c0(%rbp), %rdi
callq 0x3130
movq %rax, %rdi
leaq -0x2e0(%rbp), %rsi
movl $0x1, %ecx
movl %ecx, %edx
callq 0x17a60
movl %eax, -0x4ec(%rbp)
jmp 0x6bec
movl -0x4ec(%rbp), %eax
cmpl $0x0, %eax
je 0x6c18
movl $0x1, %edi
callq 0x33e0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x258(%rbp)
movl %eax, -0x25c(%rbp)
jmp 0x70b7
leaq 0x127e1(%rip), %rdi     # 0x19400
xorl %eax, %eax
callq 0x3050
jmp 0x6c28
movups -0x2e0(%rbp), %xmm0
movups -0x2d0(%rbp), %xmm1
movaps %xmm1, -0x310(%rbp)
movaps %xmm0, -0x320(%rbp)
movaps -0x320(%rbp), %xmm0
movaps -0x310(%rbp), %xmm1
movq %rsp, %rax
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
leaq -0x300(%rbp), %rdi
xorl %esi, %esi
callq 0xe130
jmp 0x6c6c
leaq 0x127a0(%rip), %rdi     # 0x19413
xorl %eax, %eax
callq 0x3050
jmp 0x6c7c
leaq -0x360(%rbp), %rdi
leaq -0x300(%rbp), %rsi
callq 0x3830
jmp 0x6c91
movq 0x1d338(%rip), %rdi     # 0x23fd0
leaq 0x12782(%rip), %rsi     # 0x19421
callq 0x3300
movq %rax, -0x4f8(%rbp)
jmp 0x6cad
movq -0x4f8(%rbp), %rdi
movq -0x2e0(%rbp), %rsi
callq 0x35c0
movq %rax, -0x500(%rbp)
jmp 0x6cc9
movq -0x500(%rbp), %rdi
leaq 0x12755(%rip), %rsi     # 0x1942c
callq 0x3300
movq %rax, -0x508(%rbp)
jmp 0x6ce5
movq -0x508(%rbp), %rdi
movq -0x2d8(%rbp), %rsi
callq 0x35c0
movq %rax, -0x510(%rbp)
jmp 0x6d01
movq -0x510(%rbp), %rdi
movq 0x1d2a9(%rip), %rsi     # 0x23fb8
callq 0x3350
jmp 0x6d16
leaq -0x298(%rbp), %rdi
callq 0x7c70
movq %rax, %rsi
leaq -0x380(%rbp), %rdi
callq 0x3140
jmp 0x6d33
leaq -0x380(%rbp), %rdi
callq 0x3130
movq %rax, %rdi
callq 0x35d0
movq %rax, %rdi
leaq 0x123f2(%rip), %rsi     # 0x19143
callq 0x34a0
movq %rax, -0x388(%rbp)
movq -0x388(%rbp), %rax
movq %rax, -0x520(%rbp)
leaq -0x3a9(%rbp), %rdi
movq %rdi, -0x518(%rbp)
callq 0x3590
movq -0x520(%rbp), %rsi
movq -0x518(%rbp), %rdx
leaq -0x3a8(%rbp), %rdi
callq 0x7190
jmp 0x6d9a
leaq -0x3a9(%rbp), %rdi
callq 0x3370
movq 0x1d223(%rip), %rdi     # 0x23fd0
leaq 0x12682(%rip), %rsi     # 0x19436
callq 0x3300
movq %rax, -0x528(%rbp)
jmp 0x6dc2
movq -0x528(%rbp), %rdi
leaq -0x3a8(%rbp), %rsi
callq 0x32b0
movq %rax, -0x530(%rbp)
jmp 0x6dde
movq -0x530(%rbp), %rdi
movq 0x1d1cc(%rip), %rsi     # 0x23fb8
callq 0x3350
jmp 0x6df3
movl -0x22c(%rbp), %eax
movl %eax, -0x238(%rbp)
movl -0x238(%rbp), %eax
cmpl -0x230(%rbp), %eax
jg 0x6f72
leaq -0x3d0(%rbp), %rdi
leaq -0x3a8(%rbp), %rsi
callq 0x3140
jmp 0x6e26
leaq -0x3f1(%rbp), %rdi
movq %rdi, -0x538(%rbp)
callq 0x3590
movq -0x538(%rbp), %rdx
leaq 0x1259e(%rip), %rsi     # 0x193e5
leaq -0x3f0(%rbp), %rdi
callq 0x7190
jmp 0x6e55
movl -0x234(%rbp), %r9d
movl -0x248(%rbp), %ecx
movl -0x238(%rbp), %edx
movq %rsp, %rax
movl %edx, 0x8(%rax)
movl %ecx, (%rax)
leaq -0x300(%rbp), %rdi
leaq -0x360(%rbp), %rsi
leaq -0x210(%rbp), %rdx
leaq -0x3d0(%rbp), %rcx
leaq -0x3f0(%rbp), %r8
callq 0x48a0
jmp 0x6e9a
leaq -0x3f0(%rbp), %rdi
callq 0x31c0
leaq -0x3f1(%rbp), %rdi
callq 0x3370
leaq -0x3d0(%rbp), %rdi
callq 0x31c0
movq 0x1d0f3(%rip), %rsi     # 0x23fb8
leaq -0x210(%rbp), %rdi
callq 0x3350
jmp 0x6ed3
jmp 0x6ed5
movl -0x238(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x238(%rbp)
jmp 0x6dff
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x258(%rbp)
movl %eax, -0x25c(%rbp)
leaq -0x3a9(%rbp), %rdi
callq 0x3370
jmp 0x70ab
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x258(%rbp)
movl %eax, -0x25c(%rbp)
jmp 0x709f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x258(%rbp)
movl %eax, -0x25c(%rbp)
jmp 0x6f55
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x258(%rbp)
movl %eax, -0x25c(%rbp)
leaq -0x3f0(%rbp), %rdi
callq 0x31c0
leaq -0x3f1(%rbp), %rdi
callq 0x3370
leaq -0x3d0(%rbp), %rdi
callq 0x31c0
jmp 0x709f
movq 0x1d03f(%rip), %rsi     # 0x23fb8
leaq -0x210(%rbp), %rdi
callq 0x3350
jmp 0x6f87
movups -0x2e0(%rbp), %xmm0
movups -0x2d0(%rbp), %xmm1
movaps %xmm1, -0x410(%rbp)
movaps %xmm0, -0x420(%rbp)
movaps -0x420(%rbp), %xmm0
movaps -0x410(%rbp), %xmm1
movq %rsp, %rax
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
callq 0xd7d0
jmp 0x6fc2
movups -0x300(%rbp), %xmm0
movups -0x2f0(%rbp), %xmm1
movaps %xmm1, -0x430(%rbp)
movaps %xmm0, -0x440(%rbp)
movaps -0x440(%rbp), %xmm0
movaps -0x430(%rbp), %xmm1
movq %rsp, %rax
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
callq 0xda30
jmp 0x6ffd
movups -0x360(%rbp), %xmm0
movups -0x350(%rbp), %xmm1
movups -0x340(%rbp), %xmm2
movups -0x330(%rbp), %xmm3
movaps %xmm3, -0x450(%rbp)
movaps %xmm2, -0x460(%rbp)
movaps %xmm1, -0x470(%rbp)
movaps %xmm0, -0x480(%rbp)
movaps -0x480(%rbp), %xmm0
movaps -0x470(%rbp), %xmm1
movaps -0x460(%rbp), %xmm2
movaps -0x450(%rbp), %xmm3
movq %rsp, %rax
movups %xmm3, 0x30(%rax)
movups %xmm2, 0x20(%rax)
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
callq 0x3780
jmp 0x706a
leaq -0x3a8(%rbp), %rdi
callq 0x31c0
leaq -0x380(%rbp), %rdi
callq 0x31c0
leaq -0x2c0(%rbp), %rdi
callq 0x31c0
leaq -0x298(%rbp), %rdi
callq 0x7c90
jmp 0x6b2e
leaq -0x3a8(%rbp), %rdi
callq 0x31c0
leaq -0x380(%rbp), %rdi
callq 0x31c0
leaq -0x2c0(%rbp), %rdi
callq 0x31c0
jmp 0x70f7
leaq -0x210(%rbp), %rdi
callq 0x3440
jmp 0x70d3
leaq -0x228(%rbp), %rdi
callq 0x7cb0
leaq -0x210(%rbp), %rdi
callq 0x3470
movl -0x4(%rbp), %eax
addq $0x580, %rsp            # imm = 0x580
popq %rbp
retq
leaq -0x228(%rbp), %rdi
callq 0x7cb0
leaq -0x210(%rbp), %rdi
callq 0x3470
movq -0x258(%rbp), %rdi
callq 0x3580
nopl (%rax,%rax)