// File: dguglielmi[P]dlan-linux-software/common/dlanmonitor.cpp
// Function: CDlanMonitor::RemoveDevices(bool&, bool, std::set<CMACAddress, std::less<CMACAddress>, std::allocator<CMACAddress>> const&)
void CDlanMonitor::RemoveDevices(
  bool& bUpdate,
  bool bAge,    
  const std::set<CMACAddress>& setForceRemove)
{
  for(std::map<CMACAddress,NetwAdapter>::iterator itNIC = m_mapNICs.begin(); 
    (itNIC != m_mapNICs.end()); ++itNIC)
  {
    std::map<CMACAddress,LocalDevice>::iterator itLocalDevice = itNIC->second.mapLocalDevices.begin();
    while(itLocalDevice != itNIC->second.mapLocalDevices.end())
    {
      if(bAge) ++itLocalDevice->second.iAge;

      if((itLocalDevice->second.iAge == m_timings.LocalVanishedAge) || 
        (setForceRemove.find(itLocalDevice->first) != setForceRemove.end()))
      {
        bUpdate = true;
        m_listLocalDevices.erase(itLocalDevice->second.itPublicDevice);
        itNIC->second.mapLocalDevices.erase(itLocalDevice++);
      }
      else
      {
        std::map<CMACAddress,int>::iterator itUserDataAge;
        if(bAge &&
          ((itUserDataAge = itLocalDevice->second.mapUserDataAges.find(itLocalDevice->first)) != itLocalDevice->second.mapUserDataAges.end()) &&
          (++itUserDataAge->second == m_timings.LocalVanishedAge))
        {
          UpdateLocalDevice(itNIC, itLocalDevice->first, false, CDlanDevice::eThunderbolt, true, 
            "", true, UserDataResponse(), false, CMACAddress::Null(), true, bUpdate);
          itLocalDevice->second.mapUserDataAges.erase(itUserDataAge);
        }

        std::map<CMACAddress,int>::iterator itRemoteDevice = itLocalDevice->second.mapRemoteDeviceAges.begin();
        while(itRemoteDevice != itLocalDevice->second.mapRemoteDeviceAges.end())
        {
          if(bAge) ++itRemoteDevice->second;
        
          if((itRemoteDevice->second == m_timings.RemoteVanishedAge) ||
            (setForceRemove.find(itRemoteDevice->first) != setForceRemove.end()))
          {
            bUpdate = true;
            itLocalDevice->second.itPublicDevice->RemoveRemoteDevice(itRemoteDevice->first);
            itLocalDevice->second.mapRemoteDeviceAges.erase(itRemoteDevice++);
          }
          else
          {
            if(bAge &&
              ((itUserDataAge = itLocalDevice->second.mapUserDataAges.find(itRemoteDevice->first)) != itLocalDevice->second.mapUserDataAges.end()) &&
              (++itUserDataAge->second == m_timings.RemoteVanishedAge))
            {
              UpdateRemoteDevice(itLocalDevice->second, itRemoteDevice->first, false,
                CDlanDevice::eThunderbolt, true, "", true, UserDataResponse(), false, 0.0, 0.0, true, 
                std::map<CMACAddress, CDlanDataRates>(), true, CMACAddress(), true, bUpdate);
              itLocalDevice->second.mapUserDataAges.erase(itUserDataAge);
            }

            ++itRemoteDevice;
          }
        }
        ++itLocalDevice;
      }
    }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x380, %rsp            # imm = 0x380
movb %dl, %al
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
andb $0x1, %al
movb %al, -0x11(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x2a0(%rbp)
addq $0xa8, %rdi
callq 0x17c80
movq %rax, -0x28(%rbp)
movq -0x2a0(%rbp), %rdi
addq $0xa8, %rdi
callq 0x17a70
movq %rax, -0x30(%rbp)
leaq -0x28(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x17cb0
testb $0x1, %al
jne 0x106f6
jmp 0x10fb9
leaq -0x28(%rbp), %rdi
callq 0x17d40
movq %rax, %rdi
addq $0x8, %rdi
addq $0x160, %rdi            # imm = 0x160
callq 0x17dd0
movq %rax, -0x38(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x17d40
movq %rax, %rdi
addq $0x8, %rdi
addq $0x160, %rdi            # imm = 0x160
callq 0x17fc0
movq %rax, -0x40(%rbp)
leaq -0x38(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x17f90
testb $0x1, %al
jne 0x1074c
jmp 0x10fa9
testb $0x1, -0x11(%rbp)
je 0x10764
leaq -0x38(%rbp), %rdi
callq 0x17e00
movl 0x8(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x8(%rax)
leaq -0x38(%rbp), %rdi
callq 0x17e00
movq -0x2a0(%rbp), %rdx
movl 0x8(%rax), %ecx
movb $0x1, %al
cmpl 0x48(%rdx), %ecx
movb %al, -0x2a1(%rbp)
je 0x107cb
movq -0x20(%rbp), %rax
movq %rax, -0x2b0(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x17e00
movq -0x2b0(%rbp), %rdi
movq %rax, %rsi
callq 0x17d10
movq %rax, -0x48(%rbp)
movq -0x20(%rbp), %rdi
callq 0x179e0
movq %rax, -0x50(%rbp)
leaq -0x48(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0xe190
movb %al, -0x2a1(%rbp)
movb -0x2a1(%rbp), %al
testb $0x1, %al
jne 0x107da
jmp 0x10868
movq -0x2a0(%rbp), %rax
movq -0x10(%rbp), %rcx
movb $0x1, (%rcx)
addq $0x90, %rax
movq %rax, -0x2c0(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x17e00
movq %rax, %rsi
addq $0x8, %rsi
addq $0x8, %rsi
leaq -0x58(%rbp), %rdi
callq 0x17e20
movq -0x2c0(%rbp), %rdi
movq -0x58(%rbp), %rsi
callq 0x17d80
movq %rax, -0x60(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x17d40
addq $0x8, %rax
addq $0x160, %rax            # imm = 0x160
movq %rax, -0x2b8(%rbp)
leaq -0x38(%rbp), %rdi
xorl %esi, %esi
callq 0x17ff0
movq -0x2b8(%rbp), %rdi
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rsi
callq 0x17e40
movq %rax, -0x70(%rbp)
jmp 0x10fa4
leaq -0x78(%rbp), %rdi
callq 0x18030
xorl %eax, %eax
testb $0x1, -0x11(%rbp)
movb %al, -0x2c1(%rbp)
je 0x10928
leaq -0x38(%rbp), %rdi
callq 0x17e00
addq $0x8, %rax
addq $0x40, %rax
movq %rax, -0x2d0(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x17e00
movq -0x2d0(%rbp), %rdi
movq %rax, %rsi
callq 0x18080
movq %rax, -0x80(%rbp)
movq -0x80(%rbp), %rax
movq %rax, -0x78(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x17e00
movq %rax, %rdi
addq $0x8, %rdi
addq $0x40, %rdi
callq 0x180b0
movq %rax, -0x88(%rbp)
leaq -0x78(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x18050
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, -0x2c1(%rbp)
jne 0x10900
jmp 0x10928
leaq -0x78(%rbp), %rdi
callq 0x180e0
movq -0x2a0(%rbp), %rcx
movq %rax, %rdx
movl 0x8(%rdx), %eax
addl $0x1, %eax
movl %eax, 0x8(%rdx)
cmpl 0x48(%rcx), %eax
sete %al
movb %al, -0x2c1(%rbp)
movb -0x2c1(%rbp), %al
testb $0x1, %al
jne 0x10937
jmp 0x10af1
movq -0x28(%rbp), %rax
movq %rax, -0x90(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x17e00
movq %rax, -0x2e0(%rbp)
leaq -0xb1(%rbp), %rdi
movq %rdi, -0x2d8(%rbp)
callq 0x5540
movq -0x2d8(%rbp), %rdx
leaq 0x277ee(%rip), %rsi     # 0x38161
leaq -0xb0(%rbp), %rdi
callq 0x62a0
jmp 0x10981
leaq -0x148(%rbp), %rdi
callq 0x18100
jmp 0x1098f
leaq -0x14e(%rbp), %rdi
callq 0xb750
jmp 0x1099d
movq -0x2e0(%rbp), %rdx
movq -0x2a0(%rbp), %rdi
movq -0x10(%rbp), %rcx
movq -0x90(%rbp), %rsi
movq %rsp, %rax
movq %rcx, 0x30(%rax)
leaq -0x14e(%rbp), %rcx
movq %rcx, 0x20(%rax)
leaq -0x148(%rbp), %rcx
movq %rcx, 0x10(%rax)
leaq -0xb0(%rbp), %rcx
movq %rcx, (%rax)
movl $0x1, 0x28(%rax)
movl $0x0, 0x18(%rax)
movl $0x1, 0x8(%rax)
xorl %ecx, %ecx
movl $0x2, %r8d
movl $0x1, %r9d
callq 0x11920
jmp 0x10a07
leaq -0x14e(%rbp), %rdi
callq 0x6b70
leaq -0x148(%rbp), %rdi
callq 0x9d10
leaq -0xb0(%rbp), %rdi
callq 0x5240
leaq -0xb1(%rbp), %rdi
callq 0x5380
leaq -0x38(%rbp), %rdi
callq 0x17e00
movq %rax, %rdi
addq $0x8, %rdi
addq $0x40, %rdi
movq -0x78(%rbp), %rax
movq %rax, -0x158(%rbp)
movq -0x158(%rbp), %rsi
callq 0x18150
movq %rax, -0x160(%rbp)
jmp 0x10af1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
jmp 0x10ae0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
jmp 0x10ad4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
jmp 0x10ac8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
leaq -0x14e(%rbp), %rdi
callq 0x6b70
leaq -0x148(%rbp), %rdi
callq 0x9d10
leaq -0xb0(%rbp), %rdi
callq 0x5240
leaq -0xb1(%rbp), %rdi
callq 0x5380
jmp 0x10fc2
leaq -0x38(%rbp), %rdi
callq 0x17e00
movq %rax, %rdi
addq $0x8, %rdi
addq $0x10, %rdi
callq 0x18190
movq %rax, -0x168(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x17e00
movq %rax, %rdi
addq $0x8, %rdi
addq $0x10, %rdi
callq 0x180b0
movq %rax, -0x170(%rbp)
leaq -0x168(%rbp), %rdi
leaq -0x170(%rbp), %rsi
callq 0x18050
testb $0x1, %al
jne 0x10b4d
jmp 0x10f9b
testb $0x1, -0x11(%rbp)
je 0x10b68
leaq -0x168(%rbp), %rdi
callq 0x180e0
movl 0x8(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x8(%rax)
leaq -0x168(%rbp), %rdi
callq 0x180e0
movq -0x2a0(%rbp), %rdx
movl 0x8(%rax), %ecx
movb $0x1, %al
cmpl 0x50(%rdx), %ecx
movb %al, -0x2e1(%rbp)
je 0x10be1
movq -0x20(%rbp), %rax
movq %rax, -0x2f0(%rbp)
leaq -0x168(%rbp), %rdi
callq 0x180e0
movq -0x2f0(%rbp), %rdi
movq %rax, %rsi
callq 0x17d10
movq %rax, -0x178(%rbp)
movq -0x20(%rbp), %rdi
callq 0x179e0
movq %rax, -0x180(%rbp)
leaq -0x178(%rbp), %rdi
leaq -0x180(%rbp), %rsi
callq 0xe190
movb %al, -0x2e1(%rbp)
movb -0x2e1(%rbp), %al
testb $0x1, %al
jne 0x10bf0
jmp 0x10c7e
movq -0x10(%rbp), %rax
movb $0x1, (%rax)
leaq -0x38(%rbp), %rdi
callq 0x17e00
movq %rax, %rdi
addq $0x8, %rdi
addq $0x8, %rdi
callq 0x181c0
movq %rax, -0x300(%rbp)
leaq -0x168(%rbp), %rdi
callq 0x180e0
movq -0x300(%rbp), %rdi
movq %rax, %rsi
callq 0xd370
leaq -0x38(%rbp), %rdi
callq 0x17e00
addq $0x8, %rax
addq $0x10, %rax
movq %rax, -0x2f8(%rbp)
leaq -0x168(%rbp), %rdi
xorl %esi, %esi
callq 0x181e0
movq -0x2f8(%rbp), %rdi
movq %rax, -0x188(%rbp)
movq -0x188(%rbp), %rsi
callq 0x18150
movq %rax, -0x190(%rbp)
jmp 0x10f96
xorl %eax, %eax
testb $0x1, -0x11(%rbp)
movb %al, -0x301(%rbp)
je 0x10d3e
leaq -0x38(%rbp), %rdi
callq 0x17e00
addq $0x8, %rax
addq $0x40, %rax
movq %rax, -0x310(%rbp)
leaq -0x168(%rbp), %rdi
callq 0x180e0
movq -0x310(%rbp), %rdi
movq %rax, %rsi
callq 0x18080
movq %rax, -0x198(%rbp)
movq -0x198(%rbp), %rax
movq %rax, -0x78(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x17e00
movq %rax, %rdi
addq $0x8, %rdi
addq $0x40, %rdi
callq 0x180b0
movq %rax, -0x1a0(%rbp)
leaq -0x78(%rbp), %rdi
leaq -0x1a0(%rbp), %rsi
callq 0x18050
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, -0x301(%rbp)
jne 0x10d16
jmp 0x10d3e
leaq -0x78(%rbp), %rdi
callq 0x180e0
movq -0x2a0(%rbp), %rcx
movq %rax, %rdx
movl 0x8(%rdx), %eax
addl $0x1, %eax
movl %eax, 0x8(%rdx)
cmpl 0x50(%rcx), %eax
sete %al
movb %al, -0x301(%rbp)
movb -0x301(%rbp), %al
testb $0x1, %al
jne 0x10d4d
jmp 0x10f8a
leaq -0x38(%rbp), %rdi
callq 0x17e00
addq $0x8, %rax
movq %rax, -0x328(%rbp)
leaq -0x168(%rbp), %rdi
callq 0x180e0
movq %rax, -0x320(%rbp)
leaq -0x1c1(%rbp), %rdi
movq %rdi, -0x318(%rbp)
callq 0x5540
movq -0x318(%rbp), %rdx
leaq 0x273cc(%rip), %rsi     # 0x38161
leaq -0x1c0(%rbp), %rdi
callq 0x62a0
jmp 0x10da3
leaq -0x248(%rbp), %rdi
callq 0x18100
jmp 0x10db1
xorps %xmm0, %xmm0
movaps %xmm0, -0x260(%rbp)
movaps %xmm0, -0x270(%rbp)
movaps %xmm0, -0x280(%rbp)
leaq -0x280(%rbp), %rdi
callq 0x18220
movq %rsp, %rax
movl $0x0, (%rax)
leaq -0x286(%rbp), %rdi
xorl %r9d, %r9d
movl %r9d, %esi
movl %r9d, %edx
movl %r9d, %ecx
movl %r9d, %r8d
callq 0x6230
jmp 0x10dfb
movq -0x320(%rbp), %rdx
movq -0x328(%rbp), %rsi
movq -0x2a0(%rbp), %rdi
movq -0x10(%rbp), %rcx
movq %rsp, %rax
movq %rax, -0x330(%rbp)
movq %rcx, 0x48(%rax)
leaq -0x286(%rbp), %rcx
movq %rcx, 0x38(%rax)
leaq -0x280(%rbp), %rcx
movq %rcx, 0x28(%rax)
leaq -0x248(%rbp), %rcx
movq %rcx, 0x10(%rax)
leaq -0x1c0(%rbp), %rcx
movq %rcx, (%rax)
movl $0x1, 0x40(%rax)
movl $0x1, 0x30(%rax)
movl $0x1, 0x20(%rax)
movl $0x0, 0x18(%rax)
movl $0x1, 0x8(%rax)
xorl %ecx, %ecx
movl $0x2, %r8d
movl $0x1, %r9d
xorps %xmm1, %xmm1
movaps %xmm1, %xmm0
callq 0x120e0
jmp 0x10e8b
leaq -0x286(%rbp), %rdi
callq 0x6b70
leaq -0x280(%rbp), %rdi
callq 0xacb0
leaq -0x248(%rbp), %rdi
callq 0x9d10
leaq -0x1c0(%rbp), %rdi
callq 0x5240
leaq -0x1c1(%rbp), %rdi
callq 0x5380
leaq -0x38(%rbp), %rdi
callq 0x17e00
movq %rax, %rdi
addq $0x8, %rdi
addq $0x40, %rdi
movq -0x78(%rbp), %rax
movq %rax, -0x290(%rbp)
movq -0x290(%rbp), %rsi
callq 0x18150
movq %rax, -0x298(%rbp)
jmp 0x10f8a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
jmp 0x10f7c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
jmp 0x10f70
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
jmp 0x10f58
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
leaq -0x286(%rbp), %rdi
callq 0x6b70
leaq -0x280(%rbp), %rdi
callq 0xacb0
leaq -0x248(%rbp), %rdi
callq 0x9d10
leaq -0x1c0(%rbp), %rdi
callq 0x5240
leaq -0x1c1(%rbp), %rdi
callq 0x5380
jmp 0x10fc2
leaq -0x168(%rbp), %rdi
callq 0x18240
jmp 0x10b11
leaq -0x38(%rbp), %rdi
callq 0x18270
jmp 0x10716
jmp 0x10fab
leaq -0x28(%rbp), %rdi
callq 0x17f60
jmp 0x106c9
addq $0x380, %rsp            # imm = 0x380
popq %rbp
retq
movq -0xc0(%rbp), %rdi
callq 0x5530
nop