// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1b8, %rsp            # imm = 0x1B8
movl %r9d, 0x8(%rsp)
movl %r8d, 0x4(%rsp)
movl %ecx, %r12d
movq %rsi, %rbx
movq %rdi, %rbp
leaq 0x20(%rsi), %r14
leaq 0x188(%rsi), %r13
movq %r13, %rdi
movq %rdx, 0x10(%rsp)
movq %rdx, %rsi
callq 0xd5b6
movq %rax, %r15
leaq 0x190(%rbx), %rax
cmpq %rax, %r15
je 0x7c8c
testb %r12b, %r12b
je 0x7c2c
andl $0x0, 0x28(%r15)
movb 0x1f8(%rsp), %cl
cmpb $0x0, 0x8(%rsp)
movl 0x4(%rsp), %ebp
movq 0x1f0(%rsp), %r8
je 0x7c4d
movq 0x30(%r15), %rax
movl 0x18(%rax), %ebp
movb 0x208(%rsp), %al
testb %cl, %cl
movq 0x200(%rsp), %r13
je 0x7c68
movq 0x30(%r15), %r8
addq $0x20, %r8
movb 0x218(%rsp), %cl
testb %al, %al
je 0x7df6
movq 0x30(%r15), %r10
leaq 0x40(%r10), %r9
leaq 0x60(%r10), %rax
subq $-0x80, %r10
jmp 0x7e01
movq %r13, 0x8(%rsp)
movq 0x220(%rsp), %rax
movb $0x1, (%rax)
addq $0x90, %rbp
movq %rbp, %r15
movq 0x10(%rsp), %r12
movq (%r15), %r15
cmpq %rbp, %r15
je 0x7cd6
leaq 0xa0(%r15), %rdi
movq %r14, %rsi
callq 0xab41
testb %al, %al
jne 0x7cd6
leaq 0x10(%r15), %rdi
movq %r12, %rsi
callq 0xab41
testb %al, %al
je 0x7cab
movq 0x200(%rsp), %r13
leaq 0x20(%r13), %rax
leaq 0x40(%r13), %r10
leaq 0x140(%rsp), %r11
movq %r11, 0x8(%r11)
movq %r11, (%r11)
andq $0x0, 0x10(%r11)
leaq 0x88(%rsp), %rdi
movq %r14, %rsi
movq %r12, %rdx
movl 0x4(%rsp), %ecx
movq 0x1f0(%rsp), %r8
movq %r13, %r9
pushq %r11
pushq 0x218(%rsp)
pushq %r10
pushq %rax
callq 0xab52
addq $0x20, %rsp
leaq 0x140(%rsp), %rdi
callq 0x5a2c
leaq 0x88(%rsp), %rdx
movq %rbp, %rdi
movq %r15, %rsi
callq 0xabe6
leaq 0x30(%rsp), %rcx
andl $0x0, -0x18(%rcx)
movq %rax, -0x10(%rcx)
andl $0x0, (%rcx)
andq $0x0, 0x8(%rcx)
movq %rcx, 0x10(%rcx)
movq %rcx, 0x18(%rcx)
andq $0x0, 0x20(%rcx)
leaq 0x60(%rsp), %rax
andl $0x0, (%rax)
andq $0x0, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
andq $0x0, 0x20(%rax)
movl (%r12), %eax
leaq 0x148(%rsp), %r14
movl %eax, -0x8(%r14)
movzwl 0x4(%r12), %eax
movw %ax, -0x4(%r14)
leaq 0x18(%rsp), %rsi
movq %r14, %rdi
callq 0xbda2
leaq 0x140(%rsp), %rsi
movq 0x8(%rsp), %rdi
callq 0xda96
movq %rax, %r15
movq %r14, %rdi
callq 0x5738
leaq 0x18(%rsp), %rdi
callq 0x5738
cmpl $0x3, 0x2c(%rbx)
jl 0x7de4
movl $0x2, 0x2c(%rbx)
leaq 0x88(%rsp), %rdi
callq 0x59e6
jmp 0x7e8b
leaq 0x20(%r13), %rax
leaq 0x40(%r13), %r10
movq %r13, %r9
movq 0x30(%r15), %r11
leaq 0xa6(%r11), %rdx
testb %cl, %cl
movq 0x210(%rsp), %rbx
cmovneq %rdx, %rbx
addq $0xb0, %r11
leaq 0x88(%rsp), %r12
movq %r12, %rdi
movq %r14, %rsi
movq 0x10(%rsp), %rdx
movl %ebp, %ecx
pushq %r11
pushq %rbx
pushq %r10
pushq %rax
callq 0xab52
addq $0x20, %rsp
movq 0x30(%r15), %rdi
addq $0x10, %rdi
movq %r12, %rsi
callq 0xac14
testb %al, %al
je 0x7e79
movq 0x220(%rsp), %rax
movb $0x1, (%rax)
movq 0x30(%r15), %rdi
addq $0x10, %rdi
leaq 0x88(%rsp), %rsi
callq 0xac1e
leaq 0x88(%rsp), %rdi
callq 0x59e6
movq 0x10(%rsp), %r12
cmpq $0x0, 0x8(%r13)
je 0x7ea1
leaq 0x68(%r15), %rdi
movq %r12, %rsi
callq 0xac88
andl $0x0, (%rax)
addq $0x28, %r15
movq %r15, %rax
addq $0x1b8, %rsp            # imm = 0x1B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq %r14, %rdi
callq 0x5738
leaq 0x18(%rsp), %rdi
callq 0x5738
jmp 0x7ed4
movq %rax, %rbx
jmp 0x7eeb
movq %rax, %rbx
leaq 0x140(%rsp), %rdi
callq 0x5a2c
jmp 0x7ef8
movq %rax, %rbx
leaq 0x88(%rsp), %rdi
callq 0x59e6
movq %rbx, %rdi
callq 0x4410