// File: dguglielmi[P]dlan-linux-software/common/dlanmonitor.cpp
// Function: CDlanMonitor::UpdateLocalDevice(std::_Rb_tree_iterator<std::pair<CMACAddress const, CDlanMonitor::NetwAdapter>>, CMACAddress const&, bool, CDlanDevice::teType, bool, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, bool, CDlanMonitor::UserDataResponse const&, bool, CMACAddress const&, bool, bool&)
CDlanMonitor::LocalDevice& CDlanMonitor::UpdateLocalDevice(
  std::map<CMACAddress,NetwAdapter>::iterator itNIC,
  const CMACAddress& addr,
  bool bResetAge,
  CDlanDevice::teType type,
  bool bKeepType,
  const std::string& version,
  bool bKeepVersion,
  const UserDataResponse& userData,
  bool bKeepUserData,
  const CMACAddress& cco,
  bool bKeepCCo,
  bool& bUpdate)
{
  std::map<CMACAddress,LocalDevice>::iterator itDevice = itNIC->second.mapLocalDevices.find(addr);

  if(itDevice == itNIC->second.mapLocalDevices.end())
  {
    bUpdate = true;

    CDlanLocalDeviceList::iterator itPubDevice = m_listLocalDevices.begin();
    for( ; itPubDevice != m_listLocalDevices.end(); itPubDevice++)
      if((itPubDevice->GetNICAddress() > itNIC->first) || (itPubDevice->GetAddress() > addr))
        break;

    CDlanLocalDevice localDevice(itNIC->first, addr, type, version, 
      userData.strMft, userData.strUser, userData.strAvln, cco);
    itPubDevice = m_listLocalDevices.insert(itPubDevice, localDevice);
    itDevice = itNIC->second.mapLocalDevices.insert(std::make_pair(addr, LocalDevice(itPubDevice))).first;

    if(itNIC->second.iFastBroadcastCnt > 2)
      itNIC->second.iFastBroadcastCnt = 2;
  }
  else 
  {
    if(bResetAge)
      itDevice->second.iAge = 0;

    CDlanLocalDevice updatedDevice(itNIC->first, addr,
      bKeepType ? itDevice->second.itPublicDevice->GetType() : type,
      bKeepVersion ? itDevice->second.itPublicDevice->GetVersion() : version,
      bKeepUserData ? itDevice->second.itPublicDevice->GetManufacturingString() : userData.strMft,
      bKeepUserData ? itDevice->second.itPublicDevice->GetUserDeviceName() : userData.strUser,
      bKeepUserData ? itDevice->second.itPublicDevice->GetUserNetworkName() : userData.strAvln,
      bKeepCCo ? itDevice->second.itPublicDevice->GetCCoAddress() : cco,
      itDevice->second.itPublicDevice->GetRemoteDevices());
  
    if(*itDevice->second.itPublicDevice != updatedDevice)
    {
      bUpdate = true;
      *itDevice->second.itPublicDevice = updatedDevice;
    }
  }

  if(userData.strMft.size() > 0)
    itDevice->second.mapUserDataAges[addr] = 0;

  return itDevice->second; 
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
subq $0x438, %rsp            # imm = 0x438
movl %r9d, %eax
movq %rdx, %r9
movq %rsi, %r11
movq %rdi, %r10
movb %al, %sil
movb %cl, %dil
movq 0x40(%rbp), %rax
movb 0x38(%rbp), %al
movq 0x30(%rbp), %rcx
movb 0x28(%rbp), %cl
movq 0x20(%rbp), %rdx
movb 0x18(%rbp), %dl
movq 0x10(%rbp), %rbx
movq %r11, -0x10(%rbp)
movq %r10, -0x18(%rbp)
movq %r9, -0x20(%rbp)
andb $0x1, %dil
movb %dil, -0x21(%rbp)
movl %r8d, -0x28(%rbp)
andb $0x1, %sil
movb %sil, -0x29(%rbp)
andb $0x1, %dl
movb %dl, -0x2a(%rbp)
andb $0x1, %cl
movb %cl, -0x2b(%rbp)
andb $0x1, %al
movb %al, -0x2c(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x320(%rbp)
leaq -0x10(%rbp), %rdi
callq 0x17d40
movq %rax, %rdi
addq $0x8, %rdi
addq $0x160, %rdi            # imm = 0x160
movq -0x20(%rbp), %rsi
callq 0x185e0
movq %rax, -0x38(%rbp)
leaq -0x10(%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 0x18ab0
testb $0x1, %al
jne 0x119ed
jmp 0x11d7d
movq -0x320(%rbp), %rdi
movq 0x40(%rbp), %rax
movb $0x1, (%rax)
addq $0x90, %rdi
callq 0x18ae0
movq %rax, -0x48(%rbp)
movq -0x320(%rbp), %rdi
addq $0x90, %rdi
callq 0x18b40
movq %rax, -0x50(%rbp)
leaq -0x48(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x18b10
testb $0x1, %al
jne 0x11a35
jmp 0x11aa4
leaq -0x48(%rbp), %rdi
callq 0x181c0
movq %rax, %rdi
callq 0x6620
movq %rax, -0x328(%rbp)
leaq -0x10(%rbp), %rdi
callq 0x17d40
movq -0x328(%rbp), %rdi
movq %rax, %rsi
callq 0x18b70
testb $0x1, %al
jne 0x11a8c
leaq -0x48(%rbp), %rdi
callq 0x181c0
movq %rax, %rdi
callq 0x6610
movq %rax, %rdi
movq -0x20(%rbp), %rsi
callq 0x18b70
testb $0x1, %al
jne 0x11a8c
jmp 0x11a8e
jmp 0x11aa4
jmp 0x11a90
leaq -0x48(%rbp), %rdi
xorl %esi, %esi
callq 0x18ba0
movq %rax, -0x58(%rbp)
jmp 0x11a0b
leaq -0x10(%rbp), %rdi
callq 0x17d40
movq %rax, -0x350(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x348(%rbp)
movl -0x28(%rbp), %eax
movl %eax, -0x33c(%rbp)
movq 0x10(%rbp), %rax
movq %rax, -0x338(%rbp)
movq 0x20(%rbp), %rax
movq %rax, -0x330(%rbp)
movq %rax, %rcx
addq $0x20, %rcx
movq %rcx, -0x358(%rbp)
addq $0x40, %rax
movq %rax, -0x360(%rbp)
movq 0x30(%rbp), %rax
movq %rax, -0x368(%rbp)
xorps %xmm0, %xmm0
movaps %xmm0, -0x130(%rbp)
movq $0x0, -0x120(%rbp)
leaq -0x130(%rbp), %rbx
movq %rbx, %rdi
callq 0x18bd0
movq -0x368(%rbp), %r11
movq -0x360(%rbp), %r10
movq -0x358(%rbp), %rdi
movq -0x350(%rbp), %rsi
movq -0x348(%rbp), %rdx
movl -0x33c(%rbp), %ecx
movq -0x338(%rbp), %r8
movq -0x330(%rbp), %r9
movq %rsp, %rax
movq %rbx, 0x18(%rax)
movq %r11, 0x10(%rax)
movq %r10, 0x8(%rax)
movq %rdi, (%rax)
leaq -0x110(%rbp), %rdi
callq 0x18bf0
jmp 0x11b7d
leaq -0x130(%rbp), %rdi
callq 0xaa20
movq -0x320(%rbp), %rax
addq $0x90, %rax
movq %rax, -0x378(%rbp)
leaq -0x150(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x17e20
movq -0x378(%rbp), %rdi
movq -0x150(%rbp), %rsi
leaq -0x110(%rbp), %rdx
callq 0x18cf0
movq %rax, -0x370(%rbp)
jmp 0x11bd0
movq -0x370(%rbp), %rax
movq %rax, -0x148(%rbp)
movq -0x148(%rbp), %rax
movq %rax, -0x48(%rbp)
leaq -0x10(%rbp), %rdi
callq 0x17d40
addq $0x168, %rax            # imm = 0x168
movq %rax, -0x388(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x380(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0x250(%rbp)
movq -0x250(%rbp), %rsi
leaq -0x248(%rbp), %rdi
callq 0x18de0
jmp 0x11c2a
movq -0x380(%rbp), %rsi
leaq -0x1d8(%rbp), %rdi
leaq -0x248(%rbp), %rdx
callq 0x18da0
jmp 0x11c46
movq -0x388(%rbp), %rdi
leaq -0x1d8(%rbp), %rsi
callq 0x18d60
movb %dl, -0x391(%rbp)
movq %rax, -0x390(%rbp)
jmp 0x11c68
movb -0x391(%rbp), %al
movq -0x390(%rbp), %rcx
movq %rcx, -0x260(%rbp)
movb %al, -0x258(%rbp)
movq -0x260(%rbp), %rax
movq %rax, -0x160(%rbp)
movb -0x258(%rbp), %al
movb %al, -0x158(%rbp)
movq -0x160(%rbp), %rax
movq %rax, -0x38(%rbp)
leaq -0x1d8(%rbp), %rdi
callq 0x18e30
leaq -0x248(%rbp), %rdi
callq 0x8f70
leaq -0x10(%rbp), %rdi
callq 0x17d40
cmpl $0x2, 0xc(%rax)
jle 0x11d5b
leaq -0x10(%rbp), %rdi
callq 0x17d40
movl $0x2, 0xc(%rax)
jmp 0x11d5b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x138(%rbp)
movl %eax, -0x13c(%rbp)
leaq -0x130(%rbp), %rdi
callq 0xaa20
jmp 0x120c9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x138(%rbp)
movl %eax, -0x13c(%rbp)
jmp 0x11d6c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x138(%rbp)
movl %eax, -0x13c(%rbp)
jmp 0x11d4d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x138(%rbp)
movl %eax, -0x13c(%rbp)
leaq -0x1d8(%rbp), %rdi
callq 0x18e30
leaq -0x248(%rbp), %rdi
callq 0x8f70
jmp 0x11d6c
leaq -0x110(%rbp), %rdi
callq 0xa9d0
jmp 0x12080
leaq -0x110(%rbp), %rdi
callq 0xa9d0
jmp 0x120c9
testb $0x1, -0x21(%rbp)
je 0x11d93
leaq -0x38(%rbp), %rdi
callq 0x17e00
movl $0x0, 0x8(%rax)
leaq -0x10(%rbp), %rdi
callq 0x17d40
movq %rax, -0x3a8(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x3a0(%rbp)
testb $0x1, -0x29(%rbp)
je 0x11ddd
leaq -0x38(%rbp), %rdi
callq 0x17e00
movq %rax, %rdi
addq $0x8, %rdi
addq $0x8, %rdi
callq 0x181c0
movq %rax, %rdi
callq 0x65f0
movl %eax, -0x3ac(%rbp)
jmp 0x11de6
movl -0x28(%rbp), %eax
movl %eax, -0x3ac(%rbp)
movl -0x3ac(%rbp), %eax
movl %eax, -0x3b0(%rbp)
testb $0x1, -0x2a(%rbp)
je 0x11e22
leaq -0x38(%rbp), %rdi
callq 0x17e00
movq %rax, %rdi
addq $0x8, %rdi
addq $0x8, %rdi
callq 0x181c0
movq %rax, %rdi
callq 0x18e60
movq %rax, -0x3b8(%rbp)
jmp 0x11e2d
movq 0x10(%rbp), %rax
movq %rax, -0x3b8(%rbp)
movq -0x3b8(%rbp), %rax
movq %rax, -0x3c0(%rbp)
testb $0x1, -0x2b(%rbp)
je 0x11e6b
leaq -0x38(%rbp), %rdi
callq 0x17e00
movq %rax, %rdi
addq $0x8, %rdi
addq $0x8, %rdi
callq 0x181c0
movq %rax, %rdi
callq 0x18e80
movq %rax, -0x3c8(%rbp)
jmp 0x11e76
movq 0x20(%rbp), %rax
movq %rax, -0x3c8(%rbp)
movq -0x3c8(%rbp), %rax
movq %rax, -0x3d0(%rbp)
testb $0x1, -0x2b(%rbp)
je 0x11eb4
leaq -0x38(%rbp), %rdi
callq 0x17e00
movq %rax, %rdi
addq $0x8, %rdi
addq $0x8, %rdi
callq 0x181c0
movq %rax, %rdi
callq 0x18ea0
movq %rax, -0x3d8(%rbp)
jmp 0x11ec3
movq 0x20(%rbp), %rax
addq $0x20, %rax
movq %rax, -0x3d8(%rbp)
movq -0x3d8(%rbp), %rax
movq %rax, -0x3e0(%rbp)
testb $0x1, -0x2b(%rbp)
je 0x11f01
leaq -0x38(%rbp), %rdi
callq 0x17e00
movq %rax, %rdi
addq $0x8, %rdi
addq $0x8, %rdi
callq 0x181c0
movq %rax, %rdi
callq 0x18ec0
movq %rax, -0x3e8(%rbp)
jmp 0x11f10
movq 0x20(%rbp), %rax
addq $0x40, %rax
movq %rax, -0x3e8(%rbp)
movq -0x3e8(%rbp), %rax
movq %rax, -0x3f0(%rbp)
testb $0x1, -0x2c(%rbp)
je 0x11f4e
leaq -0x38(%rbp), %rdi
callq 0x17e00
movq %rax, %rdi
addq $0x8, %rdi
addq $0x8, %rdi
callq 0x181c0
movq %rax, %rdi
callq 0x18ee0
movq %rax, -0x3f8(%rbp)
jmp 0x11f59
movq 0x30(%rbp), %rax
movq %rax, -0x3f8(%rbp)
movq -0x3f8(%rbp), %rax
movq %rax, -0x418(%rbp)
leaq -0x38(%rbp), %rdi
movq %rdi, -0x410(%rbp)
callq 0x17e00
movq %rax, %rdi
addq $0x10, %rdi
callq 0x181c0
movq %rax, %rdi
callq 0x18f00
movq -0x418(%rbp), %r11
movq -0x3f0(%rbp), %r10
movq -0x3e0(%rbp), %rdi
movq -0x3a8(%rbp), %rsi
movq -0x3a0(%rbp), %rdx
movl -0x3b0(%rbp), %ecx
movq -0x3c0(%rbp), %r8
movq -0x3d0(%rbp), %r9
movq %rax, %rbx
movq %rsp, %rax
movq %rbx, 0x18(%rax)
movq %r11, 0x10(%rax)
movq %r10, 0x8(%rax)
movq %rdi, (%rax)
leaq -0x318(%rbp), %rdi
movq %rdi, -0x408(%rbp)
callq 0x18bf0
movq -0x410(%rbp), %rdi
callq 0x17e00
movq %rax, %rdi
addq $0x10, %rdi
callq 0x18f20
movq -0x408(%rbp), %rsi
movq %rax, %rdi
callq 0x18f40
movb %al, -0x3f9(%rbp)
jmp 0x12019
movb -0x3f9(%rbp), %al
testb $0x1, %al
jne 0x12025
jmp 0x12074
movq 0x40(%rbp), %rax
movb $0x1, (%rax)
leaq -0x38(%rbp), %rdi
callq 0x17e00
movq %rax, %rdi
addq $0x10, %rdi
callq 0x18f20
movq %rax, %rdi
leaq -0x318(%rbp), %rsi
callq 0x18f70
jmp 0x12052
jmp 0x12074
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x138(%rbp)
movl %eax, -0x13c(%rbp)
leaq -0x318(%rbp), %rdi
callq 0xa9d0
jmp 0x120c9
leaq -0x318(%rbp), %rdi
callq 0xa9d0
movq 0x20(%rbp), %rdi
callq 0x5270
cmpq $0x0, %rax
jbe 0x120b2
leaq -0x38(%rbp), %rdi
callq 0x17e00
movq %rax, %rdi
addq $0x8, %rdi
addq $0x40, %rdi
movq -0x20(%rbp), %rsi
callq 0x18ff0
movl $0x0, (%rax)
leaq -0x38(%rbp), %rdi
callq 0x17e00
addq $0x8, %rax
addq $0x438, %rsp            # imm = 0x438
popq %rbx
popq %rbp
retq
movq -0x138(%rbp), %rdi
callq 0x5530
nopw %cs:(%rax,%rax)