// File: /workspace/github_cpp_makefile_star2_O2/tenup-coin[P]seeder/db.cpp
// Function: CAddrDb::GetIPs_(std::set<CNetAddr, std::less<CNetAddr>, std::allocator<CNetAddr>>&, unsigned long, int, bool const*)
void CAddrDb::GetIPs_(set<CNetAddr>& ips, uint64_t requestedFlags, int max, const bool* nets) {
  if (goodId.size() == 0) {
    int id = -1;
    if (ourId.size() == 0) {
      if (unkId.size() == 0) return;
      id = *unkId.begin();
    } else {
      id = *ourId.begin();
    }
    if (id >= 0 && (idToInfo[id].services & requestedFlags) == requestedFlags) {
      ips.insert(idToInfo[id].ip);
    }
    return;
  }
  std::vector<int> goodIdFiltered;
  for (std::set<int>::const_iterator it = goodId.begin(); it != goodId.end(); it++) {
    if ((idToInfo[*it].services & requestedFlags) == requestedFlags)
      goodIdFiltered.push_back(*it);
  }

  if (!goodIdFiltered.size())
    return;

  if (max > goodIdFiltered.size() / 2)
    max = goodIdFiltered.size() / 2;
  if (max < 1)
    max = 1;

  set<int> ids;
  while (ids.size() < max) {
    ids.insert(goodIdFiltered[rand() % goodIdFiltered.size()]);
  }
  for (set<int>::const_iterator it = ids.begin(); it != ids.end(); it++) {
    CService &ip = idToInfo[*it].ip;
    if (nets[ip.GetNetwork()])
      ips.insert(ip);
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rdx, %r12
movq %rsi, %rbx
movq %rdi, %r14
cmpq $0x0, 0x148(%rdi)
je 0xa59f
movl %ecx, 0xc(%rsp)
movq %r8, 0x30(%rsp)
movq %rbx, 0x28(%rsp)
xorps %xmm0, %xmm0
leaq 0x10(%rsp), %r13
andq $0x0, 0x10(%r13)
movaps %xmm0, (%r13)
movq 0x138(%r14), %rbp
leaq 0x128(%r14), %r15
addq $0x40, %r14
cmpq %r15, %rbp
je 0xa4b1
leaq 0x20(%rbp), %rbx
movq %r14, %rdi
movq %rbx, %rsi
callq 0xa7b4
movq 0x18(%rax), %rax
notq %rax
testq %rax, %r12
jne 0xa4a4
movq %r13, %rdi
movq %rbx, %rsi
callq 0xabee
movq %rbp, %rdi
callq 0x3460
movq %rax, %rbp
jmp 0xa479
movq 0x18(%rsp), %rax
subq 0x10(%rsp), %rax
je 0xa586
sarq $0x2, %rax
movslq 0xc(%rsp), %rcx
shrq %rax
cmpq %rcx, %rax
cmovbl %eax, %ecx
cmpl $0x2, %ecx
pushq $0x1
popq %r15
cmovgel %ecx, %r15d
leaq 0x40(%rsp), %rbx
andl $0x0, (%rbx)
andq $0x0, 0x8(%rbx)
movq %rbx, 0x10(%rbx)
movq %rbx, 0x18(%rbx)
andq $0x0, 0x20(%rbx)
leaq 0x38(%rsp), %r12
movq 0x30(%rsp), %rbp
cmpq %r15, 0x60(%rsp)
jae 0xa534
callq 0x30d0
cltq
movq 0x10(%rsp), %rcx
movq 0x18(%rsp), %rsi
subq %rcx, %rsi
sarq $0x2, %rsi
xorl %edx, %edx
divq %rsi
leaq (%rcx,%rdx,4), %rsi
movq %r12, %rdi
callq 0xb4e8
jmp 0xa502
movq 0x50(%rsp), %r12
movq 0x28(%rsp), %r15
cmpq %rbx, %r12
je 0xa57c
leaq 0x20(%r12), %rsi
movq %r14, %rdi
callq 0xa7b4
movq %rax, %r13
movq %rax, %rdi
callq 0x7416
movl %eax, %eax
cmpb $0x1, (%rbp,%rax)
jne 0xa56f
movq %r15, %rdi
movq %r13, %rsi
callq 0xc222
movq %r12, %rdi
callq 0x3460
movq %rax, %r12
jmp 0xa53e
leaq 0x38(%rsp), %rdi
callq 0xac0c
leaq 0x10(%rsp), %rdi
callq 0xc3ae
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xa0(%r14), %rdi
callq 0xa7a4
testq %rax, %rax
je 0xa5b9
movq 0xb0(%r14), %rax
jmp 0xa5ce
cmpq $0x0, 0x118(%r14)
je 0xa590
movq 0x108(%r14), %rax
addq $0x20, %rax
movl (%rax), %eax
movl %eax, 0x38(%rsp)
testl %eax, %eax
js 0xa590
addq $0x40, %r14
leaq 0x38(%rsp), %rsi
movq %r14, %rdi
callq 0xa7b4
movq 0x18(%rax), %rax
notq %rax
testq %rax, %r12
jne 0xa590
leaq 0x38(%rsp), %rsi
movq %r14, %rdi
callq 0xa7b4
movq %rbx, %rdi
movq %rax, %rsi
callq 0xc222
jmp 0xa590
jmp 0xa616
movq %rax, %rbx
jmp 0xa623
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0xac0c
leaq 0x10(%rsp), %rdi
callq 0xc3ae
movq %rbx, %rdi
callq 0x3690
nop