// File: 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
movq %rsp, %rbp
subq $0x2860, %rsp           # imm = 0x2860
movl 0x18(%rbp), %eax
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
callq 0x3060
movq %rax, -0x38(%rbp)
callq 0x4380
movq %rax, -0x40(%rbp)
movq $0x0, -0x48(%rbp)
movq $0x0, -0x50(%rbp)
movq $0x0, -0x58(%rbp)
movq $0x0, -0x60(%rbp)
leaq -0x13e8(%rbp), %rdi
movq %rdi, -0x27c0(%rbp)
callq 0x6050
movq -0x27c0(%rbp), %rdi
callq 0x60f0
movl %eax, -0x27b4(%rbp)
jmp 0x4d13
movl -0x27b4(%rbp), %eax
movl %eax, %eax
movl %eax, %esi
leaq -0x2770(%rbp), %rdi
callq 0x6110
jmp 0x4d2b
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, %rcx
decq %rcx
shrq $0x3f, %rcx
leaq -0x1(%rax,%rcx), %rdi
sarq %rdi
callq 0x6140
movsd %xmm0, -0x27c8(%rbp)
jmp 0x4d54
movsd -0x27c8(%rbp), %xmm0
cvttsd2si %xmm0, %edx
leaq -0x2784(%rbp), %rdi
xorl %esi, %esi
callq 0x6160
jmp 0x4d70
movq 0x18259(%rip), %rdi     # 0x1cfd0
leaq 0xf3a2(%rip), %rsi      # 0x14120
callq 0x3300
movq %rax, -0x27d0(%rbp)
jmp 0x4d8c
movq -0x27d0(%rbp), %rdi
movq 0x1821e(%rip), %rsi     # 0x1cfb8
callq 0x3350
jmp 0x4da1
movl $0x0, -0x2788(%rbp)
movl -0x2788(%rbp), %eax
cmpl 0x18(%rbp), %eax
jge 0x4e5a
leaq -0x2784(%rbp), %rdi
leaq -0x2770(%rbp), %rsi
callq 0x6190
movl %eax, -0x27d4(%rbp)
jmp 0x4dd5
movl -0x27d4(%rbp), %eax
cltq
movq %rax, -0x2790(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x2790(%rbp), %rcx
addq %rcx, %rcx
movq 0x10(%rbp), %r8
addq $-0x2, %r8
callq 0x45b0
movsd %xmm0, -0x27e0(%rbp)
jmp 0x4e11
movsd -0x27e0(%rbp), %xmm0
addsd -0x58(%rbp), %xmm0
movsd %xmm0, -0x58(%rbp)
movl -0x2788(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2788(%rbp)
jmp 0x4dab
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x2778(%rbp)
movl %eax, -0x277c(%rbp)
leaq -0x13e8(%rbp), %rdi
callq 0x6260
jmp 0x50c1
movsd -0x58(%rbp), %xmm0
movq -0x10(%rbp), %rax
cvtsi2sdq 0x8(%rax), %xmm1
mulsd %xmm1, %xmm0
movl 0x18(%rbp), %eax
addl %eax, %eax
cvtsi2sd %eax, %xmm1
movq 0x10(%rbp), %rax
imulq $0x328, %rax, %rax      # imm = 0x328
leaq 0x184c8(%rip), %rcx     # 0x1d350
movsd 0x10(%rax,%rcx), %xmm2
mulsd %xmm2, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x60(%rbp)
callq 0x3060
movq %rax, -0x2798(%rbp)
leaq -0x2798(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x61f0
movq %rax, -0x27e8(%rbp)
jmp 0x4ec0
movq -0x27e8(%rbp), %rax
movq %rax, -0x27b0(%rbp)
leaq -0x27b0(%rbp), %rdi
callq 0x61c0
movq %rax, -0x27f0(%rbp)
jmp 0x4ee3
movq -0x27f0(%rbp), %rax
movq %rax, -0x27a8(%rbp)
leaq -0x27a8(%rbp), %rdi
callq 0x6240
movq %rax, -0x27f8(%rbp)
jmp 0x4f06
movq -0x27f8(%rbp), %rax
movq %rax, -0x27a0(%rbp)
movq 0x180b5(%rip), %rdi     # 0x1cfd0
leaq 0xf210(%rip), %rsi      # 0x14132
callq 0x3300
movq %rax, -0x2800(%rbp)
jmp 0x4f30
movq -0x2800(%rbp), %rdi
movq -0x27a0(%rbp), %rsi
callq 0x35a0
movq %rax, -0x2808(%rbp)
jmp 0x4f4c
movq -0x2808(%rbp), %rdi
movq 0x1805e(%rip), %rsi     # 0x1cfb8
callq 0x3350
jmp 0x4f61
movq 0x18068(%rip), %rdi     # 0x1cfd0
leaq 0xf1cf(%rip), %rsi      # 0x1413e
callq 0x3300
movq %rax, -0x2810(%rbp)
jmp 0x4f7d
movq -0x2810(%rbp), %rdi
movsd -0x58(%rbp), %xmm0
callq 0x35d0
movq %rax, -0x2818(%rbp)
jmp 0x4f97
movq -0x2818(%rbp), %rdi
movq 0x18013(%rip), %rsi     # 0x1cfb8
callq 0x3350
jmp 0x4fac
movq 0x1801d(%rip), %rdi     # 0x1cfd0
leaq 0xf199(%rip), %rsi      # 0x14153
callq 0x3300
movq %rax, -0x2820(%rbp)
jmp 0x4fc8
movq -0x2820(%rbp), %rdi
movsd -0x60(%rbp), %xmm0
callq 0x35d0
movq %rax, -0x2828(%rbp)
jmp 0x4fe2
movq -0x2828(%rbp), %rdi
movq 0x17fc8(%rip), %rsi     # 0x1cfb8
callq 0x3350
jmp 0x4ff7
movq -0x20(%rbp), %rdi
movq 0x10(%rbp), %rsi
callq 0x32c0
movq %rax, -0x2830(%rbp)
jmp 0x500d
movq -0x2830(%rbp), %rdi
leaq 0xf1f4(%rip), %rsi      # 0x1420f
callq 0x3300
movq %rax, -0x2838(%rbp)
jmp 0x5029
movq -0x2838(%rbp), %rdi
movsd -0x60(%rbp), %xmm0
callq 0x35d0
movq %rax, -0x2840(%rbp)
jmp 0x5043
movq -0x2840(%rbp), %rdi
leaq 0xf1be(%rip), %rsi      # 0x1420f
callq 0x3300
movq %rax, -0x2848(%rbp)
jmp 0x505f
movq -0x2848(%rbp), %rdi
movq -0x27a0(%rbp), %rsi
callq 0x35a0
movq %rax, -0x2850(%rbp)
jmp 0x507b
movq -0x2850(%rbp), %rdi
leaq 0xf186(%rip), %rsi      # 0x1420f
callq 0x3300
movq %rax, -0x2858(%rbp)
jmp 0x5097
movq -0x2858(%rbp), %rdi
movq 0x17f13(%rip), %rsi     # 0x1cfb8
callq 0x3350
jmp 0x50ac
leaq -0x13e8(%rbp), %rdi
callq 0x6260
addq $0x2860, %rsp           # imm = 0x2860
popq %rbp
retq
movq -0x2778(%rbp), %rdi
callq 0x3570
nopl (%rax)