// File: xbai0624[P]dnn/src/ConstructLayer.cpp
// Function: ConstructLayer::ConstructLayer(LayerParameterList)
ConstructLayer::ConstructLayer(LayerParameterList p_list)
{
    // common parameters
    __type = p_list._gLayerType;

    // drop out
    if(p_list._gUseDropout)
    {
        EnableDropOut();
        __dropOutBranches = p_list._gdropoutBranches;
        SetDropOutFactor(p_list._gDropoutFactor);
    }
    else
    {
        DisableDropOut();
    }

    SetLearningRate(p_list._gLearningRate);
    __layerDimension = p_list._gLayerDimension;
    __p_data_interface = p_list._pDataInterface;
    __regularizationMethod = p_list._gRegularization;
    __regularizationParameter = p_list._gRegularizationParameter;
    __neuron_actuation_func_type = p_list._gActuationFuncType;
    __trainingType = p_list._gTrainingType;
    __use_batch_normalization = p_list._gUseBatchNormalization;

    // parameters dependent on layer type
    if(__type == LayerType::input)
    {
        __layerDimension = p_list._gLayerDimension;
    }
    else if(__type == LayerType::fullyConnected)
    {
        SetNumberOfNeuronsFC(p_list._nNeuronsFC);
    }
    else if(__type == LayerType::cnn)
    {
        SetNumberOfKernelsCNN(p_list._nKernels);
        SetKernelSizeCNN(p_list._gDimKernel);
    }
    else if(__type == LayerType::pooling)
    {
        SetNumberOfKernelsCNN(p_list._nKernels);
        SetKernelSizeCNN(p_list._gDimKernel);
    }
    else if(__type == LayerType::output)
    {
        SetNumberOfNeuronsFC(p_list._nNeuronsFC);
    }
    else
    {
        std::cout<<__func__<<" Error: trying to construct unsupported layer."
            <<std::endl;
        exit(0);
    }
}

