// File: chfeder[P]turbulence_generator/TurbGen.cpp
// Function: main
int main(int argc, char * argv[])
{
    /// initialise MPI
#ifdef HAVE_MPI
    MPI_Init(&argc, &argv);
    MPI_Comm_size(MPI_COMM_WORLD, &NPE);
    MPI_Comm_rank(MPI_COMM_WORLD, &MyPE);
#endif

    /// Parse inputs
    vector<string> Arguments(argc);
    for (int i = 0; i < argc; i++) Arguments[i] = static_cast<string>(argv[i]);
    if (ParseInputs(Arguments) == -1)
    {
        if (MyPE==0 && verbose>0) cout<<endl<<ProgSign+"Error in ParseInputs(). Exiting."<<endl;
        HelpMe();
#ifdef HAVE_MPI
        MPI_Finalize();
#endif
        return -1;
    }

    if (MyPE==0 && verbose>1) cout<<ProgSign+"started..."<<endl;

#ifdef HAVE_MPI
    // stop on error in domain decomposition if we run with MPI and number cores is > number of grid cells in X
    if (NPE > N[X]) {
        if (MyPE==0 && verbose>0) cout<<ProgSign+"Error in domain decomposition: NPE must be <= N[X]"<<endl;
        MPI_Finalize();
        return -1;
    }
#endif

    long starttime = time(NULL);
    cout<<setprecision(9);

    // create TurbGen class object
    TurbGen tg = TurbGen(MyPE);
    tg.set_verbose(verbose);

    // initialise generator to return a single turbulent realisation based on input parameters
    tg.init_single_realisation(ndim, L, k_min, k_mid, k_max, spect_form, power_law_exp, power_law_exp_2, angles_exp, sol_weight, random_seed);

    // get the number of vector field components
    int ncmp = tg.get_number_of_components();

    // set dimensionality dependencies
    if ((int)ndim < 3) { N[Z] = 1; L[Z] = 1.0; } // 2D
    if ((int)ndim < 2) { N[Y] = 1; L[Y] = 1.0; } // 1D

    // define cell size of uniform grid
    double del[3];
    for (int d = 0; d < 3; d++) del[d] = L[d] / N[d];

    // always generate within [0,L], cell-centered; user can shift output to target physical location, if needed
    double pos_beg[3] = {0.0, 0.0, 0.0}, pos_end[3] = {0.0, 0.0, 0.0}; // start and end coordinates of output grid
    // parallelise along X (generalises to non-MPI case, where NPE=1 and MyPE=0)
    int divN_PE = ceil((double)N[X]/(double)NPE);
    int NPE_main = N[X] / divN_PE;
    int modN_PE = N[X] - NPE_main * divN_PE;
    double divL_PE = L[X] * (double)divN_PE / (double)N[X];
    double modL_PE = L[X] * (double)modN_PE / (double)N[X];
    int NPE_in_use = NPE_main; if (modN_PE > 0) NPE_in_use += 1;
    int NX = 0; // number of cells in X for MyPE (idle PEs get nothing, i.e., NX=0)
    if (MyPE==0 && verbose>1)
        cout<<ProgSign+"NPE_main, divN_PE, modN_PE, divL_PE, modL_PE = "<<NPE_main<<" "<<divN_PE<<" "<<modN_PE<<" "<<divL_PE<<" "<<modL_PE<<endl;
    // set pos_beg and pos_end
    for (int d = 0; d < 3; d++) {
        if (d==X) { // parallelised direction - x
            if (MyPE < NPE_main) { // equally distribute to NPE_main cores
                pos_beg[d] = MyPE*divL_PE + del[d]/2.0; // first cell coordinate (cell center)
                pos_end[d] = (MyPE+1)*divL_PE - del[d]/2.0; // last cell coordinate (cell center)
                NX = divN_PE;
            } else if (MyPE < NPE_in_use) { // last PE gets the rest (idle PEs get nothing, i.e., NX=0)
                pos_beg[d] = NPE_main*divL_PE + del[d]/2.0; // first cell coordinate (cell center)
                pos_end[d] = L[X] - del[d]/2.0; // last cell coordinate (cell center)
                NX = modN_PE;
            }
            if (verbose>1)
                cout<<ProgSign+"MyPE, pos_beg[X], pos_beg[X], NX = "<<MyPE<<" "<<pos_beg[X]<<" "<<pos_end[X]<<" "<<NX<<endl;
        } else { // non-parallelised direction(s)
            pos_beg[d] = del[d]/2.0; // first cell coordinate (cell center)
            pos_end[d] = L[d] - del[d]/2.0; // last cell coordinate (cell center)
        }
    }

#ifdef HAVE_MPI
    if (MyPE==0 && verbose>0) {
        cout<<ProgSign+"First "<<NPE_main<<" core(s) carry(ies) NX="<<divN_PE<<" cell(s) (each)."<<endl;
        if (modN_PE > 0) cout<<ProgSign+"Core #"<<NPE_main+1<<" carries NX="<<modN_PE<<" cell(s)."<<endl;
        if (NPE_in_use < NPE) cout<<ProgSign+"Warning: non-optimal load balancing; "<<NPE-NPE_in_use<<" core(s) remain(s) idle."<<endl;
    }
#endif

    // total number of output grid cells
    int N_out[3] = {NX, N[Y], N[Z]};
    long ntot = 1; for (int d = 0; d < 3; d++) ntot *= N_out[d];
    // output grid, which receives the turbulent field (up to ndim = 3)
    float * grid_out[3];
    // allocate
    for (int d = 0; d < ncmp; d++) grid_out[d] = new float[ntot];

    // call to return uniform grid(s) with ncmp components of the turbulent field at requested positions
    tg.get_turb_vector_unigrid(pos_beg, pos_end, N_out, grid_out);

    // compute mean and std of generated turbulent field and then re-normalise to mean=0 and std=1
    double mean [3] = {0.0, 0.0, 0.0};
    double mean2[3] = {0.0, 0.0, 0.0};
    double std[3] = {0.0, 0.0, 0.0};
    for (int d = 0; d < ncmp; d++) {
        for (long ni = 0; ni < ntot; ni++) {
            mean [d] += grid_out[d][ni];
            mean2[d] += pow(grid_out[d][ni],2.0);
        }
    }
#ifdef HAVE_MPI
    MPI_Allreduce(MPI_IN_PLACE, mean , 3, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD);
    MPI_Allreduce(MPI_IN_PLACE, mean2, 3, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD);
#endif
    for (int d = 0; d < ncmp; d++) {
        mean [d] /= N[X]*N[Y]*N[Z]; // mean
        mean2[d] /= N[X]*N[Y]*N[Z]; // mean squared
        std[d] = sqrt(mean2[d] - mean[d]*mean[d]); // standard deviation
        for (long ni = 0; ni < ntot; ni++) {
            grid_out[d][ni] -= mean[d];
            grid_out[d][ni] /= std[d];
        }
    }

    // re-compute mean and std
    for (int d = 0; d < ncmp; d++) {
        mean[d] = 0.0; mean2[d] = 0.0;
        for (long ni = 0; ni < ntot; ni++) {
            mean [d] += grid_out[d][ni];
            mean2[d] += pow(grid_out[d][ni],2.0);
        }
    }
#ifdef HAVE_MPI
    MPI_Allreduce(MPI_IN_PLACE, mean , 3, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD);
    MPI_Allreduce(MPI_IN_PLACE, mean2, 3, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD);
#endif
    for (int d = 0; d < ncmp; d++) {
        mean [d] /= N[X]*N[Y]*N[Z]; // mean
        mean2[d] /= N[X]*N[Y]*N[Z]; // mean squared
        std[d] = sqrt(mean2[d] - mean[d]*mean[d]); // standard deviation
    }

    if (MyPE==0 && verbose>0) {
        cout<<ProgSign+"Generated "<<ndim<<"D turbulent field with"<<endl;
        cout<<ProgSign+" number of grid cells N ="; for (int d = 0; d < (int)ndim; d++) cout<<" "<<N[d]; cout<<endl;
        cout<<ProgSign+" physical size L ="; for (int d = 0; d < (int)ndim; d++) cout<<" "<<L[d]; cout<<endl;
        cout<<ProgSign+" mean (for each component) ="; for (int d = 0; d < ncmp; d++) cout<<" "<<mean[d]; cout<<endl;
        cout<<ProgSign+" 1D standard deviation (for each component) ="; for (int d = 0; d < ncmp; d++) cout<<" "<<std[d]; cout<<endl;
        string expected = "";
        if (ncmp==1) expected = "1";
        if (ncmp==2) expected = "sqrt(2)";
        if (ncmp==3) expected = "sqrt(3)";
        cout<<ProgSign+" total ("<<ndim<<"D) standard deviation (expected: "<<expected<<") = "<<sqrt(std[0]*std[0]+std[1]*std[1]+std[2]*std[2])<<endl;
    }

#ifdef HAVE_HDF5
    // write to HDF5 file
    if (MyPE==0 && verbose>0) {
        cout<<"-----------------------------------------------------"<<endl;
        cout<<ProgSign+"Creating '"<<outfilename<<"' for output..."<<endl;
    }
    HDFIO hdfio = HDFIO();
    hdfio.create(outfilename, MPI_COMM);
    // write scalars
    vector<int> hdf5dims(0);
    hdfio.write(&ndim, "ndim", hdf5dims, H5T_NATIVE_DOUBLE, MPI_COMM);
    hdfio.write(&ncmp, "ncmp", hdf5dims, H5T_NATIVE_INT, MPI_COMM);
    hdfio.write(&k_min, "kmin", hdf5dims, H5T_NATIVE_DOUBLE, MPI_COMM);
    hdfio.write(&k_mid, "kmid", hdf5dims, H5T_NATIVE_DOUBLE, MPI_COMM);
    hdfio.write(&k_max, "kmax", hdf5dims, H5T_NATIVE_DOUBLE, MPI_COMM);
    hdfio.write(&spect_form, "spect_form", hdf5dims, H5T_NATIVE_INT, MPI_COMM);
    if (spect_form == 2) {
        hdfio.write(&power_law_exp,   "power_law_exp",   hdf5dims, H5T_NATIVE_DOUBLE, MPI_COMM);
        hdfio.write(&power_law_exp_2, "power_law_exp_2", hdf5dims, H5T_NATIVE_DOUBLE, MPI_COMM);
        hdfio.write(&angles_exp, "angles_exp", hdf5dims, H5T_NATIVE_DOUBLE, MPI_COMM);
    }
    hdfio.write(&sol_weight, "sol_weight", hdf5dims, H5T_NATIVE_DOUBLE, MPI_COMM);
    hdfio.write(&random_seed, "random_seed", hdf5dims, H5T_NATIVE_INT, MPI_COMM);
    // write N and L vectors
    hdf5dims.resize(1); hdf5dims[0] = (int)ndim;
    int No[(int)ndim]; double Lo[(int)ndim]; // order Z,Y,X
     for (int d = 0; d < (int)ndim; d++) {
        No[(int)ndim-1-d] = N[d];
        Lo[(int)ndim-1-d] = L[d];
    }
    hdfio.write(No, "N", hdf5dims, H5T_NATIVE_INT, MPI_COMM);
    hdfio.write(Lo, "L", hdf5dims, H5T_NATIVE_DOUBLE, MPI_COMM);
    // write turbulent field (components)
    hdf5dims.resize((int)ndim); for (int d = 0; d < (int)ndim; d++) hdf5dims[(int)ndim-1-d] = N[d]; // order Z,Y,X
    if (MyPE==0 && verbose>1) { cout<<ProgSign+"hdf5dims ="; for (int d = 0; d < (int)ndim; d++) cout<<" "<<hdf5dims[d]; cout<<endl; }
    for (int dc = 0; dc < ncmp; dc++) { // loop over component(s)
        string dsetname = "turb_field";
        if (dc == 0) dsetname += "_x";
        if (dc == 1) dsetname += "_y";
        if (dc == 2) dsetname += "_z";
        hdfio.create_dataset(dsetname, hdf5dims, H5T_NATIVE_FLOAT, MPI_COMM); // create HDF5 dataset
        // specify dimensions and offset for slab operation
        hsize_t offset[(int)ndim], count[(int)ndim], out_offset[(int)ndim], out_count[(int)ndim];
        for (int d = 0; d < (int)ndim; d++) {
            int dd = (int)ndim-1-d; // order Z,Y,X
            // collective HDF5 IO only works if inactive cores participate, but with counts=0 and offsets=0
            offset[dd] = 0; count[dd] = 0; out_offset[dd] = 0; out_count[dd] = 0;
            if (MyPE < NPE_in_use) {
                if (d==0) offset[dd] = MyPE*divN_PE;
                count[dd] = N_out[d];
                out_offset[dd] = 0;
                out_count[dd] = N_out[d];
            }
        }
        if (verbose>1) {
            for (int d = 0; d < (int)ndim; d++)
                cout<<"MyPE, d, offset, count, out_offset, out_count = "<<
                        MyPE<<" "<<d<<" "<<offset[d]<<" "<<count[d]<<" "<<out_offset[d]<<" "<<out_count[d]<<endl;
        }
        // write slab to file (in parallel, if we have MPI)
        hdfio.overwrite_slab(grid_out[dc], dsetname, H5T_NATIVE_FLOAT, offset, count, (int)ndim, out_offset, out_count, MPI_COMM);
        if (MyPE==0 && verbose>0) cout<<ProgSign+"Dataset '"<<dsetname<<"' in '"<<outfilename<<"' written."<<endl;
    }
    // output generating modes and their amplitudes
    if (write_modes) {
        // modes
        vector< vector<double> > modes = tg.get_modes();
        int nmodes = modes[0].size(); // all dims have the same number of modes
        hdf5dims.resize(2); hdf5dims[0] = (int)ndim; hdf5dims[1] = nmodes;
        double * ptmp = new double[((int)ndim)*nmodes];
        for (int d = 0; d < (int)ndim; d++)
            for (int m = 0; m < nmodes; m++)
                ptmp[d*nmodes+m] = modes[d][m];
        hdfio.write(ptmp, "Fourier_modes", hdf5dims, H5T_NATIVE_DOUBLE, MPI_COMM);
        delete [] ptmp;
        // amplitudes
        vector<double> amplitudes = tg.get_amplitudes();
        ptmp = new double[amplitudes.size()];
        for (int i = 0; i < amplitudes.size(); i++) ptmp[i] = amplitudes[i];
        hdf5dims.resize(1); hdf5dims[0] = amplitudes.size();
        hdfio.write(ptmp, "Fourier_amplitudes", hdf5dims, H5T_NATIVE_DOUBLE, MPI_COMM);
        delete [] ptmp;
    }
    hdfio.close();
    if (MyPE==0 && verbose>0) cout<<ProgSign+"Finished writing '"<<outfilename<<"'."<<endl;
#endif

    // clean up
    for (int d = 0; d < ncmp; d++) {
      if (grid_out[d]) delete [] grid_out[d]; grid_out[d] = NULL;
    }

    /// print out wallclock time used
    long endtime = time(NULL);
    long duration = endtime-starttime;
    if (verbose>1) cout<<ProgSign+"["<<MyPE<<"] Local runtime: "<<duration<<"s"<<endl;
#ifdef HAVE_MPI
    MPI_Allreduce(MPI_IN_PLACE, &duration, 1, MPI_LONG, MPI_MAX, MPI_COMM_WORLD);
#endif
    if (MyPE==0 && verbose>0) {
        cout<<"-----------------------------------------------------"<<endl;
        cout<<ProgSign+"Total runtime: "<<duration<<"s"<<endl;
    }

#ifdef HAVE_MPI
    MPI_Finalize();
#endif
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x7d0, %rsp            # imm = 0x7D0
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movslq -0x8(%rbp), %rax
movq %rax, -0x628(%rbp)
leaq -0x29(%rbp), %rdi
movq %rdi, -0x620(%rbp)
callq 0x5ae0
movq -0x628(%rbp), %rsi
movq -0x620(%rbp), %rdx
leaq -0x28(%rbp), %rdi
callq 0x5b00
jmp 0x26ed
leaq -0x29(%rbp), %rdi
callq 0x5b70
movl $0x0, -0x40(%rbp)
movl -0x40(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0x27af
movq -0x10(%rbp), %rax
movslq -0x40(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x638(%rbp)
leaq -0x61(%rbp), %rdi
movq %rdi, -0x630(%rbp)
callq 0x23c0
movq -0x638(%rbp), %rsi
movq -0x630(%rbp), %rdx
leaq -0x60(%rbp), %rdi
callq 0x5a30
jmp 0x2745
movslq -0x40(%rbp), %rsi
leaq -0x28(%rbp), %rdi
callq 0x5b90
movq %rax, %rdi
leaq -0x60(%rbp), %rsi
callq 0x22c0
leaq -0x60(%rbp), %rdi
callq 0x2458
leaq -0x61(%rbp), %rdi
callq 0x2280
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x26fd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x29(%rbp), %rdi
callq 0x5b70
jmp 0x3feb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x61(%rbp), %rdi
callq 0x2280
jmp 0x3fe2
leaq -0x80(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x5bb0
jmp 0x27be
leaq -0x80(%rbp), %rdi
callq 0x4000
movl %eax, -0x63c(%rbp)
jmp 0x27cf
leaq -0x80(%rbp), %rdi
callq 0x5ca0
movl -0x63c(%rbp), %eax
cmpl $-0x1, %eax
jne 0x28dd
cmpl $0x0, 0x12b36(%rip)     # 0x15324
jne 0x28c0
cmpl $0x0, 0x12a45(%rip)     # 0x15240
jle 0x28c0
movq 0x127d0(%rip), %rdi     # 0x14fd8
movq 0x127b1(%rip), %rsi     # 0x14fc0
callq 0x2260
movq %rax, -0x648(%rbp)
jmp 0x281d
leaq 0x12abc(%rip), %rsi     # 0x152e0
leaq 0xc885(%rip), %rdx      # 0xf0b0
leaq -0xa0(%rbp), %rdi
callq 0x5d00
jmp 0x2839
movq -0x648(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x2200
movq %rax, -0x650(%rbp)
jmp 0x2855
movq -0x650(%rbp), %rdi
movq 0x1275d(%rip), %rsi     # 0x14fc0
callq 0x2260
jmp 0x286a
leaq -0xa0(%rbp), %rdi
callq 0x2458
jmp 0x28c0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x3fe2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x5ca0
jmp 0x3fe2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x2458
jmp 0x3fe2
callq 0x54d0
jmp 0x28c7
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl $0x1, -0xa4(%rbp)
jmp 0x3fcd
cmpl $0x0, 0x12a40(%rip)     # 0x15324
jne 0x296b
cmpl $0x1, 0x1294f(%rip)     # 0x15240
jle 0x296b
leaq 0x129e6(%rip), %rsi     # 0x152e0
leaq 0xc7d0(%rip), %rdx      # 0xf0d1
leaq -0xc8(%rbp), %rdi
callq 0x5d00
jmp 0x290f
movq 0x126c2(%rip), %rdi     # 0x14fd8
leaq -0xc8(%rbp), %rsi
callq 0x2200
movq %rax, -0x658(%rbp)
jmp 0x292b
movq -0x658(%rbp), %rdi
movq 0x12687(%rip), %rsi     # 0x14fc0
callq 0x2260
jmp 0x2940
leaq -0xc8(%rbp), %rdi
callq 0x2458
jmp 0x296b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0xc8(%rbp), %rdi
callq 0x2458
jmp 0x3fe2
xorl %eax, %eax
movl %eax, %edi
callq 0x2210
movq %rax, -0xd0(%rbp)
movl $0x9, %edi
callq 0x5d80
movl %eax, -0x65c(%rbp)
jmp 0x298d
movl -0x65c(%rbp), %eax
movl %eax, -0xd4(%rbp)
movl -0xd4(%rbp), %esi
movq 0x12632(%rip), %rdi     # 0x14fd8
callq 0x2350
jmp 0x29ad
movl 0x12971(%rip), %esi     # 0x15324
leaq -0x310(%rbp), %rdi
callq 0x5da0
jmp 0x29c1
movl 0x12879(%rip), %esi     # 0x15240
leaq -0x310(%rbp), %rdi
callq 0x6010
jmp 0x29d5
movsd 0x1286b(%rip), %xmm0    # 0x15248
movsd 0x12893(%rip), %xmm1    # 0x15278
movsd 0x1289b(%rip), %xmm2    # 0x15288
movsd 0x1288b(%rip), %xmm3    # 0x15280
movl 0x12895(%rip), %edx     # 0x15290
movsd 0x12895(%rip), %xmm4    # 0x15298
movsd 0x12895(%rip), %xmm5    # 0x152a0
movsd 0x12895(%rip), %xmm6    # 0x152a8
movsd 0x12895(%rip), %xmm7    # 0x152b0
movl 0x12897(%rip), %ecx     # 0x152b8
leaq 0x12838(%rip), %rsi     # 0x15260
leaq -0x310(%rbp), %rdi
callq 0x6030
jmp 0x2a36
leaq -0x310(%rbp), %rdi
callq 0x66f0
movl %eax, -0x660(%rbp)
jmp 0x2a4a
movl -0x660(%rbp), %eax
movl %eax, -0x314(%rbp)
cvttsd2si 0x127ea(%rip), %eax # 0x15248
cmpl $0x3, %eax
jge 0x2a90
movl $0x1, 0x127eb(%rip)     # 0x15258
movsd 0xc593(%rip), %xmm0     # 0xf008
movsd %xmm0, 0x127f3(%rip)    # 0x15270
jmp 0x2a90
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x3fbf
cvttsd2si 0x127b0(%rip), %eax # 0x15248
cmpl $0x2, %eax
jge 0x2ab7
movl $0x1, 0x127ad(%rip)     # 0x15254
movsd 0xc559(%rip), %xmm0     # 0xf008
movsd %xmm0, 0x127b1(%rip)    # 0x15268
movl $0x0, -0x334(%rbp)
cmpl $0x3, -0x334(%rbp)
jge 0x2b15
movslq -0x334(%rbp), %rcx
leaq 0x12788(%rip), %rax     # 0x15260
movsd (%rax,%rcx,8), %xmm0
movslq -0x334(%rbp), %rcx
leaq 0x12765(%rip), %rax     # 0x15250
cvtsi2sdl (%rax,%rcx,4), %xmm1
divsd %xmm1, %xmm0
movslq -0x334(%rbp), %rax
movsd %xmm0, -0x330(%rbp,%rax,8)
movl -0x334(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x334(%rbp)
jmp 0x2ac1
leaq -0x350(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x2100
leaq -0x370(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x2100
cvtsi2sdl 0x1270d(%rip), %xmm0 # 0x15250
cvtsi2sdl 0x12771(%rip), %xmm1 # 0x152bc
divsd %xmm1, %xmm0
callq 0x2040
cvttsd2si %xmm0, %eax
movl %eax, -0x374(%rbp)
movl 0x126ec(%rip), %eax     # 0x15250
cltd
idivl -0x374(%rbp)
movl %eax, -0x378(%rbp)
movl 0x126d9(%rip), %eax     # 0x15250
movl -0x378(%rbp), %ecx
imull -0x374(%rbp), %ecx
subl %ecx, %eax
movl %eax, -0x37c(%rbp)
movsd 0x126cc(%rip), %xmm0    # 0x15260
cvtsi2sdl -0x374(%rbp), %xmm1
mulsd %xmm1, %xmm0
cvtsi2sdl 0x126a8(%rip), %xmm1 # 0x15250
divsd %xmm1, %xmm0
movsd %xmm0, -0x388(%rbp)
movsd 0x126a4(%rip), %xmm0    # 0x15260
cvtsi2sdl -0x37c(%rbp), %xmm1
mulsd %xmm1, %xmm0
cvtsi2sdl 0x12680(%rip), %xmm1 # 0x15250
divsd %xmm1, %xmm0
movsd %xmm0, -0x390(%rbp)
movl -0x378(%rbp), %eax
movl %eax, -0x394(%rbp)
cmpl $0x0, -0x37c(%rbp)
jle 0x2c00
movl -0x394(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x394(%rbp)
movl $0x0, -0x398(%rbp)
cmpl $0x0, 0x12713(%rip)     # 0x15324
jne 0x2d97
cmpl $0x1, 0x12622(%rip)     # 0x15240
jle 0x2d97
leaq 0x126b5(%rip), %rsi     # 0x152e0
leaq 0xc4aa(%rip), %rdx      # 0xf0dc
leaq -0x3b8(%rbp), %rdi
callq 0x5d00
jmp 0x2c40
movq 0x12391(%rip), %rdi     # 0x14fd8
leaq -0x3b8(%rbp), %rsi
callq 0x2200
movq %rax, -0x668(%rbp)
jmp 0x2c5c
movq -0x668(%rbp), %rdi
movl -0x378(%rbp), %esi
callq 0x2390
movq %rax, -0x670(%rbp)
jmp 0x2c77
movq -0x670(%rbp), %rdi
leaq 0xc580(%rip), %rsi      # 0xf205
callq 0x2230
movq %rax, -0x678(%rbp)
jmp 0x2c93
movq -0x678(%rbp), %rdi
movl -0x374(%rbp), %esi
callq 0x2390
movq %rax, -0x680(%rbp)
jmp 0x2cae
movq -0x680(%rbp), %rdi
leaq 0xc549(%rip), %rsi      # 0xf205
callq 0x2230
movq %rax, -0x688(%rbp)
jmp 0x2cca
movq -0x688(%rbp), %rdi
movl -0x37c(%rbp), %esi
callq 0x2390
movq %rax, -0x690(%rbp)
jmp 0x2ce5
movq -0x690(%rbp), %rdi
leaq 0xc512(%rip), %rsi      # 0xf205
callq 0x2230
movq %rax, -0x698(%rbp)
jmp 0x2d01
movq -0x698(%rbp), %rdi
movsd -0x388(%rbp), %xmm0
callq 0x2410
movq %rax, -0x6a0(%rbp)
jmp 0x2d1e
movq -0x6a0(%rbp), %rdi
leaq 0xc4d9(%rip), %rsi      # 0xf205
callq 0x2230
movq %rax, -0x6a8(%rbp)
jmp 0x2d3a
movq -0x6a8(%rbp), %rdi
movsd -0x390(%rbp), %xmm0
callq 0x2410
movq %rax, -0x6b0(%rbp)
jmp 0x2d57
movq -0x6b0(%rbp), %rdi
movq 0x1225b(%rip), %rsi     # 0x14fc0
callq 0x2260
jmp 0x2d6c
leaq -0x3b8(%rbp), %rdi
callq 0x2458
jmp 0x2d97
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x3b8(%rbp), %rdi
callq 0x2458
jmp 0x3fbf
movl $0x0, -0x3bc(%rbp)
cmpl $0x3, -0x3bc(%rbp)
jge 0x30ee
cmpl $0x0, -0x3bc(%rbp)
jne 0x3069
movl 0x12563(%rip), %eax     # 0x15324
cmpl -0x378(%rbp), %eax
jge 0x2e82
cvtsi2sdl 0x1254f(%rip), %xmm0 # 0x15324
movsd -0x388(%rbp), %xmm2
movslq -0x3bc(%rbp), %rax
movsd -0x330(%rbp,%rax,8), %xmm1
movsd 0xc21b(%rip), %xmm3     # 0xf010
divsd %xmm3, %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movslq -0x3bc(%rbp), %rax
movsd %xmm0, -0x350(%rbp,%rax,8)
movl 0x1250d(%rip), %eax     # 0x15324
addl $0x1, %eax
cvtsi2sd %eax, %xmm0
movsd -0x388(%rbp), %xmm2
movslq -0x3bc(%rbp), %rax
movsd -0x330(%rbp,%rax,8), %xmm1
movsd 0xc1d2(%rip), %xmm3     # 0xf010
divsd %xmm3, %xmm1
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movslq -0x3bc(%rbp), %rax
movsd %xmm0, -0x370(%rbp,%rax,8)
movl -0x374(%rbp), %eax
movl %eax, -0x398(%rbp)
jmp 0x2f1e
movl 0x1249c(%rip), %eax     # 0x15324
cmpl -0x394(%rbp), %eax
jge 0x2f1c
cvtsi2sdl -0x378(%rbp), %xmm0
movsd -0x388(%rbp), %xmm2
movslq -0x3bc(%rbp), %rax
movsd -0x330(%rbp,%rax,8), %xmm1
movsd 0xc154(%rip), %xmm3     # 0xf010
divsd %xmm3, %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movslq -0x3bc(%rbp), %rax
movsd %xmm0, -0x350(%rbp,%rax,8)
movsd 0x12380(%rip), %xmm0    # 0x15260
movslq -0x3bc(%rbp), %rax
movsd -0x330(%rbp,%rax,8), %xmm1
movsd 0xc118(%rip), %xmm2     # 0xf010
divsd %xmm2, %xmm1
subsd %xmm1, %xmm0
movslq -0x3bc(%rbp), %rax
movsd %xmm0, -0x370(%rbp,%rax,8)
movl -0x37c(%rbp), %eax
movl %eax, -0x398(%rbp)
jmp 0x2f1e
cmpl $0x1, 0x1231b(%rip)     # 0x15240
jle 0x3067
leaq 0x123ae(%rip), %rsi     # 0x152e0
leaq 0xc1d3(%rip), %rdx      # 0xf10c
leaq -0x3e0(%rbp), %rdi
callq 0x5d00
jmp 0x2f47
movq 0x1208a(%rip), %rdi     # 0x14fd8
leaq -0x3e0(%rbp), %rsi
callq 0x2200
movq %rax, -0x6b8(%rbp)
jmp 0x2f63
movq -0x6b8(%rbp), %rdi
movl 0x123b4(%rip), %esi     # 0x15324
callq 0x2390
movq %rax, -0x6c0(%rbp)
jmp 0x2f7e
movq -0x6c0(%rbp), %rdi
leaq 0xc279(%rip), %rsi      # 0xf205
callq 0x2230
movq %rax, -0x6c8(%rbp)
jmp 0x2f9a
movq -0x6c8(%rbp), %rdi
movsd -0x350(%rbp), %xmm0
callq 0x2410
movq %rax, -0x6d0(%rbp)
jmp 0x2fb7
movq -0x6d0(%rbp), %rdi
leaq 0xc240(%rip), %rsi      # 0xf205
callq 0x2230
movq %rax, -0x6d8(%rbp)
jmp 0x2fd3
movq -0x6d8(%rbp), %rdi
movsd -0x370(%rbp), %xmm0
callq 0x2410
movq %rax, -0x6e0(%rbp)
jmp 0x2ff0
movq -0x6e0(%rbp), %rdi
leaq 0xc207(%rip), %rsi      # 0xf205
callq 0x2230
movq %rax, -0x6e8(%rbp)
jmp 0x300c
movq -0x6e8(%rbp), %rdi
movl -0x398(%rbp), %esi
callq 0x2390
movq %rax, -0x6f0(%rbp)
jmp 0x3027
movq -0x6f0(%rbp), %rdi
movq 0x11f8b(%rip), %rsi     # 0x14fc0
callq 0x2260
jmp 0x303c
leaq -0x3e0(%rbp), %rdi
callq 0x2458
jmp 0x3067
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x3e0(%rbp), %rdi
callq 0x2458
jmp 0x3fbf
jmp 0x30d8
movslq -0x3bc(%rbp), %rax
movsd -0x330(%rbp,%rax,8), %xmm0
movsd 0xbf8f(%rip), %xmm1     # 0xf010
divsd %xmm1, %xmm0
movslq -0x3bc(%rbp), %rax
movsd %xmm0, -0x350(%rbp,%rax,8)
movslq -0x3bc(%rbp), %rcx
leaq 0x121bd(%rip), %rax     # 0x15260
movsd (%rax,%rcx,8), %xmm0
movslq -0x3bc(%rbp), %rax
movsd -0x330(%rbp,%rax,8), %xmm1
movsd 0xbf50(%rip), %xmm2     # 0xf010
divsd %xmm2, %xmm1
subsd %xmm1, %xmm0
movslq -0x3bc(%rbp), %rax
movsd %xmm0, -0x370(%rbp,%rax,8)
jmp 0x30da
movl -0x3bc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3bc(%rbp)
jmp 0x2da1
movl -0x398(%rbp), %eax
movl %eax, -0x3ec(%rbp)
movl 0x12154(%rip), %eax     # 0x15254
movl %eax, -0x3e8(%rbp)
movl 0x1214c(%rip), %eax     # 0x15258
movl %eax, -0x3e4(%rbp)
movq $0x1, -0x3f8(%rbp)
movl $0x0, -0x3fc(%rbp)
cmpl $0x3, -0x3fc(%rbp)
jge 0x315f
movslq -0x3fc(%rbp), %rax
movslq -0x3ec(%rbp,%rax,4), %rax
imulq -0x3f8(%rbp), %rax
movq %rax, -0x3f8(%rbp)
movl -0x3fc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3fc(%rbp)
jmp 0x3127
movl $0x0, -0x424(%rbp)
movl -0x424(%rbp), %eax
cmpl -0x314(%rbp), %eax
jge 0x31c9
movq -0x3f8(%rbp), %rax
movl $0x4, %ecx
mulq %rcx
movq %rax, %rdi
movq $-0x1, %rax
cmovoq %rax, %rdi
callq 0x2030
movq %rax, -0x6f8(%rbp)
jmp 0x31a2
movq -0x6f8(%rbp), %rcx
movslq -0x424(%rbp), %rax
movq %rcx, -0x420(%rbp,%rax,8)
movl -0x424(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x424(%rbp)
jmp 0x3169
leaq -0x310(%rbp), %rdi
leaq -0x350(%rbp), %rsi
leaq -0x370(%rbp), %rdx
leaq -0x3ec(%rbp), %rcx
leaq -0x420(%rbp), %r8
callq 0x6710
jmp 0x31f3
leaq -0x440(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x2100
leaq -0x460(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x2100
leaq -0x480(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x2100
movl $0x0, -0x484(%rbp)
movl -0x484(%rbp), %eax
cmpl -0x314(%rbp), %eax
jge 0x331c
movq $0x0, -0x490(%rbp)
movq -0x490(%rbp), %rax
cmpq -0x3f8(%rbp), %rax
jge 0x3306
movslq -0x484(%rbp), %rax
movq -0x420(%rbp,%rax,8), %rcx
movq -0x490(%rbp), %rdx
movss (%rcx,%rdx,4), %xmm0
cvtss2sd %xmm0, %xmm1
movsd -0x440(%rbp,%rax,8), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x440(%rbp,%rax,8)
movslq -0x484(%rbp), %rax
movq -0x420(%rbp,%rax,8), %rax
movq -0x490(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
movsd 0xbd51(%rip), %xmm1     # 0xf010
callq 0x80a0
movsd %xmm0, -0x700(%rbp)
jmp 0x32ce
movsd -0x700(%rbp), %xmm0
movslq -0x484(%rbp), %rax
addsd -0x460(%rbp,%rax,8), %xmm0
movsd %xmm0, -0x460(%rbp,%rax,8)
movq -0x490(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x490(%rbp)
jmp 0x3253
jmp 0x3308
movl -0x484(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x484(%rbp)
jmp 0x3236
movl $0x0, -0x494(%rbp)
movl -0x494(%rbp), %eax
cmpl -0x314(%rbp), %eax
jge 0x34ca
movl 0x11f12(%rip), %eax     # 0x15250
imull 0x11f0f(%rip), %eax     # 0x15254
imull 0x11f0c(%rip), %eax     # 0x15258
cvtsi2sd %eax, %xmm1
movslq -0x494(%rbp), %rax
movsd -0x440(%rbp,%rax,8), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, -0x440(%rbp,%rax,8)
movl 0x11edd(%rip), %eax     # 0x15250
imull 0x11eda(%rip), %eax     # 0x15254
imull 0x11ed7(%rip), %eax     # 0x15258
cvtsi2sd %eax, %xmm1
movslq -0x494(%rbp), %rax
movsd -0x460(%rbp,%rax,8), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, -0x460(%rbp,%rax,8)
movslq -0x494(%rbp), %rax
movsd -0x460(%rbp,%rax,8), %xmm1
movslq -0x494(%rbp), %rax
movsd -0x440(%rbp,%rax,8), %xmm0
movslq -0x494(%rbp), %rax
movsd -0x440(%rbp,%rax,8), %xmm2
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
callq 0x21a0
movslq -0x494(%rbp), %rax
movsd %xmm0, -0x480(%rbp,%rax,8)
movq $0x0, -0x4a0(%rbp)
movq -0x4a0(%rbp), %rax
cmpq -0x3f8(%rbp), %rax
jge 0x34b4
movslq -0x494(%rbp), %rax
movsd -0x440(%rbp,%rax,8), %xmm1
movslq -0x494(%rbp), %rax
movq -0x420(%rbp,%rax,8), %rax
movq -0x4a0(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
cvtss2sd %xmm0, %xmm0
subsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, (%rax,%rcx,4)
movslq -0x494(%rbp), %rax
movsd -0x480(%rbp,%rax,8), %xmm1
movslq -0x494(%rbp), %rax
movq -0x420(%rbp,%rax,8), %rax
movq -0x4a0(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
cvtss2sd %xmm0, %xmm0
divsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, (%rax,%rcx,4)
movq -0x4a0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x4a0(%rbp)
jmp 0x3411
jmp 0x34b6
movl -0x494(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x494(%rbp)
jmp 0x3326
movl $0x0, -0x4a4(%rbp)
movl -0x4a4(%rbp), %eax
cmpl -0x314(%rbp), %eax
jge 0x35e0
movslq -0x4a4(%rbp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, -0x440(%rbp,%rax,8)
movslq -0x4a4(%rbp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, -0x460(%rbp,%rax,8)
movq $0x0, -0x4b0(%rbp)
movq -0x4b0(%rbp), %rax
cmpq -0x3f8(%rbp), %rax
jge 0x35ca
movslq -0x4a4(%rbp), %rax
movq -0x420(%rbp,%rax,8), %rcx
movq -0x4b0(%rbp), %rdx
movss (%rcx,%rdx,4), %xmm0
cvtss2sd %xmm0, %xmm1
movsd -0x440(%rbp,%rax,8), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x440(%rbp,%rax,8)
movslq -0x4a4(%rbp), %rax
movq -0x420(%rbp,%rax,8), %rax
movq -0x4b0(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
movsd 0xba8d(%rip), %xmm1     # 0xf010
callq 0x80a0
movsd %xmm0, -0x708(%rbp)
jmp 0x3592
movsd -0x708(%rbp), %xmm0
movslq -0x4a4(%rbp), %rax
addsd -0x460(%rbp,%rax,8), %xmm0
movsd %xmm0, -0x460(%rbp,%rax,8)
movq -0x4b0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x4b0(%rbp)
jmp 0x3517
jmp 0x35cc
movl -0x4a4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4a4(%rbp)
jmp 0x34d4
movl $0x0, -0x4b4(%rbp)
movl -0x4b4(%rbp), %eax
cmpl -0x314(%rbp), %eax
jge 0x36de
movl 0x11c4e(%rip), %eax     # 0x15250
imull 0x11c4b(%rip), %eax     # 0x15254
imull 0x11c48(%rip), %eax     # 0x15258
cvtsi2sd %eax, %xmm1
movslq -0x4b4(%rbp), %rax
movsd -0x440(%rbp,%rax,8), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, -0x440(%rbp,%rax,8)
movl 0x11c19(%rip), %eax     # 0x15250
imull 0x11c16(%rip), %eax     # 0x15254
imull 0x11c13(%rip), %eax     # 0x15258
cvtsi2sd %eax, %xmm1
movslq -0x4b4(%rbp), %rax
movsd -0x460(%rbp,%rax,8), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, -0x460(%rbp,%rax,8)
movslq -0x4b4(%rbp), %rax
movsd -0x460(%rbp,%rax,8), %xmm1
movslq -0x4b4(%rbp), %rax
movsd -0x440(%rbp,%rax,8), %xmm0
movslq -0x4b4(%rbp), %rax
movsd -0x440(%rbp,%rax,8), %xmm2
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
callq 0x21a0
movslq -0x4b4(%rbp), %rax
movsd %xmm0, -0x480(%rbp,%rax,8)
movl -0x4b4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4b4(%rbp)
jmp 0x35ea
cmpl $0x0, 0x11c3f(%rip)     # 0x15324
jne 0x3d17
cmpl $0x0, 0x11b4e(%rip)     # 0x15240
jle 0x3d17
leaq 0x11be1(%rip), %rsi     # 0x152e0
leaq 0xba2a(%rip), %rdx      # 0xf130
leaq -0x4d8(%rbp), %rdi
callq 0x5d00
jmp 0x3714
movq 0x118bd(%rip), %rdi     # 0x14fd8
leaq -0x4d8(%rbp), %rsi
callq 0x2200
movq %rax, -0x710(%rbp)
jmp 0x3730
movq -0x710(%rbp), %rdi
movsd 0x11b09(%rip), %xmm0    # 0x15248
callq 0x2410
movq %rax, -0x718(%rbp)
jmp 0x374d
movq -0x718(%rbp), %rdi
leaq 0xb9e0(%rip), %rsi      # 0xf13b
callq 0x2230
movq %rax, -0x720(%rbp)
jmp 0x3769
movq -0x720(%rbp), %rdi
movq 0x11849(%rip), %rsi     # 0x14fc0
callq 0x2260
jmp 0x377e
leaq -0x4d8(%rbp), %rdi
callq 0x2458
leaq 0x11b4f(%rip), %rsi     # 0x152e0
leaq 0xb9ba(%rip), %rdx      # 0xf152
leaq -0x4f8(%rbp), %rdi
callq 0x5d00
jmp 0x37a6
movq 0x1182b(%rip), %rdi     # 0x14fd8
leaq -0x4f8(%rbp), %rsi
callq 0x2200
jmp 0x37bb
leaq -0x4f8(%rbp), %rdi
callq 0x2458
movl $0x0, -0x4fc(%rbp)
movl -0x4fc(%rbp), %eax
cvttsd2si 0x11a69(%rip), %ecx # 0x15248
cmpl %ecx, %eax
jge 0x386f
movq 0x117ea(%rip), %rdi     # 0x14fd8
leaq 0xba10(%rip), %rsi      # 0xf205
callq 0x2230
movq %rax, -0x728(%rbp)
jmp 0x3803
movq -0x728(%rbp), %rdi
movslq -0x4fc(%rbp), %rcx
leaq 0x11a38(%rip), %rax     # 0x15250
movl (%rax,%rcx,4), %esi
callq 0x2390
jmp 0x3822
jmp 0x3824
movl -0x4fc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4fc(%rbp)
jmp 0x37d1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x4d8(%rbp), %rdi
callq 0x2458
jmp 0x3fbf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x4f8(%rbp), %rdi
callq 0x2458
jmp 0x3fbf
movq 0x11762(%rip), %rdi     # 0x14fd8
movq 0x11743(%rip), %rsi     # 0x14fc0
callq 0x2260
jmp 0x3884
leaq 0x11a55(%rip), %rsi     # 0x152e0
leaq 0xb8da(%rip), %rdx      # 0xf16c
leaq -0x520(%rbp), %rdi
callq 0x5d00
jmp 0x38a0
movq 0x11731(%rip), %rdi     # 0x14fd8
leaq -0x520(%rbp), %rsi
callq 0x2200
jmp 0x38b5
leaq -0x520(%rbp), %rdi
callq 0x2458
movl $0x0, -0x524(%rbp)
movl -0x524(%rbp), %eax
cvttsd2si 0x1196f(%rip), %ecx # 0x15248
cmpl %ecx, %eax
jge 0x394a
movq 0x116f4(%rip), %rdi     # 0x14fd8
leaq 0xb91a(%rip), %rsi      # 0xf205
callq 0x2230
movq %rax, -0x730(%rbp)
jmp 0x38f9
movq -0x730(%rbp), %rdi
movslq -0x524(%rbp), %rcx
leaq 0x11952(%rip), %rax     # 0x15260
movsd (%rax,%rcx,8), %xmm0
callq 0x2410
jmp 0x391a
jmp 0x391c
movl -0x524(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x524(%rbp)
jmp 0x38cb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x520(%rbp), %rdi
callq 0x2458
jmp 0x3fbf
movq 0x11687(%rip), %rdi     # 0x14fd8
movq 0x11668(%rip), %rsi     # 0x14fc0
callq 0x2260
jmp 0x395f
leaq 0x1197a(%rip), %rsi     # 0x152e0
leaq 0xb812(%rip), %rdx      # 0xf17f
leaq -0x548(%rbp), %rdi
callq 0x5d00
jmp 0x397b
movq 0x11656(%rip), %rdi     # 0x14fd8
leaq -0x548(%rbp), %rsi
callq 0x2200
jmp 0x3990
leaq -0x548(%rbp), %rdi
callq 0x2458
movl $0x0, -0x54c(%rbp)
movl -0x54c(%rbp), %eax
cmpl -0x314(%rbp), %eax
jge 0x3a1e
movq 0x1161d(%rip), %rdi     # 0x14fd8
leaq 0xb843(%rip), %rsi      # 0xf205
callq 0x2230
movq %rax, -0x738(%rbp)
jmp 0x39d0
movq -0x738(%rbp), %rdi
movslq -0x54c(%rbp), %rax
movsd -0x440(%rbp,%rax,8), %xmm0
callq 0x2410
jmp 0x39ee
jmp 0x39f0
movl -0x54c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54c(%rbp)
jmp 0x39a6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x548(%rbp), %rdi
callq 0x2458
jmp 0x3fbf
movq 0x115b3(%rip), %rdi     # 0x14fd8
movq 0x11594(%rip), %rsi     # 0x14fc0
callq 0x2260
jmp 0x3a33
leaq 0x118a6(%rip), %rsi     # 0x152e0
leaq 0xb75b(%rip), %rdx      # 0xf19c
leaq -0x570(%rbp), %rdi
callq 0x5d00
jmp 0x3a4f
movq 0x11582(%rip), %rdi     # 0x14fd8
leaq -0x570(%rbp), %rsi
callq 0x2200
jmp 0x3a64
leaq -0x570(%rbp), %rdi
callq 0x2458
movl $0x0, -0x574(%rbp)
movl -0x574(%rbp), %eax
cmpl -0x314(%rbp), %eax
jge 0x3af2
movq 0x11549(%rip), %rdi     # 0x14fd8
leaq 0xb76f(%rip), %rsi      # 0xf205
callq 0x2230
movq %rax, -0x740(%rbp)
jmp 0x3aa4
movq -0x740(%rbp), %rdi
movslq -0x574(%rbp), %rax
movsd -0x480(%rbp,%rax,8), %xmm0
callq 0x2410
jmp 0x3ac2
jmp 0x3ac4
movl -0x574(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x574(%rbp)
jmp 0x3a7a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x570(%rbp), %rdi
callq 0x2458
jmp 0x3fbf
movq 0x114df(%rip), %rdi     # 0x14fd8
movq 0x114c0(%rip), %rsi     # 0x14fc0
callq 0x2260
jmp 0x3b07
leaq -0x599(%rbp), %rdi
movq %rdi, -0x748(%rbp)
callq 0x23c0
movq -0x748(%rbp), %rdx
leaq 0xc418(%rip), %rsi      # 0xff40
leaq -0x598(%rbp), %rdi
callq 0x5a30
jmp 0x3b36
leaq -0x599(%rbp), %rdi
callq 0x2280
cmpl $0x1, -0x314(%rbp)
jne 0x3b90
leaq 0xb678(%rip), %rsi      # 0xf1ca
leaq -0x598(%rbp), %rdi
callq 0x2310
jmp 0x3b60
jmp 0x3b90
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x599(%rbp), %rdi
callq 0x2280
jmp 0x3fbf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x3d06
cmpl $0x2, -0x314(%rbp)
jne 0x3bb0
leaq 0xb62c(%rip), %rsi      # 0xf1cc
leaq -0x598(%rbp), %rdi
callq 0x2310
jmp 0x3bae
jmp 0x3bb0
cmpl $0x3, -0x314(%rbp)
jne 0x3bd0
leaq 0xb614(%rip), %rsi      # 0xf1d4
leaq -0x598(%rbp), %rdi
callq 0x2310
jmp 0x3bce
jmp 0x3bd0
leaq 0x11709(%rip), %rsi     # 0x152e0
leaq 0xb5fe(%rip), %rdx      # 0xf1dc
leaq -0x5c0(%rbp), %rdi
callq 0x5d00
jmp 0x3bec
movq 0x113e5(%rip), %rdi     # 0x14fd8
leaq -0x5c0(%rbp), %rsi
callq 0x2200
movq %rax, -0x750(%rbp)
jmp 0x3c08
movq -0x750(%rbp), %rdi
movsd 0x11631(%rip), %xmm0    # 0x15248
callq 0x2410
movq %rax, -0x758(%rbp)
jmp 0x3c25
movq -0x758(%rbp), %rdi
leaq 0xb5b2(%rip), %rsi      # 0xf1e5
callq 0x2230
movq %rax, -0x760(%rbp)
jmp 0x3c41
movq -0x760(%rbp), %rdi
leaq -0x598(%rbp), %rsi
callq 0x2200
movq %rax, -0x768(%rbp)
jmp 0x3c5d
movq -0x768(%rbp), %rdi
leaq 0xb59c(%rip), %rsi      # 0xf207
callq 0x2230
movq %rax, -0x770(%rbp)
jmp 0x3c79
movsd -0x480(%rbp), %xmm1
movsd -0x478(%rbp), %xmm0
mulsd %xmm0, %xmm0
mulsd %xmm1, %xmm1
addsd %xmm0, %xmm1
movsd -0x470(%rbp), %xmm0
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
callq 0x21a0
movq -0x770(%rbp), %rdi
callq 0x2410
movq %rax, -0x778(%rbp)
jmp 0x3cbf
movq -0x778(%rbp), %rdi
movq 0x112f3(%rip), %rsi     # 0x14fc0
callq 0x2260
jmp 0x3cd4
leaq -0x5c0(%rbp), %rdi
callq 0x2458
leaq -0x598(%rbp), %rdi
callq 0x2458
jmp 0x3d17
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x5c0(%rbp), %rdi
callq 0x2458
leaq -0x598(%rbp), %rdi
callq 0x2458
jmp 0x3fbf
movl $0x0, -0x5c4(%rbp)
movl -0x5c4(%rbp), %eax
cmpl -0x314(%rbp), %eax
jge 0x3d8f
movslq -0x5c4(%rbp), %rax
cmpq $0x0, -0x420(%rbp,%rax,8)
je 0x3d6b
movslq -0x5c4(%rbp), %rax
movq -0x420(%rbp,%rax,8), %rax
movq %rax, -0x780(%rbp)
cmpq $0x0, %rax
je 0x3d69
movq -0x780(%rbp), %rdi
callq 0x22f0
jmp 0x3d6b
movslq -0x5c4(%rbp), %rax
movq $0x0, -0x420(%rbp,%rax,8)
movl -0x5c4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c4(%rbp)
jmp 0x3d21
xorl %eax, %eax
movl %eax, %edi
callq 0x2210
movq %rax, -0x5d0(%rbp)
movq -0x5d0(%rbp), %rax
subq -0xd0(%rbp), %rax
movq %rax, -0x5d8(%rbp)
cmpl $0x1, 0x11485(%rip)     # 0x15240
jle 0x3ea8
leaq 0x11518(%rip), %rsi     # 0x152e0
leaq 0xb43d(%rip), %rdx      # 0xf20c
leaq -0x5f8(%rbp), %rdi
callq 0x5d00
jmp 0x3ddd
movq 0x111f4(%rip), %rdi     # 0x14fd8
leaq -0x5f8(%rbp), %rsi
callq 0x2200
movq %rax, -0x788(%rbp)
jmp 0x3df9
movq -0x788(%rbp), %rdi
movl 0x1151e(%rip), %esi     # 0x15324
callq 0x2390
movq %rax, -0x790(%rbp)
jmp 0x3e14
movq -0x790(%rbp), %rdi
leaq 0xb3ec(%rip), %rsi      # 0xf20e
callq 0x2230
movq %rax, -0x798(%rbp)
jmp 0x3e30
movq -0x798(%rbp), %rdi
movq -0x5d8(%rbp), %rsi
callq 0x23f0
movq %rax, -0x7a0(%rbp)
jmp 0x3e4c
movq -0x7a0(%rbp), %rdi
leaq 0xbd95(%rip), %rsi      # 0xfbef
callq 0x2230
movq %rax, -0x7a8(%rbp)
jmp 0x3e68
movq -0x7a8(%rbp), %rdi
movq 0x1114a(%rip), %rsi     # 0x14fc0
callq 0x2260
jmp 0x3e7d
leaq -0x5f8(%rbp), %rdi
callq 0x2458
jmp 0x3ea8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x5f8(%rbp), %rdi
callq 0x2458
jmp 0x3fbf
cmpl $0x0, 0x11475(%rip)     # 0x15324
jne 0x3fa0
cmpl $0x0, 0x11384(%rip)     # 0x15240
jle 0x3fa0
movq 0x1110f(%rip), %rdi     # 0x14fd8
leaq 0xb350(%rip), %rsi      # 0xf220
callq 0x2230
movq %rax, -0x7b0(%rbp)
jmp 0x3ede
movq -0x7b0(%rbp), %rdi
movq 0x110d4(%rip), %rsi     # 0x14fc0
callq 0x2260
jmp 0x3ef3
leaq 0x113e6(%rip), %rsi     # 0x152e0
leaq 0xb355(%rip), %rdx      # 0xf256
leaq -0x618(%rbp), %rdi
callq 0x5d00
jmp 0x3f0f
movq 0x110c2(%rip), %rdi     # 0x14fd8
leaq -0x618(%rbp), %rsi
callq 0x2200
movq %rax, -0x7b8(%rbp)
jmp 0x3f2b
movq -0x7b8(%rbp), %rdi
movq -0x5d8(%rbp), %rsi
callq 0x23f0
movq %rax, -0x7c0(%rbp)
jmp 0x3f47
movq -0x7c0(%rbp), %rdi
leaq 0xbc9a(%rip), %rsi      # 0xfbef
callq 0x2230
movq %rax, -0x7c8(%rbp)
jmp 0x3f63
movq -0x7c8(%rbp), %rdi
movq 0x1104f(%rip), %rsi     # 0x14fc0
callq 0x2260
jmp 0x3f78
leaq -0x618(%rbp), %rdi
callq 0x2458
jmp 0x3fa0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x618(%rbp), %rdi
callq 0x2458
jmp 0x3fbf
movl $0x0, -0x4(%rbp)
movl $0x1, -0xa4(%rbp)
leaq -0x310(%rbp), %rdi
callq 0x80d0
jmp 0x3fcd
leaq -0x310(%rbp), %rdi
callq 0x80d0
jmp 0x3fe2
leaq -0x28(%rbp), %rdi
callq 0x5ca0
movl -0x4(%rbp), %eax
addq $0x7d0, %rsp            # imm = 0x7D0
popq %rbp
retq
leaq -0x28(%rbp), %rdi
callq 0x5ca0
movq -0x38(%rbp), %rdi
callq 0x23b0
nopw %cs:(%rax,%rax)