// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc8, %rsp
movq %rdx, %r14
movq %rsi, 0xa8(%rsp)
movq %rdi, %r12
movq 0x4850(%rip), %rbx      # 0x9fd8
leaq 0x1a4c(%rip), %rsi      # 0x71db
movl $0xe, %edx
movq %rbx, %rdi
callq 0x21e0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2110
movq %r14, 0x98(%rsp)
cmpl $0x0, 0x80(%r14)
jle 0x611f
xorl %ebx, %ebx
movq %rsp, %r13
xorl %ebp, %ebp
movl $0x0, 0x4c(%rsp)
cmpl $0x0, (%r12)
jle 0x60ad
xorl %ecx, %ecx
movq %rcx, 0xa0(%rsp)
xorpd %xmm0, %xmm0
movapd %xmm0, 0x80(%rsp)
movq %rbx, 0x90(%rsp)
movq %rbx, 0x60(%rsp)
movapd %xmm0, 0x50(%rsp)
movslq 0xc(%r12), %rbx
leaq (,%rbx,4), %r14
testq %rbx, %rbx
movq %r14, %rdi
movq $-0x1, %rax
cmovsq %rax, %rdi
callq 0x2030
movq %rax, 0x70(%rsp)
testl %ebx, %ebx
movq 0x70(%rsp), %rbx
jle 0x585b
movq %rbx, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x2100
movq 0xa8(%rsp), %rax
movq 0x20(%rax), %rax
movq 0xa0(%rsp), %rcx
cvttsd2si (%rax,%rcx,8), %eax
cltq
movl $0x1, (%rbx,%rax,4)
cmpl $0x0, 0x8(%r12)
jle 0x5af4
leaq (%rcx,%rcx,2), %rax
movq %rax, 0x78(%rsp)
xorl %ebx, %ebx
testq %rbx, %rbx
je 0x58f2
movq 0x10(%r12), %rax
movslq -0x4(%rax,%rbx,4), %r13
leaq (,%r13,8), %rdi
testq %r13, %r13
movq $-0x1, %rax
cmovsq %rax, %rdi
callq 0x2030
movq %rax, %r15
testl %r13d, %r13d
jle 0x58dc
xorl %eax, %eax
movsd (%rbp,%rax,8), %xmm0
movsd %xmm0, (%r15,%rax,8)
incq %rax
cmpq %rax, %r13
jne 0x58c8
testq %rbp, %rbp
je 0x59e3
movq %rbp, %rdi
callq 0x2210
jmp 0x59e3
movslq 0x4(%r12), %r14
leaq (,%r14,8), %rdi
testq %r14, %r14
movq $-0x1, %rax
cmovsq %rax, %rdi
callq 0x2030
movq %rax, %r15
movl %r14d, %r13d
testl %r14d, %r14d
jle 0x5947
movq 0xa8(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x78(%rsp), %rcx
movq (%rax,%rcx,8), %rax
xorl %ecx, %ecx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, (%r15,%rcx,8)
incq %rcx
cmpq %rcx, %r14
jne 0x5934
xorpd %xmm0, %xmm0
movapd %xmm0, (%rsp)
movq $0x0, 0x10(%rsp)
movq %r15, %rbp
testl %r13d, %r13d
jle 0x5995
movq 0x8(%rsp), %rsi
cmpq 0x10(%rsp), %rsi
je 0x5981
movsd (%rbp), %xmm0
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x8(%rsp)
jmp 0x598c
movq %rsp, %rdi
movq %rbp, %rdx
callq 0x67b2
addq $0x8, %rbp
decq %r14
jne 0x5961
leaq 0x80(%rsp), %rdi
movq %rsp, %rsi
callq 0x6484
movq (%rsp), %rdi
movq 0x10(%rsp), %rsi
xorpd %xmm0, %xmm0
movapd %xmm0, (%rsp)
movq $0x0, 0x10(%rsp)
testq %rdi, %rdi
je 0x59cd
subq %rdi, %rsi
callq 0x21c0
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x59e3
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x21c0
movq 0x10(%r12), %r14
movslq (%r14,%rbx,4), %rax
leaq (,%rax,8), %rdi
testq %rax, %rax
movq $-0x1, %rax
cmovsq %rax, %rdi
callq 0x2030
movq %rax, %rbp
movq 0x28(%r12), %rax
movq (%rax,%rbx,8), %rdi
movl (%r14,%rbx,4), %r9d
movq %r15, %rsi
movq %rbp, %rdx
xorl %ecx, %ecx
movl %r13d, %r8d
callq 0x44f6
movq %r15, %rdi
callq 0x2210
xorpd %xmm0, %xmm0
movapd %xmm0, (%rsp)
movq $0x0, 0x10(%rsp)
movq 0x10(%r12), %rax
cmpl $0x0, (%rax,%rbx,4)
movq %rsp, %r13
jle 0x5a95
movq %rbp, %r14
xorl %r15d, %r15d
movq 0x8(%rsp), %rsi
cmpq 0x10(%rsp), %rsi
je 0x5a75
movsd (%r14), %xmm0
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x8(%rsp)
jmp 0x5a80
movq %r13, %rdi
movq %r14, %rdx
callq 0x67b2
incq %r15
movq 0x10(%r12), %rax
movslq (%rax,%rbx,4), %rax
addq $0x8, %r14
cmpq %rax, %r15
jl 0x5a55
leaq 0x80(%rsp), %rdi
movq %r13, %rsi
callq 0x6484
movq (%rsp), %rdi
movq 0x10(%rsp), %rsi
xorpd %xmm0, %xmm0
movapd %xmm0, (%rsp)
movq $0x0, 0x10(%rsp)
testq %rdi, %rdi
je 0x5acd
subq %rdi, %rsi
callq 0x21c0
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x5ae3
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x21c0
incq %rbx
movslq 0x8(%r12), %rax
cmpq %rax, %rbx
jl 0x5894
movq 0x30(%r12), %r15
movslq 0x8(%r15), %rax
leaq (,%rax,8), %rdi
testq %rax, %rax
movq $-0x1, %rax
cmovsq %rax, %rdi
callq 0x2030
movq %r15, %rdi
movq %rbp, %rsi
movq %rax, 0xb0(%rsp)
movq %rax, %rdx
callq 0x4d66
xorpd %xmm0, %xmm0
movapd %xmm0, (%rsp)
movq $0x0, 0x10(%rsp)
movq 0x30(%r12), %rax
cmpl $0x0, 0x8(%rax)
jle 0x5bc6
xorl %ebx, %ebx
movq 0x70(%rsp), %rax
xorps %xmm1, %xmm1
cvtsi2sdl (%rax,%rbx,4), %xmm1
movq 0xb0(%rsp), %rax
movsd (%rax,%rbx,8), %xmm2
subsd %xmm2, %xmm1
xorpd 0x158d(%rip), %xmm1     # 0x7100
mulsd %xmm2, %xmm1
movsd 0x1499(%rip), %xmm0     # 0x7018
subsd %xmm2, %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, 0x20(%rsp)
movq 0x8(%rsp), %rsi
cmpq 0x10(%rsp), %rsi
je 0x5ba8
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x8(%rsp)
jmp 0x5bb5
movq %r13, %rdi
leaq 0x20(%rsp), %rdx
callq 0x64b0
incq %rbx
movq 0x30(%r12), %rax
movslq 0x8(%rax), %rax
cmpq %rax, %rbx
jl 0x5b4d
leaq 0x50(%rsp), %rdi
movq %r13, %rsi
callq 0x6484
movq (%rsp), %rdi
movq 0x10(%rsp), %rsi
xorpd %xmm0, %xmm0
movapd %xmm0, (%rsp)
movq $0x0, 0x10(%rsp)
testq %rdi, %rdi
je 0x5bfb
subq %rdi, %rsi
callq 0x21c0
movslq 0x8(%r12), %rbx
testq %rbx, %rbx
leaq 0x20(%rsp), %r13
js 0x5e70
movl 0x8(%r12), %eax
xorpd %xmm0, %xmm0
cmpq %rax, %rbx
jne 0x5d19
movapd %xmm0, 0x20(%rsp)
movq $0x0, 0x30(%rsp)
movq 0x30(%r12), %rcx
cmpl $0x0, 0x4(%rcx)
jle 0x5d07
movslq %ebx, %r14
xorl %r15d, %r15d
movq $0x0, 0x40(%rsp)
movslq 0x8(%rcx), %rax
testq %rax, %rax
jle 0x5c98
movsd 0x40(%rsp), %xmm0
movq 0x18(%rcx), %rcx
movslq 0x8(%r12), %rdx
subq %r14, %rdx
movq 0x50(%rsp), %rsi
leaq (%rdx,%rdx,2), %rdx
movq (%rsi,%rdx,8), %rdx
xorl %esi, %esi
movq (%rcx,%rsi,8), %rdi
movsd (%rdi,%r15,8), %xmm1
mulsd (%rdx,%rsi,8), %xmm1
addsd %xmm1, %xmm0
movsd %xmm0, 0x40(%rsp)
incq %rsi
cmpq %rsi, %rax
jne 0x5c77
movq 0x80(%rsp), %rax
leaq (%rbx,%rbx,2), %rcx
movq (%rax,%rcx,8), %rax
movsd (%rax,%r15,8), %xmm1
movsd 0x1362(%rip), %xmm0     # 0x7018
subsd %xmm1, %xmm0
mulsd %xmm1, %xmm0
mulsd 0x40(%rsp), %xmm0
movsd %xmm0, 0x40(%rsp)
movq 0x28(%rsp), %rsi
cmpq 0x30(%rsp), %rsi
je 0x5ce5
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x28(%rsp)
jmp 0x5cf2
movq %r13, %rdi
leaq 0x40(%rsp), %rdx
callq 0x67b2
incq %r15
movq 0x30(%r12), %rcx
movslq 0x4(%rcx), %rax
cmpq %rax, %r15
jl 0x5c44
leaq 0x50(%rsp), %rdi
movq %r13, %rsi
callq 0x6484
jmp 0x5e1f
movapd %xmm0, 0x20(%rsp)
movq $0x0, 0x30(%rsp)
movq 0x28(%r12), %rax
movq (%rax,%rbx,8), %rcx
cmpl $0x0, 0x4(%rcx)
jle 0x5e12
leaq (%rax,%rbx,8), %rax
movslq %ebx, %r15
xorl %r14d, %r14d
movq $0x0, 0x40(%rsp)
movq (%rax), %rcx
movslq 0x8(%rcx), %rax
testq %rax, %rax
jle 0x5d9c
movsd 0x40(%rsp), %xmm0
movq 0x10(%rcx), %rcx
movslq 0x8(%r12), %rdx
subq %r15, %rdx
movq 0x50(%rsp), %rsi
leaq (%rdx,%rdx,2), %rdx
movq (%rsi,%rdx,8), %rdx
xorl %esi, %esi
movq (%rcx,%rsi,8), %rdi
movsd (%rdi,%r14,8), %xmm1
mulsd (%rdx,%rsi,8), %xmm1
addsd %xmm1, %xmm0
movsd %xmm0, 0x40(%rsp)
incq %rsi
cmpq %rsi, %rax
jne 0x5d7b
movq 0x80(%rsp), %rax
leaq (%rbx,%rbx,2), %rcx
movq (%rax,%rcx,8), %rax
movsd (%rax,%r14,8), %xmm1
movsd 0x125e(%rip), %xmm0     # 0x7018
subsd %xmm1, %xmm0
mulsd %xmm1, %xmm0
mulsd 0x40(%rsp), %xmm0
movsd %xmm0, 0x40(%rsp)
movq 0x28(%rsp), %rsi
cmpq 0x30(%rsp), %rsi
je 0x5de9
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x28(%rsp)
jmp 0x5df6
movq %r13, %rdi
leaq 0x40(%rsp), %rdx
callq 0x67b2
incq %r14
movq 0x28(%r12), %rax
leaq (%rax,%rbx,8), %rax
movq (%rax), %rcx
movslq 0x4(%rcx), %rcx
cmpq %rcx, %r14
jl 0x5d45
leaq 0x50(%rsp), %rdi
movq %r13, %rsi
callq 0x6484
movq 0x20(%rsp), %rdi
movq 0x30(%rsp), %rsi
xorpd %xmm0, %xmm0
movapd %xmm0, 0x20(%rsp)
movq $0x0, 0x30(%rsp)
testq %rdi, %rdi
je 0x5e49
subq %rdi, %rsi
callq 0x21c0
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x5e60
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x21c0
leaq -0x1(%rbx), %rax
testq %rbx, %rbx
movq %rax, %rbx
jg 0x5c0e
movslq 0x8(%r12), %rax
movq %rax, 0x78(%rsp)
testq %rax, %rax
jle 0x5f81
movq 0x28(%r12), %rax
movq %rax, 0xc0(%rsp)
movq 0x50(%rsp), %rax
movq %rax, 0xb8(%rsp)
xorl %esi, %esi
movq 0xc0(%rsp), %rax
movq (%rax,%rsi,8), %rdi
movslq 0x8(%rdi), %r8
testq %r8, %r8
jle 0x5f73
movl 0x4(%rdi), %r9d
movq 0x78(%rsp), %rcx
movq %rcx, %rax
subq %rsi, %rax
leaq (%rax,%rax,2), %r10
shlq $0x3, %r10
addq 0x50(%rsp), %r10
leaq (%rsi,%rsi,2), %r11
shlq $0x3, %r11
addq 0x80(%rsp), %r11
movq %rcx, %rax
subq %rsi, %rax
leaq (%rax,%rax,2), %rax
movq 0xb8(%rsp), %rcx
movq (%rcx,%rax,8), %rbx
movq 0x18(%rdi), %r14
xorl %r15d, %r15d
testl %r9d, %r9d
jle 0x5f4e
movq (%r10), %r13
movq (%r11), %rdx
movq 0x10(%rdi), %rax
movq (%rax,%r15,8), %rcx
xorl %eax, %eax
movsd (%r13,%r15,8), %xmm0
movsd (%rcx,%rax,8), %xmm1
movsd 0x18(%r12), %xmm2
mulsd (%rdx,%rax,8), %xmm0
mulsd %xmm1, %xmm2
addsd %xmm2, %xmm0
mulsd 0x20(%r12), %xmm0
subsd %xmm0, %xmm1
movsd %xmm1, (%rcx,%rax,8)
incq %rax
cmpq %rax, %r9
jne 0x5f16
movsd 0x20(%r12), %xmm0
movsd (%r14,%r15,8), %xmm1
mulsd (%rbx,%r15,8), %xmm0
subsd %xmm0, %xmm1
movsd %xmm1, (%r14,%r15,8)
incq %r15
cmpq %r8, %r15
jne 0x5f01
incq %rsi
cmpq 0x78(%rsp), %rsi
jne 0x5e9f
movq 0x30(%r12), %rdi
movq 0x98(%rsp), %rax
movsd 0x98(%rax), %xmm0
movq %rbp, %rsi
movq 0x70(%rsp), %rdx
callq 0x4b68
movq %rsp, %r13
xorpd %xmm0, %xmm0
movapd %xmm0, 0x20(%rsp)
xorl %ebx, %ebx
movq %rbx, 0x30(%rsp)
movq 0x28(%rsp), %rax
movq 0x30(%rsp), %rcx
movq 0x80(%rsp), %rdx
movq %rdx, 0x20(%rsp)
movups 0x88(%rsp), %xmm0
movups %xmm0, 0x28(%rsp)
movq %rbx, 0x80(%rsp)
movq %rax, 0x88(%rsp)
movq %rcx, 0x90(%rsp)
leaq 0x20(%rsp), %r14
movq %r14, %rdi
callq 0x318e
movq %rbx, 0x30(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
movq 0x28(%rsp), %rax
movq 0x30(%rsp), %rcx
movq 0x50(%rsp), %rdx
movq %rdx, 0x20(%rsp)
movupd 0x58(%rsp), %xmm0
movupd %xmm0, 0x28(%rsp)
movq %rbx, 0x50(%rsp)
movq %rax, 0x58(%rsp)
movq %rcx, 0x60(%rsp)
movq %r14, %rdi
callq 0x318e
movq 0x70(%rsp), %rdi
callq 0x2210
movq 0xb0(%rsp), %rdi
callq 0x2210
testq %rbp, %rbp
je 0x6068
movq %rbp, %rdi
callq 0x2210
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x607e
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x21c0
leaq 0x50(%rsp), %rdi
callq 0x318e
leaq 0x80(%rsp), %rdi
callq 0x318e
movq 0xa0(%rsp), %rcx
incq %rcx
movslq (%r12), %rax
cmpq %rax, %rcx
jl 0x57f5
movl $0x13, %edx
movq 0x3f1f(%rip), %r14      # 0x9fd8
movq %r14, %rdi
leaq 0x1127(%rip), %rsi      # 0x71ea
callq 0x21e0
movq %r14, %rdi
movl 0x4c(%rsp), %r15d
movl %r15d, %esi
callq 0x22a0
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %esi
movq %r14, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2110
incl %r15d
movq 0x98(%rsp), %rax
movl %r15d, 0x4c(%rsp)
cmpl 0x80(%rax), %r15d
jl 0x57e8
leaq 0x10d8(%rip), %rsi      # 0x71fe
movl $0x11, %edx
movq 0x3ea6(%rip), %rbx      # 0x9fd8
movq %rbx, %rdi
callq 0x21e0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2110
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x6183
jmp 0x6183
jmp 0x61a8
jmp 0x61a8
jmp 0x61a8
jmp 0x618c
jmp 0x618c
jmp 0x61a8
movq %rax, %rbx
jmp 0x61c1
jmp 0x61a8
jmp 0x618c
movq %rax, %rbx
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x61ab
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x21c0
jmp 0x61ab
movq %rax, %rbx
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x61c1
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x21c0
leaq 0x50(%rsp), %rdi
callq 0x318e
leaq 0x80(%rsp), %rdi
callq 0x318e
movq %rbx, %rdi
callq 0x22b0