// File: /workspace/github_cpp_makefile_star2_O3/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 $0x1a8, %rsp            # imm = 0x1A8
movq %rcx, %r14
movsd %xmm0, 0x110(%rsp)
movl %edx, %ebp
movl %esi, %ebx
movq %rdi, %r15
leaq 0x17e44(%rip), %rdi     # 0x30b40
callq 0x2350
movq 0x108(%r15), %rsi
leaq 0x17541(%rip), %rdi     # 0x30250
xorl %eax, %eax
callq 0x2030
movq %r15, %rdi
callq 0x1dfcc
leaq 0x17539(%rip), %rdi     # 0x3025e
movq %rax, %rsi
xorl %eax, %eax
callq 0x2030
movq 0x58(%r15), %rsi
leaq 0x17539(%rip), %rdi     # 0x30273
xorl %eax, %eax
callq 0x2030
leaq 0x17540(%rip), %rdi     # 0x30288
xorl %eax, %eax
callq 0x2030
leaq 0x118(%rsp), %rdi
xorl %esi, %esi
callq 0x2360
leaq 0x178(%rsp), %rdi
movq %r15, %rsi
movl %ebp, %edx
callq 0xb162
leaq 0x128(%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 0x1dfcc
movsd 0x173c9(%rip), %xmm0    # 0x301a0
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 0x17416(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subsd %xmm2, %xmm1
subpd 0x1741a(%rip), %xmm0    # 0x30230
movapd %xmm0, %xmm2
unpckhpd %xmm0, %xmm2            # xmm2 = xmm2[1],xmm0[1]
addsd %xmm0, %xmm2
cvtsi2sd %ebp, %xmm3
mulsd %xmm1, %xmm2
divsd %xmm3, %xmm2
movsd 0x110(%rsp), %xmm0
ucomisd %xmm2, %xmm0
movapd %xmm2, 0x150(%rsp)
jbe 0x18f39
leaq 0x118(%rsp), %rdi
xorl %esi, %esi
callq 0x2360
leaq 0x50(%rsp), %rdi
movq %r15, %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0xb162
leaq 0x128(%rsp), %rdi
xorl %esi, %esi
callq 0x2360
cvtsi2sdq 0x118(%rsp), %xmm4
xorps %xmm1, %xmm1
cvtsi2sdq 0x120(%rsp), %xmm1
movsd 0x17307(%rip), %xmm3    # 0x301a0
divsd %xmm3, %xmm1
xorps %xmm2, %xmm2
cvtsi2sdq 0x128(%rsp), %xmm2
xorps %xmm0, %xmm0
cvtsi2sdq 0x130(%rsp), %xmm0
addsd %xmm4, %xmm1
divsd %xmm3, %xmm0
addsd %xmm2, %xmm0
subsd %xmm1, %xmm0
leaq 0x1758c(%rip), %rdi     # 0x3045a
movsd %xmm0, 0x30(%rsp)
movb $0x1, %al
callq 0x2030
movq %r15, %rdi
callq 0x1dfcc
movq %rax, %xmm0
punpckldq 0x17330(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x17338(%rip), %xmm0    # 0x30230
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movsd 0x30(%rsp), %xmm0
divsd %xmm1, %xmm0
leaq 0x17444(%rip), %rdi     # 0x30359
movb $0x1, %al
callq 0x2030
leaq 0x17bef(%rip), %rdi     # 0x30b12
callq 0x2350
leaq 0x50(%rsp), %rdi
callq 0xd912
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0x18f80
leaq 0x1751a(%rip), %rdi     # 0x3045a
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 0x173ef(%rip), %rdi     # 0x30359
movb $0x1, %al
callq 0x2030
movapd 0x150(%rsp), %xmm0
movsd %xmm0, 0x30(%rsp)
movq (%r14), %rax
movq 0x8(%r14), %rcx
cmpq %rax, %rcx
jne 0x18fac
leaq 0x17b99(%rip), %rdi     # 0x30b2c
callq 0x2350
movl %ebx, %edi
movq %r15, %rsi
movq %r14, %rdx
callq 0x16ecd
movq (%r14), %rax
movq 0x8(%r14), %rcx
movl %ebx, 0x4c(%rsp)
xorpd %xmm0, %xmm0
movapd %xmm0, 0xe0(%rsp)
xorl %edx, %edx
movq %rdx, 0xf0(%rsp)
movq %rdx, 0xc0(%rsp)
movapd %xmm0, 0xb0(%rsp)
cmpq %rax, %rcx
je 0x19553
movapd %xmm0, 0xd0(%rsp)
xorpd %xmm0, %xmm0
movsd %xmm0, 0x38(%rsp)
xorl %r12d, %r12d
movl (%rax,%r12,8), %r13d
movl 0x4(%rax,%r12,8), %ebx
leaq 0x17545(%rip), %rdi     # 0x3054c
movl %r13d, %esi
movl %ebx, %edx
xorl %eax, %eax
callq 0x2030
leaq 0x118(%rsp), %rdi
xorl %esi, %esi
callq 0x2360
movq %r15, %rdi
movl %r13d, %esi
movl %ebx, %edx
leaq 0x50(%rsp), %rcx
movl %ebp, %r8d
movl %ebp, %r9d
callq 0x1e880
leaq 0x128(%rsp), %rdi
xorl %esi, %esi
callq 0x2360
movsd 0x90(%rsp), %xmm0
addsd 0x88(%rsp), %xmm0
movapd %xmm0, 0x10(%rsp)
movq %r15, %rdi
movl %r13d, %esi
movl %ebx, %edx
leaq 0x28(%rsp), %rcx
movl %ebp, %r8d
callq 0x1eac6
cmpl $0x0, 0x60(%rsp)
jne 0x1908e
movl $0x1, 0x60(%rsp)
movq $0x0, 0x70(%rsp)
movl 0x64(%rsp), %eax
testl %eax, %eax
jne 0x190ac
movl $0x1, 0x64(%rsp)
movq $0x0, 0x78(%rsp)
movl $0x1, %eax
movl 0x68(%rsp), %ecx
testl %ecx, %ecx
jne 0x190cd
movl $0x1, 0x68(%rsp)
movq $0x0, 0x80(%rsp)
movl $0x1, %ecx
movsd 0x110(%rsp), %xmm0
ucomisd 0x150(%rsp), %xmm0
ja 0x19122
movd %ecx, %xmm0
movd %eax, %xmm1
punpckldq %xmm0, %xmm1    # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
cvtdq2pd %xmm1, %xmm0
cvtdq2pd 0xa4(%rsp), %xmm2
movupd 0x78(%rsp), %xmm1
mulpd %xmm1, %xmm2
divpd %xmm0, %xmm2
movapd %xmm2, %xmm0
addsd 0x170e4(%rip), %xmm0    # 0x301f8
unpckhpd %xmm2, %xmm2            # xmm2 = xmm2[1,1]
addsd %xmm0, %xmm2
movapd %xmm2, 0x10(%rsp)
movsd 0x30(%rsp), %xmm0
divsd 0x10(%rsp), %xmm0
movsd %xmm0, 0x40(%rsp)
movq 0xb8(%rsp), %rsi
cmpq 0xc0(%rsp), %rsi
movsd %xmm0, 0x8(%rsp)
je 0x1915e
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0xb8(%rsp)
jmp 0x19170
leaq 0xb0(%rsp), %rdi
leaq 0x40(%rsp), %rdx
callq 0x1bc90
movq %r15, %rdi
callq 0x1dfcc
xorps %xmm0, %xmm0
cvtsi2sdl 0xa0(%rsp), %xmm0
movl 0x50(%rsp), %ecx
movd %ecx, %xmm1
addl 0x54(%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 0x16e78(%rip), %xmm5    # 0x30030
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 0x16ffc(%rip), %xmm5    # 0x301e8
unpcklpd %xmm5, %xmm5            # xmm5 = xmm5[0,0]
divpd 0x17048(%rip), %xmm5    # 0x30240
movapd %xmm5, 0x100(%rsp)
movsd 0x78(%rsp), %xmm0
xorps %xmm1, %xmm1
cvtsi2sdl 0x64(%rsp), %xmm1
divsd %xmm1, %xmm0
movsd 0x28(%rsp), %xmm1
subsd %xmm1, %xmm0
xorps %xmm2, %xmm2
cvtsi2sdl 0xa4(%rsp), %xmm2
mulsd %xmm0, %xmm2
addsd 0x16fc2(%rip), %xmm2    # 0x301f8
movsd 0x80(%rsp), %xmm0
xorps %xmm3, %xmm3
cvtsi2sdl 0x68(%rsp), %xmm3
divsd %xmm3, %xmm0
subsd %xmm1, %xmm0
xorps %xmm1, %xmm1
cvtsi2sdl 0xa8(%rsp), %xmm1
mulsd %xmm0, %xmm1
addsd %xmm2, %xmm1
movsd 0x30(%rsp), %xmm0
divsd %xmm1, %xmm0
leaq 0x173c8(%rip), %rdi     # 0x3063d
movb $0x1, %al
callq 0x2030
movl 0x50(%rsp), %ebx
movq %r15, %rdi
callq 0x1dfcc
xorps %xmm0, %xmm0
cvtsi2sd %ebx, %xmm0
movq %rax, %xmm1
movq 0x16f84(%rip), %xmm2    # 0x30220
punpckldq %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
movapd 0x16f88(%rip), %xmm2    # 0x30230
subpd %xmm2, %xmm1
movapd %xmm1, %xmm2
unpckhpd %xmm1, %xmm2            # xmm2 = xmm2[1],xmm1[1]
addsd %xmm1, %xmm2
divsd %xmm2, %xmm0
leaq 0x1739c(%rip), %rdi     # 0x3065f
movl %ebx, %esi
movb $0x1, %al
callq 0x2030
movl 0x54(%rsp), %esi
xorps %xmm0, %xmm0
cvtsi2sd %esi, %xmm0
movsd 0x58(%r15), %xmm1
unpcklps 0x16f3c(%rip), %xmm1    # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x16f44(%rip), %xmm1    # 0x30230
movapd %xmm1, %xmm2
unpckhpd %xmm1, %xmm2            # xmm2 = xmm2[1],xmm1[1]
addsd %xmm1, %xmm2
divsd %xmm2, %xmm0
leaq 0x1737c(%rip), %rdi     # 0x3067f
movb $0x1, %al
callq 0x2030
movl $0xa, %edi
callq 0x22f0
leaq 0x17384(%rip), %rdi     # 0x3069f
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 0x1737a(%rip), %rdi     # 0x306b9
movsd 0x8(%rsp), %xmm0
movb $0x3, %al
callq 0x2030
movl $0xa, %edi
callq 0x22f0
movsd 0x78(%rsp), %xmm0
xorps %xmm1, %xmm1
cvtsi2sdl 0x64(%rsp), %xmm1
divsd %xmm1, %xmm0
movapd %xmm0, %xmm1
divsd 0x28(%rsp), %xmm1
leaq 0x17361(%rip), %rdi     # 0x306db
movb $0x2, %al
callq 0x2030
movsd 0x80(%rsp), %xmm0
xorps %xmm1, %xmm1
cvtsi2sdl 0x68(%rsp), %xmm1
divsd %xmm1, %xmm0
movapd %xmm0, %xmm1
divsd 0x28(%rsp), %xmm1
leaq 0x1735b(%rip), %rdi     # 0x30703
movb $0x2, %al
callq 0x2030
movsd 0x28(%rsp), %xmm0
movapd %xmm0, %xmm1
divsd %xmm0, %xmm1
leaq 0x17367(%rip), %rdi     # 0x3072b
movb $0x2, %al
callq 0x2030
movl $0xa, %edi
callq 0x22f0
movl 0xa0(%rsp), %r8d
xorps %xmm0, %xmm0
cvtsi2sd %r8d, %xmm0
movl 0x60(%rsp), %edx
xorps %xmm1, %xmm1
cvtsi2sdl 0x50(%rsp), %xmm1
divsd %xmm1, %xmm0
leaq 0x1735d(%rip), %rdi     # 0x3075a
movl $0x8, %esi
movl $0x8, %ecx
movb $0x1, %al
callq 0x2030
movl 0xa4(%rsp), %r8d
xorps %xmm0, %xmm0
cvtsi2sd %r8d, %xmm0
movl 0x64(%rsp), %edx
xorps %xmm1, %xmm1
cvtsi2sdl 0x50(%rsp), %xmm1
divsd %xmm1, %xmm0
leaq 0x17352(%rip), %rdi     # 0x30788
movl $0x8, %esi
movl $0x8, %ecx
movb $0x1, %al
callq 0x2030
movl 0xa8(%rsp), %r8d
xorps %xmm0, %xmm0
cvtsi2sd %r8d, %xmm0
movl 0x68(%rsp), %edx
xorps %xmm1, %xmm1
cvtsi2sdl 0x50(%rsp), %xmm1
divsd %xmm1, %xmm0
leaq 0x17347(%rip), %rdi     # 0x307b6
movl $0x8, %esi
movl $0x8, %ecx
movb $0x1, %al
callq 0x2030
movl $0xa, %edi
callq 0x22f0
movsd 0x88(%rsp), %xmm0
leaq 0x1734a(%rip), %rdi     # 0x307e4
movb $0x1, %al
callq 0x2030
movsd 0x98(%rsp), %xmm0
leaq 0x1734d(%rip), %rdi     # 0x307fe
movb $0x1, %al
callq 0x2030
movq 0xe8(%rsp), %rax
cmpq 0xf0(%rsp), %rax
je 0x194f1
movl $0xc, %ecx
movq %rax, %rdi
leaq 0x50(%rsp), %rsi
rep  movsq (%rsi), %es:(%rdi)
addq $0x60, %rax
movq %rax, 0xe8(%rsp)
movapd 0x100(%rsp), %xmm1
jmp 0x1950f
leaq 0xe0(%rsp), %rdi
movq %rax, %rsi
leaq 0x50(%rsp), %rdx
callq 0x1bb22
movapd 0x100(%rsp), %xmm1
movsd 0x38(%rsp), %xmm0
addsd 0x8(%rsp), %xmm0
movsd %xmm0, 0x38(%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 0x18ff7
jmp 0x19566
movapd %xmm0, 0xd0(%rsp)
xorpd %xmm0, %xmm0
movsd %xmm0, 0x38(%rsp)
xorps %xmm3, %xmm3
cvtsi2sdl 0x4c(%rsp), %xmm3
movsd 0x38(%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 0x17276(%rip), %rdi     # 0x30815
movb $0x3, %al
callq 0x2030
leaq 0x138(%rsp), %rdi
leaq 0xb0(%rsp), %rsi
callq 0x1b2b8
leaq 0x138(%rsp), %rdi
leaq 0x50(%rsp), %rsi
leaq 0x40(%rsp), %rdx
leaq 0x28(%rsp), %rcx
leaq 0x170(%rsp), %r8
leaq 0x168(%rsp), %r9
callq 0x2f758
movq 0x138(%rsp), %rdi
testq %rdi, %rdi
je 0x19604
movq 0x148(%rsp), %rsi
subq %rdi, %rsi
callq 0x2250
movsd 0x40(%rsp), %xmm1
mulsd 0x16bde(%rip), %xmm1    # 0x301f0
xorpd %xmm0, %xmm0
movsd 0x10(%rsp), %xmm2
ucomisd %xmm0, %xmm2
movapd %xmm2, %xmm0
jb 0x1962c
sqrtsd %xmm0, %xmm0
jmp 0x1963d
movsd %xmm1, 0x10(%rsp)
callq 0x21d0
movsd 0x10(%rsp), %xmm1
divsd %xmm0, %xmm1
movsd 0x50(%rsp), %xmm2
movapd %xmm2, %xmm0
subsd %xmm1, %xmm0
addsd %xmm2, %xmm1
leaq 0x16db0(%rip), %rdi     # 0x3040a
movb $0x2, %al
callq 0x2030
movq 0xb0(%rsp), %rdi
testq %rdi, %rdi
je 0x1967e
movq 0xc0(%rsp), %rsi
subq %rdi, %rsi
callq 0x2250
movq 0xe0(%rsp), %rdi
testq %rdi, %rdi
je 0x1969b
movq 0xf0(%rsp), %rsi
subq %rdi, %rsi
callq 0x2250
leaq 0x178(%rsp), %rdi
callq 0xd912
addq $0x1a8, %rsp            # imm = 0x1A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x196f1
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0xd912
jmp 0x1973b
jmp 0x196f1
movq %rax, %rbx
movq 0x138(%rsp), %rdi
testq %rdi, %rdi
je 0x19701
movq 0x148(%rsp), %rsi
subq %rdi, %rsi
callq 0x2250
jmp 0x19701
jmp 0x196fe
movq %rax, %rbx
jmp 0x1973b
jmp 0x196fe
jmp 0x196fe
jmp 0x196fe
jmp 0x196fe
movq %rax, %rbx
movq 0xb0(%rsp), %rdi
testq %rdi, %rdi
je 0x1971e
movq 0xc0(%rsp), %rsi
subq %rdi, %rsi
callq 0x2250
movq 0xe0(%rsp), %rdi
testq %rdi, %rdi
je 0x1973b
movq 0xf0(%rsp), %rsi
subq %rdi, %rsi
callq 0x2250
leaq 0x178(%rsp), %rdi
callq 0xd912
movq %rbx, %rdi
callq 0x23b0