// File: /workspace/github_cpp_makefile_star2_O2/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2758, %rsp           # imm = 0x2758
movq %rdi, %rbx
movq 0x60(%rdi), %rdi
movq 0x68(%rbx), %rcx
movq %rcx, %rax
subq %rdi, %rax
pushq $0x18
popq %rsi
cqto
idivq %rsi
movq %rax, 0x30(%rsp)
cmpq %rdi, %rcx
je 0xc65a
callq 0x17a6a
testq %rax, %rax
je 0xc679
movq %rdx, %r14
testq %rdx, %rdx
je 0xc698
movq %rax, %r12
imull %r14d, %eax
cvtsi2sd %eax, %xmm0
mulsd 0x3d8(%rbx), %xmm0
movsd %xmm0, 0x28(%rsp)
leaq 0x48(%rsp), %r15
movq %r15, %rdi
callq 0x11a0a
movq %r15, %rdi
callq 0x42b0
movl %eax, %esi
leaq 0x13d0(%rsp), %rdi
callq 0x131a2
cvttsd2si 0x28(%rsp), %eax
leaq 0x40(%rsp), %rcx
andl $0x0, (%rcx)
decl %r12d
movl %r12d, 0x4(%rcx)
decl %r14d
leaq 0x38(%rsp), %rcx
andl $0x0, (%rcx)
movl %r14d, 0x4(%rcx)
movslq %eax, %r14
xorl %ebp, %ebp
leaq 0x13d0(%rsp), %r13
cmpq 0x30(%rsp), %rbp
je 0xc63e
andq $0x0, 0x20(%rsp)
xorpd %xmm0, %xmm0
movapd %xmm0, 0x10(%rsp)
xorl %r15d, %r15d
xorl %r12d, %r12d
movq %r12, %rax
subq %r15, %rax
sarq $0x3, %rax
cmpq %r14, %rax
jae 0xc627
leaq 0x40(%rsp), %rdi
movq %r13, %rsi
callq 0x11a60
movl %eax, 0x8(%rsp)
leaq 0x38(%rsp), %rdi
movq %r13, %rsi
callq 0x11a60
movl %eax, 0xc(%rsp)
movl 0x8(%rsp), %ecx
movq 0x10(%rsp), %r15
movq 0x18(%rsp), %r12
movq %r15, %rsi
cmpq %r12, %rsi
je 0xc5de
movq %rsi, %rdx
addq $0x8, %rsi
cmpl %ecx, (%rdx)
jne 0xc5c7
cmpl %eax, 0x4(%rdx)
jne 0xc5c7
jmp 0xc581
leaq 0x10(%rsp), %rdi
leaq 0x8(%rsp), %rsi
leaq 0xc(%rsp), %rdx
callq 0x11a68
movq 0x10(%rsp), %r15
movq 0x18(%rsp), %r12
jmp 0xc581
movq 0x108(%rbx), %rax
imulq $0x18, %rbp, %rcx
movslq (%r15), %rdx
imulq $0x28, %rdx, %rdi
addq (%rax,%rcx), %rdi
movslq 0x4(%r15), %rsi
callq 0x11440
notq %rdx
andq %rdx, (%rax)
addq $0x8, %r15
cmpq %r12, %r15
jne 0xc5fe
leaq 0x10(%rsp), %rdi
callq 0x1320e
incq %rbp
jmp 0xc560
leaq 0x48(%rsp), %rdi
callq 0x11a8e
addq $0x2758, %rsp           # imm = 0x2758
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1597e(%rip), %rdi     # 0x21fdf
leaq 0x15072(%rip), %rsi     # 0x216da
leaq 0x15eb7(%rip), %rcx     # 0x22526
movl $0xac3, %edx            # imm = 0xAC3
callq 0x4180
leaq 0x1571f(%rip), %rdi     # 0x21d9f
leaq 0x15053(%rip), %rsi     # 0x216da
leaq 0x15e98(%rip), %rcx     # 0x22526
movl $0xac5, %edx            # imm = 0xAC5
callq 0x4180
leaq 0x15747(%rip), %rdi     # 0x21de6
leaq 0x15034(%rip), %rsi     # 0x216da
leaq 0x15e79(%rip), %rcx     # 0x22526
movl $0xac6, %edx            # imm = 0xAC6
callq 0x4180
movq %rax, %rbx
jmp 0xc6cf
jmp 0xc6c2
jmp 0xc6c2
jmp 0xc6c2
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x1320e
leaq 0x48(%rsp), %rdi
callq 0x11a8e
movq %rbx, %rdi
callq 0x43b0
nop