// File: /workspace/github_cpp_makefile_star2_O2/tenup-coin[P]seeder/main.cpp
// Function: GetIPList
int GetIPList(void *data, char *requestedHostname, addr_t* addr, int max, int ipv4, int ipv6) {
  CDnsThread *thread = (CDnsThread*)data;

  uint64_t requestedFlags = 0;
  int hostlen = strlen(requestedHostname);
  if (hostlen > 1 && requestedHostname[0] == 'x' && requestedHostname[1] != '0') {
    char *pEnd;
    uint64_t flags = (uint64_t)strtoull(requestedHostname+1, &pEnd, 16);
    if (*pEnd == '.' && pEnd <= requestedHostname+17 && std::find(thread->filterWhitelist.begin(), thread->filterWhitelist.end(), flags) != thread->filterWhitelist.end())
      requestedFlags = flags;
    else
      return 0;
  }
  else if (strcasecmp(requestedHostname, thread->dns_opt.host))
    return 0;
  thread->cacheHit(requestedFlags);
  auto& thisflag = thread->perflag[requestedFlags];
  unsigned int size = thisflag.cache.size();
  unsigned int maxmax = (ipv4 ? thisflag.nIPv4 : 0) + (ipv6 ? thisflag.nIPv6 : 0);
  if (max > size)
    max = size;
  if (max > maxmax)
    max = maxmax;
  int i=0;
  while (i<max) {
    int j = i + (rand() % (size - i));
    do {
        bool ok = (ipv4 && thisflag.cache[j].v == 4) ||
                  (ipv6 && thisflag.cache[j].v == 6);
        if (ok) break;
        j++;
        if (j==size)
            j=i;
    } while(1);
    addr[i] = thisflag.cache[j];
    thisflag.cache[j] = thisflag.cache[i];
    thisflag.cache[i] = addr[i];
    i++;
  }
  return max;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %r9d, %ebx
movl %r8d, %ebp
movl %ecx, %r13d
movq %rdx, %r14
movq %rsi, %r12
movq %rdi, %r15
andq $0x0, 0x10(%rsp)
movq %rsi, %rdi
callq 0x31b0
cmpl $0x2, %eax
jl 0xc6dd
cmpb $0x78, (%r12)
jne 0xc6dd
cmpb $0x30, 0x1(%r12)
jne 0xc822
movq 0x10(%r15), %rsi
movq %r12, %rdi
callq 0x3450
xorl %ecx, %ecx
testl %eax, %eax
jne 0xc811
xorl %esi, %esi
movl %r13d, (%rsp)
xorl %r12d, %r12d
movq %r15, %rdi
xorl %edx, %edx
callq 0xd828
addq $0x40, %r15
leaq 0x10(%rsp), %rsi
movq %r15, %rdi
callq 0xd9f4
movq %rax, %r15
movq 0x10(%rax), %rax
subq 0x8(%r15), %rax
pushq $0x14
popq %rcx
cqto
idivq %rcx
movq %rax, %r13
movl %ebp, %eax
testl %ebp, %ebp
je 0xc736
movl (%r15), %eax
movl %ebx, %ecx
testl %ebx, %ebx
je 0xc740
movl 0x4(%r15), %ecx
addl %eax, %ecx
movl (%rsp), %eax
cmpl %eax, %r13d
cmovbl %r13d, %eax
cmpl %ecx, %eax
cmovael %ecx, %eax
testl %eax, %eax
movl $0x0, %ecx
movq %rax, 0x18(%rsp)
cmovgl %eax, %ecx
movq %rcx, (%rsp)
cmpq (%rsp), %r12
je 0xc80c
callq 0x30d0
movl %r13d, %ecx
subl %r12d, %ecx
xorl %edx, %edx
divl %ecx
addl %r12d, %edx
movq 0x8(%r15), %rax
testl %ebp, %ebp
je 0xc7a2
movslq %edx, %rcx
imulq $0x14, %rcx, %rsi
movl (%rax,%rsi), %esi
testl %ebx, %ebx
je 0xc79b
cmpl $0x4, %esi
jne 0xc7b0
cmpl $0x4, %esi
jne 0xc7b5
jmp 0xc7c0
testl %ebx, %ebx
je 0xc7b5
movslq %edx, %rcx
imulq $0x14, %rcx, %rsi
movl (%rax,%rsi), %esi
cmpl $0x6, %esi
je 0xc7c0
incl %edx
cmpl %r13d, %edx
cmovel %r12d, %edx
jmp 0xc784
imulq $0x14, %rcx, %rcx
imulq $0x14, %r12, %rdx
movl 0x10(%rax,%rcx), %esi
movl %esi, 0x10(%r14,%rdx)
movups (%rax,%rcx), %xmm0
movups %xmm0, (%r14,%rdx)
movq 0x8(%r15), %rax
movl 0x10(%rax,%rdx), %esi
movl %esi, 0x10(%rax,%rcx)
movups (%rax,%rdx), %xmm0
movups %xmm0, (%rax,%rcx)
movq 0x8(%r15), %rax
movl 0x10(%r14,%rdx), %ecx
movl %ecx, 0x10(%rax,%rdx)
movups (%r14,%rdx), %xmm0
movups %xmm0, (%rax,%rdx)
incq %r12
jmp 0xc764
movq 0x18(%rsp), %rcx
movl %ecx, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %r13d, (%rsp)
leaq 0x1(%r12), %rdi
leaq 0x20(%rsp), %r13
pushq $0x10
popq %rdx
movq %r13, %rsi
callq 0x3520
movq %rax, 0x8(%rsp)
movq (%r13), %rax
cmpb $0x2e, (%rax)
setne %cl
addq $0x11, %r12
cmpq %r12, %rax
seta %al
orb %cl, %al
jne 0xc88a
movq 0x90(%r15), %rdi
leaq 0x80(%r15), %r12
leaq 0x8(%rsp), %rdx
movq %r12, %rsi
callq 0xf703
cmpq %r12, %rax
je 0xc88a
movq 0x8(%rsp), %rax
movq %rax, %rsi
movq %rax, 0x10(%rsp)
jmp 0xc6f9
xorl %ecx, %ecx
jmp 0xc811