// File: /workspace/github_cpp_makefile_star2_O3/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 0x3060
movq %rax, 0x30(%rsp)
leaq 0x13c0(%rsp), %rbx
movq %rbx, %rdi
callq 0x5e3c
movq %rbx, %rdi
callq 0x3380
movl 0x2788(%rsp), %r13d
movq 0x2780(%rsp), %r15
movl %eax, %eax
movq %rax, 0x38(%rsp)
movl $0x1, %ecx
movq %rax, %rdx
shrq $0x1e, %rdx
xorl %eax, %edx
imull $0x6c078965, %edx, %eax # imm = 0x6C078965
addl %ecx, %eax
movq %rax, 0x38(%rsp,%rcx,8)
incq %rcx
cmpq $0x270, %rcx            # imm = 0x270
jne 0x4562
movq $0x270, 0x13b8(%rsp) # imm = 0x270
movq 0x8(%r12), %rax
leaq -0x1(%rax), %rcx
shrq $0x3f, %rcx
addq %rcx, %rax
decq %rax
shrq %rax
movl $0x0, 0x18(%rsp)
movl %eax, 0x1c(%rsp)
movq 0x9a17(%rip), %rbx      # 0xdfd0
leaq 0x5b28(%rip), %rsi      # 0xa0e8
movl $0x11, %edx
movq %rbx, %rdi
callq 0x3310
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x3290
movsbl %al, %esi
movq 0x99e5(%rip), %rdi      # 0xdfd0
callq 0x3040
movq %rax, %rdi
callq 0x31b0
movq %r14, 0x28(%rsp)
testl %r13d, %r13d
jle 0x4658
leaq -0x2(%r15), %r14
xorpd %xmm0, %xmm0
movsd %xmm0, 0x8(%rsp)
leaq 0x38(%rsp), %rbx
leaq 0x18(%rsp), %r15
movq %r15, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x6650
movslq %eax, %rcx
addq %rcx, %rcx
movq %rbp, %rdi
movq %r12, %rsi
movq 0x10(%rsp), %rdx
movq %r14, %r8
callq 0x402e
movsd 0x8(%rsp), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, 0x8(%rsp)
decl %r13d
jne 0x461a
jmp 0x4662
xorpd %xmm0, %xmm0
movsd %xmm0, 0x8(%rsp)
xorps %xmm0, %xmm0
cvtsi2sdq 0x8(%r12), %xmm0
movsd %xmm0, 0x10(%rsp)
movl 0x2788(%rsp), %eax
addl %eax, %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
movq 0x2780(%rsp), %r14
imulq $0x328, %r14, %rax      # imm = 0x328
leaq 0x9c28(%rip), %rcx      # 0xe2c0
mulsd 0x10(%rax,%rcx), %xmm0
movsd %xmm0, 0x20(%rsp)
callq 0x3060
subq 0x30(%rsp), %rax
movabsq $0x20c49ba5e353f7cf, %rcx # imm = 0x20C49BA5E353F7CF
imulq %rcx
movq %rdx, %r15
movq 0x990b(%rip), %rdi      # 0xdfd0
leaq 0x5a2e(%rip), %rsi      # 0xa0fa
movl $0xb, %edx
callq 0x3310
movq %r15, %rax
shrq $0x3f, %rax
sarq $0x7, %r15
addq %rax, %r15
movq 0x98e5(%rip), %rdi      # 0xdfd0
movq %r15, %rsi
callq 0x3270
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3290
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31b0
movq 0x98ac(%rip), %rdi      # 0xdfd0
leaq 0x59db(%rip), %rsi      # 0xa106
movl $0x14, %edx
callq 0x3310
movq 0x9894(%rip), %rdi      # 0xdfd0
movsd 0x8(%rsp), %xmm0
callq 0x3440
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3290
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31b0
movq 0x9858(%rip), %rdi      # 0xdfd0
leaq 0x599c(%rip), %rsi      # 0xa11b
movl $0x6, %edx
callq 0x3310
movsd 0x8(%rsp), %xmm0
mulsd 0x10(%rsp), %xmm0
divsd 0x20(%rsp), %xmm0
movq 0x982e(%rip), %rdi      # 0xdfd0
movsd %xmm0, 0x8(%rsp)
callq 0x3440
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3290
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31b0
movq 0x28(%rsp), %rdi
movq %r14, %rsi
callq 0x31a0
movq %rax, %rbx
leaq 0x5951(%rip), %rsi      # 0xa13f
movl $0x1, %edx
movq %rax, %rdi
callq 0x3310
movq %rbx, %rdi
movsd 0x8(%rsp), %xmm0
callq 0x3440
movq %rax, %rbx
leaq 0x592c(%rip), %rsi      # 0xa13f
movl $0x1, %edx
movq %rax, %rdi
callq 0x3310
movq %rbx, %rdi
movq %r15, %rsi
callq 0x3270
movq %rax, %rbx
leaq 0x590a(%rip), %rsi      # 0xa13f
movl $0x1, %edx
movq %rax, %rdi
callq 0x3310
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3290
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31b0
leaq 0x13c0(%rsp), %rdi
callq 0x3260
addq $0x2748, %rsp           # imm = 0x2748
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x48a8
jmp 0x4890
jmp 0x4890
jmp 0x4890
movq %rax, %rbx
leaq 0x13c0(%rsp), %rdi
callq 0x3260
movq %rbx, %rdi
callq 0x34a0
movq %rax, %rdi
callq 0x5f9c