// File: /workspace/github_cpp_makefile_star2_O3/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 0x15f18(%rip), %rdi     # 0x30b40
callq 0x2350
movq 0x108(%r15), %rsi
leaq 0x15615(%rip), %rdi     # 0x30250
xorl %eax, %eax
callq 0x2030
movq %r15, %rdi
callq 0x1dfcc
leaq 0x1560d(%rip), %rdi     # 0x3025e
movq %rax, %rsi
xorl %eax, %eax
callq 0x2030
movq 0x58(%r15), %rsi
leaq 0x1560d(%rip), %rdi     # 0x30273
xorl %eax, %eax
callq 0x2030
leaq 0x80(%rsp), %rbx
movq %rbx, %rdi
callq 0x152ae
movq %rbx, %rdi
movq %r15, %rsi
callq 0x1cf40
leaq 0x1560c(%rip), %rdi     # 0x3029b
xorl %eax, %eax
callq 0x2030
leaq 0x50(%rsp), %rdi
xorl %esi, %esi
callq 0x2360
movq %r15, %rdi
callq 0x28006
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 0x2872a
cvtsi2sd %rbp, %xmm0
movsd 0x154c2(%rip), %xmm1    # 0x301a0
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 0x15614(%rip), %rdi     # 0x30328
movq %rax, %rsi
xorl %eax, %eax
callq 0x2030
leaq 0x15581(%rip), %rdi     # 0x302a6
movsd 0x10(%rsp), %xmm0
movb $0x1, %al
callq 0x2030
leaq 0x15df3(%rip), %rdi     # 0x30b2c
callq 0x2350
movq (%r14), %rax
movq 0x8(%r14), %rcx
cmpq %rax, %rcx
jne 0x1ad60
movl 0x4(%rsp), %edi
movq %r15, %rsi
movq %r14, %rdx
callq 0x16ecd
movq (%r14), %rax
movq 0x8(%r14), %rcx
xorpd %xmm0, %xmm0
movapd %xmm0, 0x20(%rsp)
movq $0x0, 0x30(%rsp)
xorpd %xmm0, %xmm0
cmpq %rax, %rcx
je 0x1afe5
movsd %xmm0, 0x8(%rsp)
leaq 0x15547(%rip), %rbp     # 0x302d4
xorl %r13d, %r13d
movl (%rax,%r13,8), %ebx
movl 0x4(%rax,%r13,8), %r12d
leaq 0x1551e(%rip), %rdi     # 0x302be
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 0x2851e
leaq 0x60(%rsp), %rdi
xorl %esi, %esi
callq 0x2360
xorps %xmm0, %xmm0
cvtsi2sdq 0x50(%rsp), %xmm0
xorps %xmm1, %xmm1
cvtsi2sdq 0x58(%rsp), %xmm1
movsd 0x153b3(%rip), %xmm3    # 0x301a0
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 0x1dfcc
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 0x1dfcc
movq %r12, %xmm0
movq 0x153a2(%rip), %xmm3    # 0x30220
punpckldq %xmm3, %xmm0    # xmm0 = xmm0[0],xmm3[0],xmm0[1],xmm3[1]
movapd 0x153a6(%rip), %xmm1    # 0x30230
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 0x15472(%rip), %rdi     # 0x30375
movl %ebx, %esi
movb $0x1, %al
callq 0x2030
movl 0x4c(%rsp), %esi
xorps %xmm0, %xmm0
cvtsi2sd %esi, %xmm0
movsd 0x58(%r15), %xmm1
unpcklps 0x152fc(%rip), %xmm1    # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x15304(%rip), %xmm1    # 0x30230
movapd %xmm1, %xmm2
unpckhpd %xmm1, %xmm2            # xmm2 = xmm2[1],xmm1[1]
addsd %xmm1, %xmm2
divsd %xmm2, %xmm0
leaq 0x1544f(%rip), %rdi     # 0x30392
movb $0x1, %al
callq 0x2030
movl $0xa, %edi
callq 0x22f0
leaq 0x15b17(%rip), %rdi     # 0x30a72
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 0x1afa8
movq 0x48(%rsp), %rax
movq %rax, 0x10(%rsi)
movupd 0x38(%rsp), %xmm0
movupd %xmm0, (%rsi)
addq $0x18, 0x28(%rsp)
jmp 0x1afb7
leaq 0x20(%rsp), %rdi
leaq 0x38(%rsp), %rdx
callq 0x1b5ee
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 0x1ad90
jmp 0x1afeb
movsd %xmm0, 0x8(%rsp)
xorps %xmm1, %xmm1
cvtsi2sdl 0x4(%rsp), %xmm1
movsd 0x8(%rsp), %xmm0
divsd %xmm1, %xmm0
leaq 0x15a84(%rip), %rdi     # 0x30a89
movb $0x1, %al
callq 0x2030
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x1b023
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x2250
leaq 0x80(%rsp), %rdi
callq 0x15650
addq $0x328, %rsp            # imm = 0x328
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1b044
movq %rax, %rbx
jmp 0x1b067
jmp 0x1b04d
jmp 0x1b04d
movq %rax, %rbx
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x1b067
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x2250
leaq 0x80(%rsp), %rdi
callq 0x15650
movq %rbx, %rdi
callq 0x23b0