// File: fjamour[P]icentral/src/experiments.cc
// Function: insertion_test_fuad_max_iter(graph_t&, int, int, double, std::vector<std::pair<unsigned int, unsigned int>, std::allocator<std::pair<unsigned int, unsigned int>>>)
void insertion_test_fuad_max_iter(graph_t& graph,
        int num_edges_to_insert,
        int num_iter,
        double time_to_run_all_iter,
        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());
    
    double brandes_time;
    timer tm;
    
    printf("Brandes runtime: \t");
    tm.start();
    tr1_map_t(double) bc_vec = brandes_bc_hash_out(graph, num_iter);
    tm.stop();
    brandes_time = (tm.interval()*graph.size()/num_iter);
    
    bool do_all_iter = false;
    if(brandes_time < time_to_run_all_iter)
        do_all_iter = true;
    
    if(do_all_iter) {
        num_iter = -1;
        tm.start();
        tr1_map_t(double) bc_vec = brandes_bc_hash_out(graph, num_iter);
        tm.stop();
        brandes_time = tm.interval();
        printf("%f\n", brandes_time);
        printf("Brandes avg iter time: \t%f\n", tm.interval()/graph.size());
        printf("WILL DO ALL ITERATIONS...\n");
    } else {
        printf("%f\n", brandes_time);
        printf("Brandes avg iter time: \t%f\n", tm.interval()/num_iter);
    }

    
    //vector<edge_t> rand_edge_vec;
    if(rand_edge_vec.size() == 0) {
        printf("Generating edges...\n");
        gen_rand_edges(num_edges_to_insert, graph, rand_edge_vec);
    }

    double tot_fuad_time = 0;
    double tot_speedup = 0;
    
    double tot_ideal_speedup_perfect = 0;
    double tot_ideal_speedup = 0;
    
    vector<bcc_stat_t>  bcc_stat_vec;
    vector<double>      speedup_vec;
    for(int i = 0; i < rand_edge_vec.size(); ++i) {
        bcc_stat_t bcc_stat;
        edge_t rand_edge = rand_edge_vec[i];
        double est_time = 0;
        
        printf("Inserting edge (%d, %d) and updating bc...\n", rand_edge.first, rand_edge.second);
        tm.start();
        graph.insert_edge_update_bc_experimental(rand_edge.first, rand_edge.second, bcc_stat, num_iter, num_iter);
        tm.stop();
        if(do_all_iter) {
            est_time = bcc_stat.bc_update_time + bcc_stat.bcc_find_time;
            
            // TMP XXX FIX THIS
            //est_time = bcc_stat.bc_update_time;
            ////
        }
        
        double avg_iter_time_naive;
        graph.approx_bcc_iter_tm(rand_edge.first, rand_edge.second, avg_iter_time_naive, num_iter);
        tot_fuad_time += tm.interval();
        
        //fix counts if will produce errors:
        if(bcc_stat.num_d0_iter == 0) {
            bcc_stat.num_d0_iter = 1;
            bcc_stat.tot_d0_tm = 0;
        }
        if(bcc_stat.num_d1_iter == 0) {
            bcc_stat.num_d1_iter = 1;
            bcc_stat.tot_d1_tm = 0;
        }
        if(bcc_stat.num_d2_iter == 0) {
            bcc_stat.num_d2_iter = 1;
            bcc_stat.tot_d2_tm = 0;
        }
        ////
        if(!do_all_iter) {
            est_time += bcc_stat.tot_d1_tm*bcc_stat.tot_d1_iter/bcc_stat.num_d1_iter;
            est_time += bcc_stat.tot_d2_tm*bcc_stat.tot_d2_iter/bcc_stat.num_d2_iter;
        }
        

        tot_speedup += (brandes_time/est_time);
        speedup_vec.push_back(brandes_time/est_time);
        
        //ideal speedup estimation
        double ideal_speedup_perfect, ideal_speedup;
        double G_n   = graph.size(); 
        double G_m   = graph.edge_set.size();
        double BCC_n = bcc_stat.bcc_num_nodes;
        double BCC_m = bcc_stat.bcc_num_edges;
        double inc_iter_ratio = 150;//PARAMETER!! IMP make a #define
        double iter_frac = 1 - ((double)bcc_stat.tot_d0_iter/BCC_n);
        ideal_speedup_perfect =
                fuad_ideal_speedup(iter_frac, 
                    BCC_n,
                    BCC_m,
                    G_n,
                    G_m,
                    100);
        ideal_speedup =
                fuad_ideal_speedup(iter_frac, 
                    BCC_n,
                    BCC_m,
                    G_n,
                    G_m,
                    inc_iter_ratio);
        
        tot_ideal_speedup_perfect += ideal_speedup_perfect;
        tot_ideal_speedup += ideal_speedup;
        ////
        
        //speedup if BFS DAGS were to be stored in memory
        double in_mem_speedup;
        double in_mem_time = 0;
        in_mem_time += (bcc_stat.tot_d1_tm/bcc_stat.num_d1_iter-avg_iter_time_naive)*bcc_stat.tot_d1_iter;
        in_mem_time += (bcc_stat.tot_d2_tm/bcc_stat.num_d2_iter-avg_iter_time_naive)*bcc_stat.tot_d2_iter;
        in_mem_speedup = brandes_time/in_mem_time;
        printf("\tStored DAGS ideal speedup: \t%f\n\n", in_mem_speedup);
        ////
        
        printf("\tBCC num nodes: \t\t\t%d (%f G_n)\n",
                bcc_stat.bcc_num_nodes,
                (double)bcc_stat.bcc_num_nodes/graph.size());
        printf("\tBCC num edges: \t\t\t%d (%f G_m)\n",
                bcc_stat.bcc_num_edges,
                (double)bcc_stat.bcc_num_edges/graph.edge_set.size());
        printf("\n");
        printf("\tTime to update BC: \t\t%f\n",
                est_time);
        printf("\tSpeedup: \t\t\t%f (Ideal: %f - %f)\n",
                brandes_time/est_time,
                ideal_speedup,
                ideal_speedup_perfect);
        printf("\n");
        printf("\tBCC d1 time: \t\t\t%f (%f to naive iter)\n",
                bcc_stat.tot_d1_tm/bcc_stat.num_d1_iter,
                (bcc_stat.tot_d1_tm/bcc_stat.num_d1_iter)/avg_iter_time_naive);
        printf("\tBCC d2 time: \t\t\t%f (%f to naive iter)\n",
                bcc_stat.tot_d2_tm/bcc_stat.num_d2_iter,
                (bcc_stat.tot_d2_tm/bcc_stat.num_d2_iter)/avg_iter_time_naive);
        printf("\tavg iter time naive: \t\t%f (%f to naive iter)\n",
                avg_iter_time_naive,
                avg_iter_time_naive/avg_iter_time_naive);
        printf("\n");
        printf("\tBCC num/tot d0 BFS: \t\t%*d/%*d (%f to BCC_n)\n",
                8,
                bcc_stat.num_d0_iter,
                8,
                bcc_stat.tot_d0_iter,
                bcc_stat.tot_d0_iter/(double)bcc_stat.bcc_num_nodes);
        printf("\tBCC num/tot d1 BFS: \t\t%*d/%*d (%f to BCC_n)\n",
                8,
                bcc_stat.num_d1_iter,
                8,
                bcc_stat.tot_d1_iter,
                bcc_stat.tot_d1_iter/(double)bcc_stat.bcc_num_nodes);
        printf("\tBCC num/tot d2 BFS: \t\t%*d/%*d (%f to BCC_n)\n",
                8,
                bcc_stat.num_d2_iter,
                8,
                bcc_stat.tot_d2_iter,
                bcc_stat.tot_d2_iter/(double)bcc_stat.bcc_num_nodes);
        printf("\n");
        printf("\tBCC bcc find time: \t\t%f\n", bcc_stat.bcc_find_time);
        printf("\tBCC sssp time: \t\t\t%f\n", bcc_stat.sssp_tm);
        
        bcc_stat_vec.push_back(bcc_stat);
        
        //dont remove the edge, to have fair comparison to QUBE
        //in my QUBE implementation the MUC update after edge removal is not
        //implemented
        //graph.remove_edge(rand_edge.first, rand_edge.second);
    }
    
    //double avg_speedup = (num_edges_to_insert*brandes_time)/tot_fuad_time;
    double avg_speedup = tot_speedup/num_edges_to_insert;
    double avg_ideal_speedup_perfect = tot_ideal_speedup_perfect/num_edges_to_insert;
    double avg_ideal_speedup = tot_ideal_speedup/num_edges_to_insert;
    
    printf("[[Average speedup: %f (Ideal: %f - %f)]]\n",
        avg_speedup,
        avg_ideal_speedup,
        avg_ideal_speedup_perfect);
    
    //calculating 95% confidence interval
    double s_mean, s_median, s_stddev, s_min, s_max;
    simple_stats(speedup_vec, s_mean, s_stddev, s_median, s_min, s_max);
    double diff = 1.96*s_stddev/sqrt(num_edges_to_insert);
    double v1 = s_mean - diff;
    double v2 = s_mean + diff;
    printf("[[Speedup 95 CI: %f - %f]]\n", v1, v2);
}

