// File: lipiji[P]PG_DEEP/deep.cpp
// Function: DBN::finetune(Dataset, Conf)
void DBN::finetune(Dataset data, Conf conf)
{
    cout << "Fine-tuning..." << endl;
    // BP fine-tuning method
    // First, train the LR model without fine-tuning
    double *layer_input = NULL;
    double *pre_layer_input = NULL;
    int pre_size;

    for(int epoch=0; epoch<conf.epoch; epoch++)
    {
        //ofstream fout("./model/x.txt");
        for(int i=0; i<n_samples; i++)
        {
            vector<vector<double> > ai;
            vector<vector<double> > deltai;

            int *train_y = new int[n_labels];
            for(int yi=0; yi<n_labels; yi++)
                train_y[yi] = 0;
            train_y[int(data.Y[i])] = 1;
            // some x may be computed many times
            // which may be replaced by DP algoritham
            for(int j=0; j<n_layers; j++)
            {
                if(j == 0)
                {
                    pre_size = n_features;
                    pre_layer_input = new double[pre_size];
                    for(int f=0; f<pre_size; f++)
                        pre_layer_input[f] = data.X[i][f];
                    
                    //a0 = v0
                    vector<double> al;
                    for(int ia=0; ia<pre_size; ia++)
                        al.push_back(pre_layer_input[ia]);
                    ai.push_back(al);
                    vector<double>().swap(al);
                }
                else
                {
                    pre_size = hidden_layer_size[j-1];
                    pre_layer_input = new double[pre_size];

                    for(int f=0; f<pre_size; f++)
                        pre_layer_input[f] = layer_input[f];
                    delete[] layer_input;

                }
                layer_input = new double[hidden_layer_size[j]];
                rbm_layers[j]->activate_hidden(pre_layer_input, layer_input, NULL, pre_size, hidden_layer_size[j]);
                delete[] pre_layer_input;
                vector<double> al;
                for(int ia=0; ia<hidden_layer_size[j]; ia++)
                    al.push_back(layer_input[ia]);
                ai.push_back(al);
                vector<double>().swap(al);
            }
            ///////////
            // for(int ii=0; ii<hidden_layer_size[n_layers-1]; ii++)
            //   fout << layer_input[ii] << " ";
            //fout << int(data.Y[i]) << endl;
            /////////

            //output layer
            //in http://deeplearning.stanford.edu/wiki/index.php/Fine-tuning_Stacked_AEs
            double *pred_y = new double[lr_layer->n_labels];
            lr_layer->predict(layer_input, pred_y);
            vector<double> di0;
            for(int j=0; j<lr_layer->n_labels; j++)
                di0.push_back(-1*(train_y[j] - pred_y[j]) * pred_y[j] * (1 - pred_y[j]));
            deltai.push_back(di0);
            vector<double>().swap(di0);
            
            // hidden layer
            for(int l=n_layers; l>=0; l--)
            {
                if(l == n_layers)
                {
                    vector<double> di;
                    for(int j=0; j<lr_layer->n_features; j++)
                    {
                        double di_tmp = 0;
                        for(int f=0; f<lr_layer->n_labels; f++)
                        {
                            di_tmp += lr_layer->W[f][j] * deltai[n_layers-l][f];
                        }
                        di_tmp *= ai[l][j] * (1 -  ai[l][j]);
                        di.push_back(di_tmp);
                    }
                    deltai.push_back(di);
                    vector<double>().swap(di);
                }
                else
                {
                    vector<double> di;
                    for(int j=0; j<rbm_layers[l]->n_visible; j++)
                    {
                        double di_tmp = 0;
                        for(int f=0; f<rbm_layers[l]->n_hidden; f++)
                        {
                            di_tmp += rbm_layers[l]->W[f][j] * deltai[n_layers-l][f];
                        }
                        di_tmp *= ai[l][j] * (1 -  ai[l][j]);
                        di.push_back(di_tmp);
                    }
                    deltai.push_back(di);
                    vector<double>().swap(di);
                }
            }// end deltai

            // update hidden layer parameters
            for(int l=0; l<n_layers; l++)
            {
                for(int j=0; j<rbm_layers[l]->n_hidden; j++)
                {
                    for(int f=0; f<rbm_layers[l]->n_visible; f++)
                    {
                        rbm_layers[l]->W[j][f] -= alpha*(deltai[n_layers-l][j]*ai[l][f] + lamda * rbm_layers[l]->W[j][f]); 
                    }
                    rbm_layers[l]->hbias[j] -= alpha * deltai[n_layers-l][j];
                }
            }
            // update the parameters in LR layer
            lr_layer->train(layer_input, train_y, conf.learning_rate);
            
            vector<vector<double> >().swap(ai);
            vector<vector<double> >().swap(deltai);

            delete[] train_y;
            delete[] pred_y;
            delete[] layer_input;
        }//end xi


        ////////////
        //fout << flush;fout.close();
        cout << "Fine-tuning epoch: " << epoch <<endl;
    }//end epoch
    cout << "Fine-tuning done." << endl;

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2e0, %rsp            # imm = 0x2E0
movq %rsi, -0x238(%rbp)
movq %rdx, -0x230(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x228(%rbp)
movq 0x73d9(%rip), %rdi      # 0xefd0
leaq 0x35ad(%rip), %rsi      # 0xb1ab
callq 0x2210
movq %rax, %rdi
movq 0x73b3(%rip), %rsi      # 0xefc0
callq 0x2240
movq $0x0, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
movl $0x0, -0x30(%rbp)
movq -0x230(%rbp), %rcx
movl -0x30(%rbp), %eax
cmpl 0x80(%rcx), %eax
jge 0x8ab8
movl $0x0, -0x34(%rbp)
movq -0x228(%rbp), %rcx
movl -0x34(%rbp), %eax
cmpl (%rcx), %eax
jge 0x8a7d
leaq -0x50(%rbp), %rdi
callq 0x8ed0
leaq -0x68(%rbp), %rdi
callq 0x8ed0
movq -0x228(%rbp), %rax
movslq 0xc(%rax), %rax
movl $0x4, %ecx
mulq %rcx
movq %rax, %rdi
movq $-0x1, %rax
cmovoq %rax, %rdi
callq 0x2030
movq %rax, -0x240(%rbp)
jmp 0x7c99
movq -0x240(%rbp), %rax
movq %rax, -0x70(%rbp)
movl $0x0, -0x80(%rbp)
movq -0x228(%rbp), %rcx
movl -0x80(%rbp), %eax
cmpl 0xc(%rcx), %eax
jge 0x7ce5
movq -0x70(%rbp), %rax
movslq -0x80(%rbp), %rcx
movl $0x0, (%rax,%rcx,4)
movl -0x80(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x80(%rbp)
jmp 0x7cab
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0x8a69
movq -0x238(%rbp), %rdi
movq -0x70(%rbp), %rax
movq %rax, -0x248(%rbp)
addq $0x20, %rdi
movslq -0x34(%rbp), %rsi
callq 0x3300
movq %rax, %rcx
movq -0x248(%rbp), %rax
cvttsd2si (%rcx), %ecx
movslq %ecx, %rcx
movl $0x1, (%rax,%rcx,4)
movl $0x0, -0x84(%rbp)
movq -0x228(%rbp), %rcx
movl -0x84(%rbp), %eax
cmpl 0x8(%rcx), %eax
jge 0x80f5
cmpl $0x0, -0x84(%rbp)
jne 0x7eb5
movq -0x228(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0x2c(%rbp)
movslq -0x2c(%rbp), %rax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
movq $-0x1, %rax
cmovoq %rax, %rdi
callq 0x2030
movq %rax, -0x250(%rbp)
jmp 0x7d7e
movq -0x250(%rbp), %rax
movq %rax, -0x28(%rbp)
movl $0x0, -0x88(%rbp)
movl -0x88(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jge 0x7de6
movq -0x238(%rbp), %rdi
addq $0x8, %rdi
movslq -0x34(%rbp), %rsi
callq 0x32e0
movq %rax, %rdi
movslq -0x88(%rbp), %rsi
callq 0x3300
movsd (%rax), %xmm0
movq -0x28(%rbp), %rax
movslq -0x88(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x88(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x88(%rbp)
jmp 0x7d93
leaq -0xa0(%rbp), %rdi
callq 0x8ef0
movl $0x0, -0xa4(%rbp)
movl -0xa4(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jge 0x7e54
movq -0x28(%rbp), %rax
movslq -0xa4(%rbp), %rcx
leaq (%rax,%rcx,8), %rsi
leaq -0xa0(%rbp), %rdi
callq 0x9070
jmp 0x7e24
jmp 0x7e26
movl -0xa4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa4(%rbp)
jmp 0x7dfc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x3c10
jmp 0x8a69
leaq -0x50(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x8f40
jmp 0x7e66
leaq -0xc0(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x2130
leaq -0xc0(%rbp), %rdi
callq 0x8ef0
leaq -0xc0(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x8fb0
leaq -0xc0(%rbp), %rdi
callq 0x3c10
leaq -0xa0(%rbp), %rdi
callq 0x3c10
jmp 0x7f69
movq -0x228(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x84(%rbp), %ecx
decl %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x2c(%rbp)
movslq -0x2c(%rbp), %rax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
movq $-0x1, %rax
cmovoq %rax, %rdi
callq 0x2030
movq %rax, -0x258(%rbp)
jmp 0x7ef9
movq -0x258(%rbp), %rax
movq %rax, -0x28(%rbp)
movl $0x0, -0xc4(%rbp)
movl -0xc4(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jge 0x7f4a
movq -0x20(%rbp), %rax
movslq -0xc4(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x28(%rbp), %rax
movslq -0xc4(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0xc4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc4(%rbp)
jmp 0x7f0e
movq -0x20(%rbp), %rax
movq %rax, -0x260(%rbp)
cmpq $0x0, %rax
je 0x7f67
movq -0x260(%rbp), %rdi
callq 0x22e0
jmp 0x7f69
movq -0x228(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x84(%rbp), %rcx
movslq (%rax,%rcx,4), %rax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
movq $-0x1, %rax
cmovoq %rax, %rdi
callq 0x2030
movq %rax, -0x268(%rbp)
jmp 0x7fa3
movq -0x228(%rbp), %rax
movq -0x268(%rbp), %rcx
movq %rcx, -0x20(%rbp)
movq 0x28(%rax), %rcx
movslq -0x84(%rbp), %rdx
movq (%rcx,%rdx,8), %rdi
movq -0x28(%rbp), %rsi
movq -0x20(%rbp), %rdx
movl -0x2c(%rbp), %r8d
movq 0x10(%rax), %rax
movslq -0x84(%rbp), %rcx
movl (%rax,%rcx,4), %r9d
xorl %eax, %eax
movl %eax, %ecx
callq 0x5e60
movq -0x28(%rbp), %rax
movq %rax, -0x270(%rbp)
cmpq $0x0, %rax
je 0x8005
movq -0x270(%rbp), %rdi
callq 0x22e0
leaq -0xe0(%rbp), %rdi
callq 0x8ef0
movl $0x0, -0xe4(%rbp)
movq -0x228(%rbp), %rcx
movl -0xe4(%rbp), %eax
movq 0x10(%rcx), %rcx
movslq -0x84(%rbp), %rdx
cmpl (%rcx,%rdx,4), %eax
jge 0x8085
movq -0x20(%rbp), %rax
movslq -0xe4(%rbp), %rcx
leaq (%rax,%rcx,8), %rsi
leaq -0xe0(%rbp), %rdi
callq 0x9070
jmp 0x8055
jmp 0x8057
movl -0xe4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xe4(%rbp)
jmp 0x801b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0xe0(%rbp), %rdi
callq 0x3c10
jmp 0x8a69
leaq -0x50(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0x8f40
jmp 0x8097
leaq -0x100(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x2130
leaq -0x100(%rbp), %rdi
callq 0x8ef0
leaq -0x100(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0x8fb0
leaq -0x100(%rbp), %rdi
callq 0x3c10
leaq -0xe0(%rbp), %rdi
callq 0x3c10
movl -0x84(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x84(%rbp)
jmp 0x7d26
movq -0x228(%rbp), %rax
movq 0x30(%rax), %rax
movslq 0x8(%rax), %rax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
movq $-0x1, %rax
cmovoq %rax, %rdi
callq 0x2030
movq %rax, -0x278(%rbp)
jmp 0x8128
movq -0x228(%rbp), %rax
movq -0x278(%rbp), %rcx
movq %rcx, -0x108(%rbp)
movq 0x30(%rax), %rdi
movq -0x20(%rbp), %rsi
movq -0x108(%rbp), %rdx
callq 0x6c60
leaq -0x120(%rbp), %rdi
callq 0x8ef0
movl $0x0, -0x124(%rbp)
movq -0x228(%rbp), %rcx
movl -0x124(%rbp), %eax
movq 0x30(%rcx), %rcx
cmpl 0x8(%rcx), %eax
jge 0x8204
movq -0x70(%rbp), %rax
movslq -0x124(%rbp), %rcx
cvtsi2sdl (%rax,%rcx,4), %xmm0
movq -0x108(%rbp), %rax
movsd (%rax,%rcx,8), %xmm2
subsd %xmm2, %xmm0
movaps 0x2f48(%rip), %xmm1     # 0xb0f0
pxor %xmm1, %xmm0
mulsd %xmm2, %xmm0
movsd 0x2e50(%rip), %xmm1     # 0xb008
subsd %xmm2, %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, -0x130(%rbp)
leaq -0x120(%rbp), %rdi
leaq -0x130(%rbp), %rsi
callq 0x8f10
jmp 0x81dd
jmp 0x81df
movl -0x124(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x124(%rbp)
jmp 0x8167
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0x8a5d
leaq -0x68(%rbp), %rdi
leaq -0x120(%rbp), %rsi
callq 0x8f40
jmp 0x8216
leaq -0x148(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x2130
leaq -0x148(%rbp), %rdi
callq 0x8ef0
leaq -0x148(%rbp), %rdi
leaq -0x120(%rbp), %rsi
callq 0x8fb0
leaq -0x148(%rbp), %rdi
callq 0x3c10
movq -0x228(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x14c(%rbp)
cmpl $0x0, -0x14c(%rbp)
jl 0x86e5
movq -0x228(%rbp), %rcx
movl -0x14c(%rbp), %eax
cmpl 0x8(%rcx), %eax
jne 0x849d
leaq -0x168(%rbp), %rdi
callq 0x8ef0
movl $0x0, -0x16c(%rbp)
movq -0x228(%rbp), %rcx
movl -0x16c(%rbp), %eax
movq 0x30(%rcx), %rcx
cmpl 0x4(%rcx), %eax
jge 0x843c
xorps %xmm0, %xmm0
movsd %xmm0, -0x178(%rbp)
movl $0x0, -0x17c(%rbp)
movq -0x228(%rbp), %rcx
movl -0x17c(%rbp), %eax
movq 0x30(%rcx), %rcx
cmpl 0x8(%rcx), %eax
jge 0x8370
movq -0x228(%rbp), %rax
movq 0x30(%rax), %rcx
movq 0x18(%rcx), %rcx
movslq -0x17c(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
movslq -0x16c(%rbp), %rdx
movsd (%rcx,%rdx,8), %xmm0
movsd %xmm0, -0x280(%rbp)
movl 0x8(%rax), %eax
subl -0x14c(%rbp), %eax
movslq %eax, %rsi
leaq -0x68(%rbp), %rdi
callq 0x32e0
movq %rax, %rdi
movslq -0x17c(%rbp), %rsi
callq 0x3300
movsd -0x280(%rbp), %xmm0
movsd (%rax), %xmm2
movsd -0x178(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x178(%rbp)
movl -0x17c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x17c(%rbp)
jmp 0x82cc
movslq -0x14c(%rbp), %rsi
leaq -0x50(%rbp), %rdi
movq %rdi, -0x290(%rbp)
callq 0x32e0
movq %rax, %rdi
movslq -0x16c(%rbp), %rsi
callq 0x3300
movq -0x290(%rbp), %rdi
movsd (%rax), %xmm0
movsd %xmm0, -0x288(%rbp)
movslq -0x14c(%rbp), %rsi
callq 0x32e0
movq %rax, %rdi
movslq -0x16c(%rbp), %rsi
callq 0x3300
movsd -0x288(%rbp), %xmm1
movsd (%rax), %xmm2
movsd 0x2c30(%rip), %xmm0     # 0xb008
subsd %xmm2, %xmm0
mulsd %xmm0, %xmm1
movsd -0x178(%rbp), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, -0x178(%rbp)
leaq -0x168(%rbp), %rdi
leaq -0x178(%rbp), %rsi
callq 0x9070
jmp 0x8409
jmp 0x840b
movl -0x16c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x16c(%rbp)
jmp 0x829d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0x168(%rbp), %rdi
callq 0x3c10
jmp 0x8a5d
leaq -0x68(%rbp), %rdi
leaq -0x168(%rbp), %rsi
callq 0x8f40
jmp 0x844e
leaq -0x198(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x2130
leaq -0x198(%rbp), %rdi
callq 0x8ef0
leaq -0x198(%rbp), %rdi
leaq -0x168(%rbp), %rsi
callq 0x8fb0
leaq -0x198(%rbp), %rdi
callq 0x3c10
leaq -0x168(%rbp), %rdi
callq 0x3c10
jmp 0x86cf
leaq -0x1b0(%rbp), %rdi
callq 0x8ef0
movl $0x0, -0x1b4(%rbp)
movq -0x228(%rbp), %rcx
movl -0x1b4(%rbp), %eax
movq 0x28(%rcx), %rcx
movslq -0x14c(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
cmpl 0x4(%rcx), %eax
jge 0x8673
xorps %xmm0, %xmm0
movsd %xmm0, -0x1c0(%rbp)
movl $0x0, -0x1c4(%rbp)
movq -0x228(%rbp), %rcx
movl -0x1c4(%rbp), %eax
movq 0x28(%rcx), %rcx
movslq -0x14c(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
cmpl 0x8(%rcx), %eax
jge 0x85a7
movq -0x228(%rbp), %rax
movq 0x28(%rax), %rcx
movslq -0x14c(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
movq 0x10(%rcx), %rcx
movslq -0x1c4(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
movslq -0x1b4(%rbp), %rdx
movsd (%rcx,%rdx,8), %xmm0
movsd %xmm0, -0x298(%rbp)
movl 0x8(%rax), %eax
subl -0x14c(%rbp), %eax
movslq %eax, %rsi
leaq -0x68(%rbp), %rdi
callq 0x32e0
movq %rax, %rdi
movslq -0x1c4(%rbp), %rsi
callq 0x3300
movsd -0x298(%rbp), %xmm0
movsd (%rax), %xmm2
movsd -0x1c0(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x1c0(%rbp)
movl -0x1c4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c4(%rbp)
jmp 0x84ed
movslq -0x14c(%rbp), %rsi
leaq -0x50(%rbp), %rdi
movq %rdi, -0x2a8(%rbp)
callq 0x32e0
movq %rax, %rdi
movslq -0x1b4(%rbp), %rsi
callq 0x3300
movq -0x2a8(%rbp), %rdi
movsd (%rax), %xmm0
movsd %xmm0, -0x2a0(%rbp)
movslq -0x14c(%rbp), %rsi
callq 0x32e0
movq %rax, %rdi
movslq -0x1b4(%rbp), %rsi
callq 0x3300
movsd -0x2a0(%rbp), %xmm1
movsd (%rax), %xmm2
movsd 0x29f9(%rip), %xmm0     # 0xb008
subsd %xmm2, %xmm0
mulsd %xmm0, %xmm1
movsd -0x1c0(%rbp), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, -0x1c0(%rbp)
leaq -0x1b0(%rbp), %rdi
leaq -0x1c0(%rbp), %rsi
callq 0x9070
jmp 0x8640
jmp 0x8642
movl -0x1b4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1b4(%rbp)
jmp 0x84b3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0x1b0(%rbp), %rdi
callq 0x3c10
jmp 0x8a5d
leaq -0x68(%rbp), %rdi
leaq -0x1b0(%rbp), %rsi
callq 0x8f40
jmp 0x8685
leaq -0x1e0(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x2130
leaq -0x1e0(%rbp), %rdi
callq 0x8ef0
leaq -0x1e0(%rbp), %rdi
leaq -0x1b0(%rbp), %rsi
callq 0x8fb0
leaq -0x1e0(%rbp), %rdi
callq 0x3c10
leaq -0x1b0(%rbp), %rdi
callq 0x3c10
jmp 0x86d1
movl -0x14c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x14c(%rbp)
jmp 0x8264
movl $0x0, -0x1e4(%rbp)
movq -0x228(%rbp), %rcx
movl -0x1e4(%rbp), %eax
cmpl 0x8(%rcx), %eax
jge 0x8938
movl $0x0, -0x1e8(%rbp)
movq -0x228(%rbp), %rcx
movl -0x1e8(%rbp), %eax
movq 0x28(%rcx), %rcx
movslq -0x1e4(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
cmpl 0x8(%rcx), %eax
jge 0x8922
movl $0x0, -0x1ec(%rbp)
movq -0x228(%rbp), %rcx
movl -0x1ec(%rbp), %eax
movq 0x28(%rcx), %rcx
movslq -0x1e4(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
cmpl 0x4(%rcx), %eax
jge 0x887d
movq -0x228(%rbp), %rax
movsd 0x20(%rax), %xmm0
movsd %xmm0, -0x2b0(%rbp)
movl 0x8(%rax), %eax
subl -0x1e4(%rbp), %eax
movslq %eax, %rsi
leaq -0x68(%rbp), %rdi
callq 0x32e0
movq %rax, %rdi
movslq -0x1e8(%rbp), %rsi
callq 0x3300
movsd (%rax), %xmm0
movsd %xmm0, -0x2b8(%rbp)
movslq -0x1e4(%rbp), %rsi
leaq -0x50(%rbp), %rdi
callq 0x32e0
movq %rax, %rdi
movslq -0x1ec(%rbp), %rsi
callq 0x3300
movsd -0x2b8(%rbp), %xmm2
movsd -0x2b0(%rbp), %xmm0
movq %rax, %rcx
movq -0x228(%rbp), %rax
movsd (%rcx), %xmm3
movsd 0x18(%rax), %xmm1
movq 0x28(%rax), %rcx
movslq -0x1e4(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
movq 0x10(%rcx), %rcx
movslq -0x1e8(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
movslq -0x1ec(%rbp), %rdx
mulsd (%rcx,%rdx,8), %xmm1
mulsd %xmm3, %xmm2
addsd %xmm1, %xmm2
movq 0x28(%rax), %rax
movslq -0x1e4(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x10(%rax), %rax
movslq -0x1e8(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x1ec(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm1
movq %xmm0, %rdx
movabsq $-0x8000000000000000, %rsi # imm = 0x8000000000000000
xorq %rsi, %rdx
movq %rdx, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movl -0x1ec(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1ec(%rbp)
jmp 0x873e
movq -0x228(%rbp), %rax
movsd 0x20(%rax), %xmm0
movsd %xmm0, -0x2c0(%rbp)
movl 0x8(%rax), %eax
subl -0x1e4(%rbp), %eax
movslq %eax, %rsi
leaq -0x68(%rbp), %rdi
callq 0x32e0
movq %rax, %rdi
movslq -0x1e8(%rbp), %rsi
callq 0x3300
movsd -0x2c0(%rbp), %xmm0
movq %rax, %rcx
movq -0x228(%rbp), %rax
movsd (%rcx), %xmm2
movq 0x28(%rax), %rax
movslq -0x1e4(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x18(%rax), %rax
movslq -0x1e8(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm1
movq %xmm0, %rdx
movabsq $-0x8000000000000000, %rsi # imm = 0x8000000000000000
xorq %rsi, %rdx
movq %rdx, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movl -0x1e8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1e8(%rbp)
jmp 0x870f
jmp 0x8924
movl -0x1e4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1e4(%rbp)
jmp 0x86ef
movq -0x230(%rbp), %rax
movq -0x228(%rbp), %rcx
movq 0x30(%rcx), %rdi
movq -0x20(%rbp), %rsi
movq -0x70(%rbp), %rdx
movsd 0x98(%rax), %xmm0
callq 0x68f0
jmp 0x8961
leaq -0x208(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x2130
leaq -0x208(%rbp), %rdi
callq 0x8ed0
leaq -0x208(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x9010
leaq -0x208(%rbp), %rdi
callq 0x3500
leaq -0x220(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x2130
leaq -0x220(%rbp), %rdi
callq 0x8ed0
leaq -0x220(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x9010
leaq -0x220(%rbp), %rdi
callq 0x3500
movq -0x70(%rbp), %rax
movq %rax, -0x2c8(%rbp)
cmpq $0x0, %rax
je 0x89f4
movq -0x2c8(%rbp), %rdi
callq 0x22e0
movq -0x108(%rbp), %rax
movq %rax, -0x2d0(%rbp)
cmpq $0x0, %rax
je 0x8a14
movq -0x2d0(%rbp), %rdi
callq 0x22e0
movq -0x20(%rbp), %rax
movq %rax, -0x2d8(%rbp)
cmpq $0x0, %rax
je 0x8a31
movq -0x2d8(%rbp), %rdi
callq 0x22e0
leaq -0x120(%rbp), %rdi
callq 0x3c10
leaq -0x68(%rbp), %rdi
callq 0x3500
leaq -0x50(%rbp), %rdi
callq 0x3500
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x7c46
leaq -0x120(%rbp), %rdi
callq 0x3c10
leaq -0x68(%rbp), %rdi
callq 0x3500
leaq -0x50(%rbp), %rdi
callq 0x3500
jmp 0x8ae3
movq 0x654c(%rip), %rdi      # 0xefd0
leaq 0x272f(%rip), %rsi      # 0xb1ba
callq 0x2210
movq %rax, %rdi
movl -0x30(%rbp), %esi
callq 0x2380
movq %rax, %rdi
movq 0x651b(%rip), %rsi      # 0xefc0
callq 0x2240
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x7c29
movq 0x6511(%rip), %rdi      # 0xefd0
leaq 0x2708(%rip), %rsi      # 0xb1ce
callq 0x2210
movq %rax, %rdi
movq 0x64eb(%rip), %rsi      # 0xefc0
callq 0x2240
addq $0x2e0, %rsp            # imm = 0x2E0
popq %rbp
retq
movq -0x78(%rbp), %rdi
callq 0x23a0
nopl (%rax)