// File: /workspace/github_cpp_makefile_star2_O3/CoinBlack[P]blackcoin-seeder/main.cpp
// Function: main
int main(int argc, char **argv) {
  signal(SIGPIPE, SIG_IGN);
  setbuf(stdout, NULL);
  CDnsSeedOpts opts;
  opts.ParseCommandLine(argc, argv);
  printf("Supporting whitelisted filters: ");
  for (std::set<uint64_t>::const_iterator it = opts.filter_whitelist.begin(); it != opts.filter_whitelist.end(); it++) {
      if (it != opts.filter_whitelist.begin()) {
          printf(",");
      }
      printf("0x%lx", (unsigned long)*it);
  }
  printf("\n");
  if (opts.tor) {
    CService service(opts.tor, 9050);
    if (service.IsValid()) {
      printf("Using Tor proxy at %s\n", service.ToStringIPPort().c_str());
      SetProxy(NET_TOR, service);
    }
  }
  if (opts.ipv4_proxy) {
    CService service(opts.ipv4_proxy, 9050);
    if (service.IsValid()) {
      printf("Using IPv4 proxy at %s\n", service.ToStringIPPort().c_str());
      SetProxy(NET_IPV4, service);
    }
  }
  if (opts.ipv6_proxy) {
    CService service(opts.ipv6_proxy, 9050);
    if (service.IsValid()) {
      printf("Using IPv6 proxy at %s\n", service.ToStringIPPort().c_str());
      SetProxy(NET_IPV6, service);
    }
  }
  bool fDNS = true;
  if (opts.fUseTestNet) {
      printf("Using testnet.\n");
      pchMessageStart[0] = 0xcd;
      pchMessageStart[1] = 0xf2;
      pchMessageStart[2] = 0xc0;
      pchMessageStart[3] = 0xef;
      seeds = testnet_seeds;
      fTestNet = true;
  }
  if (opts.nP2Port) {
    printf("Using P2P port %i\n", opts.nP2Port);
    nDefaultP2Port = opts.nP2Port;
  }
  if (opts.magic) {
    printf("Using magic %s\n", opts.magic);
    for (int n=0; n<4; ++n) {
      unsigned int c = 0;
      sscanf(&opts.magic[n*2], "%2x", &c);
      pchMessageStart[n] = (unsigned char) (c & 0xff);
    }
  }
  if (opts.nMinimumHeight) {
    printf("Using minimum height %i\n", opts.nMinimumHeight);
    nMinimumHeight = opts.nMinimumHeight;
  }
  if (!opts.vSeeds.empty()) {
    printf("Overriding DNS seeds\n");
    swap(opts.vSeeds, vSeeds);
  } else {
    for (int i=0; seeds[i][0]; i++) {
      vSeeds.emplace_back(seeds[i]);
    }
  }
  if (!opts.ns) {
    printf("No nameserver set. Not starting DNS server.\n");
    fDNS = false;
  }
  if (fDNS && !opts.host) {
    fprintf(stderr, "No hostname set. Please use -h.\n");
    exit(1);
  }
  if (fDNS && !opts.mbox) {
    fprintf(stderr, "No e-mail address set. Please use -m.\n");
    exit(1);
  }
  FILE *f = fopen("dnsseed.dat","r");
  if (f) {
    printf("Loading dnsseed.dat...");
    CAutoFile cf(f);
    cf >> db;
    if (opts.fWipeBan)
        db.banned.clear();
    if (opts.fWipeIgnore)
        db.ResetIgnores();
    printf("done\n");
  }
  pthread_t threadDns, threadSeed, threadDump, threadStats;
  if (fDNS) {
    printf("Starting %i DNS threads for %s on %s (port %i)...", opts.nDnsThreads, opts.host, opts.ns, opts.nPort);
    dnsThread.clear();
    for (int i=0; i<opts.nDnsThreads; i++) {
      dnsThread.push_back(new CDnsThread(&opts, i));
      pthread_create(&threadDns, NULL, ThreadDNS, dnsThread[i]);
      printf(".");
      Sleep(20);
    }
    printf("done\n");
  }
  printf("Starting seeder...");
  pthread_create(&threadSeed, NULL, ThreadSeeder, NULL);
  printf("done\n");
  printf("Starting %i crawler threads...", opts.nThreads);
  pthread_attr_t attr_crawler;
  pthread_attr_init(&attr_crawler);
  pthread_attr_setstacksize(&attr_crawler, 0x20000);
  for (int i=0; i<opts.nThreads; i++) {
    pthread_t thread;
    pthread_create(&thread, &attr_crawler, ThreadCrawler, &opts.nThreads);
  }
  pthread_attr_destroy(&attr_crawler);
  printf("done\n");
  pthread_create(&threadStats, NULL, ThreadStats, NULL);
  pthread_create(&threadDump, NULL, ThreadDumper, NULL);
  void* res;
  pthread_join(threadDump, &res);
  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x138, %rsp            # imm = 0x138
movq %rsi, %rbx
movl %edi, %ebp
movl $0x1, %esi
movl $0xd, %edi
callq 0x3470
movq 0xeac4(%rip), %rax      # 0x1cfa0
movq (%rax), %rdi
xorl %r14d, %r14d
xorl %esi, %esi
callq 0x3590
movsd 0x658f(%rip), %xmm0     # 0x14a80
leaq 0xf0(%rsp), %r15
movaps %xmm0, -0x80(%r15)
movl $0x4, -0x70(%r15)
xorps %xmm0, %xmm0
movups %xmm0, -0x6c(%r15)
movups %xmm0, -0x5c(%r15)
movups %xmm0, -0x50(%r15)
leaq 0x69bc(%rip), %rax      # 0x14edb
movq %rax, -0x40(%r15)
movl $0x0, (%r15)
movq %r14, 0x8(%r15)
movups %xmm0, -0x38(%r15)
movups %xmm0, -0x28(%r15)
movups %xmm0, -0x18(%r15)
movq %r15, 0x10(%r15)
movq %r15, 0x18(%r15)
movq %r14, 0x20(%r15)
leaq 0x70(%rsp), %rdi
movl %ebp, %esi
movq %rbx, %rdx
callq 0xf5c6
leaq 0x67fb(%rip), %rdi      # 0x14d5a
xorl %eax, %eax
callq 0x3050
movq 0x100(%rsp), %rbx
cmpq %r15, %rbx
je 0xe5ac
leaq 0x6801(%rip), %r14      # 0x14d7b
cmpq 0x100(%rsp), %rbx
je 0xe58e
movl $0x2c, %edi
callq 0x3550
movq 0x20(%rbx), %rsi
movq %r14, %rdi
xorl %eax, %eax
callq 0x3050
movq %rbx, %rdi
callq 0x3450
movq %rax, %rbx
cmpq %r15, %rax
jne 0xe57a
movl $0xa, %edi
callq 0x3550
movq 0xa8(%rsp), %rsi
testq %rsi, %rsi
je 0xe638
leaq 0x18(%rsp), %rdi
movl $0x235a, %edx           # imm = 0x235A
xorl %ecx, %ecx
callq 0xa246
leaq 0x18(%rsp), %rdi
callq 0x7e0c
testb %al, %al
je 0xe638
leaq 0x30(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0xa4dc
leaq 0x40(%rsp), %rbx
movq -0x10(%rbx), %rsi
leaq 0x6780(%rip), %rdi      # 0x14d81
xorl %eax, %eax
callq 0x3050
movq -0x10(%rbx), %rdi
cmpq %rbx, %rdi
je 0xe616
callq 0x33c0
movzwl 0x28(%rsp), %eax
movw %ax, 0x10(%rsp)
movups 0x18(%rsp), %xmm0
movups %xmm0, (%rsp)
movl $0x3, %edi
movl $0x5, %esi
callq 0x7d95
movq 0xb8(%rsp), %rsi
testq %rsi, %rsi
je 0xe6ba
leaq 0x18(%rsp), %rdi
movl $0x235a, %edx           # imm = 0x235A
xorl %ecx, %ecx
callq 0xa246
leaq 0x18(%rsp), %rdi
callq 0x7e0c
testb %al, %al
je 0xe6ba
leaq 0x30(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0xa4dc
leaq 0x40(%rsp), %rbx
movq -0x10(%rbx), %rsi
leaq 0x6715(%rip), %rdi      # 0x14d98
xorl %eax, %eax
callq 0x3050
movq -0x10(%rbx), %rdi
cmpq %rbx, %rdi
je 0xe698
callq 0x33c0
movzwl 0x28(%rsp), %eax
movw %ax, 0x10(%rsp)
movups 0x18(%rsp), %xmm0
movups %xmm0, (%rsp)
movl $0x1, %edi
movl $0x5, %esi
callq 0x7d95
movq 0xc0(%rsp), %rsi
testq %rsi, %rsi
je 0xe73c
leaq 0x18(%rsp), %rdi
movl $0x235a, %edx           # imm = 0x235A
xorl %ecx, %ecx
callq 0xa246
leaq 0x18(%rsp), %rdi
callq 0x7e0c
testb %al, %al
je 0xe73c
leaq 0x30(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0xa4dc
leaq 0x40(%rsp), %rbx
movq -0x10(%rbx), %rsi
leaq 0x66ab(%rip), %rdi      # 0x14db0
xorl %eax, %eax
callq 0x3050
movq -0x10(%rbx), %rdi
cmpq %rbx, %rdi
je 0xe71a
callq 0x33c0
movzwl 0x28(%rsp), %eax
movw %ax, 0x10(%rsp)
movups 0x18(%rsp), %xmm0
movups %xmm0, (%rsp)
movl $0x2, %edi
movl $0x5, %esi
callq 0x7d95
cmpl $0x0, 0x84(%rsp)
je 0xe774
leaq 0x6cf9(%rip), %rdi      # 0x15446
callq 0x35e0
leaq 0xec8b(%rip), %rax      # 0x1d3e4
movl $0xefc0f2cd, (%rax)     # imm = 0xEFC0F2CD
leaq 0xefda(%rip), %rax      # 0x1d740
movq %rax, 0xec7b(%rip)      # 0x1d3e8
movb $0x1, 0xed3c(%rip)      # 0x1d4b0
movl 0x78(%rsp), %esi
testl %esi, %esi
je 0xe799
leaq 0x6645(%rip), %rdi      # 0x14dc8
xorl %eax, %eax
callq 0x3050
movzwl 0x78(%rsp), %eax
leaq 0xed0c(%rip), %rcx      # 0x1d4a2
movw %ax, (%rcx)
movq 0xc8(%rsp), %rsi
testq %rsi, %rsi
je 0xe7fe
leaq 0x662e(%rip), %rdi      # 0x14ddb
xorl %eax, %eax
callq 0x3050
leaq 0xec29(%rip), %r15      # 0x1d3e4
leaq 0x6629(%rip), %rbx      # 0x14deb
leaq 0x30(%rsp), %r14
xorl %r12d, %r12d
movl $0x0, 0x30(%rsp)
movq 0xc8(%rsp), %rdi
addq %r12, %rdi
movq %rbx, %rsi
movq %r14, %rdx
xorl %eax, %eax
callq 0x33e0
movb 0x30(%rsp), %al
movb %al, (%r15)
addq $0x2, %r12
incq %r15
cmpq $0x8, %r12
jne 0xe7ca
movl 0x7c(%rsp), %esi
testl %esi, %esi
je 0xe821
leaq 0x65e2(%rip), %rdi      # 0x14def
xorl %eax, %eax
callq 0x3050
movl 0x7c(%rsp), %eax
leaq 0xec85(%rip), %rcx      # 0x1d4a4
movl %eax, (%rcx)
movq 0xd0(%rsp), %rax
cmpq 0xd8(%rsp), %rax
je 0xe87d
leaq 0x6c1b(%rip), %rdi      # 0x15455
callq 0x35e0
movq 0xe0(%rsp), %rax
movaps 0xef92(%rip), %xmm0     # 0x1d7e0
movq 0xef9b(%rip), %rcx      # 0x1d7f0
movq %rcx, 0xe0(%rsp)
movaps 0xd0(%rsp), %xmm1
movaps %xmm0, 0xd0(%rsp)
movaps %xmm1, 0xef6c(%rip)     # 0x1d7e0
movq %rax, 0xef75(%rip)      # 0x1d7f0
jmp 0xe8b8
movq 0xeb64(%rip), %rsi      # 0x1d3e8
movq (%rsi), %rax
cmpb $0x0, (%rax)
je 0xe8b8
movl $0x20, %r14d
leaq 0xef47(%rip), %rbx      # 0x1d7e0
movq %rbx, %rdi
callq 0xfa40
movq 0xeb40(%rip), %rsi      # 0x1d3e8
movq (%rsi,%r14), %rax
addq %r14, %rsi
addq $0x20, %r14
cmpb $0x0, (%rax)
jne 0xe899
movq 0x98(%rsp), %r14
testq %r14, %r14
je 0xe8e4
cmpq $0x0, 0xa0(%rsp)
je 0xebeb
cmpq $0x0, 0x90(%rsp)
jne 0xe8f0
callq 0x37e7
leaq 0x6b7f(%rip), %rdi      # 0x1546a
callq 0x35e0
leaq 0x6214(%rip), %rdi      # 0x14b0b
leaq 0x595b(%rip), %rsi      # 0x14259
callq 0x3460
testq %rax, %rax
je 0xe9b2
movq %rax, %rbx
leaq 0x653a(%rip), %rdi      # 0x14e50
xorl %eax, %eax
callq 0x3050
leaq 0x30(%rsp), %rdi
movq %rbx, (%rdi)
movl $0x11180, 0x10(%rdi)    # imm = 0x11180
movabsq $0x200050000, %rax      # imm = 0x200050000
movq %rax, 0x8(%rdi)
leaq 0xeb77(%rip), %rsi      # 0x1d4b8
callq 0xfa7e
cmpl $0x0, 0x88(%rsp)
je 0xe95c
leaq 0xecb9(%rip), %rdi      # 0x1d610
callq 0xd012
cmpl $0x0, 0x8c(%rsp)
sete %cl
leaq 0xeb4a(%rip), %rdx      # 0x1d4b8
movq 0x58(%rdx), %rax
addq $0x48, %rdx
cmpq %rdx, %rax
sete %dl
orb %cl, %dl
jne 0xe99c
leaq 0xeb79(%rip), %rbx      # 0x1d500
movq $0x0, 0x60(%rax)
movq %rax, %rdi
callq 0x32b0
cmpq %rbx, %rax
jne 0xe987
leaq 0x6af3(%rip), %rdi      # 0x15496
callq 0x35e0
leaq 0x30(%rsp), %rdi
callq 0x106f6
testq %r14, %r14
je 0xeacb
movl 0x74(%rsp), %r8d
movl 0x80(%rsp), %esi
movq 0xa0(%rsp), %rdx
movq 0x98(%rsp), %rcx
leaq 0x6489(%rip), %rdi      # 0x14e67
xorl %eax, %eax
callq 0x3050
movq 0xec54(%rip), %rax      # 0x1d640
cmpq %rax, 0xec55(%rip)      # 0x1d648
je 0xe9fc
movq %rax, 0xec4c(%rip)      # 0x1d648
cmpl $0x0, 0x80(%rsp)
jle 0xeabf
xorl %ebx, %ebx
leaq 0x70(%rsp), %r14
leaq 0x30(%rsp), %r12
leaq -0xd14(%rip), %r13      # 0xdd09
leaq 0x18(%rsp), %rbp
movl $0xb0, %edi
callq 0x3400
movq %rax, %r15
movq %rax, %rdi
movq %r14, %rsi
movl %ebx, %edx
callq 0xfb04
movq %r15, 0x30(%rsp)
movq 0xec00(%rip), %rsi      # 0x1d648
cmpq 0xec01(%rip), %rsi      # 0x1d650
je 0xea5e
movq %r15, (%rsi)
addq $0x8, 0xebec(%rip)      # 0x1d648
jmp 0xea6d
leaq 0xebdb(%rip), %rdi      # 0x1d640
movq %r12, %rdx
callq 0x1318e
movq 0xebcc(%rip), %rax      # 0x1d640
movq (%rax,%rbx,8), %rcx
movq %rbp, %rdi
xorl %esi, %esi
movq %r13, %rdx
callq 0x36f0
movl $0x2e, %edi
callq 0x3550
movq $0x0, 0x30(%rsp)
movq $0x1312d00, 0x38(%rsp)  # imm = 0x1312D00
movq %r12, %rdi
xorl %esi, %esi
callq 0x3100
incq %rbx
movslq 0x80(%rsp), %rax
cmpq %rax, %rbx
jl 0xea22
leaq 0x69d0(%rip), %rdi      # 0x15496
callq 0x35e0
leaq 0x63c7(%rip), %rdi      # 0x14e99
xorl %r13d, %r13d
xorl %eax, %eax
callq 0x3050
leaq -0x85c(%rip), %rdx      # 0xe287
leaq 0x130(%rsp), %rdi
xorl %esi, %esi
xorl %ecx, %ecx
callq 0x36f0
leaq 0x699b(%rip), %rdi      # 0x15496
callq 0x35e0
movl 0x70(%rsp), %esi
leaq 0x63a1(%rip), %rdi      # 0x14eac
xorl %eax, %eax
callq 0x3050
leaq 0x30(%rsp), %rbx
movq %rbx, %rdi
callq 0x3490
movl $0x20000, %esi          # imm = 0x20000
movq %rbx, %rdi
callq 0x3540
cmpl $0x0, 0x70(%rsp)
jle 0xeb64
leaq -0x1256(%rip), %rbx     # 0xd8e4
leaq 0x68(%rsp), %r14
leaq 0x30(%rsp), %r15
leaq 0x70(%rsp), %r12
movq %r14, %rdi
movq %r15, %rsi
movq %rbx, %rdx
movq %r12, %rcx
callq 0x36f0
incl %r13d
cmpl 0x70(%rsp), %r13d
jl 0xeb49
leaq 0x30(%rsp), %rdi
callq 0x3660
leaq 0x6921(%rip), %rdi      # 0x15496
callq 0x35e0
leaq -0xa58(%rip), %rdx      # 0xe129
leaq 0x120(%rsp), %rdi
xorl %esi, %esi
xorl %ecx, %ecx
callq 0x36f0
leaq -0xe58(%rip), %rdx      # 0xdd41
leaq 0x128(%rsp), %rbx
movq %rbx, %rdi
xorl %esi, %esi
xorl %ecx, %ecx
callq 0x36f0
movq (%rbx), %rdi
leaq 0x68(%rsp), %rsi
callq 0x3380
leaq 0xd0(%rsp), %rbx
leaq 0xe8(%rsp), %rdi
callq 0x10e8e
movq %rbx, %rdi
callq 0xf500
xorl %eax, %eax
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x380c
jmp 0xec2a
jmp 0xec2a
jmp 0xec2a
jmp 0xec07
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x106f6
jmp 0xec2d
movq %rax, %rdi
callq 0x55ca
jmp 0xec2a
jmp 0xec2a
jmp 0xec2a
jmp 0xec2a
jmp 0xec2a
jmp 0xec2a
movq %rax, %rbx
movq %r15, %rdi
callq 0x33c0
jmp 0xec2d
jmp 0xec2a
movq %rax, %rbx
leaq 0xe8(%rsp), %rdi
callq 0x10e8e
leaq 0xd0(%rsp), %rdi
callq 0xf500
movq %rbx, %rdi
callq 0x3690
nop