// File: 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
movq %rsp, %rbp
subq $0x1a0, %rsp            # imm = 0x1A0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movq %r8, -0x28(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x128(%rbp)
addq $0x120, %rdi            # imm = 0x120
callq 0x1a210
cmpq $0x0, %rax
jne 0x19beb
movq -0x128(%rbp), %rdi
movl $0xffffffff, -0x2c(%rbp) # imm = 0xFFFFFFFF
addq $0xa0, %rdi
callq 0x1a230
cmpq $0x0, %rax
jne 0x19b64
movq -0x128(%rbp), %rdi
addq $0xf0, %rdi
callq 0x1a210
cmpq $0x0, %rax
jne 0x19b3d
jmp 0x19f2d
movq -0x128(%rbp), %rdi
addq $0xf0, %rdi
callq 0x1add0
movq %rax, -0x38(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x1a2d0
movl (%rax), %eax
movl %eax, -0x2c(%rbp)
jmp 0x19b89
movq -0x128(%rbp), %rsi
addq $0xa0, %rsi
leaq -0x58(%rbp), %rdi
callq 0x1ae00
leaq -0x58(%rbp), %rdi
callq 0x1ae30
movl (%rax), %eax
movl %eax, -0x2c(%rbp)
cmpl $0x0, -0x2c(%rbp)
jl 0x19be6
movq -0x128(%rbp), %rdi
addq $0x40, %rdi
leaq -0x2c(%rbp), %rsi
callq 0x1a370
movq 0x18(%rax), %rax
andq -0x18(%rbp), %rax
cmpq -0x18(%rbp), %rax
jne 0x19be6
movq -0x128(%rbp), %rdi
movq -0x10(%rbp), %rax
movq %rax, -0x130(%rbp)
addq $0x40, %rdi
leaq -0x2c(%rbp), %rsi
callq 0x1a370
movq -0x130(%rbp), %rdi
movq %rax, %rsi
callq 0x1ae50
movq %rax, -0x68(%rbp)
movb %dl, -0x60(%rbp)
jmp 0x19f2d
leaq -0x80(%rbp), %rdi
callq 0x1aea0
movq -0x128(%rbp), %rdi
addq $0x120, %rdi            # imm = 0x120
callq 0x1add0
movq %rax, -0x88(%rbp)
movq -0x128(%rbp), %rdi
addq $0x120, %rdi            # imm = 0x120
callq 0x1a260
movq %rax, -0x90(%rbp)
leaq -0x88(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x1aec0
testb $0x1, %al
jne 0x19c44
jmp 0x19cde
movq -0x128(%rbp), %rax
addq $0x40, %rax
movq %rax, -0x140(%rbp)
leaq -0x88(%rbp), %rdi
callq 0x1a2d0
movq -0x140(%rbp), %rdi
movq %rax, %rsi
callq 0x1a370
movq %rax, -0x138(%rbp)
jmp 0x19c7a
movq -0x138(%rbp), %rax
movq 0x18(%rax), %rax
andq -0x18(%rbp), %rax
cmpq -0x18(%rbp), %rax
jne 0x19cc2
leaq -0x88(%rbp), %rdi
callq 0x1a2d0
movq %rax, %rsi
leaq -0x80(%rbp), %rdi
callq 0x1aef0
jmp 0x19ca9
jmp 0x19cc2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x98(%rbp)
movl %eax, -0x9c(%rbp)
jmp 0x19f36
jmp 0x19cc4
leaq -0x88(%rbp), %rdi
xorl %esi, %esi
callq 0x1af60
movq %rax, -0xa8(%rbp)
jmp 0x19c0e
leaq -0x80(%rbp), %rdi
callq 0x1afa0
cmpq $0x0, %rax
jne 0x19cfc
movl $0x1, -0xac(%rbp)
jmp 0x19f24
movslq -0x1c(%rbp), %rax
movq %rax, -0x148(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x1afa0
movq %rax, %rcx
movq -0x148(%rbp), %rax
shrq %rcx
cmpq %rcx, %rax
jbe 0x19d31
leaq -0x80(%rbp), %rdi
callq 0x1afa0
shrq %rax
movl %eax, -0x1c(%rbp)
cmpl $0x1, -0x1c(%rbp)
jge 0x19d3e
movl $0x1, -0x1c(%rbp)
leaq -0xe0(%rbp), %rdi
callq 0x1afc0
leaq -0xe0(%rbp), %rdi
callq 0x1a210
movslq -0x1c(%rbp), %rcx
cmpq %rcx, %rax
jae 0x19dff
callq 0x4110
cltq
movq %rax, -0x160(%rbp)
leaq -0x80(%rbp), %rdi
movq %rdi, -0x168(%rbp)
callq 0x1afa0
movq -0x168(%rbp), %rdi
movq %rax, %rcx
movq -0x160(%rbp), %rax
xorl %edx, %edx
divq %rcx
movq %rdx, %rsi
callq 0x1afe0
movq %rax, %rsi
leaq -0xe0(%rbp), %rdi
callq 0x1a950
movb %dl, -0x151(%rbp)
movq %rax, -0x150(%rbp)
jmp 0x19dbd
movb -0x151(%rbp), %al
movq -0x150(%rbp), %rcx
movq %rcx, -0xf0(%rbp)
movb %al, -0xe8(%rbp)
jmp 0x19d4a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x98(%rbp)
movl %eax, -0x9c(%rbp)
leaq -0xe0(%rbp), %rdi
callq 0x1b000
jmp 0x19f36
leaq -0xe0(%rbp), %rdi
callq 0x1add0
movq %rax, -0xf8(%rbp)
leaq -0xe0(%rbp), %rdi
callq 0x1a260
movq %rax, -0x100(%rbp)
leaq -0xf8(%rbp), %rdi
leaq -0x100(%rbp), %rsi
callq 0x1aec0
testb $0x1, %al
jne 0x19e41
jmp 0x19f0e
movq -0x128(%rbp), %rax
addq $0x40, %rax
movq %rax, -0x178(%rbp)
leaq -0xf8(%rbp), %rdi
callq 0x1a2d0
movq -0x178(%rbp), %rdi
movq %rax, %rsi
callq 0x1a370
movq %rax, -0x170(%rbp)
jmp 0x19e77
movq -0x170(%rbp), %rax
movq %rax, -0x108(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x188(%rbp)
movq -0x108(%rbp), %rdi
callq 0x105c0
movl %eax, -0x17c(%rbp)
jmp 0x19ea4
movq -0x188(%rbp), %rax
movl -0x17c(%rbp), %ecx
movl %ecx, %ecx
testb $0x1, (%rax,%rcx)
je 0x19ef2
movq -0x10(%rbp), %rdi
movq -0x108(%rbp), %rsi
callq 0x1ae50
movb %dl, -0x191(%rbp)
movq %rax, -0x190(%rbp)
jmp 0x19ed8
movb -0x191(%rbp), %al
movq -0x190(%rbp), %rcx
movq %rcx, -0x118(%rbp)
movb %al, -0x110(%rbp)
jmp 0x19ef4
leaq -0xf8(%rbp), %rdi
xorl %esi, %esi
callq 0x1af60
movq %rax, -0x120(%rbp)
jmp 0x19e12
leaq -0xe0(%rbp), %rdi
callq 0x1b000
movl $0x0, -0xac(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x1b020
addq $0x1a0, %rsp            # imm = 0x1A0
popq %rbp
retq
leaq -0x80(%rbp), %rdi
callq 0x1b020
movq -0x98(%rbp), %rdi
callq 0x47f0
nopl (%rax,%rax)