// File: /workspace/github_cpp_makefile_star2_O1/fjamour[P]icentral/src/experiments.cc
// Function: qube_ideal_speedup(graph_t&, int, std::vector<std::pair<unsigned int, unsigned int>, std::allocator<std::pair<unsigned int, unsigned int>>>)
void qube_ideal_speedup(graph_t& graph,
        int num_edges_to_insert,
        vector<edge_t> rand_edge_vec)
{
    printf("==========================================================\n");
    printf("Graph: \t\t\t%s\n", graph.graph_name.c_str());
    printf("Graph # nodes: \t\t%d\n", graph.size());
    printf("Graph # edges: \t\t%d\n", graph.edge_set.size());
    graph_hash_t g;
    g.fill_graph(graph);
    
    double brandes_time, muc_find_time;
    timer tm;
  
    printf("# MUCs: \t\t");
    tm.start();
    graph.find_mucs();
    tm.stop();
    muc_find_time = tm.interval();
    printf("%d\n", graph.get_num_mucs());
    printf("Time to find MUCs: \t%f\n", muc_find_time);
    
    printf("Generating edges...\n");
    if(rand_edge_vec.size() == 0) {
        gen_rand_edges(num_edges_to_insert, graph, rand_edge_vec);
    }
    vector<edge_stat_t> edge_stat_vec;
    
    double tot_ideal_speedup = 0;
    
    for(int i = 0; i < rand_edge_vec.size(); ++i) {
        edge_t rand_edge = rand_edge_vec[i];
        edge_stat_t edge_stat;
        printf("Adding edge (%d, %d)\n", rand_edge.first, rand_edge.second);
        tm.start();
        graph.insert_edge_update_muc(rand_edge.first, rand_edge.second);
        tm.stop();
        edge_stat.edge_ins_time = tm.interval();

        muc_id_t muc_id = graph.node_to_muc_vec[rand_edge.first];
        edge_stat.muc_num_edges = graph.muc_vec[muc_id].muc_subgraph.edge_set.size();
        edge_stat.muc_num_nodes = graph.muc_vec[muc_id].muc_subgraph.nodes_map.size();
        
        //estimating ideal speedup using the node and edge proportions
        double ideal_speedup;
        double V  = graph.size(); double E = graph.edge_set.size();
        double Vm = edge_stat.muc_num_nodes; double Em = edge_stat.muc_num_edges;
        ideal_speedup = ((V+E)/(Vm+Em))*(V/Vm);
        tot_ideal_speedup += ideal_speedup;
        ////
        
        printf("\tMUC # nodes: \t\t%d (%f G_n)\n",
                edge_stat.muc_num_nodes,
                edge_stat.muc_num_nodes/(double)graph.size());
        printf("\tMUC # edges: \t\t%d (%f G_M)\n",
                edge_stat.muc_num_edges,
                edge_stat.muc_num_edges/(double)graph.edge_set.size());
        printf("\n");
        printf("\tSpeedup (ideal): \t%f\n", ideal_speedup);
        printf("\n");
        printf("\tTime to update MUCs: \t%f\n", edge_stat.edge_ins_time);

        edge_stat_vec.push_back(edge_stat);
    }
    
    double avg_ideal_speedup = tot_ideal_speedup/num_edges_to_insert;
    printf("[[Average speedup (ideal): %f]]\n",
        avg_ideal_speedup);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x328, %rsp            # imm = 0x328
movq %rdx, %r14
movl %esi, 0x4(%rsp)
movq %rdi, %r15
leaq 0x16e79(%rip), %rdi     # 0x31b40
callq 0x2350
movq 0x108(%r15), %rsi
leaq 0x16576(%rip), %rdi     # 0x31250
xorl %eax, %eax
callq 0x2030
movq %r15, %rdi
callq 0x1e160
leaq 0x1656e(%rip), %rdi     # 0x3125e
movq %rax, %rsi
xorl %eax, %eax
callq 0x2030
movq 0x58(%r15), %rsi
leaq 0x1656e(%rip), %rdi     # 0x31273
xorl %eax, %eax
callq 0x2030
leaq 0x80(%rsp), %rbx
movq %rbx, %rdi
callq 0x153ae
movq %rbx, %rdi
movq %r15, %rsi
callq 0x1d062
leaq 0x1656d(%rip), %rdi     # 0x3129b
xorl %eax, %eax
callq 0x2030
leaq 0x50(%rsp), %rdi
xorl %esi, %esi
callq 0x2360
movq %r15, %rdi
callq 0x282ae
leaq 0x60(%rsp), %rbp
movq %rbp, %rdi
xorl %esi, %esi
callq 0x2360
movq -0x10(%rbp), %rbx
movq -0x8(%rbp), %r12
movq (%rbp), %r13
movq 0x8(%rbp), %rbp
movq %r15, %rdi
callq 0x289cc
cvtsi2sd %rbp, %xmm0
movsd 0x16423(%rip), %xmm1    # 0x311a0
divsd %xmm1, %xmm0
cvtsi2sd %r13, %xmm2
addsd %xmm0, %xmm2
xorps %xmm0, %xmm0
cvtsi2sd %r12, %xmm0
divsd %xmm1, %xmm0
xorps %xmm1, %xmm1
cvtsi2sd %rbx, %xmm1
addsd %xmm0, %xmm1
subsd %xmm1, %xmm2
movsd %xmm2, 0x10(%rsp)
leaq 0x16575(%rip), %rdi     # 0x31328
movq %rax, %rsi
xorl %eax, %eax
callq 0x2030
leaq 0x164e2(%rip), %rdi     # 0x312a6
movsd 0x10(%rsp), %xmm0
movb $0x1, %al
callq 0x2030
leaq 0x16d54(%rip), %rdi     # 0x31b2c
callq 0x2350
movq 0x8(%r14), %rax
cmpq (%r14), %rax
jne 0x1adf5
movl 0x4(%rsp), %edi
movq %r15, %rsi
movq %r14, %rdx
callq 0x16f89
xorpd %xmm0, %xmm0
movapd %xmm0, 0x20(%rsp)
movq $0x0, 0x30(%rsp)
movq (%r14), %rax
cmpq %rax, 0x8(%r14)
je 0x1b07e
xorpd %xmm0, %xmm0
movsd %xmm0, 0x8(%rsp)
leaq 0x164ae(%rip), %rbp     # 0x312d4
xorl %r13d, %r13d
movl (%rax,%r13,8), %ebx
movl 0x4(%rax,%r13,8), %r12d
leaq 0x16485(%rip), %rdi     # 0x312be
movl %ebx, %esi
movl %r12d, %edx
xorl %eax, %eax
callq 0x2030
leaq 0x50(%rsp), %rdi
xorl %esi, %esi
callq 0x2360
movq %r15, %rdi
movl %ebx, %esi
movl %r12d, %edx
callq 0x287c6
leaq 0x60(%rsp), %rdi
xorl %esi, %esi
callq 0x2360
xorps %xmm0, %xmm0
cvtsi2sdq 0x50(%rsp), %xmm0
xorps %xmm1, %xmm1
cvtsi2sdq 0x58(%rsp), %xmm1
movsd 0x1631a(%rip), %xmm3    # 0x311a0
divsd %xmm3, %xmm1
addsd %xmm0, %xmm1
xorps %xmm0, %xmm0
cvtsi2sdq 0x60(%rsp), %xmm0
xorps %xmm2, %xmm2
cvtsi2sdq 0x68(%rsp), %xmm2
divsd %xmm3, %xmm2
addsd %xmm0, %xmm2
subsd %xmm1, %xmm2
movsd %xmm2, 0x38(%rsp)
movq 0x18(%r15), %rax
movq 0x60(%r15), %rcx
movl (%rax,%rbx,4), %eax
imulq $0x568, %rax, %rax      # imm = 0x568
movl 0xb8(%rcx,%rax), %edx
movl %edx, 0x4c(%rsp)
movl 0x78(%rcx,%rax), %eax
movl %eax, 0x48(%rsp)
movq %r15, %rdi
callq 0x1e160
movq %rax, %r12
movsd 0x58(%r15), %xmm0
movaps %xmm0, 0x70(%rsp)
movl 0x48(%rsp), %ebx
xorps %xmm0, %xmm0
cvtsi2sdl 0x4c(%rsp), %xmm0
movsd %xmm0, 0x10(%rsp)
movq %r15, %rdi
callq 0x1e160
movq %r12, %xmm0
movq 0x16309(%rip), %xmm3    # 0x31220
punpckldq %xmm3, %xmm0    # xmm0 = xmm0[0],xmm3[0],xmm0[1],xmm3[1]
movapd 0x1630d(%rip), %xmm1    # 0x31230
subpd %xmm1, %xmm0
movapd %xmm0, %xmm2
unpckhpd %xmm0, %xmm2            # xmm2 = xmm2[1],xmm0[1]
addsd %xmm0, %xmm2
movdqa 0x70(%rsp), %xmm0
punpckldq %xmm3, %xmm0    # xmm0 = xmm0[0],xmm3[0],xmm0[1],xmm3[1]
subpd %xmm1, %xmm0
movapd %xmm1, %xmm4
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
xorps %xmm0, %xmm0
cvtsi2sd %ebx, %xmm0
addsd %xmm2, %xmm1
movsd 0x10(%rsp), %xmm5
addsd %xmm0, %xmm5
divsd %xmm5, %xmm1
divsd %xmm0, %xmm2
mulsd %xmm1, %xmm2
movapd %xmm2, 0x10(%rsp)
movq %rax, %xmm1
punpckldq %xmm3, %xmm1    # xmm1 = xmm1[0],xmm3[0],xmm1[1],xmm3[1]
subpd %xmm4, %xmm1
movapd %xmm1, %xmm2
unpckhpd %xmm1, %xmm2            # xmm2 = xmm2[1],xmm1[1]
addsd %xmm1, %xmm2
divsd %xmm2, %xmm0
leaq 0x163d9(%rip), %rdi     # 0x31375
movl %ebx, %esi
movb $0x1, %al
callq 0x2030
movl 0x4c(%rsp), %esi
xorps %xmm0, %xmm0
cvtsi2sd %esi, %xmm0
movsd 0x58(%r15), %xmm1
unpcklps 0x16263(%rip), %xmm1    # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x1626b(%rip), %xmm1    # 0x31230
movapd %xmm1, %xmm2
unpckhpd %xmm1, %xmm2            # xmm2 = xmm2[1],xmm1[1]
addsd %xmm1, %xmm2
divsd %xmm2, %xmm0
leaq 0x163b6(%rip), %rdi     # 0x31392
movb $0x1, %al
callq 0x2030
movl $0xa, %edi
callq 0x22f0
leaq 0x16a7e(%rip), %rdi     # 0x31a72
movaps 0x10(%rsp), %xmm0
movb $0x1, %al
callq 0x2030
movl $0xa, %edi
callq 0x22f0
movsd 0x38(%rsp), %xmm0
movq %rbp, %rdi
movb $0x1, %al
callq 0x2030
movq 0x28(%rsp), %rsi
cmpq 0x30(%rsp), %rsi
je 0x1b041
movq 0x48(%rsp), %rax
movq %rax, 0x10(%rsi)
movupd 0x38(%rsp), %xmm0
movupd %xmm0, (%rsi)
addq $0x18, 0x28(%rsp)
jmp 0x1b050
leaq 0x20(%rsp), %rdi
leaq 0x38(%rsp), %rdx
callq 0x1b6b4
movsd 0x8(%rsp), %xmm0
addsd 0x10(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
incq %r13
movq (%r14), %rax
movq 0x8(%r14), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
cmpq %r13, %rcx
ja 0x1ae29
jmp 0x1b088
xorpd %xmm0, %xmm0
movsd %xmm0, 0x8(%rsp)
xorps %xmm1, %xmm1
cvtsi2sdl 0x4(%rsp), %xmm1
movsd 0x8(%rsp), %xmm0
divsd %xmm1, %xmm0
leaq 0x169e7(%rip), %rdi     # 0x31a89
movb $0x1, %al
callq 0x2030
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x1b0c0
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x2250
leaq 0x80(%rsp), %rdi
callq 0x15750
addq $0x328, %rsp            # imm = 0x328
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1b0e1
movq %rax, %rbx
jmp 0x1b104
jmp 0x1b0ea
jmp 0x1b0ea
movq %rax, %rbx
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x1b104
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x2250
leaq 0x80(%rsp), %rdi
callq 0x15750
movq %rbx, %rdi
callq 0x23b0