// File: /workspace/github_cpp_makefile_star2_O2/dguglielmi[P]dlan-linux-software/common/dlanmonitor.cpp
// Function: CDlanMonitor::TriggerUnknownDevices(std::_Rb_tree_iterator<std::pair<CMACAddress const, CDlanMonitor::NetwAdapter>>)
void CDlanMonitor::TriggerUnknownDevices(
  std::map<CMACAddress,NetwAdapter>::iterator itNIC)
{
  if(((m_eMode & eMonitorHP1) == eMonitorHP1) || ((m_eMode & eMonitorTurbo) == eMonitorTurbo))
  {
    itNIC->second.setDevicesToTrigger.insert(
      itNIC->second.setParamsAndStatsResponses.begin(), itNIC->second.setParamsAndStatsResponses.end());
    itNIC->second.setDevicesToTrigger.insert(
      itNIC->second.setRemoteTurboResponses.begin(), itNIC->second.setRemoteTurboResponses.end());

    for(std::set<CMACAddress>::iterator itDeviceToTrigger = itNIC->second.setDevicesToTrigger.begin();
      (itDeviceToTrigger != itNIC->second.setDevicesToTrigger.end()); ++itDeviceToTrigger)
    {
      bool bIsWellKnown = false;

      if(itNIC->second.mapLocalDevices.find(*itDeviceToTrigger) != itNIC->second.mapLocalDevices.end())
        bIsWellKnown = true;

      for(std::map<CMACAddress,LocalDevice>::iterator itLocalDevice = itNIC->second.mapLocalDevices.begin();
        (bIsWellKnown == false) && (itLocalDevice != itNIC->second.mapLocalDevices.end()); ++itLocalDevice)
      {
        if(itLocalDevice->second.mapRemoteDeviceAges.find(*itDeviceToTrigger) != itLocalDevice->second.mapRemoteDeviceAges.end())
          bIsWellKnown = true;
      }

      if(!bIsWellKnown)
      {
        itNIC->second.queuePendingPackets.push(
          new HomePlugMMEs::ParamsAndStats::CRequest(*itDeviceToTrigger, itNIC->first));
      }
    }

    for(std::map<CMACAddress,LocalDevice>::iterator itLocalDevice = itNIC->second.mapLocalDevices.begin();
      (itLocalDevice != itNIC->second.mapLocalDevices.end()); ++itLocalDevice)
    {
      for(std::map<CMACAddress,int>::iterator itRemoteDevice = itLocalDevice->second.mapRemoteDeviceAges.begin();
        (itRemoteDevice != itLocalDevice->second.mapRemoteDeviceAges.end()); ++itRemoteDevice)
      {
        if(itRemoteDevice->second >= m_timings.RemoteRefreshAge)
        {
          itNIC->second.queuePendingPackets.push(
            new HomePlugMMEs::ParamsAndStats::CRequest(itRemoteDevice->first, itNIC->first));
        }
      }
    }
  }

  if((m_eMode & eMonitorThunderbolt) == eMonitorThunderbolt)
  {
    std::set<CMACAddress> setGetVersion, setGetUserData;
    std::map<CMACAddress,std::string> mapUnknownGetVersionResponses = itNIC->second.mapGetVersionResponses;
  
    for(std::map<CMACAddress,NetworkInfoResponse>::const_iterator itNetworkInfo = itNIC->second.mapNetworkInfoResponses.begin();
      itNetworkInfo != itNIC->second.mapNetworkInfoResponses.end(); ++itNetworkInfo)
    {
      mapUnknownGetVersionResponses.erase(itNetworkInfo->first);
    
      for(std::list<HomePlugAvMMEs::ThunderNetworkInfo::StationInfo>::const_iterator itStation = itNetworkInfo->second.stations.begin();
        itStation != itNetworkInfo->second.stations.end(); ++itStation)
      {
        mapUnknownGetVersionResponses.erase(itStation->GetAddress());

        if(itNIC->second.mapGetVersionResponses.find(itStation->GetAddress()) == itNIC->second.mapGetVersionResponses.end())
          setGetVersion.insert(itStation->GetAddress());

        if(itNIC->second.mapUserDataResponses.find(itStation->GetAddress()) == itNIC->second.mapUserDataResponses.end())
          setGetUserData.insert(itStation->GetAddress());
      }
    }

    for(std::set<CMACAddress>::iterator it = setGetVersion.begin(); it != setGetVersion.end(); ++it)
    {
      itNIC->second.queuePendingPackets.push(new HomePlugAvMMEs::ThunderGetVersion::CRequest(*it, itNIC->first));
    }

    for(std::map<CMACAddress,std::string>::iterator it = mapUnknownGetVersionResponses.begin(); 
      it != mapUnknownGetVersionResponses.end(); ++it)
    {
      itNIC->second.queuePendingPackets.push(new HomePlugAvMMEs::ThunderGetVersion::CRequest(it->first, itNIC->first));
    }

    for(std::set<CMACAddress>::iterator it = setGetUserData.begin(); it != setGetUserData.end(); ++it)
    {
      itNIC->second.queuePendingPackets.push(new HomePlugAvMMEs::ThunderReadModuleData::CRequest(*it, itNIC->first, 
        HomePlugAvMMEs::ThunderReadModuleData::ePib, 208, 36));
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc8, %rsp
movq %rsi, %rbp
movl 0x20(%rdi), %eax
movl %eax, %ecx
notl %ecx
testb $0x3, %cl
setne %dl
testb $0xc, %cl
setne %cl
testb %cl, %dl
movq %rsi, 0x30(%rsp)
jne 0x873e
movq %rdi, %r14
leaq 0x20(%rbp), %r15
leaq 0x98(%rbp), %rbx
movq 0x50(%rbp), %rsi
leaq 0x40(%rbp), %rdx
movq %rbx, %rdi
callq 0xd430
movq 0x80(%rbp), %rsi
leaq 0x70(%rbp), %rdx
movq %rbx, %rdi
callq 0xd430
movq 0xb0(%rbp), %rcx
leaq 0xa0(%rbp), %rax
movq %rax, 0x28(%rsp)
leaq 0x188(%rbp), %rax
movq %rax, 0x20(%rsp)
leaq 0x190(%rbp), %rbx
leaq 0x1b8(%rbp), %rax
movq %rax, 0x18(%rsp)
cmpq 0x28(%rsp), %rcx
je 0x869d
movq %rcx, 0x8(%rsp)
leaq 0x20(%rcx), %r13
movq 0x20(%rsp), %rdi
movq %r13, %rsi
callq 0xd5b6
cmpq %rbx, %rax
setne %r12b
movq 0x1a0(%rbp), %rbp
testb $0x1, %r12b
jne 0x8630
cmpq %rbx, %rbp
je 0x8630
leaq 0x38(%rbp), %rdi
movq %r13, %rsi
callq 0xd10c
leaq 0x40(%rbp), %rcx
cmpq %rcx, %rax
movzbl %r12b, %r12d
pushq $0x1
popq %rax
cmovnel %eax, %r12d
movq %rbp, %rdi
callq 0x41e0
movq %rax, %rbp
jmp 0x85fa
testb $0x1, %r12b
jne 0x8686
pushq $0x20
popq %rdi
callq 0x4270
leaq 0x1641b(%rip), %rcx     # 0x1ea60
movq %rcx, (%rax)
movl (%r13), %ecx
movl %ecx, 0x8(%rax)
movzwl 0x4(%r13), %ecx
movw %cx, 0xc(%rax)
movl (%r15), %ecx
movl %ecx, 0xe(%rax)
movzwl 0x4(%r15), %ecx
movw %cx, 0x12(%rax)
movl $0x7017b88, 0x14(%rax)  # imm = 0x7017B88
movb $0x0, 0x18(%rax)
movq %rax, 0x38(%rsp)
movq 0x18(%rsp), %rdi
leaq 0x38(%rsp), %rsi
callq 0xd1d0
movq 0x8(%rsp), %rdi
callq 0x42c0
movq %rax, %rcx
movq 0x30(%rsp), %rbp
jmp 0x85cb
movq 0x1a0(%rbp), %rax
leaq 0x38(%rsp), %r12
cmpq %rbx, %rax
je 0x873a
movq 0x50(%rax), %rbp
movq %rax, 0x8(%rsp)
leaq 0x40(%rax), %r13
cmpq %r13, %rbp
je 0x8726
movl 0x28(%rbp), %eax
cmpl 0x4c(%r14), %eax
jl 0x8719
pushq $0x20
popq %rdi
callq 0x4270
leaq 0x16384(%rip), %rcx     # 0x1ea60
movq %rcx, (%rax)
movl 0x20(%rbp), %ecx
movl %ecx, 0x8(%rax)
movzwl 0x24(%rbp), %ecx
movw %cx, 0xc(%rax)
movl (%r15), %ecx
movl %ecx, 0xe(%rax)
movzwl 0x4(%r15), %ecx
movw %cx, 0x12(%rax)
movl $0x7017b88, 0x14(%rax)  # imm = 0x7017B88
movb $0x0, 0x18(%rax)
movq %rax, 0x38(%rsp)
movq 0x18(%rsp), %rdi
movq %r12, %rsi
callq 0xd1d0
movq %rbp, %rdi
callq 0x41e0
movq %rax, %rbp
jmp 0x86bf
movq 0x8(%rsp), %rdi
callq 0x41e0
movq 0x30(%rsp), %rbp
jmp 0x86a9
movl 0x20(%r14), %eax
notl %eax
testb $0x30, %al
jne 0x89dc
leaq 0x40(%rsp), %rax
andl $0x0, (%rax)
andq $0x0, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
andq $0x0, 0x20(%rax)
leaq 0xa0(%rsp), %rax
andl $0x0, (%rax)
andq $0x0, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
andq $0x0, 0x20(%rax)
leaq 0xf8(%rbp), %rsi
leaq 0x68(%rsp), %rdi
movq %rsi, 0x18(%rsp)
callq 0xba16
leaq 0x20(%rbp), %rax
movq %rax, 0x8(%rsp)
movq 0x170(%rbp), %r15
leaq 0x160(%rbp), %rax
movq %rax, 0x20(%rsp)
leaq 0x100(%rbp), %rbx
leaq 0x128(%rbp), %r12
leaq 0x130(%rbp), %r14
cmpq 0x20(%rsp), %r15
je 0x885d
leaq 0x20(%r15), %rsi
leaq 0x68(%rsp), %rdi
callq 0xd62c
movq %r15, 0x28(%rsp)
addq $0x30, %r15
movq %r15, %rbp
movq (%rbp), %rbp
cmpq %r15, %rbp
je 0x8846
leaq 0x10(%rbp), %r13
leaq 0x68(%rsp), %rdi
movq %r13, %rsi
callq 0xd62c
movq 0x18(%rsp), %rdi
movq %r13, %rsi
callq 0xd82e
cmpq %rbx, %rax
jne 0x8824
leaq 0x38(%rsp), %rdi
movq %r13, %rsi
callq 0xcb94
movq %r12, %rdi
movq %r13, %rsi
callq 0xd86c
cmpq %r14, %rax
jne 0x87eb
leaq 0x98(%rsp), %rdi
movq %r13, %rsi
callq 0xcb94
jmp 0x87eb
movq 0x28(%rsp), %rdi
callq 0x42c0
movq %rax, %r15
movq 0x30(%rsp), %rbp
jmp 0x87c6
movq 0x50(%rsp), %r14
addq $0x1b8, %rbp            # imm = 0x1B8
pushq $0x20
popq %rbx
leaq 0x16145(%rip), %r12     # 0x1e9b8
leaq 0x10(%rsp), %r15
leaq 0x40(%rsp), %rax
cmpq %rax, %r14
je 0x88e1
movq %rbx, %rdi
callq 0x4270
movq %r12, (%rax)
movl 0x20(%r14), %ecx
movl %ecx, 0x8(%rax)
movzwl 0x24(%r14), %ecx
movw %cx, 0xc(%rax)
movq 0x8(%rsp), %rdx
movl (%rdx), %ecx
movl %ecx, 0xe(%rax)
movzwl 0x4(%rdx), %ecx
movw %cx, 0x12(%rax)
movw $0xe188, 0x14(%rax)     # imm = 0xE188
movb $0x0, 0x16(%rax)
movl $0xb000a000, 0x17(%rax) # imm = 0xB000A000
movb $0x52, 0x1b(%rax)
movq %rax, 0x10(%rsp)
movq %rbp, %rdi
movq %r15, %rsi
callq 0xd1d0
movq %r14, %rdi
callq 0x42c0
movq %rax, %r14
jmp 0x8878
leaq 0x70(%rsp), %r13
movq 0x10(%r13), %r15
pushq $0x20
popq %rbx
leaq 0x10(%rsp), %r14
cmpq %r13, %r15
je 0x8956
movq %rbx, %rdi
callq 0x4270
movq %r12, (%rax)
movl 0x20(%r15), %ecx
movl %ecx, 0x8(%rax)
movzwl 0x24(%r15), %ecx
movw %cx, 0xc(%rax)
movq 0x8(%rsp), %rdx
movl (%rdx), %ecx
movl %ecx, 0xe(%rax)
movzwl 0x4(%rdx), %ecx
movw %cx, 0x12(%rax)
movw $0xe188, 0x14(%rax)     # imm = 0xE188
movb $0x0, 0x16(%rax)
movl $0xb000a000, 0x17(%rax) # imm = 0xB000A000
movb $0x52, 0x1b(%rax)
movq %rax, 0x10(%rsp)
movq %rbp, %rdi
movq %r14, %rsi
callq 0xd1d0
movq %r15, %rdi
callq 0x41e0
movq %rax, %r15
jmp 0x88f2
movq 0xb0(%rsp), %r14
pushq $0x2
popq %rbx
pushq $0x24
popq %r15
leaq 0x10(%rsp), %r12
leaq 0xa0(%rsp), %rax
cmpq %rax, %r14
je 0x89bb
pushq $0x28
popq %rdi
callq 0x4270
movq %rax, %r13
leaq 0x20(%r14), %rsi
movq %rax, %rdi
movq 0x8(%rsp), %rdx
movl %ebx, %ecx
movl $0xd0, %r8d
movl %r15d, %r9d
callq 0xaaa8
movq %r13, 0x10(%rsp)
movq %rbp, %rdi
movq %r12, %rsi
callq 0xd1d0
movq %r14, %rdi
callq 0x42c0
movq %rax, %r14
jmp 0x896a
leaq 0x68(%rsp), %rdi
callq 0x58f6
leaq 0x98(%rsp), %rdi
callq 0x595a
leaq 0x38(%rsp), %rdi
callq 0x595a
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x8a1c
movq %rax, %rbx
pushq $0x28
popq %rsi
movq %r13, %rdi
callq 0x4280
jmp 0x8a12
jmp 0x8a0f
jmp 0x8a0f
jmp 0x8a0f
jmp 0x8a0f
jmp 0x8a0f
jmp 0x8a0f
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
callq 0x58f6
leaq 0x98(%rsp), %rdi
callq 0x595a
leaq 0x38(%rsp), %rdi
callq 0x595a
movq %rbx, %rdi
callq 0x4410
nop