// File: /workspace/github_cpp_makefile_star2_O2/sjain12[P]CliqueCounting/tests/../Escape/CliquesGraft.h
// Function: cliques_edge_sampling_2(Escape::Graph&, Escape::CGraph&, CDAG&, std::basic_ofstream<char, std::char_traits<char>>&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, unsigned long long, int)
void cliques_edge_sampling_2(Graph &g, CGraph &CG, CDAG &DG, ofstream &of, string gname, string fname, unsigned long long clique_size, int num_samples)
{    
    high_resolution_clock::time_point t_elim_s = high_resolution_clock::now();
    Stack* stack = newStack();
    VertexSet *path = NULL, *nbrs = NULL;
 
    double num_cliques = 0, est = 0;

    std::random_device rd{}; // use to seed the rng 
    std::mt19937 rng{rd()}; // rng

    std::uniform_int_distribution<int> distribution(0,floor((CG.nEdges-1)/2));

	cout << "Starting sampling" << endl;
    for (int i=0; i<num_samples; i++)
    {
        EdgeIdx edge = distribution(rng);
        num_cliques += get_edge_cliques(g, CG, DG, 2*edge, clique_size - 2);
    }
    est = num_cliques * CG.nEdges/ (2 * num_samples * nCr[clique_size][2]);

	high_resolution_clock::time_point t_elim_e = high_resolution_clock::now();
    auto duration_program = std::chrono::duration_cast<std::chrono::microseconds>( t_elim_e - t_elim_s ).count();
    
    cout << "time reqd: " << duration_program << endl;
	cout << "number of cliques = " << num_cliques << endl;
    cout << "est = " << est << endl;
    
    of << clique_size << "," << est << "," << duration_program << "," << endl;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2748, %rsp           # imm = 0x2748
movq %rcx, %r14
movq %rdx, 0x10(%rsp)
movq %rsi, %r12
movq %rdi, %rbp
callq 0x3050
movq %rax, 0x30(%rsp)
callq 0x3c67
leaq 0x38(%rsp), %rbx
movq %rbx, %rdi
callq 0x4d5e
movq %rbx, %rdi
callq 0x3360
movl %eax, %esi
leaq 0x13c0(%rsp), %rdi
callq 0x571c
movq %r14, 0x28(%rsp)
movq 0x8(%r12), %rax
decq %rax
pushq $0x2
popq %rcx
cqto
idivq %rcx
andl $0x0, 0x18(%rsp)
movl %eax, 0x1c(%rsp)
movq 0x9e49(%rip), %rdi      # 0xdfd0
leaq 0x4f22(%rip), %rsi      # 0x90b0
callq 0x3280
movq %rax, %rdi
callq 0x3140
movl 0x2788(%rsp), %ecx
movq 0x2780(%rsp), %rax
xorl %r13d, %r13d
testl %ecx, %ecx
cmovgl %ecx, %r13d
leaq -0x2(%rax), %rbx
xorpd %xmm0, %xmm0
movsd %xmm0, 0x8(%rsp)
leaq 0x18(%rsp), %r14
leaq 0x13c0(%rsp), %r15
subl $0x1, %r13d
jb 0x420a
movq %r14, %rdi
movq %r15, %rsi
callq 0x4db4
movslq %eax, %rcx
addq %rcx, %rcx
movq %rbp, %rdi
movq %r12, %rsi
movq 0x10(%rsp), %rdx
movq %rbx, %r8
callq 0x3d7e
movsd 0x8(%rsp), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, 0x8(%rsp)
jmp 0x41ce
cvtsi2sdq 0x8(%r12), %xmm0
movsd %xmm0, 0x10(%rsp)
movl 0x2788(%rsp), %eax
addl %eax, %eax
cvtsi2sd %eax, %xmm0
movq 0x2780(%rsp), %rbx
imulq $0x328, %rbx, %rax      # imm = 0x328
leaq 0xa086(%rip), %rcx      # 0xe2c0
mulsd 0x10(%rax,%rcx), %xmm0
movsd %xmm0, 0x20(%rsp)
callq 0x3050
subq 0x30(%rsp), %rax
movl $0x3e8, %ecx            # imm = 0x3E8
cqto
idivq %rcx
movq %rax, %r15
movq 0x9d6c(%rip), %rdi      # 0xdfd0
leaq 0x4e57(%rip), %rsi      # 0x90c2
callq 0x3280
movq %rax, %rdi
movq %r15, %rsi
callq 0x3250
movq %rax, %rdi
callq 0x3140
movq 0x9d46(%rip), %rdi      # 0xdfd0
leaq 0x4e3d(%rip), %rsi      # 0x90ce
callq 0x3280
movq %rax, %rdi
movsd 0x8(%rsp), %xmm0
callq 0x3440
movq %rax, %rdi
callq 0x3140
movq 0x9d1d(%rip), %rdi      # 0xdfd0
leaq 0x4e29(%rip), %rsi      # 0x90e3
callq 0x3280
movsd 0x8(%rsp), %xmm0
mulsd 0x10(%rsp), %xmm0
divsd 0x20(%rsp), %xmm0
movq %rax, %rdi
movsd %xmm0, 0x8(%rsp)
callq 0x3440
movq %rax, %rdi
callq 0x3140
movq 0x28(%rsp), %rdi
movq %rbx, %rsi
callq 0x3190
leaq 0x4e0c(%rip), %rsi      # 0x9107
movq %rax, %rdi
callq 0x3280
movq %rax, %rdi
movsd 0x8(%rsp), %xmm0
callq 0x3440
leaq 0x4def(%rip), %rsi      # 0x9107
movq %rax, %rdi
callq 0x3280
movq %rax, %rdi
movq %r15, %rsi
callq 0x3250
leaq 0x4dd5(%rip), %rsi      # 0x9107
movq %rax, %rdi
callq 0x3280
movq %rax, %rdi
callq 0x3140
leaq 0x38(%rsp), %rdi
callq 0x4dbc
addq $0x2748, %rsp           # imm = 0x2748
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x4364
jmp 0x4364
jmp 0x4364
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x4dbc
movq %rbx, %rdi
callq 0x34a0