// File: /workspace/github_cpp_makefile_star2_O1/dguglielmi[P]dlan-linux-software/tools/dlanlist.cpp
// Function: main
int main(int argc, char** argv)
{
  int result = 0;
  std::set<std::string> setIfcNames;

  for(int i = 1; i < argc; ++i)
  {
    if(argv[i][0] == '-')
      result = -1;
    else
      setIfcNames.insert(argv[i]);
  }
  
  if(result == -1)
  {
    printf("Usage: dlanlist [IFACES...]\n"
           "\n"
           "List dlan devices found on the given network interfaces,\n"
           "or on all interfaces, if none where given.\n"
           "\n");

    return result;
  }

  CPacketInterfaceLinux pktIfc(setIfcNames);
  CDlanMonitor m(pktIfc);
  CPacketTaskRunner(pktIfc, m).Run(1000, MSCounter());

  if(m.GetLocalDevices().empty())
  {
    printf("no devices found\n");
    return 1;
  }

  printf("Type    MAC address        Mbps TX/RX       Version/Product\n");
  for(CDlanLocalDeviceList::const_iterator itLocal = m.GetLocalDevices().begin();
    (itLocal != m.GetLocalDevices().end()); ++itLocal)
  {
    printf("local   %s  ---.-- / ---.--  %s\n",
      itLocal->GetAddress().ToString().c_str(),
      VersionProductString(*itLocal).c_str());
 
    for(CDlanRemoteDeviceList::const_iterator itRemote = itLocal->GetRemoteDevices().begin();
      (itRemote != itLocal->GetRemoteDevices().end()); ++itRemote)
    {
      if(itRemote->GetType() == CDlanDevice::eThunderbolt)
      {
        printf("remote  %s  %6.02f / %6.02f  %s\n",
          itRemote->GetAddress().ToString().c_str(),
          itRemote->GetTxRate(),
          itRemote->GetRxRate(),
          itRemote->GetVersion().c_str());
      }
      else
      {
        printf("remote  %s  %6.02f / ---.--  %s\n",
          itRemote->GetAddress().ToString().c_str(),
          itRemote->GetTxRate(),
          VersionProductString(*itRemote).c_str());
      }
    }
  }
  
  return result;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x228, %rsp            # imm = 0x228
leaq 0x78(%rsp), %rax
movl $0x0, (%rax)
xorl %ebp, %ebp
movq %rbp, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
movq %rbp, 0x20(%rax)
cmpl $0x2, %edi
jl 0x476e
movq %rsi, %rbx
movl %edi, %r13d
movl $0x1, %r15d
leaq 0xa0(%rsp), %r14
leaq 0x70(%rsp), %r12
movq (%rbx,%r15,8), %rsi
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpb $0x2d, (%rsi)
je 0x475b
movq %r14, %rdi
leaq 0x178(%rsp), %rdx
callq 0x4b04
movq %r12, %rdi
movq %r14, %rsi
callq 0x5da0
movq 0xa0(%rsp), %rdi
leaq 0xb0(%rsp), %rax
cmpq %rax, %rdi
je 0x4759
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x4270
movl %ebp, %eax
incq %r15
movl %eax, %ebp
cmpq %r15, %r13
jne 0x470b
cmpl $-0x1, %eax
je 0x4a3e
leaq 0x178(%rsp), %rdi
leaq 0x70(%rsp), %rsi
callq 0x13450
leaq 0x11a01(%rip), %rcx     # 0x16188
leaq 0xa0(%rsp), %rbx
leaq 0x178(%rsp), %r14
movq %rbx, %rdi
movq %r14, %rsi
movl $0x3f, %edx
callq 0x4b42
movq %rsp, %rdi
movq %r14, (%rdi)
movq %rbx, 0x8(%rdi)
movl $0x3e8, %esi            # imm = 0x3E8
callq 0x4c4e
leaq 0x130(%rsp), %rbx
cmpq %rbx, (%rbx)
je 0x49f5
leaq 0x118e4(%rip), %rdi     # 0x160b7
callq 0x4380
movq 0x130(%rsp), %r12
cmpq %rbx, %r12
je 0x49f1
leaq 0x30(%rsp), %rbx
leaq 0x20(%rsp), %r15
movq %rbx, 0x20(%rsp)
movq %r15, %rdi
leaq 0x11847(%rip), %rsi     # 0x16049
leaq 0x11841(%rip), %rdx     # 0x1604a
callq 0x5d10
leaq 0x10(%r12), %rbp
movq %rsp, %rdi
movq %rbp, %rsi
movq %r15, %rdx
callq 0x13134
movq (%rsp), %r13
leaq 0x40(%rsp), %rdi
movq %rbp, %rsi
callq 0x458c
movq 0x40(%rsp), %rdx
leaq 0x117ea(%rip), %rdi     # 0x16028
movq %r13, %rsi
xorl %eax, %eax
callq 0x4040
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x4864
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x4270
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x487f
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x4270
movq 0x20(%rsp), %rdi
cmpq %rbx, %rdi
je 0x4896
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x4270
leaq 0xb0(%r12), %r14
movq %r12, 0x60(%rsp)
movq 0xb0(%r12), %r12
cmpq %r14, %r12
je 0x49d7
leaq 0x10(%r12), %rbp
cmpl $0x2, 0x18(%r12)
jne 0x491a
movq %rbx, 0x20(%rsp)
movq %r15, %rdi
leaq 0x11779(%rip), %rsi     # 0x16049
leaq 0x11773(%rip), %rdx     # 0x1604a
callq 0x5d10
movq %rsp, %rdi
movq %rbp, %rsi
movq %r15, %rdx
callq 0x13134
movq (%rsp), %rsi
movsd 0xa0(%r12), %xmm0
movsd 0xa8(%r12), %xmm1
movq 0x20(%r12), %rdx
leaq 0x1173d(%rip), %rdi     # 0x1604b
movb $0x2, %al
callq 0x4040
jmp 0x499c
movq %rbx, 0x20(%rsp)
movq %r15, %rdi
leaq 0x11720(%rip), %rsi     # 0x16049
leaq 0x1171a(%rip), %rdx     # 0x1604a
callq 0x5d10
movq %rsp, %rdi
movq %rbp, %rsi
movq %r15, %rdx
callq 0x13134
movq (%rsp), %r13
movsd 0xa0(%r12), %xmm0
movsd %xmm0, 0x68(%rsp)
leaq 0x40(%rsp), %rdi
movq %rbp, %rsi
callq 0x458c
movq 0x40(%rsp), %rdx
leaq 0x116fc(%rip), %rdi     # 0x1606c
movq %r13, %rsi
movsd 0x68(%rsp), %xmm0
movb $0x1, %al
callq 0x4040
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x499c
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x4270
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x49b7
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x4270
movq 0x20(%rsp), %rdi
cmpq %rbx, %rdi
je 0x49ce
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x4270
movq (%r12), %r12
jmp 0x48ab
movq 0x60(%rsp), %r12
movq (%r12), %r12
leaq 0x130(%rsp), %rax
cmpq %rax, %r12
jne 0x47f3
xorl %ebx, %ebx
jmp 0x4a06
leaq 0x116f7(%rip), %rdi     # 0x160f3
callq 0x4380
movl $0x1, %ebx
leaq 0xa0(%rsp), %rdi
callq 0xb76a
leaq 0x178(%rsp), %rdi
callq 0x1352c
leaq 0x70(%rsp), %rdi
callq 0x5c08
movl %ebx, %eax
addq $0x228, %rsp            # imm = 0x228
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x116bf(%rip), %rdi     # 0x16104
callq 0x4380
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
jmp 0x4a20
jmp 0x4ab9
movq %rax, %r14
jmp 0x4ae5
jmp 0x4a5d
movq %rax, %r14
jmp 0x4af2
movq %rax, %r14
movq 0xa0(%rsp), %rdi
leaq 0xb0(%rsp), %rax
cmpq %rax, %rdi
je 0x4af2
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x4270
jmp 0x4af2
jmp 0x4ab9
jmp 0x4abe
jmp 0x4a97
jmp 0x4ab9
movq %rax, %r14
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x4ac1
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x4270
jmp 0x4ac1
jmp 0x4abe
movq %rax, %r14
jmp 0x4ad8
movq %rax, %r14
movq 0x20(%rsp), %rdi
cmpq %rbx, %rdi
je 0x4ad8
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x4270
leaq 0xa0(%rsp), %rdi
callq 0xb76a
leaq 0x178(%rsp), %rdi
callq 0x1352c
leaq 0x70(%rsp), %rdi
callq 0x5c08
movq %r14, %rdi
callq 0x43e0