// File: /workspace/github_cpp_makefile_star2_O3/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 $0x58, %rsp
movq %rdx, %r12
movq %rsi, %rbx
movq %rdi, %r14
cmpq $0x0, 0x148(%rdi)
je 0xb77c
movq %rbx, 0x20(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
movq $0x0, 0x10(%rsp)
movq 0x138(%r14), %r13
leaq 0x128(%r14), %rbp
cmpq %rbp, %r13
je 0xb888
movq %r8, %r15
movl %ecx, 0x1c(%rsp)
addq $0x40, %r14
leaq 0x20(%r13), %rbx
movq %r14, %rdi
movq %rbx, %rsi
callq 0xba30
movq 0x18(%rax), %rax
notq %rax
testq %rax, %r12
jne 0xb6df
movq 0x8(%rsp), %rsi
cmpq 0x10(%rsp), %rsi
je 0xb6d4
movl (%rbx), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rsp)
jmp 0xb6df
movq %rsp, %rdi
movq %rbx, %rdx
callq 0xd1b6
movq %r13, %rdi
callq 0x3450
movq %rax, %r13
cmpq %rbp, %rax
jne 0xb69e
movq (%rsp), %rdi
movq 0x8(%rsp), %rax
subq %rdi, %rax
je 0xb87e
sarq $0x2, %rax
movslq 0x1c(%rsp), %rcx
shrq %rax
cmpq %rcx, %rax
cmovbl %eax, %ecx
cmpl $0x2, %ecx
movl $0x1, %ebx
cmovgel %ecx, %ebx
leaq 0x30(%rsp), %r13
movl $0x0, (%r13)
xorl %eax, %eax
movq %rax, 0x8(%r13)
movq %r13, 0x10(%r13)
movq %r13, 0x18(%r13)
movq %rax, 0x20(%r13)
leaq 0x28(%rsp), %r12
movq 0x20(%rsp), %rbp
cmpq %rbx, 0x50(%rsp)
jae 0xb82a
callq 0x30c0
cltq
movq (%rsp), %rcx
movq 0x8(%rsp), %rsi
subq %rcx, %rsi
sarq $0x2, %rsi
xorl %edx, %edx
divq %rsi
leaq (%rcx,%rdx,4), %rsi
movq %r12, %rdi
callq 0xc602
jmp 0xb747
movq 0xe8(%r14), %rax
movq %rax, %rcx
subq 0xc8(%r14), %rcx
shrq $0x3, %rcx
cmpq $0x1, %rax
adcq $-0x1, %rcx
movq 0xd0(%r14), %rdx
subq 0xd8(%r14), %rdx
shlq $0x7, %rcx
sarq $0x2, %rdx
addq %rcx, %rdx
movq 0xb0(%r14), %rax
movq 0xc0(%r14), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
addq %rdx, %rcx
jne 0xb7e5
cmpq $0x0, 0x118(%r14)
je 0xb888
movq 0x108(%r14), %rax
addq $0x20, %rax
movl (%rax), %eax
movl %eax, 0x28(%rsp)
testl %eax, %eax
js 0xb888
addq $0x40, %r14
leaq 0x28(%rsp), %rsi
movq %r14, %rdi
callq 0xba30
movq 0x18(%rax), %rax
notq %rax
testq %rax, %r12
jne 0xb888
leaq 0x28(%rsp), %rsi
movq %r14, %rdi
callq 0xba30
movq %rbx, %rdi
movq %rax, %rsi
callq 0xd082
jmp 0xb888
movq 0x40(%rsp), %r12
cmpq %r13, %r12
je 0xb870
leaq 0x20(%r12), %rsi
movq %r14, %rdi
callq 0xba30
movq %rax, %rbx
movq %rax, %rdi
callq 0x7e22
movl %eax, %eax
cmpb $0x1, (%r15,%rax)
jne 0xb860
movq %rbp, %rdi
movq %rbx, %rsi
callq 0xd082
movq %r12, %rdi
callq 0x3450
movq %rax, %r12
cmpq %r13, %rax
jne 0xb834
leaq 0x28(%rsp), %rdi
callq 0xbe24
movq (%rsp), %rdi
testq %rdi, %rdi
je 0xb888
callq 0x33d0
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xb899
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0xbe24
jmp 0xb8ab
movq %rax, %rbx
movq (%rsp), %rdi
testq %rdi, %rdi
je 0xb8b9
callq 0x33d0
movq %rbx, %rdi
callq 0x3650
nop