// File: xbai0624[P]dnn/src/UnitTest.cpp
// Function: UnitTest::TestDNN()
void UnitTest::TestDNN()
{
    // setup a 1D data interface
    DataInterface *data_interface = new DataInterface("unit_test_data/data_signal.dat", "unit_test_data/data_cosmic.dat", LayerDimension::_1D);

    // setup a 1D input layer
    LayerParameterList p_list0(LayerType::input, LayerDimension::_1D, data_interface, 0, 0, 
            std::pair<size_t, size_t>(0, 0), 0, false, 0, 0.5, Regularization::Undefined, 0, ActuationFuncType::Sigmoid, TrainingType::NewTraining, false);
    Layer* layer_input = new ConstructLayer(p_list0);
    // NOTE: a data_interface class pointer must be passed to input layer before calling input_layer->Init() function
    //       because Initialization rely on data_interface
    layer_input->Init();

    // setup a FC layer
    LayerParameterList p_list3(LayerType::fullyConnected, LayerDimension::_1D, data_interface, 5, 0, 
            std::pair<size_t, size_t>(0, 0), 0.1, true, 2, 0.5, Regularization::L2, 0.1, ActuationFuncType::Sigmoid, TrainingType::NewTraining, false);
    Layer *l3 = new ConstructLayer(p_list3);
    l3->SetPrevLayer(layer_input);
    l3->Init();

    // setup an output layer
    LayerParameterList p_list_output(LayerType::output, LayerDimension::_1D, data_interface, 2, 0, 
            std::pair<size_t, size_t>(0, 0), 0.1, false, 0, 0.5, Regularization::L2, 0.1, ActuationFuncType::SoftMax, TrainingType::NewTraining, false);
    Layer* layer_output = new ConstructLayer(p_list_output);
    layer_output -> SetPrevLayer(l3);
    layer_output -> Init();

    // connect all  layers
    l3->SetNextLayer(layer_output); // This line is ugly, to be improved


    // loop epoch
    for(int epoch = 0;epoch<1;epoch++) // only 1 epoch
    { //
        // loop batch
        for(int nbatch = 0;nbatch<1;nbatch++) // only 1 batch
        { //

            // test start here
            l3->BatchInit();
            layer_output->BatchInit();

            data_interface -> GetNewBatchData();
            data_interface -> GetNewBatchLabel();
            layer_input -> FillBatchDataToInputLayerA();

            size_t sample_size = layer_input->GetBatchSize();
            cout<<"sample size: "<<sample_size<<endl;

            auto show_layer_in_forward = [&](Layer *l, size_t id)
            {
                // show full a image
                cout<<"===layer=layer=layer=layer=layer=layer=layer=layer=layer==="<<endl;
                cout<<"layer id: "<<l->GetID()<<", "<<l->GetType()<<endl;

                cout<<"original w Matrix: "<<endl;
                for(auto &i: *(l->GetWeightMatrixOriginal()))
                    cout<<i<<endl;

                //cout<<"active w Matrix: "<<endl;
                //for(auto &i: *(l->GetWeightMatrix()))
                //    cout<<i<<endl;

                cout<<"original bias vector: "<<endl;
                for(auto &i: *(l->GetBiasVectorOriginal()))
                    cout<<i<<endl;

                //cout<<"active bias vector: "<<endl;
                //for(auto &i: *(l->GetBiasVector()))
                //    cout<<i<<endl;

                //cout<<"active Z images: "<<endl;
                //if((l->GetImagesActiveZ()).size() > 0)
                //    for(auto &i: (l->GetImagesActiveZ())[id].OutputImageFromKernel)
                //		cout<<i<<endl;

                cout<<"full Z images: "<<endl;
                if((l->GetImagesFullZ()).size()>0)
                    for(auto &i: (l->GetImagesFullZ())[id].OutputImageFromKernel)
                        cout<<i<<endl;

                //cout<<"active a images: "<<endl;
                //if((l->GetImagesActiveA()).size() > 0)
                //    for(auto &i: (l->GetImagesActiveA())[id].OutputImageFromKernel)
                //	cout<<i<<endl;

                cout<<"full a images: "<<endl;
                if((l->GetImagesFullA()).size() > 0)
                    for(auto &i: (l->GetImagesFullA())[id].OutputImageFromKernel)
                        cout<<i<<endl;
            };


            // loop sample forward direction
            for(size_t sample_id = 0;sample_id < sample_size;sample_id++)
            {
                cout<<"forward propagation sample: "<<sample_id<<endl;
                l3->ForwardPropagate_Z_ForSample(sample_id);
                l3->ForwardPropagate_SigmaPrimeAndA_ForSample(sample_id);
                layer_output->ForwardPropagate_Z_ForSample(sample_id);
                layer_output->ForwardPropagate_SigmaPrimeAndA_ForSample(sample_id);
            }

            //==============================================================
            // use your eyes here.... check forward propagation
            //==============================================================
            for(size_t id=0;id<sample_size;id++)
            {
                // check for each sample
                cout<<"%%%%%%%%%%%%%%%%%%%%%%% checking sample : "<<id<<" start %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"<<endl;
                show_layer_in_forward(layer_input, id);
                show_layer_in_forward(l3, id);
                show_layer_in_forward(layer_output, id);
                cout<<"%%%%%%%%%%%%%%%%%%%%%%% checking sample : "<<id<<" end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"<<endl;
                getchar();
            }
            // check everything is saved properly after batch finished
            cout<<"................ Check Batch Results ................."<<endl;
            auto check_forward_batch_results= [&](Layer* layer) 
            {
                cout<<"############## layer: "<<layer->GetID()<<" ##############"<<endl;
                cout<<"--------  full image Z: -------  "<<endl;
                for(auto &i: layer->GetImagesFullZ())
                {
                    cout<<"sample:"<<endl;
                    for(auto &j: i.OutputImageFromKernel)
                    {
                        cout<<"    kernel: "<<endl;
                        cout<<j<<endl;
                    }
                }

                cout<<"--------  full image A: -------  "<<endl;
                for(auto &i: layer->GetImagesFullA())
                {
                    cout<<"sample:"<<endl;
                    for(auto &j: i.OutputImageFromKernel)
                    {
                        cout<<"    kernel: "<<endl;
                        cout<<j<<endl;
                    }
                }

                cout<<"--------  full image SigmaPrime: -------  "<<endl;
                for(auto &i: layer->GetImagesFullSigmaPrime())
                {
                    cout<<"sample:"<<endl;
                    for(auto &j: i.OutputImageFromKernel)
                    {
                        cout<<"    kernel: "<<endl;
                        cout<<j<<endl;
                    }
                }

            };

            check_forward_batch_results(layer_input);
            check_forward_batch_results(l3);
            check_forward_batch_results(layer_output);

            // loop sample backward direction
            for(size_t sample_id = 0;sample_id < sample_size;sample_id++)
            {
                cout<<"backward propagation sample: "<<sample_id<<endl;
                layer_output->BackwardPropagateForSample(sample_id);
                l3->BackwardPropagateForSample(sample_id);
            }

            // show backward batch results
            auto show_layer_in_backward = [&](Layer* layer)
            {
                cout<<"===layer=layer=layer=layer=layer=layer=layer=layer=layer==="<<endl;
                cout<<"layer id: "<<layer->GetID()<<", "<<layer->GetType()<<endl;

                cout<<"--------  full image Delta: -------  "<<endl;
                for(auto &i: layer->GetImagesFullDelta())
                {
                    cout<<"sample:"<<endl;
                    for(auto &j: i.OutputImageFromKernel)
                    {
                        cout<<"    kernel: "<<endl;
                        cout<<j<<endl;
                    }
                }
            };

            auto print_wb_matrix =[&](Layer *l)
            {
                cout<<"W&B matrix of layer id: "<<l->GetID()<<", "<<l->GetType()<<endl;
                cout<<"original w Matrix: "<<endl;
                for(auto &i: *(l->GetWeightMatrixOriginal()))
                    cout<<i<<endl;

                cout<<"original bias vector: "<<endl;
                for(auto &i: *(l->GetBiasVectorOriginal()))
                    cout<<i<<endl;
            };

            //==============================================================
            //     use your eyes here.... check backward propagation
            //==============================================================
            cout<<"######################### BACKWARDCHECK ########################"<<endl;
            show_layer_in_backward(layer_output);
            print_wb_matrix(layer_output);
            show_layer_in_backward(l3);


            // check weights and bias update
            cout<<"show l3 previous layer a image: "<<endl;
            cout<<"show l3 layer delta image: "<<endl;
            l3->UpdateWeightsAndBias();

            layer_output->UpdateWeightsAndBias();


        } //
    } //
}