// Assembly:
subq $0x308, %rsp            # imm = 0x308
movq %rcx, 0xa0(%rsp)
movq %rdi, 0x300(%rsp)
movl %esi, 0x2fc(%rsp)
movl %edx, 0x2f8(%rsp)
movsd %xmm0, 0x2f0(%rsp)
movq %rcx, 0x2e8(%rsp)
leaq 0x30f13(%rip), %rdi     # 0x7b2e0
xorl %eax, %eax
movb %al, 0xaf(%rsp)
callq 0x9040
movq 0x300(%rsp), %rdi
addq $0x108, %rdi            # imm = 0x108
callq 0x9250
movq %rax, %rsi
movb 0xaf(%rsp), %al
leaq 0x30f1c(%rip), %rdi     # 0x7b31c
callq 0x9040
movq 0x300(%rsp), %rdi
callq 0x56b40
movq %rax, %rsi
movb 0xaf(%rsp), %al
leaq 0x30f07(%rip), %rdi     # 0x7b32a
callq 0x9040
movq 0x300(%rsp), %rdi
addq $0x30, %rdi
callq 0x4dbe0
movq %rax, %rsi
movb 0xaf(%rsp), %al
leaq 0x30ef5(%rip), %rdi     # 0x7b33f
callq 0x9040
movb 0xaf(%rsp), %al
leaq 0x30ef7(%rip), %rdi     # 0x7b354
callq 0x9040
leaq 0x2c0(%rsp), %rdi
movq %rdi, 0xb0(%rsp)
callq 0x2d430
movq 0x300(%rsp), %rsi
movl 0x2f8(%rsp), %edx
leaq 0x290(%rsp), %rdi
callq 0x29120
movq 0xb0(%rsp), %rdi
callq 0x2d450
jmp 0x4a4a2
leaq 0x2c0(%rsp), %rdi
callq 0x2d470
movsd %xmm0, 0x98(%rsp)
jmp 0x4a4ba
movq 0x300(%rsp), %rdi
callq 0x56b40
movq %rax, 0x90(%rsp)
jmp 0x4a4d1
movsd 0x98(%rsp), %xmm0
movq 0x90(%rsp), %rax
movq %rax, %xmm1
movaps 0x30dc2(%rip), %xmm2    # 0x7b2b0
punpckldq %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
movapd 0x30dc6(%rip), %xmm2    # 0x7b2c0
subpd %xmm2, %xmm1
movaps %xmm1, %xmm2
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm2, %xmm1
mulsd %xmm1, %xmm0
cvtsi2sdl 0x2f8(%rsp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x2e0(%rsp)
movb $0x0, 0x283(%rsp)
movsd 0x2e0(%rsp), %xmm1
movsd 0x2f0(%rsp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x4a566
movb $0x1, 0x283(%rsp)
jmp 0x4a566
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x288(%rsp)
movl %eax, 0x284(%rsp)
jmp 0x4b1b4
testb $0x1, 0x283(%rsp)
je 0x4a6b8
movl $0xffffffff, 0x2f8(%rsp) # imm = 0xFFFFFFFF
leaq 0x2c0(%rsp), %rdi
callq 0x2d430
jmp 0x4a58e
movq 0x300(%rsp), %rsi
movl 0x2f8(%rsp), %edx
leaq 0x250(%rsp), %rdi
callq 0x29120
jmp 0x4a5ac
leaq 0x2c0(%rsp), %rdi
callq 0x2d450
jmp 0x4a5bb
leaq 0x2c0(%rsp), %rdi
callq 0x2d470
movsd %xmm0, 0x88(%rsp)
jmp 0x4a5d3
movsd 0x88(%rsp), %xmm0
movsd %xmm0, 0x2e0(%rsp)
movsd 0x2e0(%rsp), %xmm0
leaq 0x30f5b(%rip), %rdi     # 0x7b550
movb $0x1, %al
callq 0x9040
jmp 0x4a5fe
leaq 0x2c0(%rsp), %rdi
callq 0x2d470
movsd %xmm0, 0x80(%rsp)
jmp 0x4a616
movq 0x300(%rsp), %rdi
callq 0x56b40
movq %rax, 0x78(%rsp)
jmp 0x4a62a
movsd 0x80(%rsp), %xmm0
movq 0x78(%rsp), %rax
movq %rax, %xmm1
movaps 0x30c6c(%rip), %xmm2    # 0x7b2b0
punpckldq %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
movapd 0x30c70(%rip), %xmm2    # 0x7b2c0
subpd %xmm2, %xmm1
movaps %xmm1, %xmm2
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm2, %xmm1
divsd %xmm1, %xmm0
leaq 0x30dd0(%rip), %rdi     # 0x7b43a
movb $0x1, %al
callq 0x9040
jmp 0x4a673
leaq 0x310b9(%rip), %rdi     # 0x7b733
xorl %eax, %eax
callq 0x9040
jmp 0x4a683
leaq 0x250(%rsp), %rdi
callq 0x2d420
jmp 0x4a70b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x288(%rsp)
movl %eax, 0x284(%rsp)
leaq 0x250(%rsp), %rdi
callq 0x2d420
jmp 0x4b1b4
movsd 0x2e0(%rsp), %xmm0
leaq 0x30e88(%rip), %rdi     # 0x7b550
movb $0x1, %al
callq 0x9040
jmp 0x4a6d1
leaq 0x2c0(%rsp), %rdi
callq 0x2d470
movsd %xmm0, 0x70(%rsp)
jmp 0x4a6e6
movsd 0x70(%rsp), %xmm0
cvtsi2sdl 0x2f8(%rsp), %xmm1
divsd %xmm1, %xmm0
leaq 0x30d3a(%rip), %rdi     # 0x7b43a
movb $0x1, %al
callq 0x9040
jmp 0x4a709
jmp 0x4a70b
movq 0xa0(%rsp), %rdi
callq 0x47680
cmpq $0x0, %rax
jne 0x4a74e
leaq 0x30d31(%rip), %rdi     # 0x7b456
xorl %eax, %eax
callq 0x9040
jmp 0x4a72e
movq 0xa0(%rsp), %rdx
movl 0x2fc(%rsp), %edi
movq 0x300(%rsp), %rsi
callq 0x47910
jmp 0x4a74c
jmp 0x4a74e
xorps %xmm0, %xmm0
movsd %xmm0, 0x248(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, 0x240(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, 0x238(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, 0x230(%rsp)
leaq 0x218(%rsp), %rdi
callq 0x4e090
leaq 0x200(%rsp), %rdi
callq 0xfa00
movl $0x0, 0x1fc(%rsp)
movq 0xa0(%rsp), %rdi
movslq 0x1fc(%rsp), %rax
movq %rax, 0x68(%rsp)
callq 0x47680
movq %rax, %rcx
movq 0x68(%rsp), %rax
cmpq %rcx, %rax
jae 0x4afc1
movq 0xa0(%rsp), %rdi
movslq 0x1fc(%rsp), %rsi
callq 0x4dbc0
movq (%rax), %rax
movq %rax, 0x190(%rsp)
movq $0x0, 0x188(%rsp)
movl 0x190(%rsp), %esi
movl 0x194(%rsp), %edx
leaq 0x30e33(%rip), %rdi     # 0x7b642
xorl %eax, %eax
callq 0x9040
jmp 0x4a818
leaq 0x2c0(%rsp), %rdi
callq 0x2d430
jmp 0x4a827
movq 0x300(%rsp), %rdi
movl 0x190(%rsp), %esi
movl 0x194(%rsp), %edx
movl 0x2f8(%rsp), %r9d
leaq 0x198(%rsp), %rcx
movl %r9d, %r8d
callq 0x575f0
jmp 0x4a857
leaq 0x2c0(%rsp), %rdi
callq 0x2d450
jmp 0x4a866
testb $0x1, 0x283(%rsp)
je 0x4a8a6
movsd 0x1d8(%rsp), %xmm0
addsd 0x1d0(%rsp), %xmm0
movsd %xmm0, 0x188(%rsp)
jmp 0x4a8a6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x288(%rsp)
movl %eax, 0x284(%rsp)
jmp 0x4b19a
movq 0x300(%rsp), %rdi
movl 0x190(%rsp), %esi
movl 0x194(%rsp), %edx
movl 0x2f8(%rsp), %r8d
leaq 0x180(%rsp), %rcx
callq 0x57880
jmp 0x4a8d3
leaq 0x2c0(%rsp), %rdi
callq 0x2d470
movsd %xmm0, 0x60(%rsp)
jmp 0x4a8e8
movsd 0x60(%rsp), %xmm0
addsd 0x248(%rsp), %xmm0
movsd %xmm0, 0x248(%rsp)
cmpl $0x0, 0x1a8(%rsp)
jne 0x4a921
movl $0x1, 0x1a8(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, 0x1b8(%rsp)
cmpl $0x0, 0x1ac(%rsp)
jne 0x4a942
movl $0x1, 0x1ac(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, 0x1c0(%rsp)
cmpl $0x0, 0x1b0(%rsp)
jne 0x4a963
movl $0x1, 0x1b0(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, 0x1c8(%rsp)
testb $0x1, 0x283(%rsp)
jne 0x4a9d7
movsd 0x1c0(%rsp), %xmm0
cvtsi2sdl 0x1ec(%rsp), %xmm1
mulsd %xmm1, %xmm0
cvtsi2sdl 0x1ac(%rsp), %xmm1
divsd %xmm1, %xmm0
addsd 0x188(%rsp), %xmm0
movsd %xmm0, 0x188(%rsp)
movsd 0x1c8(%rsp), %xmm0
cvtsi2sdl 0x1f0(%rsp), %xmm1
mulsd %xmm1, %xmm0
cvtsi2sdl 0x1b0(%rsp), %xmm1
divsd %xmm1, %xmm0
addsd 0x188(%rsp), %xmm0
movsd %xmm0, 0x188(%rsp)
movsd 0x2e0(%rsp), %xmm1
movsd 0x188(%rsp), %xmm0
divsd %xmm0, %xmm1
movsd 0x240(%rsp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x240(%rsp)
movsd 0x2e0(%rsp), %xmm0
movsd 0x188(%rsp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x178(%rsp)
leaq 0x200(%rsp), %rdi
leaq 0x178(%rsp), %rsi
callq 0x4e170
jmp 0x4aa39
movq 0x300(%rsp), %rdi
callq 0x56b40
movq %rax, 0x58(%rsp)
jmp 0x4aa4d
movq 0x58(%rsp), %rax
movq %rax, %xmm0
movaps 0x30852(%rip), %xmm1    # 0x7b2b0
movaps %xmm1, 0x30(%rsp)
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x30851(%rip), %xmm1    # 0x7b2c0
movaps %xmm1, 0x40(%rsp)
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movsd %xmm0, 0x160(%rsp)
movq 0x300(%rsp), %rdi
addq $0x30, %rdi
callq 0x4dbe0
movaps 0x30(%rsp), %xmm2
movaps 0x40(%rsp), %xmm1
movq %rax, %xmm0
punpckldq %xmm2, %xmm0    # xmm0 = xmm0[0],xmm2[0],xmm0[1],xmm2[1]
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movsd %xmm0, 0x158(%rsp)
cvtsi2sdl 0x198(%rsp), %xmm0
movsd %xmm0, 0x150(%rsp)
cvtsi2sdl 0x19c(%rsp), %xmm0
movsd %xmm0, 0x148(%rsp)
movabsq $0x4062c00000000000, %rax # imm = 0x4062C00000000000
movq %rax, 0x140(%rsp)
cvtsi2sdl 0x1e8(%rsp), %xmm1
movsd 0x150(%rsp), %xmm0
divsd %xmm0, %xmm1
movsd 0x304f4(%rip), %xmm0    # 0x7b010
subsd %xmm1, %xmm0
movsd %xmm0, 0x138(%rsp)
movsd 0x138(%rsp), %xmm0
cvttsd2si 0x150(%rsp), %edi
cvttsd2si 0x148(%rsp), %esi
cvttsd2si 0x160(%rsp), %edx
cvttsd2si 0x158(%rsp), %ecx
movl $0x64, %r8d
callq 0x47870
movsd %xmm0, 0x170(%rsp)
movsd 0x138(%rsp), %xmm0
cvttsd2si 0x150(%rsp), %edi
cvttsd2si 0x148(%rsp), %esi
cvttsd2si 0x160(%rsp), %edx
cvttsd2si 0x158(%rsp), %ecx
cvttsd2si 0x140(%rsp), %r8d
callq 0x47870
movsd %xmm0, 0x168(%rsp)
movsd 0x170(%rsp), %xmm1
movsd 0x238(%rsp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x238(%rsp)
movsd 0x168(%rsp), %xmm1
movsd 0x230(%rsp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x230(%rsp)
movq $0x0, 0x128(%rsp)
movsd 0x1c0(%rsp), %xmm0
cvtsi2sdl 0x1ac(%rsp), %xmm1
divsd %xmm1, %xmm0
movsd 0x180(%rsp), %xmm1
subsd %xmm1, %xmm0
cvtsi2sdl 0x1ec(%rsp), %xmm2
movsd 0x128(%rsp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x128(%rsp)
movsd 0x1c8(%rsp), %xmm0
cvtsi2sdl 0x1b0(%rsp), %xmm1
divsd %xmm1, %xmm0
movsd 0x180(%rsp), %xmm1
subsd %xmm1, %xmm0
cvtsi2sdl 0x1f0(%rsp), %xmm2
movsd 0x128(%rsp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x128(%rsp)
movsd 0x2e0(%rsp), %xmm0
movsd 0x128(%rsp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x130(%rsp)
movsd 0x130(%rsp), %xmm0
leaq 0x30a9a(%rip), %rdi     # 0x7b74e
movb $0x1, %al
callq 0x9040
jmp 0x4acbd
movl 0x198(%rsp), %eax
movl %eax, 0x1c(%rsp)
cvtsi2sd %eax, %xmm0
movsd %xmm0, 0x20(%rsp)
movq 0x300(%rsp), %rdi
callq 0x56b40
movq %rax, 0x28(%rsp)
jmp 0x4ace6
movl 0x1c(%rsp), %esi
movsd 0x20(%rsp), %xmm0
movq 0x28(%rsp), %rax
movq %rax, %xmm1
movaps 0x305af(%rip), %xmm2    # 0x7b2b0
punpckldq %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
movapd 0x305b3(%rip), %xmm2    # 0x7b2c0
subpd %xmm2, %xmm1
movaps %xmm1, %xmm2
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm2, %xmm1
divsd %xmm1, %xmm0
leaq 0x30a49(%rip), %rdi     # 0x7b770
movb $0x1, %al
callq 0x9040
jmp 0x4ad30
movl 0x19c(%rsp), %eax
movl %eax, 0x18(%rsp)
cvtsi2sd %eax, %xmm0
movsd %xmm0, 0x10(%rsp)
movq 0x300(%rsp), %rdi
addq $0x30, %rdi
callq 0x4dbe0
movsd 0x10(%rsp), %xmm0
movl 0x18(%rsp), %esi
movq %rax, %xmm1
movaps 0x30544(%rip), %xmm2    # 0x7b2b0
punpckldq %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
movapd 0x30548(%rip), %xmm2    # 0x7b2c0
subpd %xmm2, %xmm1
movaps %xmm1, %xmm2
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm2, %xmm1
divsd %xmm1, %xmm0
leaq 0x309fe(%rip), %rdi     # 0x7b790
movb $0x1, %al
callq 0x9040
jmp 0x4ad9b
leaq 0x31080(%rip), %rdi     # 0x7be22
xorl %eax, %eax
callq 0x9040
jmp 0x4adab
movsd 0x188(%rsp), %xmm0
leaq 0x309f5(%rip), %rdi     # 0x7b7b0
movb $0x1, %al
callq 0x9040
jmp 0x4adc4
movsd 0x2e0(%rsp), %xmm0
movsd 0x188(%rsp), %xmm1
divsd %xmm1, %xmm0
movsd 0x168(%rsp), %xmm1
movsd 0x170(%rsp), %xmm2
leaq 0x309d7(%rip), %rdi     # 0x7b7ca
movb $0x3, %al
callq 0x9040
jmp 0x4adfc
leaq 0x3101f(%rip), %rdi     # 0x7be22
xorl %eax, %eax
callq 0x9040
jmp 0x4ae0c
movsd 0x1c0(%rsp), %xmm0
cvtsi2sdl 0x1ac(%rsp), %xmm1
divsd %xmm1, %xmm0
movsd 0x180(%rsp), %xmm2
movaps %xmm0, %xmm1
divsd %xmm2, %xmm1
leaq 0x309b3(%rip), %rdi     # 0x7b7ec
movb $0x2, %al
callq 0x9040
jmp 0x4ae42
movsd 0x1c8(%rsp), %xmm0
cvtsi2sdl 0x1b0(%rsp), %xmm1
divsd %xmm1, %xmm0
movsd 0x180(%rsp), %xmm2
movaps %xmm0, %xmm1
divsd %xmm2, %xmm1
leaq 0x309a5(%rip), %rdi     # 0x7b814
movb $0x2, %al
callq 0x9040
jmp 0x4ae78
movsd 0x180(%rsp), %xmm0
movaps %xmm0, %xmm1
divsd %xmm1, %xmm1
leaq 0x309ad(%rip), %rdi     # 0x7b83c
movb $0x2, %al
callq 0x9040
jmp 0x4ae98
leaq 0x30f83(%rip), %rdi     # 0x7be22
xorl %eax, %eax
callq 0x9040
jmp 0x4aea8
movl 0x1a8(%rsp), %edx
movl 0x1e8(%rsp), %r8d
cvtsi2sd %r8d, %xmm0
cvtsi2sdl 0x198(%rsp), %xmm1
divsd %xmm1, %xmm0
leaq 0x3099b(%rip), %rdi     # 0x7b86b
movl $0x8, %ecx
movb $0x1, %al
movl %ecx, %esi
callq 0x9040
jmp 0x4aee0
movl 0x1ac(%rsp), %edx
movl 0x1ec(%rsp), %r8d
cvtsi2sd %r8d, %xmm0
cvtsi2sdl 0x198(%rsp), %xmm1
divsd %xmm1, %xmm0
leaq 0x30991(%rip), %rdi     # 0x7b899
movl $0x8, %ecx
movb $0x1, %al
movl %ecx, %esi
callq 0x9040
jmp 0x4af18
movl 0x1b0(%rsp), %edx
movl 0x1f0(%rsp), %r8d
cvtsi2sd %r8d, %xmm0
cvtsi2sdl 0x198(%rsp), %xmm1
divsd %xmm1, %xmm0
leaq 0x30987(%rip), %rdi     # 0x7b8c7
movl $0x8, %ecx
movb $0x1, %al
movl %ecx, %esi
callq 0x9040
jmp 0x4af50
leaq 0x30ecb(%rip), %rdi     # 0x7be22
xorl %eax, %eax
callq 0x9040
jmp 0x4af60
movsd 0x1d0(%rsp), %xmm0
leaq 0x30985(%rip), %rdi     # 0x7b8f5
movb $0x1, %al
callq 0x9040
jmp 0x4af79
movsd 0x1e0(%rsp), %xmm0
leaq 0x30986(%rip), %rdi     # 0x7b90f
movb $0x1, %al
callq 0x9040
jmp 0x4af92
leaq 0x218(%rsp), %rdi
leaq 0x198(%rsp), %rsi
callq 0x4e0a0
jmp 0x4afa9
jmp 0x4afab
movl 0x1fc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1fc(%rsp)
jmp 0x4a7a3
movsd 0x240(%rsp), %xmm0
cvtsi2sdl 0x2fc(%rsp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x120(%rsp)
movsd 0x238(%rsp), %xmm0
cvtsi2sdl 0x2fc(%rsp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x118(%rsp)
movsd 0x230(%rsp), %xmm0
cvtsi2sdl 0x2fc(%rsp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x110(%rsp)
movsd 0x120(%rsp), %xmm0
movsd 0x110(%rsp), %xmm1
movsd 0x118(%rsp), %xmm2
leaq 0x308e6(%rip), %rdi     # 0x7b926
movb $0x3, %al
callq 0x9040
jmp 0x4b049
leaq 0xd0(%rsp), %rdi
leaq 0x200(%rsp), %rsi
callq 0x4de90
jmp 0x4b060
leaq 0xd0(%rsp), %rdi
leaq 0x108(%rsp), %rsi
leaq 0xf8(%rsp), %rdx
leaq 0x100(%rsp), %rcx
leaq 0xf0(%rsp), %r8
leaq 0xe8(%rsp), %r9
callq 0x78710
jmp 0x4b097
leaq 0xd0(%rsp), %rdi
callq 0xfa50
movsd 0xf8(%rsp), %xmm0
movsd 0x301eb(%rip), %xmm1    # 0x7b2a0
mulsd %xmm1, %xmm0
movsd %xmm0, (%rsp)
movl 0x2fc(%rsp), %edi
callq 0x4df90
movsd %xmm0, 0x8(%rsp)
jmp 0x4b0d2
movsd 0x8(%rsp), %xmm1
movsd (%rsp), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, 0xc8(%rsp)
movsd 0x108(%rsp), %xmm0
movsd 0xc8(%rsp), %xmm1
subsd %xmm1, %xmm0
movsd %xmm0, 0xc0(%rsp)
movsd 0x108(%rsp), %xmm0
movsd 0xc8(%rsp), %xmm1
addsd %xmm1, %xmm0
movsd %xmm0, 0xb8(%rsp)
movsd 0xc0(%rsp), %xmm0
movsd 0xb8(%rsp), %xmm1
leaq 0x303bf(%rip), %rdi     # 0x7b500
movb $0x2, %al
callq 0x9040
jmp 0x4b14a
leaq 0x200(%rsp), %rdi
callq 0xfa50
leaq 0x218(%rsp), %rdi
callq 0x4e110
leaq 0x290(%rsp), %rdi
callq 0x2d420
addq $0x308, %rsp            # imm = 0x308
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x288(%rsp)
movl %eax, 0x284(%rsp)
leaq 0xd0(%rsp), %rdi
callq 0xfa50
leaq 0x200(%rsp), %rdi
callq 0xfa50
leaq 0x218(%rsp), %rdi
callq 0x4e110
leaq 0x290(%rsp), %rdi
callq 0x2d420
movq 0x288(%rsp), %rdi
callq 0x9cf0
nop