// File: /workspace/github_cpp_makefile_star2_O3/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 $0x2768, %rsp           # imm = 0x2768
movq %rdi, %rax
movq 0x60(%rdi), %rdi
movq %rax, 0x18(%rsp)
movq 0x68(%rax), %r15
subq %rdi, %r15
je 0xd7fe
callq 0x1abb8
testq %rax, %rax
je 0xd81d
movq %rdx, %rbx
testq %rdx, %rdx
je 0xd83c
movq %rax, %r12
imull %ebx, %eax
cvtsi2sd %eax, %xmm0
movq 0x18(%rsp), %rax
mulsd 0x3d8(%rax), %xmm0
movsd %xmm0, (%rsp)
leaq 0x13e0(%rsp), %r14
movq %r14, %rdi
callq 0x14082
movq %r14, %rdi
callq 0x42d0
sarq $0x3, %r15
movabsq $-0x5555555555555555, %rsi # imm = 0xAAAAAAAAAAAAAAAB
cvttsd2si (%rsp), %ecx
movl %ecx, 0xc(%rsp)
imulq %r15, %rsi
movl %eax, %eax
movq %rax, 0x58(%rsp)
movl $0x1, %ecx
movq %rax, %rdx
shrq $0x1e, %rdx
xorl %eax, %edx
imull $0x6c078965, %edx, %eax # imm = 0x6C078965
addl %ecx, %eax
movq %rax, 0x58(%rsp,%rcx,8)
incq %rcx
cmpq $0x270, %rcx            # imm = 0x270
jne 0xd633
movabsq $-0x8000000000000000, %rax # imm = 0x8000000000000000
leaq 0x58(%rsp), %r14
movq $0x270, 0x1380(%r14) # imm = 0x270
decl %r12d
xorl %ecx, %ecx
leaq 0x50(%rsp), %r15
movl %ecx, (%r15)
movl %r12d, 0x4(%r15)
decl %ebx
leaq 0x48(%rsp), %r12
movq $0x0, (%rsp)
movl %ecx, (%r12)
movl %ebx, 0x4(%r12)
movslq 0xc(%rsp), %r13
cmpq $0x1, %rsi
adcq $0x0, %rsi
movq %rsi, 0x40(%rsp)
leaq 0x14(%rsp), %rbx
leaq 0x3f(%rax), %rbp
xorpd %xmm0, %xmm0
movapd %xmm0, 0x20(%rsp)
movq $0x0, 0x30(%rsp)
cmpl $0x0, 0xc(%rsp)
je 0xd7c9
movq %r15, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x15c08
movl %eax, 0x10(%rsp)
movq %r12, %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x15c08
movl %eax, 0x14(%rsp)
movq 0x20(%rsp), %rdi
movq 0x28(%rsp), %rdx
cmpq %rdx, %rdi
je 0xd71d
movl 0x10(%rsp), %ecx
movq %rdi, %rsi
cmpl %ecx, (%rsi)
jne 0xd714
cmpl %eax, 0x4(%rsi)
je 0xd739
addq $0x8, %rsi
cmpq %rdx, %rsi
jne 0xd70b
leaq 0x20(%rsp), %rdi
leaq 0x10(%rsp), %rsi
movq %rbx, %rdx
callq 0x140ec
movq 0x20(%rsp), %rdi
movq 0x28(%rsp), %rdx
movq %rdx, %rax
subq %rdi, %rax
sarq $0x3, %rax
cmpq %r13, %rax
jb 0xd6d1
cmpq %rdx, %rdi
movabsq $-0x8000000000000000, %r11 # imm = 0x8000000000000000
je 0xd7bf
movq 0x18(%rsp), %rax
movq 0x108(%rax), %rax
movq (%rsp), %rcx
leaq (%rcx,%rcx,2), %rcx
movq (%rax,%rcx,8), %rax
movq %rdi, %rsi
movslq (%rsi), %rcx
leaq (%rcx,%rcx,4), %r8
movslq 0x4(%rsi), %rcx
leal 0x3f(%rcx), %r9d
testq %rcx, %rcx
cmovnsl %ecx, %r9d
sarl $0x6, %r9d
movslq %r9d, %r9
shlq $0x3, %r9
addq (%rax,%r8,8), %r9
movq %rcx, %r8
andq %rbp, %r8
xorl %r10d, %r10d
cmpq %r11, %r8
setbe %r10b
movq $-0x2, %r8
rolq %cl, %r8
andq %r8, -0x8(%r9,%r10,8)
addq $0x8, %rsi
cmpq %rdx, %rsi
jne 0xd772
testq %rdi, %rdi
je 0xd7c9
callq 0x4230
movq (%rsp), %rcx
incq %rcx
movq %rcx, (%rsp)
cmpq 0x40(%rsp), %rcx
jne 0xd6b3
leaq 0x13e0(%rsp), %rdi
callq 0x4220
addq $0x2768, %rsp           # imm = 0x2768
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1a84a(%rip), %rdi     # 0x2804f
leaq 0x19f3e(%rip), %rsi     # 0x2774a
leaq 0x1ad83(%rip), %rcx     # 0x28596
movl $0xac3, %edx            # imm = 0xAC3
callq 0x4160
leaq 0x1a5eb(%rip), %rdi     # 0x27e0f
leaq 0x19f1f(%rip), %rsi     # 0x2774a
leaq 0x1ad64(%rip), %rcx     # 0x28596
movl $0xac5, %edx            # imm = 0xAC5
callq 0x4160
leaq 0x1a613(%rip), %rdi     # 0x27e56
leaq 0x19f00(%rip), %rsi     # 0x2774a
leaq 0x1ad45(%rip), %rcx     # 0x28596
movl $0xac6, %edx            # imm = 0xAC6
callq 0x4160
jmp 0xd88d
movq %rax, %rbx
jmp 0xd878
jmp 0xd866
jmp 0xd866
movq %rax, %rbx
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0xd878
callq 0x4230
leaq 0x13e0(%rsp), %rdi
callq 0x4220
movq %rbx, %rdi
callq 0x43e0
movq %rax, %rdi
callq 0x14607
nop