// Assembly:
subq $0x188, %rsp            # imm = 0x188
leaq 0x190(%rsp), %rax
movq %rax, 0x140(%rsp)
movq %rdi, 0x180(%rsp)
movq 0x180(%rsp), %rdi
movq %rdi, 0x148(%rsp)
callq 0x3afb0
movq 0x148(%rsp), %rdi
leaq 0x65655(%rip), %rax     # 0x6a538
movq %rax, (%rdi)
movl $0x0, 0xc(%rdi)
movq $0x0, 0x10(%rdi)
movq $0x0, 0x18(%rdi)
addq $0x20, %rdi
callq 0x1f020
jmp 0x4f08
movq 0x148(%rsp), %rdi
addq $0x30, %rdi
callq 0x1f020
jmp 0x4f1b
movq 0x148(%rsp), %rdi
addq $0x40, %rdi
movq %rdi, 0x30(%rsp)
callq 0x1f040
movq 0x148(%rsp), %rdi
movl $0x0, 0x58(%rdi)
addq $0x60, %rdi
movq %rdi, 0x38(%rsp)
callq 0x1f050
movq 0x148(%rsp), %rdi
addq $0x78, %rdi
movq %rdi, 0x40(%rsp)
callq 0x1f050
movq 0x148(%rsp), %rdi
addq $0x90, %rdi
movq %rdi, 0x48(%rsp)
callq 0x1f060
movq 0x148(%rsp), %rdi
addq $0xa8, %rdi
movq %rdi, 0x50(%rsp)
callq 0x1f060
movq 0x148(%rsp), %rdi
movabsq $0x3fb999999999999a, %rax # imm = 0x3FB999999999999A
movq %rax, 0xc0(%rdi)
movl $0x0, 0xc8(%rdi)
movq $0x0, 0xd0(%rdi)
addq $0xd8, %rdi
movq %rdi, 0x58(%rsp)
callq 0x1f050
movq 0x148(%rsp), %rdi
addq $0xf0, %rdi
movq %rdi, 0x60(%rsp)
callq 0x1f050
movq 0x148(%rsp), %rdi
addq $0x108, %rdi            # imm = 0x108
movq %rdi, 0x68(%rsp)
callq 0x1f070
movq 0x148(%rsp), %rdi
addq $0x120, %rdi            # imm = 0x120
movq %rdi, 0x70(%rsp)
callq 0x1f080
movq 0x148(%rsp), %rdi
addq $0x138, %rdi            # imm = 0x138
movq %rdi, 0x78(%rsp)
callq 0x1f060
movq 0x148(%rsp), %rdi
addq $0x150, %rdi            # imm = 0x150
movq %rdi, 0x80(%rsp)
callq 0x1f060
movq 0x148(%rsp), %rdi
addq $0x168, %rdi            # imm = 0x168
movq %rdi, 0x88(%rsp)
callq 0x1f060
movq 0x148(%rsp), %rdi
addq $0x180, %rdi            # imm = 0x180
movq %rdi, 0x90(%rsp)
callq 0x1f060
movq 0x148(%rsp), %rdi
addq $0x198, %rdi            # imm = 0x198
movq %rdi, 0x98(%rsp)
callq 0x1f060
movq 0x148(%rsp), %rdi
addq $0x1b0, %rdi            # imm = 0x1B0
movq %rdi, 0xa0(%rsp)
callq 0x1f060
movq 0x148(%rsp), %rdi
addq $0x1c8, %rdi            # imm = 0x1C8
movq %rdi, 0xa8(%rsp)
callq 0x1f060
movq 0x148(%rsp), %rdi
addq $0x1e0, %rdi            # imm = 0x1E0
movq %rdi, 0xb0(%rsp)
callq 0x1f060
movq 0x148(%rsp), %rdi
addq $0x1f8, %rdi            # imm = 0x1F8
movq %rdi, 0xb8(%rsp)
callq 0x1f090
movq 0x148(%rsp), %rdi
movb $0x0, 0x210(%rdi)
addq $0x218, %rdi            # imm = 0x218
movq %rdi, 0xc0(%rsp)
callq 0x1f060
movq 0x148(%rsp), %rdi
addq $0x230, %rdi            # imm = 0x230
movq %rdi, 0xc8(%rsp)
callq 0x1f060
movq 0x148(%rsp), %rdi
addq $0x248, %rdi            # imm = 0x248
movq %rdi, 0xd0(%rsp)
callq 0x1f060
movq 0x148(%rsp), %rdi
addq $0x260, %rdi            # imm = 0x260
movq %rdi, 0xd8(%rsp)
callq 0x1f060
movq 0x148(%rsp), %rdi
addq $0x278, %rdi            # imm = 0x278
movq %rdi, 0xe0(%rsp)
callq 0x1f060
movq 0x148(%rsp), %rdi
addq $0x290, %rdi            # imm = 0x290
movq %rdi, 0xe8(%rsp)
callq 0x1f060
movq 0x148(%rsp), %rdi
addq $0x2a8, %rdi            # imm = 0x2A8
movq %rdi, 0xf0(%rsp)
callq 0x1f060
movq 0x148(%rsp), %rdi
addq $0x2c0, %rdi            # imm = 0x2C0
movq %rdi, 0xf8(%rsp)
callq 0x1f060
movq 0x148(%rsp), %rdi
addq $0x2d8, %rdi            # imm = 0x2D8
movq %rdi, 0x100(%rsp)
callq 0x1f060
movq 0x148(%rsp), %rdi
addq $0x2f0, %rdi            # imm = 0x2F0
movq %rdi, 0x108(%rsp)
callq 0x1f060
movq 0x148(%rsp), %rdi
addq $0x308, %rdi            # imm = 0x308
movq %rdi, 0x110(%rsp)
callq 0x1f050
movq 0x148(%rsp), %rdi
addq $0x320, %rdi            # imm = 0x320
movq %rdi, 0x118(%rsp)
callq 0x1f050
movq 0x148(%rsp), %rdi
addq $0x338, %rdi            # imm = 0x338
movq %rdi, 0x120(%rsp)
callq 0x1f050
movq 0x148(%rsp), %rdi
addq $0x350, %rdi            # imm = 0x350
movq %rdi, 0x128(%rsp)
callq 0x1f050
movq 0x148(%rsp), %rdi
addq $0x368, %rdi            # imm = 0x368
movq %rdi, 0x130(%rsp)
callq 0x1f050
movq 0x148(%rsp), %rdi
addq $0x380, %rdi            # imm = 0x380
movq %rdi, 0x138(%rsp)
callq 0x1f050
movq 0x148(%rsp), %rdi
addq $0x398, %rdi            # imm = 0x398
callq 0x1f0a0
jmp 0x52f6
movq 0x148(%rsp), %rdi
addq $0x3b0, %rdi            # imm = 0x3B0
callq 0x1f0a0
jmp 0x530c
movq 0x148(%rsp), %rdi
movb $0x0, 0x3c8(%rdi)
movl $0x2, 0x3cc(%rdi)
movq $0x0, 0x3d0(%rdi)
movsd 0x4ccd8(%rip), %xmm0    # 0x52010
movsd %xmm0, 0x3d8(%rdi)
movl $0x1, 0x3e0(%rdi)
movl $0x0, 0x3e4(%rdi)
movl $0x0, 0x3e8(%rdi)
movq $0x0, 0x3f0(%rdi)
movq $0x0, 0x3f8(%rdi)
movq $0x0, 0x400(%rdi)
movl $0x2, 0x408(%rdi)
movl $0x0, 0x40c(%rdi)
addq $0x410, %rdi            # imm = 0x410
movq %rdi, 0x10(%rsp)
callq 0x1f090
movq 0x148(%rsp), %rdi
addq $0x428, %rdi            # imm = 0x428
movq %rdi, 0x18(%rsp)
callq 0x1f090
movq 0x148(%rsp), %rdi
movl $0x1, 0x440(%rdi)
addq $0x448, %rdi            # imm = 0x448
movq %rdi, 0x20(%rsp)
callq 0x1f050
movq 0x148(%rsp), %rdi
addq $0x460, %rdi            # imm = 0x460
movq %rdi, 0x28(%rsp)
callq 0x1f050
movq 0x148(%rsp), %rcx
movq 0x140(%rsp), %rax
movsd 0x4cbf7(%rip), %xmm0    # 0x52008
movsd %xmm0, 0x478(%rcx)
movsd 0x4cbe7(%rip), %xmm0    # 0x52008
movsd %xmm0, 0x480(%rcx)
movb $0x1, 0x488(%rcx)
movl (%rax), %edx
movl %edx, 0xc(%rcx)
testb $0x1, 0x38(%rax)
je 0x54f9
movq 0x148(%rsp), %rdi
movq (%rdi), %rax
movq 0x138(%rax), %rax
callq *%rax
jmp 0x5455
movq 0x148(%rsp), %rdi
movq 0x140(%rsp), %rax
movl 0x3c(%rax), %ecx
movl %ecx, 0x3cc(%rdi)
movsd 0x40(%rax), %xmm0
movq (%rdi), %rax
movq 0x1e0(%rax), %rax
callq *%rax
jmp 0x5481
jmp 0x5511
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x178(%rsp)
movl %eax, 0x174(%rsp)
jmp 0x58e2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x178(%rsp)
movl %eax, 0x174(%rsp)
jmp 0x5746
movq 0x28(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x178(%rsp)
movl %eax, 0x174(%rsp)
callq 0x1f0d0
movq 0x20(%rsp), %rdi
callq 0x1f0d0
movq 0x18(%rsp), %rdi
callq 0x1f190
movq 0x10(%rsp), %rdi
callq 0x1f190
jmp 0x5746
movq 0x148(%rsp), %rdi
movq (%rdi), %rax
movq 0x140(%rax), %rax
callq *%rax
jmp 0x550f
jmp 0x5511
movq 0x148(%rsp), %rdi
movq 0x140(%rsp), %rax
movsd 0x30(%rax), %xmm0
movq (%rdi), %rax
movq 0x60(%rax), %rax
callq *%rax
jmp 0x5531
movq 0x148(%rsp), %rax
movq 0x140(%rsp), %rcx
movl 0x4(%rcx), %edx
movl %edx, 0x408(%rax)
movq 0x8(%rcx), %rdx
movq %rdx, 0x400(%rax)
movl 0x48(%rcx), %edx
movl %edx, 0xc8(%rax)
movsd 0x50(%rcx), %xmm0
movsd %xmm0, 0xd0(%rax)
movl 0x58(%rcx), %edx
movl %edx, 0x58(%rax)
movl 0x5c(%rcx), %edx
movl %edx, 0x40c(%rax)
movb 0x60(%rcx), %cl
andb $0x1, %cl
movb %cl, 0x210(%rax)
cmpl $0x3, 0xc(%rax)
jne 0x55aa
movq 0x148(%rsp), %rax
movq 0x140(%rsp), %rcx
movl 0x4(%rcx), %ecx
movl %ecx, 0x408(%rax)
jmp 0x573e
movq 0x148(%rsp), %rax
cmpl $0x0, 0xc(%rax)
jne 0x55df
movq 0x148(%rsp), %rdi
movq 0x140(%rsp), %rax
movq 0x10(%rax), %rsi
movq (%rdi), %rax
movq 0xa0(%rax), %rax
callq *%rax
jmp 0x55da
jmp 0x573c
movq 0x148(%rsp), %rax
cmpl $0x1, 0xc(%rax)
jne 0x564e
movq 0x148(%rsp), %rdi
movq 0x140(%rsp), %rax
movq 0x18(%rax), %rsi
movq (%rdi), %rax
movq 0xa8(%rax), %rax
callq *%rax
jmp 0x560f
movq 0x148(%rsp), %rdi
movq 0x140(%rsp), %rax
movups 0x20(%rax), %xmm0
movaps %xmm0, 0x160(%rsp)
movq 0x160(%rsp), %rsi
movq 0x168(%rsp), %rdx
movq (%rdi), %rax
movq 0xb0(%rax), %rax
callq *%rax
jmp 0x5649
jmp 0x573a
movq 0x148(%rsp), %rax
cmpl $0x2, 0xc(%rax)
jne 0x56ba
movq 0x148(%rsp), %rdi
movq 0x140(%rsp), %rax
movq 0x18(%rax), %rsi
movq (%rdi), %rax
movq 0xa8(%rax), %rax
callq *%rax
jmp 0x567e
movq 0x148(%rsp), %rdi
movq 0x140(%rsp), %rax
movups 0x20(%rax), %xmm0
movaps %xmm0, 0x150(%rsp)
movq 0x150(%rsp), %rsi
movq 0x158(%rsp), %rdx
movq (%rdi), %rax
movq 0xb0(%rax), %rax
callq *%rax
jmp 0x56b8
jmp 0x5738
movq 0x148(%rsp), %rax
cmpl $0x4, 0xc(%rax)
jne 0x56ec
movq 0x148(%rsp), %rdi
movq 0x140(%rsp), %rax
movq 0x10(%rax), %rsi
movq (%rdi), %rax
movq 0xa0(%rax), %rax
callq *%rax
jmp 0x56ea
jmp 0x5736
movq 0x658e5(%rip), %rdi     # 0x6afd8
leaq 0x4c986(%rip), %rsi     # 0x52080
callq 0x4230
movq %rax, 0x8(%rsp)
jmp 0x5706
movq 0x8(%rsp), %rdi
leaq 0x4c97d(%rip), %rsi     # 0x5208f
callq 0x4230
movq %rax, (%rsp)
jmp 0x571d
movq (%rsp), %rdi
movq 0x65888(%rip), %rsi     # 0x6afb0
callq 0x4260
jmp 0x572f
xorl %edi, %edi
callq 0x4290
jmp 0x5738
jmp 0x573a
jmp 0x573c
jmp 0x573e
addq $0x188, %rsp            # imm = 0x188
retq
movq 0x138(%rsp), %rdi
callq 0x1f0d0
movq 0x130(%rsp), %rdi
callq 0x1f0d0
movq 0x128(%rsp), %rdi
callq 0x1f0d0
movq 0x120(%rsp), %rdi
callq 0x1f0d0
movq 0x118(%rsp), %rdi
callq 0x1f0d0
movq 0x110(%rsp), %rdi
callq 0x1f0d0
movq 0x108(%rsp), %rdi
callq 0x1f130
movq 0x100(%rsp), %rdi
callq 0x1f130
movq 0xf8(%rsp), %rdi
callq 0x1f130
movq 0xf0(%rsp), %rdi
callq 0x1f130
movq 0xe8(%rsp), %rdi
callq 0x1f130
movq 0xe0(%rsp), %rdi
callq 0x1f130
movq 0xd8(%rsp), %rdi
callq 0x1f130
movq 0xd0(%rsp), %rdi
callq 0x1f130
movq 0xc8(%rsp), %rdi
callq 0x1f130
movq 0xc0(%rsp), %rdi
callq 0x1f130
movq 0xb8(%rsp), %rdi
callq 0x1f190
movq 0xb0(%rsp), %rdi
callq 0x1f130
movq 0xa8(%rsp), %rdi
callq 0x1f130
movq 0xa0(%rsp), %rdi
callq 0x1f130
movq 0x98(%rsp), %rdi
callq 0x1f130
movq 0x90(%rsp), %rdi
callq 0x1f130
movq 0x88(%rsp), %rdi
callq 0x1f130
movq 0x80(%rsp), %rdi
callq 0x1f130
movq 0x78(%rsp), %rdi
callq 0x1f130
movq 0x70(%rsp), %rdi
callq 0x1f1f0
movq 0x68(%rsp), %rdi
callq 0x1f250
movq 0x60(%rsp), %rdi
callq 0x1f0d0
movq 0x58(%rsp), %rdi
callq 0x1f0d0
movq 0x50(%rsp), %rdi
callq 0x1f130
movq 0x48(%rsp), %rdi
callq 0x1f130
movq 0x40(%rsp), %rdi
callq 0x1f0d0
movq 0x38(%rsp), %rdi
callq 0x1f0d0
movq 0x30(%rsp), %rdi
callq 0x1f2b0
movq 0x148(%rsp), %rdi
callq 0x3aff0
movq 0x178(%rsp), %rdi
callq 0x43f0
nopl (%rax)