// File: xbai0624[P]dnn/src/ConstructLayer.cpp
// Function: ConstructLayer::__UpdateActiveFlagCNN_Obsolete()
void ConstructLayer::__UpdateActiveFlagCNN_Obsolete() // this function has been made obsolete
{
    // for drop out
    // randomly mask out a few elements of weight matrix
    size_t nKernel = __weightMatrix.size();
    assert(nKernel > 0);
    auto dim = __weightMatrix[0].Dimension();
    assert(dim.first >= 1);
    assert(dim.second >= 1);
    // total matrix elements
    int nTotal = (int)dim.first * (int)dim.second;
    // number of elements to mask out
    int nDead = nTotal * __dropOut;

    // setup a random engine
    std::random_device rd;
    std::mt19937 gen(rd());
    std::uniform_int_distribution<> row(0, (int)dim.first-1);
    std::uniform_int_distribution<> col(0, (int)dim.second-1);

    auto not_inside = [&](std::vector<std::pair<int, int>> &v, std::pair<int, int>&p) -> bool
    {
        for(auto &i: v)
            if (i == p) return false;
        return true;
    };

    for(size_t k=0;k<nKernel;k++)
    {
        std::vector<std::pair<int, int>> rand_elements;
        while(rand_elements.size() < (size_t)nDead)
        {
            int r = row(gen);
            int c = col(gen);
            std::pair<int, int> p(r, c);
            if(not_inside(rand_elements, p)) 
                rand_elements.emplace_back(r, c);
        }

        for(auto &i: rand_elements)
        {
            __activeFlag[k][i.first][i.second] = false;
        }
    }
}

