// File: /workspace/github_cpp_makefile_star2_O3/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 %ecx, %ecx
movq %rcx, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
movq %rcx, 0x20(%rax)
cmpl $0x2, %edi
jl 0x37ac
movq %rsi, %rbx
movl %edi, %ebp
negq %rbp
movl $0x1, %r13d
movl $0x0, 0x20(%rsp)
leaq 0xa0(%rsp), %r14
leaq 0x178(%rsp), %r15
leaq 0x70(%rsp), %r12
incq %r13
movq -0x8(%rbx,%r13,8), %rsi
cmpb $0x2d, (%rsi)
je 0x377f
movq %r14, %rdi
movq %r15, %rdx
callq 0x3b30
movq %r12, %rdi
movq %r14, %rsi
callq 0x459e
movq 0xa0(%rsp), %rdi
leaq 0xb0(%rsp), %rax
cmpq %rax, %rdi
je 0x3769
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x3270
leaq 0x1(,%r13), %rax
addq %rbp, %rax
incq %r13
cmpq $0x1, %rax
jne 0x3724
jmp 0x378f
movb $0x1, %al
movl %eax, 0x20(%rsp)
movq %rbp, %rax
addq %r13, %rax
jne 0x3721
jmp 0x3796
testb $0x1, 0x20(%rsp)
je 0x37ac
leaq 0x10967(%rip), %rdi     # 0x14104
callq 0x3380
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
jmp 0x3a5e
leaq 0x178(%rsp), %rdi
leaq 0x70(%rsp), %rsi
callq 0x11f64
leaq 0x109c3(%rip), %rcx     # 0x14188
leaq 0xa0(%rsp), %rbx
leaq 0x178(%rsp), %r14
movq %rbx, %rdi
movq %r14, %rsi
movl $0x3f, %edx
callq 0x3b6e
movq %rsp, %rdi
movq %r14, (%rdi)
movq %rbx, 0x8(%rdi)
movl $0x3e8, %esi            # imm = 0x3E8
callq 0x3c7a
leaq 0x130(%rsp), %rbx
cmpq %rbx, (%rbx)
je 0x3a33
leaq 0x108a6(%rip), %rdi     # 0x140b7
callq 0x3380
movq 0x130(%rsp), %r12
cmpq %rbx, %r12
je 0x3a2f
leaq 0x38(%rsp), %rbx
leaq 0x28(%rsp), %r15
movq %rbx, 0x28(%rsp)
movq %r15, %rdi
leaq 0x10809(%rip), %rsi     # 0x14049
leaq 0x10803(%rip), %rdx     # 0x1404a
callq 0x4508
leaq 0x10(%r12), %rbp
movq %rsp, %rdi
movq %rbp, %rsi
movq %r15, %rdx
callq 0x11c54
movq (%rsp), %r13
leaq 0x48(%rsp), %rdi
movq %rbp, %rsi
callq 0x358c
movq 0x48(%rsp), %rdx
leaq 0x107ac(%rip), %rdi     # 0x14028
movq %r13, %rsi
xorl %eax, %eax
callq 0x3040
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x38a2
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x3270
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x38bd
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3270
movq 0x28(%rsp), %rdi
cmpq %rbx, %rdi
je 0x38d4
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x3270
leaq 0xb0(%r12), %r14
movq %r12, 0x68(%rsp)
movq 0xb0(%r12), %r12
cmpq %r14, %r12
je 0x3a15
leaq 0x10(%r12), %rbp
cmpl $0x2, 0x18(%r12)
jne 0x3958
movq %rbx, 0x28(%rsp)
movq %r15, %rdi
leaq 0x1073b(%rip), %rsi     # 0x14049
leaq 0x10735(%rip), %rdx     # 0x1404a
callq 0x4508
movq %rsp, %rdi
movq %rbp, %rsi
movq %r15, %rdx
callq 0x11c54
movq (%rsp), %rsi
movsd 0xa0(%r12), %xmm0
movsd 0xa8(%r12), %xmm1
movq 0x20(%r12), %rdx
leaq 0x106ff(%rip), %rdi     # 0x1404b
movb $0x2, %al
callq 0x3040
jmp 0x39da
movq %rbx, 0x28(%rsp)
movq %r15, %rdi
leaq 0x106e2(%rip), %rsi     # 0x14049
leaq 0x106dc(%rip), %rdx     # 0x1404a
callq 0x4508
movq %rsp, %rdi
movq %rbp, %rsi
movq %r15, %rdx
callq 0x11c54
movq (%rsp), %r13
movsd 0xa0(%r12), %xmm0
movsd %xmm0, 0x20(%rsp)
leaq 0x48(%rsp), %rdi
movq %rbp, %rsi
callq 0x358c
movq 0x48(%rsp), %rdx
leaq 0x106be(%rip), %rdi     # 0x1406c
movq %r13, %rsi
movsd 0x20(%rsp), %xmm0
movb $0x1, %al
callq 0x3040
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x39da
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x3270
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x39f5
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3270
movq 0x28(%rsp), %rdi
cmpq %rbx, %rdi
je 0x3a0c
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x3270
movq (%r12), %r12
jmp 0x38e9
movq 0x68(%rsp), %r12
movq (%r12), %r12
leaq 0x130(%rsp), %rax
cmpq %rax, %r12
jne 0x3831
xorl %ebx, %ebx
jmp 0x3a44
leaq 0x106b9(%rip), %rdi     # 0x140f3
callq 0x3380
movl $0x1, %ebx
leaq 0xa0(%rsp), %rdi
callq 0x9d48
leaq 0x178(%rsp), %rdi
callq 0x12040
leaq 0x70(%rsp), %rdi
callq 0x43fa
movl %ebx, %eax
addq $0x228, %rsp            # imm = 0x228
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x3ae4
movq %rax, %r14
jmp 0x3b10
jmp 0x3a8e
jmp 0x3ae4
jmp 0x3ae9
jmp 0x3ac2
movq %rax, %r14
jmp 0x3b1d
movq %rax, %r14
movq 0xa0(%rsp), %rdi
leaq 0xb0(%rsp), %rax
cmpq %rax, %rdi
je 0x3b1d
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x3270
jmp 0x3b1d
jmp 0x3ae4
movq %rax, %r14
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x3aec
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3270
jmp 0x3aec
jmp 0x3ae9
movq %rax, %r14
jmp 0x3b03
movq %rax, %r14
movq 0x28(%rsp), %rdi
cmpq %rbx, %rdi
je 0x3b03
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x3270
leaq 0xa0(%rsp), %rdi
callq 0x9d48
leaq 0x178(%rsp), %rdi
callq 0x12040
leaq 0x70(%rsp), %rdi
callq 0x43fa
movq %r14, %rdi
callq 0x33e0
nop