// File: /workspace/github_cpp_makefile_star2_O1/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1b8, %rsp            # imm = 0x1B8
movq %rcx, %r14
movsd %xmm0, 0x38(%rsp)
movl %edx, %ebp
movl %esi, %ebx
movq %rdi, %r15
leaq 0x18d9b(%rip), %rdi     # 0x31b40
callq 0x2350
movq 0x108(%r15), %rsi
leaq 0x18498(%rip), %rdi     # 0x31250
xorl %eax, %eax
callq 0x2030
movq %r15, %rdi
callq 0x1e160
leaq 0x18490(%rip), %rdi     # 0x3125e
movq %rax, %rsi
xorl %eax, %eax
callq 0x2030
movq 0x58(%r15), %rsi
leaq 0x18490(%rip), %rdi     # 0x31273
xorl %eax, %eax
callq 0x2030
leaq 0x18497(%rip), %rdi     # 0x31288
xorl %eax, %eax
callq 0x2030
leaq 0x110(%rsp), %rdi
xorl %esi, %esi
callq 0x2360
leaq 0x188(%rsp), %rdi
movq %r15, %rsi
movl %ebp, %edx
callq 0xb150
leaq 0x120(%rsp), %r12
movq %r12, %rdi
xorl %esi, %esi
callq 0x2360
xorps %xmm0, %xmm0
cvtsi2sdq -0x10(%r12), %xmm0
movsd %xmm0, 0xd0(%rsp)
xorps %xmm0, %xmm0
cvtsi2sdq -0x8(%r12), %xmm0
movsd %xmm0, 0x8(%rsp)
xorps %xmm0, %xmm0
cvtsi2sdq (%r12), %xmm0
movsd %xmm0, 0x100(%rsp)
xorps %xmm0, %xmm0
cvtsi2sdq 0x8(%r12), %xmm0
movsd %xmm0, 0x10(%rsp)
movq %r15, %rdi
callq 0x1e160
movsd 0x18320(%rip), %xmm0    # 0x311a0
movsd 0x8(%rsp), %xmm2
divsd %xmm0, %xmm2
addsd 0xd0(%rsp), %xmm2
movsd 0x10(%rsp), %xmm1
divsd %xmm0, %xmm1
addsd 0x100(%rsp), %xmm1
movq %rax, %xmm0
punpckldq 0x1836d(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subsd %xmm2, %xmm1
subpd 0x18371(%rip), %xmm0    # 0x31230
movapd %xmm0, %xmm2
unpckhpd %xmm0, %xmm2            # xmm2 = xmm2[1],xmm0[1]
addsd %xmm0, %xmm2
cvtsi2sd %ebp, %xmm3
mulsd %xmm1, %xmm2
divsd %xmm3, %xmm2
movsd 0x38(%rsp), %xmm0
ucomisd %xmm2, %xmm0
movapd %xmm2, 0x130(%rsp)
jbe 0x18fdf
leaq 0x110(%rsp), %rdi
xorl %esi, %esi
callq 0x2360
leaq 0x48(%rsp), %rdi
movq %r15, %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0xb150
leaq 0x120(%rsp), %rdi
xorl %esi, %esi
callq 0x2360
cvtsi2sdq 0x110(%rsp), %xmm4
xorps %xmm1, %xmm1
cvtsi2sdq 0x118(%rsp), %xmm1
movsd 0x18261(%rip), %xmm3    # 0x311a0
divsd %xmm3, %xmm1
xorps %xmm2, %xmm2
cvtsi2sdq 0x120(%rsp), %xmm2
xorps %xmm0, %xmm0
cvtsi2sdq 0x128(%rsp), %xmm0
addsd %xmm4, %xmm1
divsd %xmm3, %xmm0
addsd %xmm2, %xmm0
subsd %xmm1, %xmm0
leaq 0x184e6(%rip), %rdi     # 0x3145a
movsd %xmm0, 0x28(%rsp)
movb $0x1, %al
callq 0x2030
movq %r15, %rdi
callq 0x1e160
movq %rax, %xmm0
punpckldq 0x1828a(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x18292(%rip), %xmm0    # 0x31230
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movsd 0x28(%rsp), %xmm0
divsd %xmm1, %xmm0
leaq 0x1839e(%rip), %rdi     # 0x31359
movb $0x1, %al
callq 0x2030
leaq 0x18b49(%rip), %rdi     # 0x31b12
callq 0x2350
leaq 0x48(%rsp), %rdi
callq 0xd8b4
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0x19026
leaq 0x18474(%rip), %rdi     # 0x3145a
movapd %xmm2, %xmm0
movb $0x1, %al
movsd %xmm1, 0x10(%rsp)
movsd %xmm3, 0x8(%rsp)
callq 0x2030
movsd 0x10(%rsp), %xmm0
divsd 0x8(%rsp), %xmm0
leaq 0x18349(%rip), %rdi     # 0x31359
movb $0x1, %al
callq 0x2030
movapd 0x130(%rsp), %xmm0
movsd %xmm0, 0x28(%rsp)
movq 0x8(%r14), %rax
cmpq (%r14), %rax
jne 0x19048
leaq 0x18af6(%rip), %rdi     # 0x31b2c
callq 0x2350
movl %ebx, %edi
movq %r15, %rsi
movq %r14, %rdx
callq 0x16f89
movl %ebx, 0xac(%rsp)
xorpd %xmm0, %xmm0
movapd %xmm0, 0xe0(%rsp)
xorl %eax, %eax
movq %rax, 0xf0(%rsp)
movq %rax, 0xc0(%rsp)
movapd %xmm0, 0xb0(%rsp)
movq (%r14), %rax
cmpq %rax, 0x8(%r14)
je 0x195f2
movapd %xmm0, 0xd0(%rsp)
movapd 0x130(%rsp), %xmm0
cmpltsd 0x38(%rsp), %xmm0
movapd %xmm0, 0x160(%rsp)
xorpd %xmm0, %xmm0
movsd %xmm0, 0x30(%rsp)
xorl %r12d, %r12d
movl (%rax,%r12,8), %r13d
movl 0x4(%rax,%r12,8), %ebx
leaq 0x18489(%rip), %rdi     # 0x3154c
movl %r13d, %esi
movl %ebx, %edx
xorl %eax, %eax
callq 0x2030
leaq 0x110(%rsp), %rdi
xorl %esi, %esi
callq 0x2360
movq %r15, %rdi
movl %r13d, %esi
movl %ebx, %edx
leaq 0x48(%rsp), %rcx
movl %ebp, %r8d
movl %ebp, %r9d
callq 0x1e9f4
leaq 0x120(%rsp), %rdi
xorl %esi, %esi
callq 0x2360
movsd 0x88(%rsp), %xmm0
addsd 0x80(%rsp), %xmm0
movapd %xmm0, 0x10(%rsp)
movq %r15, %rdi
movl %r13d, %esi
movl %ebx, %edx
leaq 0x20(%rsp), %rcx
movl %ebp, %r8d
callq 0x1ec3a
cmpl $0x0, 0x58(%rsp)
jne 0x1914a
movl $0x1, 0x58(%rsp)
movq $0x0, 0x68(%rsp)
cmpl $0x0, 0x5c(%rsp)
movapd 0x10(%rsp), %xmm2
jne 0x19168
movl $0x1, 0x5c(%rsp)
movq $0x0, 0x70(%rsp)
cmpl $0x0, 0x60(%rsp)
jne 0x19180
movl $0x1, 0x60(%rsp)
movq $0x0, 0x78(%rsp)
andpd 0x160(%rsp), %xmm2
movsd 0x38(%rsp), %xmm0
ucomisd 0x130(%rsp), %xmm0
ja 0x191c3
movupd 0x70(%rsp), %xmm0
cvtdq2pd 0x9c(%rsp), %xmm1
mulpd %xmm0, %xmm1
cvtdq2pd 0x5c(%rsp), %xmm0
divpd %xmm0, %xmm1
addsd %xmm1, %xmm2
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm1, %xmm2
movsd 0x28(%rsp), %xmm0
movapd %xmm2, 0x10(%rsp)
divsd %xmm2, %xmm0
movsd %xmm0, 0x40(%rsp)
movq 0xb8(%rsp), %rsi
cmpq 0xc0(%rsp), %rsi
movsd %xmm0, 0x8(%rsp)
je 0x19203
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0xb8(%rsp)
jmp 0x19215
leaq 0xb0(%rsp), %rdi
leaq 0x40(%rsp), %rdx
callq 0x1bd76
movq %r15, %rdi
callq 0x1e160
xorps %xmm0, %xmm0
cvtsi2sdl 0x98(%rsp), %xmm0
movl 0x48(%rsp), %ecx
movd %ecx, %xmm1
addl 0x4c(%rsp), %ecx
movd %eax, %xmm2
addl 0x58(%r15), %eax
movd %ecx, %xmm3
punpckldq %xmm1, %xmm3    # xmm3 = xmm3[0],xmm1[0],xmm3[1],xmm1[1]
cvtdq2pd %xmm3, %xmm1
movapd %xmm1, %xmm3
unpckhpd %xmm1, %xmm3            # xmm3 = xmm3[1],xmm1[1]
divsd %xmm3, %xmm0
movsd 0x17dd3(%rip), %xmm5    # 0x31030
movapd %xmm5, %xmm3
movd %eax, %xmm4
punpckldq %xmm2, %xmm4    # xmm4 = xmm4[0],xmm2[0],xmm4[1],xmm2[1]
cvtdq2pd %xmm4, %xmm2
subsd %xmm0, %xmm3
divpd %xmm2, %xmm1
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
mulsd %xmm3, %xmm0
mulsd %xmm1, %xmm0
divsd %xmm0, %xmm5
mulsd 0x17f57(%rip), %xmm5    # 0x311e8
unpcklpd %xmm5, %xmm5            # xmm5 = xmm5[0,0]
divpd 0x17fa3(%rip), %xmm5    # 0x31240
movapd %xmm5, 0x100(%rsp)
movsd 0x70(%rsp), %xmm0
xorps %xmm1, %xmm1
cvtsi2sdl 0x5c(%rsp), %xmm1
divsd %xmm1, %xmm0
movsd 0x20(%rsp), %xmm1
subsd %xmm1, %xmm0
xorps %xmm2, %xmm2
cvtsi2sdl 0x9c(%rsp), %xmm2
mulsd %xmm0, %xmm2
addsd 0x17f1d(%rip), %xmm2    # 0x311f8
movsd 0x78(%rsp), %xmm0
xorps %xmm3, %xmm3
cvtsi2sdl 0x60(%rsp), %xmm3
divsd %xmm3, %xmm0
subsd %xmm1, %xmm0
xorps %xmm1, %xmm1
cvtsi2sdl 0xa0(%rsp), %xmm1
mulsd %xmm0, %xmm1
addsd %xmm2, %xmm1
movsd 0x28(%rsp), %xmm0
divsd %xmm1, %xmm0
leaq 0x18326(%rip), %rdi     # 0x3163d
movb $0x1, %al
callq 0x2030
movl 0x48(%rsp), %ebx
movq %r15, %rdi
callq 0x1e160
xorps %xmm0, %xmm0
cvtsi2sd %ebx, %xmm0
movq %rax, %xmm1
movq 0x17ee2(%rip), %xmm2    # 0x31220
punpckldq %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
movapd 0x17ee6(%rip), %xmm2    # 0x31230
subpd %xmm2, %xmm1
movapd %xmm1, %xmm2
unpckhpd %xmm1, %xmm2            # xmm2 = xmm2[1],xmm1[1]
addsd %xmm1, %xmm2
divsd %xmm2, %xmm0
leaq 0x182fa(%rip), %rdi     # 0x3165f
movl %ebx, %esi
movb $0x1, %al
callq 0x2030
movl 0x4c(%rsp), %esi
xorps %xmm0, %xmm0
cvtsi2sd %esi, %xmm0
movsd 0x58(%r15), %xmm1
unpcklps 0x17e9a(%rip), %xmm1    # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x17ea2(%rip), %xmm1    # 0x31230
movapd %xmm1, %xmm2
unpckhpd %xmm1, %xmm2            # xmm2 = xmm2[1],xmm1[1]
addsd %xmm1, %xmm2
divsd %xmm2, %xmm0
leaq 0x182da(%rip), %rdi     # 0x3167f
movb $0x1, %al
callq 0x2030
movl $0xa, %edi
callq 0x22f0
leaq 0x182e2(%rip), %rdi     # 0x3169f
movaps 0x10(%rsp), %xmm0
movb $0x1, %al
callq 0x2030
movapd 0x100(%rsp), %xmm1
movapd %xmm1, %xmm2
unpckhpd %xmm1, %xmm2            # xmm2 = xmm2[1],xmm1[1]
leaq 0x182d8(%rip), %rdi     # 0x316b9
movsd 0x8(%rsp), %xmm0
movb $0x3, %al
callq 0x2030
movl $0xa, %edi
callq 0x22f0
movsd 0x70(%rsp), %xmm0
xorps %xmm1, %xmm1
cvtsi2sdl 0x5c(%rsp), %xmm1
divsd %xmm1, %xmm0
movapd %xmm0, %xmm1
divsd 0x20(%rsp), %xmm1
leaq 0x182bf(%rip), %rdi     # 0x316db
movb $0x2, %al
callq 0x2030
movsd 0x78(%rsp), %xmm0
xorps %xmm1, %xmm1
cvtsi2sdl 0x60(%rsp), %xmm1
divsd %xmm1, %xmm0
movapd %xmm0, %xmm1
divsd 0x20(%rsp), %xmm1
leaq 0x182bc(%rip), %rdi     # 0x31703
movb $0x2, %al
callq 0x2030
movsd 0x20(%rsp), %xmm0
movapd %xmm0, %xmm1
divsd %xmm0, %xmm1
leaq 0x182c8(%rip), %rdi     # 0x3172b
movb $0x2, %al
callq 0x2030
movl $0xa, %edi
callq 0x22f0
movl 0x98(%rsp), %r8d
xorps %xmm0, %xmm0
cvtsi2sd %r8d, %xmm0
movl 0x58(%rsp), %edx
xorps %xmm1, %xmm1
cvtsi2sdl 0x48(%rsp), %xmm1
divsd %xmm1, %xmm0
leaq 0x182be(%rip), %rdi     # 0x3175a
movl $0x8, %esi
movl $0x8, %ecx
movb $0x1, %al
callq 0x2030
movl 0x9c(%rsp), %r8d
xorps %xmm0, %xmm0
cvtsi2sd %r8d, %xmm0
movl 0x5c(%rsp), %edx
xorps %xmm1, %xmm1
cvtsi2sdl 0x48(%rsp), %xmm1
divsd %xmm1, %xmm0
leaq 0x182b3(%rip), %rdi     # 0x31788
movl $0x8, %esi
movl $0x8, %ecx
movb $0x1, %al
callq 0x2030
movl 0xa0(%rsp), %r8d
xorps %xmm0, %xmm0
cvtsi2sd %r8d, %xmm0
movl 0x60(%rsp), %edx
xorps %xmm1, %xmm1
cvtsi2sdl 0x48(%rsp), %xmm1
divsd %xmm1, %xmm0
leaq 0x182a8(%rip), %rdi     # 0x317b6
movl $0x8, %esi
movl $0x8, %ecx
movb $0x1, %al
callq 0x2030
movl $0xa, %edi
callq 0x22f0
movsd 0x80(%rsp), %xmm0
leaq 0x182ab(%rip), %rdi     # 0x317e4
movb $0x1, %al
callq 0x2030
movsd 0x90(%rsp), %xmm0
leaq 0x182ae(%rip), %rdi     # 0x317fe
movb $0x1, %al
callq 0x2030
movq 0xe8(%rsp), %rax
cmpq 0xf0(%rsp), %rax
je 0x19590
movl $0xc, %ecx
movq %rax, %rdi
leaq 0x48(%rsp), %rsi
rep  movsq (%rsi), %es:(%rdi)
addq $0x60, %rax
movq %rax, 0xe8(%rsp)
movapd 0x100(%rsp), %xmm1
jmp 0x195ae
leaq 0xe0(%rsp), %rdi
movq %rax, %rsi
leaq 0x48(%rsp), %rdx
callq 0x1bc08
movapd 0x100(%rsp), %xmm1
movsd 0x30(%rsp), %xmm0
addsd 0x8(%rsp), %xmm0
movsd %xmm0, 0x30(%rsp)
movapd 0xd0(%rsp), %xmm0
addpd %xmm1, %xmm0
movapd %xmm0, 0xd0(%rsp)
incq %r12
movq (%r14), %rax
movq 0x8(%r14), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
cmpq %r12, %rcx
ja 0x190b3
jmp 0x19605
movapd %xmm0, 0xd0(%rsp)
xorpd %xmm0, %xmm0
movsd %xmm0, 0x30(%rsp)
xorps %xmm3, %xmm3
cvtsi2sdl 0xac(%rsp), %xmm3
movsd 0x30(%rsp), %xmm0
divsd %xmm3, %xmm0
movapd 0xd0(%rsp), %xmm1
movapd %xmm1, %xmm2
unpckhpd %xmm1, %xmm2            # xmm2 = xmm2[1],xmm1[1]
divsd %xmm3, %xmm2
movsd %xmm3, 0x10(%rsp)
divsd %xmm3, %xmm1
leaq 0x181d4(%rip), %rdi     # 0x31815
movb $0x3, %al
callq 0x2030
leaq 0x148(%rsp), %rdi
leaq 0xb0(%rsp), %rsi
callq 0x1b35e
leaq 0x148(%rsp), %rdi
leaq 0x48(%rsp), %rsi
leaq 0x40(%rsp), %rdx
leaq 0x20(%rsp), %rcx
leaq 0x180(%rsp), %r8
leaq 0x178(%rsp), %r9
callq 0x2fae4
movq 0x148(%rsp), %rdi
testq %rdi, %rdi
je 0x196a6
movq 0x158(%rsp), %rsi
subq %rdi, %rsi
callq 0x2250
movsd 0x40(%rsp), %xmm1
mulsd 0x17b3c(%rip), %xmm1    # 0x311f0
xorpd %xmm0, %xmm0
movsd 0x10(%rsp), %xmm2
ucomisd %xmm0, %xmm2
movapd %xmm2, %xmm0
jb 0x196ce
sqrtsd %xmm0, %xmm0
jmp 0x196df
movsd %xmm1, 0x10(%rsp)
callq 0x21d0
movsd 0x10(%rsp), %xmm1
divsd %xmm0, %xmm1
movsd 0x48(%rsp), %xmm2
movapd %xmm2, %xmm0
subsd %xmm1, %xmm0
addsd %xmm2, %xmm1
leaq 0x17d0e(%rip), %rdi     # 0x3140a
movb $0x2, %al
callq 0x2030
movq 0xb0(%rsp), %rdi
testq %rdi, %rdi
je 0x19720
movq 0xc0(%rsp), %rsi
subq %rdi, %rsi
callq 0x2250
movq 0xe0(%rsp), %rdi
testq %rdi, %rdi
je 0x1973d
movq 0xf0(%rsp), %rsi
subq %rdi, %rsi
callq 0x2250
leaq 0x188(%rsp), %rdi
callq 0xd8b4
addq $0x1b8, %rsp            # imm = 0x1B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x19793
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0xd8b4
jmp 0x197dd
jmp 0x19793
movq %rax, %rbx
movq 0x148(%rsp), %rdi
testq %rdi, %rdi
je 0x197a3
movq 0x158(%rsp), %rsi
subq %rdi, %rsi
callq 0x2250
jmp 0x197a3
jmp 0x197a0
movq %rax, %rbx
jmp 0x197dd
jmp 0x197a0
jmp 0x197a0
jmp 0x197a0
jmp 0x197a0
movq %rax, %rbx
movq 0xb0(%rsp), %rdi
testq %rdi, %rdi
je 0x197c0
movq 0xc0(%rsp), %rsi
subq %rdi, %rsi
callq 0x2250
movq 0xe0(%rsp), %rdi
testq %rdi, %rdi
je 0x197dd
movq 0xf0(%rsp), %rsi
subq %rdi, %rsi
callq 0x2250
leaq 0x188(%rsp), %rdi
callq 0xd8b4
movq %rbx, %rdi
callq 0x23b0