// File: /workspace/github_cpp_makefile_star2_O2/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 $0x338, %rsp            # imm = 0x338
movq %rdx, %r14
movl %esi, %ebp
movq %rdi, %r15
leaq 0x12d16(%rip), %rdi     # 0x28b00
callq 0x2360
movq 0x108(%r15), %rsi
leaq 0x12413(%rip), %rdi     # 0x28210
xorl %eax, %eax
callq 0x2030
movq %r15, %rdi
callq 0x18d3c
leaq 0x1240b(%rip), %rdi     # 0x2821e
movq %rax, %rsi
xorl %eax, %eax
callq 0x2030
movq 0x58(%r15), %rsi
leaq 0x1240b(%rip), %rdi     # 0x28233
xorl %eax, %eax
callq 0x2030
leaq 0x90(%rsp), %rbx
movq %rbx, %rdi
callq 0x11468
movq %rbx, %rdi
movq %r15, %rsi
callq 0x17db0
leaq 0x1240a(%rip), %rdi     # 0x2825b
xorl %eax, %eax
callq 0x2030
leaq 0x70(%rsp), %rdi
callq 0xb094
movq %r15, %rdi
callq 0x2058a
leaq 0x70(%rsp), %rbx
movq %rbx, %rdi
callq 0xb09c
movq %rbx, %rdi
callq 0xb0a8
movsd %xmm0, 0x10(%rsp)
movq %r15, %rdi
callq 0x20b20
leaq 0x12454(%rip), %rdi     # 0x282e8
movq %rax, %rsi
xorl %eax, %eax
callq 0x2030
leaq 0x123c1(%rip), %rdi     # 0x28266
movsd 0x10(%rsp), %xmm0
movb $0x1, %al
callq 0x2030
leaq 0x12c33(%rip), %rdi     # 0x28aec
callq 0x2360
movq 0x8(%r14), %rax
cmpq (%r14), %rax
jne 0x15ed4
movl %ebp, %edi
movq %r15, %rsi
movq %r14, %rdx
callq 0x12cba
movl %ebp, 0xc(%rsp)
xorpd %xmm0, %xmm0
leaq 0x40(%rsp), %rax
movapd %xmm0, (%rax)
andq $0x0, 0x10(%rax)
xorpd %xmm0, %xmm0
leaq 0x70(%rsp), %rbp
xorl %ebx, %ebx
movq (%r14), %rax
movq 0x8(%r14), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
cmpq %rbx, %rcx
jbe 0x160e3
movsd %xmm0, 0x38(%rsp)
movl (%rax,%rbx,8), %r12d
movl 0x4(%rax,%rbx,8), %r13d
leaq 0x1235c(%rip), %rdi     # 0x2827e
movl %r12d, %esi
movl %r13d, %edx
xorl %eax, %eax
callq 0x2030
movq %rbp, %rdi
callq 0xb094
movq %r15, %rdi
movl %r12d, %esi
movl %r13d, %edx
callq 0x20972
movq %rbp, %rdi
callq 0xb09c
movq %rbp, %rdi
callq 0xb0a8
movsd %xmm0, 0x20(%rsp)
movq 0x18(%r15), %rax
movq 0x60(%r15), %rcx
movl (%rax,%r12,4), %eax
imulq $0x568, %rax, %rax      # imm = 0x568
movl 0xb8(%rcx,%rax), %edx
movl %edx, 0x34(%rsp)
movl 0x78(%rcx,%rax), %eax
movl %eax, 0x30(%rsp)
movq %r15, %rdi
callq 0x18d3c
movq %rax, %r13
movsd 0x58(%r15), %xmm0
movaps %xmm0, 0x60(%rsp)
movl 0x30(%rsp), %r12d
cvtsi2sdl 0x34(%rsp), %xmm0
movsd %xmm0, 0x10(%rsp)
movq %r15, %rdi
callq 0x18d3c
movq %r13, %xmm0
movq 0x12233(%rip), %xmm3    # 0x281f0
punpckldq %xmm3, %xmm0    # xmm0 = xmm0[0],xmm3[0],xmm0[1],xmm3[1]
movapd 0x12237(%rip), %xmm1    # 0x28200
subpd %xmm1, %xmm0
movapd %xmm0, %xmm2
unpckhpd %xmm0, %xmm2            # xmm2 = xmm2[1],xmm0[1]
addsd %xmm0, %xmm2
movdqa 0x60(%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
cvtsi2sd %r12d, %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 0x122f5(%rip), %rdi     # 0x28335
movl %r12d, %esi
movb $0x1, %al
callq 0x2030
movl 0x34(%rsp), %esi
cvtsi2sd %esi, %xmm0
movsd 0x58(%r15), %xmm1
unpcklps 0x12191(%rip), %xmm1    # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x12199(%rip), %xmm1    # 0x28200
movapd %xmm1, %xmm2
unpckhpd %xmm1, %xmm2            # xmm2 = xmm2[1],xmm1[1]
addsd %xmm1, %xmm2
divsd %xmm2, %xmm0
leaq 0x122d4(%rip), %rdi     # 0x28352
movb $0x1, %al
callq 0x2030
pushq $0xa
popq %r12
movl %r12d, %edi
callq 0x2300
leaq 0x1299a(%rip), %rdi     # 0x28a32
movaps 0x10(%rsp), %xmm0
movb $0x1, %al
callq 0x2030
movl %r12d, %edi
callq 0x2300
movsd 0x20(%rsp), %xmm0
leaq 0x121db(%rip), %rdi     # 0x28294
movb $0x1, %al
callq 0x2030
leaq 0x40(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x1637e
movsd 0x38(%rsp), %xmm0
addsd 0x10(%rsp), %xmm0
incq %rbx
jmp 0x15ef5
cvtsi2sdl 0xc(%rsp), %xmm1
divsd %xmm1, %xmm0
leaq 0x12955(%rip), %rdi     # 0x28a49
movb $0x1, %al
callq 0x2030
leaq 0x40(%rsp), %rdi
callq 0x16772
leaq 0x90(%rsp), %rdi
callq 0x1173e
addq $0x338, %rsp            # imm = 0x338
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x16126
movq %rax, %rbx
jmp 0x1613c
jmp 0x1612f
jmp 0x1612f
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x16772
leaq 0x90(%rsp), %rdi
callq 0x1173e
movq %rbx, %rdi
callq 0x23d0