// Assembly:
subq $0x3d8, %rsp            # imm = 0x3D8
movq %rdi, 0x3d0(%rsp)
movl $0xc8, %edi
callq 0x4240
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0x98(%rsp)
leaq 0xb292(%rip), %rsi      # 0x56430
leaq 0xb2aa(%rip), %rdx      # 0x5644f
xorl %ecx, %ecx
callq 0x38ff0
jmp 0x4b1ae
movq 0x98(%rsp), %rax
movq %rax, 0x3c8(%rsp)
movq 0x3c8(%rsp), %rax
movq %rax, 0x88(%rsp)
movl $0x0, 0x33c(%rsp)
movl $0x0, 0x338(%rsp)
leaq 0x340(%rsp), %rdi
leaq 0x33c(%rsp), %rsi
leaq 0x338(%rsp), %rdx
callq 0x279d0
movq 0x88(%rsp), %rcx
movups 0x340(%rsp), %xmm0
movq %rsp, %rax
movups %xmm0, (%rax)
movl $0x0, 0x38(%rax)
movl $0x0, 0x30(%rax)
movl $0x0, 0x28(%rax)
movl $0x2, 0x20(%rax)
movl $0x0, 0x18(%rax)
movl $0x0, 0x10(%rax)
xorl %edx, %edx
movl %edx, %r9d
leaq 0x350(%rsp), %rdi
movl $0x3, %esi
movsd 0x6db5(%rip), %xmm1     # 0x52010
xorps %xmm2, %xmm2
movq %r9, %r8
movaps %xmm2, %xmm0
callq 0x46830
movl $0x490, %edi            # imm = 0x490
callq 0x4240
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0x90(%rsp)
movq 0x3b0(%rsp), %rax
movq %rax, 0x320(%rsp)
movups 0x3a0(%rsp), %xmm0
movaps %xmm0, 0x310(%rsp)
movups 0x390(%rsp), %xmm0
movaps %xmm0, 0x300(%rsp)
movups 0x350(%rsp), %xmm0
movups 0x360(%rsp), %xmm1
movups 0x370(%rsp), %xmm2
movups 0x380(%rsp), %xmm3
movaps %xmm3, 0x2f0(%rsp)
movaps %xmm2, 0x2e0(%rsp)
movaps %xmm1, 0x2d0(%rsp)
movaps %xmm0, 0x2c0(%rsp)
movq 0x320(%rsp), %rcx
movq %rsp, %rax
movq %rcx, 0x60(%rax)
movaps 0x310(%rsp), %xmm0
movups %xmm0, 0x50(%rax)
movaps 0x300(%rsp), %xmm0
movups %xmm0, 0x40(%rax)
movaps 0x2c0(%rsp), %xmm0
movaps 0x2d0(%rsp), %xmm1
movaps 0x2e0(%rsp), %xmm2
movaps 0x2f0(%rsp), %xmm3
movups %xmm3, 0x30(%rax)
movups %xmm2, 0x20(%rax)
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
callq 0x4ea0
jmp 0x4b34e
movq 0x90(%rsp), %rax
movq %rax, 0x330(%rsp)
movq 0x330(%rsp), %rdi
movq (%rdi), %rax
movq 0x10(%rax), %rax
callq *%rax
movq 0x3c8(%rsp), %rax
movq %rax, 0x78(%rsp)
movl $0x0, 0x244(%rsp)
movl $0x0, 0x240(%rsp)
leaq 0x248(%rsp), %rdi
leaq 0x244(%rsp), %rsi
leaq 0x240(%rsp), %rdx
callq 0x279d0
movq 0x78(%rsp), %rcx
movups 0x248(%rsp), %xmm0
movq %rsp, %rax
movups %xmm0, (%rax)
movl $0x0, 0x38(%rax)
movl $0x0, 0x30(%rax)
movl $0x0, 0x28(%rax)
movl $0x0, 0x20(%rax)
movl $0x2, 0x18(%rax)
movl $0x1, 0x10(%rax)
xorl %edx, %edx
movl %edx, %r9d
leaq 0x258(%rsp), %rdi
movl $0x5, %r8d
movsd 0x6c09(%rip), %xmm1     # 0x52010
movsd 0xa481(%rip), %xmm2     # 0x55890
movl %edx, %esi
movaps %xmm2, %xmm0
callq 0x46830
movl $0x490, %edi            # imm = 0x490
callq 0x4240
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0x80(%rsp)
movq 0x2b8(%rsp), %rax
movq %rax, 0x230(%rsp)
movups 0x2a8(%rsp), %xmm0
movaps %xmm0, 0x220(%rsp)
movups 0x298(%rsp), %xmm0
movaps %xmm0, 0x210(%rsp)
movups 0x258(%rsp), %xmm0
movups 0x268(%rsp), %xmm1
movups 0x278(%rsp), %xmm2
movups 0x288(%rsp), %xmm3
movaps %xmm3, 0x200(%rsp)
movaps %xmm2, 0x1f0(%rsp)
movaps %xmm1, 0x1e0(%rsp)
movaps %xmm0, 0x1d0(%rsp)
movq 0x230(%rsp), %rcx
movq %rsp, %rax
movq %rcx, 0x60(%rax)
movaps 0x220(%rsp), %xmm0
movups %xmm0, 0x50(%rax)
movaps 0x210(%rsp), %xmm0
movups %xmm0, 0x40(%rax)
movaps 0x1d0(%rsp), %xmm0
movaps 0x1e0(%rsp), %xmm1
movaps 0x1f0(%rsp), %xmm2
movaps 0x200(%rsp), %xmm3
movups %xmm3, 0x30(%rax)
movups %xmm2, 0x20(%rax)
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
callq 0x4ea0
jmp 0x4b4fe
movq 0x80(%rsp), %rax
movq %rax, 0x238(%rsp)
movq 0x238(%rsp), %rdi
movq 0x330(%rsp), %rsi
movq (%rdi), %rax
movq 0x1e8(%rax), %rax
callq *%rax
movq 0x238(%rsp), %rdi
movq (%rdi), %rax
movq 0x10(%rax), %rax
callq *%rax
movq 0x3c8(%rsp), %rax
movq %rax, 0x68(%rsp)
movl $0x0, 0x154(%rsp)
movl $0x0, 0x150(%rsp)
leaq 0x158(%rsp), %rdi
leaq 0x154(%rsp), %rsi
leaq 0x150(%rsp), %rdx
callq 0x279d0
movq 0x68(%rsp), %rcx
movups 0x158(%rsp), %xmm0
movq %rsp, %rax
movups %xmm0, (%rax)
movl $0x0, 0x38(%rax)
movl $0x0, 0x30(%rax)
movl $0x1, 0x28(%rax)
movl $0x0, 0x20(%rax)
movl $0x0, 0x18(%rax)
movl $0x0, 0x10(%rax)
xorl %edx, %edx
movl %edx, %r9d
leaq 0x168(%rsp), %rdi
movl $0x4, %esi
movl $0x2, %r8d
movsd 0x6a38(%rip), %xmm1     # 0x52010
movsd 0xa2b0(%rip), %xmm2     # 0x55890
movaps %xmm2, %xmm0
callq 0x46830
movl $0x490, %edi            # imm = 0x490
callq 0x4240
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0x70(%rsp)
movq 0x1c8(%rsp), %rax
movq %rax, 0x140(%rsp)
movups 0x1b8(%rsp), %xmm0
movaps %xmm0, 0x130(%rsp)
movups 0x1a8(%rsp), %xmm0
movaps %xmm0, 0x120(%rsp)
movups 0x168(%rsp), %xmm0
movups 0x178(%rsp), %xmm1
movups 0x188(%rsp), %xmm2
movups 0x198(%rsp), %xmm3
movaps %xmm3, 0x110(%rsp)
movaps %xmm2, 0x100(%rsp)
movaps %xmm1, 0xf0(%rsp)
movaps %xmm0, 0xe0(%rsp)
movq 0x140(%rsp), %rcx
movq %rsp, %rax
movq %rcx, 0x60(%rax)
movaps 0x130(%rsp), %xmm0
movups %xmm0, 0x50(%rax)
movaps 0x120(%rsp), %xmm0
movups %xmm0, 0x40(%rax)
movaps 0xe0(%rsp), %xmm0
movaps 0xf0(%rsp), %xmm1
movaps 0x100(%rsp), %xmm2
movaps 0x110(%rsp), %xmm3
movups %xmm3, 0x30(%rax)
movups %xmm2, 0x20(%rax)
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
callq 0x4ea0
jmp 0x4b6ca
movq 0x70(%rsp), %rax
movq %rax, 0x148(%rsp)
movq 0x148(%rsp), %rdi
movq 0x238(%rsp), %rsi
movq (%rdi), %rax
callq *0x1e8(%rax)
movq 0x148(%rsp), %rdi
movq (%rdi), %rax
callq *0x10(%rax)
movq 0x238(%rsp), %rdi
movq 0x148(%rsp), %rsi
movq (%rdi), %rax
callq *0x1f0(%rax)
movl $0x0, 0xdc(%rsp)
cmpl $0x1, 0xdc(%rsp)
jge 0x4bc47
movl $0x0, 0xd8(%rsp)
cmpl $0x1, 0xd8(%rsp)
jge 0x4bc2f
movq 0x238(%rsp), %rdi
movq (%rdi), %rax
callq *0x88(%rax)
movq 0x148(%rsp), %rdi
movq (%rdi), %rax
callq *0x88(%rax)
movq 0x3c8(%rsp), %rdi
callq 0x39b20
movq 0x3c8(%rsp), %rdi
callq 0x3a030
movq 0x330(%rsp), %rdi
movq (%rdi), %rax
callq *0x180(%rax)
movq 0x330(%rsp), %rdi
movq (%rdi), %rax
callq *0x2a0(%rax)
cltq
movq %rax, 0xd0(%rsp)
movq 0x1f820(%rip), %rdi     # 0x6afd8
leaq 0xacaf(%rip), %rsi      # 0x5646e
callq 0x4230
movq %rax, %rdi
movq 0xd0(%rsp), %rsi
callq 0x4080
movq %rax, %rdi
movq 0x1f7d2(%rip), %rsi     # 0x6afb0
callq 0x4260
movq $0x0, 0xc0(%rsp)
movq 0xc0(%rsp), %rax
cmpq 0xd0(%rsp), %rax
jae 0x4b945
movq 0x1f7cc(%rip), %rdi     # 0x6afd8
leaq 0xac69(%rip), %rsi      # 0x5647c
callq 0x4230
movq %rax, %rdi
movq 0xc0(%rsp), %rsi
callq 0x4080
movq %rax, %rdi
movq 0x1f77e(%rip), %rsi     # 0x6afb0
callq 0x4260
movq 0x238(%rsp), %rdi
movq 0xc0(%rsp), %rax
movl %eax, %esi
movq (%rdi), %rax
callq *0x28(%rax)
movq 0x238(%rsp), %rdi
movq 0xc0(%rsp), %rax
movl %eax, %esi
movq (%rdi), %rax
callq *0x30(%rax)
movq 0x148(%rsp), %rdi
movq 0xc0(%rsp), %rax
movl %eax, %esi
movq (%rdi), %rax
callq *0x28(%rax)
movq 0x148(%rsp), %rdi
movq 0xc0(%rsp), %rax
movl %eax, %esi
movq (%rdi), %rax
callq *0x30(%rax)
movq 0xc0(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xc0(%rsp)
jmp 0x4b7ef
movq 0x98(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x3c0(%rsp)
movl %eax, 0x3bc(%rsp)
callq 0x4220
jmp 0x4bc4f
movq 0x90(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x3c0(%rsp)
movl %eax, 0x3bc(%rsp)
callq 0x4220
jmp 0x4bc4f
movq 0x80(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x3c0(%rsp)
movl %eax, 0x3bc(%rsp)
callq 0x4220
jmp 0x4bc4f
movq 0x70(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x3c0(%rsp)
movl %eax, 0x3bc(%rsp)
callq 0x4220
jmp 0x4bc4f
movq $0x0, 0xb8(%rsp)
movq 0xb8(%rsp), %rax
cmpq 0xd0(%rsp), %rax
jae 0x4ba5e
movq 0x1f66a(%rip), %rdi     # 0x6afd8
leaq 0xab24(%rip), %rsi      # 0x56499
callq 0x4230
movq %rax, %rdi
movq 0xb8(%rsp), %rsi
callq 0x4080
movq %rax, %rdi
leaq 0xab30(%rip), %rsi      # 0x564c4
callq 0x4230
movq %rax, %rdi
movq 0x1f60d(%rip), %rsi     # 0x6afb0
callq 0x4260
movq 0x330(%rsp), %rsi
movq 0xb8(%rsp), %rdx
leaq 0xcf(%rsp), %rdi
callq 0x4bc60
movq 0x238(%rsp), %rsi
movq 0xb8(%rsp), %rdx
leaq 0xcf(%rsp), %rdi
callq 0x4bc60
movq 0x148(%rsp), %rsi
movq 0xb8(%rsp), %rdx
leaq 0xcf(%rsp), %rdi
callq 0x4bc60
movq 0x1f5d2(%rip), %rdi     # 0x6afd8
leaq 0xaa8c(%rip), %rsi      # 0x56499
callq 0x4230
movq %rax, %rdi
movq 0xb8(%rsp), %rsi
callq 0x4080
movq %rax, %rdi
leaq 0xaac0(%rip), %rsi      # 0x564ec
callq 0x4230
movq %rax, %rdi
movq 0x1f575(%rip), %rsi     # 0x6afb0
callq 0x4260
callq 0x4310
movq 0xb8(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xb8(%rsp)
jmp 0x4b951
movq 0x1f573(%rip), %rdi     # 0x6afd8
leaq 0xaaa6(%rip), %rsi      # 0x56512
callq 0x4230
movq %rax, %rdi
movq 0x1f535(%rip), %rsi     # 0x6afb0
callq 0x4260
movq 0x330(%rsp), %rsi
leaq 0xb7(%rsp), %rdi
callq 0x4c050
movq 0x238(%rsp), %rsi
leaq 0xb7(%rsp), %rdi
callq 0x4c050
movq 0x148(%rsp), %rsi
leaq 0xb7(%rsp), %rdi
callq 0x4c050
movq $0x0, 0xa8(%rsp)
movq 0xa8(%rsp), %rax
cmpq 0xd0(%rsp), %rax
jae 0x4bb58
movq 0x1f4f4(%rip), %rdi     # 0x6afd8
leaq 0xaa5e(%rip), %rsi      # 0x56549
callq 0x4230
movq %rax, %rdi
movq 0xa8(%rsp), %rsi
callq 0x4080
movq %rax, %rdi
movq 0x1f4a6(%rip), %rsi     # 0x6afb0
callq 0x4260
movq 0x148(%rsp), %rdi
movq 0xa8(%rsp), %rax
movl %eax, %esi
movq (%rdi), %rax
callq *0x38(%rax)
movq 0x238(%rsp), %rdi
movq 0xa8(%rsp), %rax
movl %eax, %esi
movq (%rdi), %rax
callq *0x38(%rax)
movq 0xa8(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xa8(%rsp)
jmp 0x4bacb
movq 0x1f479(%rip), %rdi     # 0x6afd8
leaq 0xaa01(%rip), %rsi      # 0x56567
callq 0x4230
movq %rax, %rdi
movq 0x1f43b(%rip), %rsi     # 0x6afb0
callq 0x4260
movq 0x148(%rsp), %rsi
leaq 0xa7(%rsp), %rdi
callq 0x4c4f0
movq 0x148(%rsp), %rsi
leaq 0xa6(%rsp), %rdi
callq 0x4c6e0
movq 0x238(%rsp), %rsi
leaq 0xa7(%rsp), %rdi
callq 0x4c4f0
movq 0x1f418(%rip), %rdi     # 0x6afd8
leaq 0xa9e1(%rip), %rsi      # 0x565a8
callq 0x4230
movq %rax, %rdi
movq 0x1f3da(%rip), %rsi     # 0x6afb0
callq 0x4260
movq 0x1f3f6(%rip), %rdi     # 0x6afd8
leaq 0xa9e0(%rip), %rsi      # 0x565c9
callq 0x4230
movq %rax, %rdi
movq 0x1f3b8(%rip), %rsi     # 0x6afb0
callq 0x4260
movq 0x238(%rsp), %rdi
movq (%rdi), %rax
callq *0x50(%rax)
movq 0x148(%rsp), %rdi
movq (%rdi), %rax
callq *0x50(%rax)
movl 0xd8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xd8(%rsp)
jmp 0x4b73b
jmp 0x4bc31
movl 0xdc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xdc(%rsp)
jmp 0x4b722
addq $0x3d8, %rsp            # imm = 0x3D8
retq
movq 0x3c0(%rsp), %rdi
callq 0x43f0
nopl (%rax)