// Assembly:
subq $0x27f8, %rsp           # imm = 0x27F8
movq %rdi, 0x27f0(%rsp)
movq 0x27f0(%rsp), %rdi
movq %rdi, 0x38(%rsp)
addq $0x60, %rdi
callq 0x1f9c0
movq %rax, 0x27e8(%rsp)
cmpq $0x0, 0x27e8(%rsp)
jbe 0x143da
jmp 0x143f9
leaq 0x3e735(%rip), %rdi     # 0x52b16
leaq 0x3ddea(%rip), %rsi     # 0x521d2
movl $0xac3, %edx            # imm = 0xAC3
leaq 0x3ec69(%rip), %rcx     # 0x5305d
callq 0x4170
movq 0x38(%rsp), %rdi
addq $0x60, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x1f9e0
movq %rax, %rdi
callq 0x3bae0
movq %rax, 0x27d8(%rsp)
movq %rdx, 0x27e0(%rsp)
cmpq $0x1, 0x27d8(%rsp)
jb 0x14430
jmp 0x1444f
leaq 0x3e49f(%rip), %rdi     # 0x528d6
leaq 0x3dd94(%rip), %rsi     # 0x521d2
movl $0xac5, %edx            # imm = 0xAC5
leaq 0x3ec13(%rip), %rcx     # 0x5305d
callq 0x4170
cmpq $0x1, 0x27e0(%rsp)
jb 0x1445c
jmp 0x1447b
leaq 0x3e4ba(%rip), %rdi     # 0x5291d
leaq 0x3dd68(%rip), %rsi     # 0x521d2
movl $0xac6, %edx            # imm = 0xAC6
leaq 0x3ebe7(%rip), %rcx     # 0x5305d
callq 0x4170
movq 0x38(%rsp), %rax
movl 0x27d8(%rsp), %ecx
movl 0x27e0(%rsp), %edx
imull %edx, %ecx
movl %ecx, 0x27d4(%rsp)
cvtsi2sdl 0x27d4(%rsp), %xmm0
movsd 0x3d8(%rax), %xmm1
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, 0x27d0(%rsp)
leaq 0x1448(%rsp), %rdi
movq %rdi, 0x28(%rsp)
callq 0x21140
movq 0x28(%rsp), %rdi
callq 0x211e0
movl %eax, 0x34(%rsp)
jmp 0x144da
movl 0x34(%rsp), %eax
movl %eax, %eax
movl %eax, %esi
leaq 0xc0(%rsp), %rdi
callq 0x211f0
jmp 0x144f1
movl 0x27d8(%rsp), %edx
decl %edx
leaq 0xac(%rsp), %rdi
xorl %esi, %esi
callq 0x21220
jmp 0x1450b
movl 0x27e0(%rsp), %edx
decl %edx
leaq 0xa4(%rsp), %rdi
xorl %esi, %esi
callq 0x21220
jmp 0x14525
movq $0x0, 0x98(%rsp)
movq 0x98(%rsp), %rax
cmpq 0x27e8(%rsp), %rax
jae 0x1474b
leaq 0x80(%rsp), %rdi
callq 0x21250
leaq 0x80(%rsp), %rdi
callq 0x21260
movslq 0x27d0(%rsp), %rcx
cmpq %rcx, %rax
jae 0x14657
leaq 0xac(%rsp), %rdi
leaq 0xc0(%rsp), %rsi
callq 0x21280
movl %eax, 0x24(%rsp)
jmp 0x1458d
movl 0x24(%rsp), %eax
movl %eax, 0x7c(%rsp)
leaq 0xa4(%rsp), %rdi
leaq 0xc0(%rsp), %rsi
callq 0x21280
movl %eax, 0x20(%rsp)
jmp 0x145b0
movl 0x20(%rsp), %eax
movl %eax, 0x78(%rsp)
leaq 0x70(%rsp), %rdi
leaq 0x7c(%rsp), %rsi
leaq 0x78(%rsp), %rdx
callq 0x212b0
jmp 0x145ce
leaq 0xa3(%rsp), %rdi
leaq 0x80(%rsp), %rsi
leaq 0x70(%rsp), %rdx
callq 0x14780
movb %al, 0x1f(%rsp)
jmp 0x145ee
movb 0x1f(%rsp), %al
testb $0x1, %al
jne 0x145f8
jmp 0x14652
leaq 0x80(%rsp), %rdi
leaq 0x7c(%rsp), %rsi
leaq 0x78(%rsp), %rdx
callq 0x212e0
jmp 0x14611
jmp 0x14652
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xb8(%rsp)
movl %eax, 0xb4(%rsp)
jmp 0x14760
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xb8(%rsp)
movl %eax, 0xb4(%rsp)
leaq 0x80(%rsp), %rdi
callq 0x21430
jmp 0x14760
jmp 0x14554
leaq 0x80(%rsp), %rax
movq %rax, 0x68(%rsp)
movq 0x68(%rsp), %rdi
callq 0x21360
movq %rax, 0x60(%rsp)
movq 0x68(%rsp), %rdi
callq 0x21390
movq %rax, 0x58(%rsp)
leaq 0x60(%rsp), %rdi
leaq 0x58(%rsp), %rsi
callq 0x213c0
testb $0x1, %al
jne 0x1469a
jmp 0x14725
leaq 0x60(%rsp), %rdi
callq 0x21400
movq 0x38(%rsp), %rdi
movq %rax, 0x50(%rsp)
addq $0x108, %rdi            # imm = 0x108
movq 0x98(%rsp), %rsi
callq 0x1ff80
movq %rax, %rdi
movq 0x50(%rsp), %rax
movslq (%rax), %rsi
callq 0x1fff0
movq %rax, 0x10(%rsp)
jmp 0x146d9
movq 0x10(%rsp), %rdi
movq 0x50(%rsp), %rax
movslq 0x4(%rax), %rsi
callq 0x20020
movq %rdx, (%rsp)
movq %rax, 0x8(%rsp)
jmp 0x146f7
movq (%rsp), %rax
movq 0x8(%rsp), %rcx
movq %rcx, 0x40(%rsp)
movq %rax, 0x48(%rsp)
leaq 0x40(%rsp), %rdi
xorl %esi, %esi
callq 0x20ff0
leaq 0x60(%rsp), %rdi
callq 0x21410
jmp 0x14682
leaq 0x80(%rsp), %rdi
callq 0x21430
movq 0x98(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x98(%rsp)
jmp 0x14531
leaq 0x1448(%rsp), %rdi
callq 0x21490
addq $0x27f8, %rsp           # imm = 0x27F8
retq
leaq 0x1448(%rsp), %rdi
callq 0x21490
movq 0xb8(%rsp), %rdi
callq 0x43f0
nopw (%rax,%rax)