// File: /workspace/github_cpp_makefile_star2_O2/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
pushq $0xd
popq %rdi
pushq $0x1
popq %rsi
callq 0x3480
movq 0xfdd7(%rip), %rax      # 0x1cfa0
movq (%rax), %rdi
xorl %esi, %esi
callq 0x35d0
movsd 0x58a5(%rip), %xmm0     # 0x12a80
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 0x5cd2(%rip), %rax      # 0x12edb
movq %rax, -0x40(%r15)
andl $0x0, (%r15)
andq $0x0, 0x8(%r15)
movups %xmm0, -0x38(%r15)
movups %xmm0, -0x28(%r15)
movups %xmm0, -0x18(%r15)
movq %r15, 0x10(%r15)
movq %r15, 0x18(%r15)
andq $0x0, 0x20(%r15)
leaq 0x70(%rsp), %rdi
movl %ebp, %esi
movq %rbx, %rdx
callq 0xe15c
leaq 0x5b12(%rip), %rdi      # 0x12d5a
xorl %eax, %eax
callq 0x3050
movq 0x100(%rsp), %r14
leaq 0x5b1d(%rip), %rbx      # 0x12d7b
pushq $0x2c
popq %rbp
cmpq %r15, %r14
je 0xd292
cmpq 0x100(%rsp), %r14
je 0xd277
movl %ebp, %edi
callq 0x3590
movq 0x20(%r14), %rsi
movq %rbx, %rdi
xorl %eax, %eax
callq 0x3050
movq %r14, %rdi
callq 0x3460
movq %rax, %r14
jmp 0xd261
pushq $0xa
popq %rdi
callq 0x3590
movq 0xa8(%rsp), %rsi
testq %rsi, %rsi
je 0xd311
leaq 0x18(%rsp), %rdi
movl $0x235a, %edx           # imm = 0x235A
xorl %ecx, %ecx
callq 0x8e96
leaq 0x18(%rsp), %rdi
callq 0x71cc
testb %al, %al
je 0xd311
leaq 0x30(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x9104
leaq 0x30(%rsp), %rbx
movq (%rbx), %rsi
leaq 0x5a9d(%rip), %rdi      # 0x12d81
xorl %eax, %eax
callq 0x3050
movq %rbx, %rdi
callq 0x31d0
movzwl 0x28(%rsp), %eax
movw %ax, 0x10(%rsp)
movups 0x18(%rsp), %xmm0
movups %xmm0, (%rsp)
pushq $0x3
popq %rdi
pushq $0x5
popq %rsi
callq 0x7155
movq 0xb8(%rsp), %rsi
testq %rsi, %rsi
je 0xd388
leaq 0x18(%rsp), %rdi
movl $0x235a, %edx           # imm = 0x235A
xorl %ecx, %ecx
callq 0x8e96
leaq 0x18(%rsp), %rdi
callq 0x71cc
testb %al, %al
je 0xd388
leaq 0x30(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x9104
leaq 0x30(%rsp), %rbx
movq (%rbx), %rsi
leaq 0x5a3d(%rip), %rdi      # 0x12d98
xorl %eax, %eax
callq 0x3050
movq %rbx, %rdi
callq 0x31d0
movzwl 0x28(%rsp), %eax
movw %ax, 0x10(%rsp)
movups 0x18(%rsp), %xmm0
movups %xmm0, (%rsp)
pushq $0x1
popq %rdi
pushq $0x5
popq %rsi
callq 0x7155
movq 0xc0(%rsp), %rsi
testq %rsi, %rsi
je 0xd3ff
leaq 0x18(%rsp), %rdi
movl $0x235a, %edx           # imm = 0x235A
xorl %ecx, %ecx
callq 0x8e96
leaq 0x18(%rsp), %rdi
callq 0x71cc
testb %al, %al
je 0xd3ff
leaq 0x30(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x9104
leaq 0x30(%rsp), %rbx
movq (%rbx), %rsi
leaq 0x59de(%rip), %rdi      # 0x12db0
xorl %eax, %eax
callq 0x3050
movq %rbx, %rdi
callq 0x31d0
movzwl 0x28(%rsp), %eax
movw %ax, 0x10(%rsp)
movups 0x18(%rsp), %xmm0
movups %xmm0, (%rsp)
pushq $0x2
popq %rdi
pushq $0x5
popq %rsi
callq 0x7155
cmpl $0x0, 0x84(%rsp)
je 0xd437
leaq 0x6036(%rip), %rdi      # 0x13446
callq 0x3620
leaq 0xfff8(%rip), %rax      # 0x1d414
movl $0xefc0f2cd, (%rax)     # imm = 0xEFC0F2CD
leaq 0x10347(%rip), %rax     # 0x1d770
movq %rax, 0xffe8(%rip)      # 0x1d418
movb $0x1, 0x100a9(%rip)     # 0x1d4e0
movl 0x78(%rsp), %esi
testl %esi, %esi
je 0xd45c
leaq 0x5982(%rip), %rdi      # 0x12dc8
xorl %eax, %eax
callq 0x3050
movzwl 0x78(%rsp), %eax
leaq 0x10079(%rip), %rcx     # 0x1d4d2
movw %ax, (%rcx)
movq 0xc8(%rsp), %rsi
testq %rsi, %rsi
je 0xd4c0
leaq 0x596b(%rip), %rdi      # 0x12ddb
xorl %eax, %eax
callq 0x3050
leaq 0xff96(%rip), %r15      # 0x1d414
leaq 0x5966(%rip), %rbx      # 0x12deb
leaq 0x30(%rsp), %r14
xorl %r12d, %r12d
cmpq $0x8, %r12
je 0xd4c0
andl $0x0, 0x30(%rsp)
movq 0xc8(%rsp), %rdi
addq %r12, %rdi
movq %rbx, %rsi
movq %r14, %rdx
xorl %eax, %eax
callq 0x33f0
movb 0x30(%rsp), %al
movb %al, (%r15)
addq $0x2, %r12
incq %r15
jmp 0xd48d
movl 0x7c(%rsp), %esi
testl %esi, %esi
je 0xd4e3
leaq 0x5920(%rip), %rdi      # 0x12def
xorl %eax, %eax
callq 0x3050
movl 0x7c(%rsp), %eax
leaq 0xfff3(%rip), %rcx      # 0x1d4d4
movl %eax, (%rcx)
movq 0xd0(%rsp), %rax
cmpq 0xd8(%rsp), %rax
je 0xd580
leaq 0x5f55(%rip), %rdi      # 0x13455
callq 0x3620
movq 0xe0(%rsp), %rax
movaps 0x102fc(%rip), %xmm0    # 0x1d810
movq 0x10305(%rip), %rcx     # 0x1d820
movq %rcx, 0xe0(%rsp)
movaps 0xd0(%rsp), %xmm1
movaps %xmm0, 0xd0(%rsp)
movaps %xmm1, 0x102d6(%rip)    # 0x1d810
movq %rax, 0x102df(%rip)     # 0x1d820
movq 0x98(%rsp), %r14
testq %r14, %r14
je 0xd5ab
cmpq $0x0, 0xa0(%rsp)
je 0xd824
cmpq $0x0, 0x90(%rsp)
jne 0xd5b7
movq 0xfa61(%rip), %rax      # 0x1cfd0
movq (%rax), %rcx
leaq 0x58b0(%rip), %rdi      # 0x12e29
pushq $0x26
jmp 0xd837
xorl %r14d, %r14d
leaq 0x10286(%rip), %rbx     # 0x1d810
movq 0xfe87(%rip), %rsi      # 0x1d418
movq (%rsi,%r14), %rax
cmpb $0x0, (%rax)
je 0xd541
addq %r14, %rsi
movq %rbx, %rdi
callq 0xe8d2
addq $0x20, %r14
jmp 0xd58a
leaq 0x5eb8(%rip), %rdi      # 0x1346a
callq 0x3620
leaq 0x554d(%rip), %rdi      # 0x12b0b
leaq 0x4c5a(%rip), %rsi      # 0x1221f
callq 0x3470
testq %rax, %rax
je 0xd64b
movq %rax, %rbx
leaq 0x5877(%rip), %rdi      # 0x12e50
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 0xfee4(%rip), %rsi      # 0x1d4e8
callq 0xe8fe
cmpl $0x0, 0x88(%rsp)
je 0xd61f
leaq 0x10026(%rip), %rdi     # 0x1d640
callq 0xbd02
cmpl $0x0, 0x8c(%rsp)
je 0xd635
leaq 0xfeb8(%rip), %rdi      # 0x1d4e8
callq 0xe982
leaq 0x5e5a(%rip), %rdi      # 0x13496
callq 0x3620
leaq 0x30(%rsp), %rdi
callq 0xdfcc
testq %r14, %r14
je 0xd723
movl 0x74(%rsp), %r8d
movl 0x80(%rsp), %esi
movq 0xa0(%rsp), %rdx
movq 0x98(%rsp), %rcx
leaq 0x57f0(%rip), %rdi      # 0x12e67
xorl %eax, %eax
callq 0x3050
movq 0xffeb(%rip), %rax      # 0x1d670
cmpq %rax, 0xffec(%rip)      # 0x1d678
je 0xd695
movq %rax, 0xffe3(%rip)      # 0x1d678
xorl %ebx, %ebx
leaq -0xb51(%rip), %r13      # 0xcb4d
leaq 0x18(%rsp), %rbp
pushq $0x2e
popq %r14
pushq $0x14
popq %r15
movslq 0x80(%rsp), %rax
cmpq %rax, %rbx
jge 0xd717
movl $0xb0, %edi
callq 0x3410
movq %rax, %r12
movq %rax, %rdi
leaq 0x70(%rsp), %rsi
movl %ebx, %edx
callq 0xe9a4
movq %r12, 0x30(%rsp)
leaq 0xff90(%rip), %rdi      # 0x1d670
leaq 0x30(%rsp), %rsi
callq 0x1179a
movq 0xff7f(%rip), %rax      # 0x1d670
movq (%rax,%rbx,8), %rcx
movq %rbp, %rdi
xorl %esi, %esi
movq %r13, %rdx
callq 0x3730
movl %r14d, %edi
callq 0x3590
movl %r15d, %edi
callq 0xc926
incq %rbx
jmp 0xd6ab
leaq 0x5d78(%rip), %rdi      # 0x13496
callq 0x3620
leaq 0x576f(%rip), %rdi      # 0x12e99
xorl %r13d, %r13d
xorl %eax, %eax
callq 0x3050
leaq -0x7a9(%rip), %rdx      # 0xcf92
leaq 0x130(%rsp), %rdi
xorl %esi, %esi
xorl %ecx, %ecx
callq 0x3730
leaq 0x5d43(%rip), %rdi      # 0x13496
callq 0x3620
leaq 0x70(%rsp), %rbx
movl (%rbx), %esi
leaq 0x5746(%rip), %rdi      # 0x12eac
xorl %eax, %eax
callq 0x3050
leaq 0x30(%rsp), %r14
movq %r14, %rdi
callq 0x34a0
movl $0x20000, %esi          # imm = 0x20000
movq %r14, %rdi
callq 0x3560
leaq -0x101a(%rip), %r15     # 0xc774
leaq 0x68(%rsp), %r12
cmpl 0x70(%rsp), %r13d
jge 0xd7b0
movq %r12, %rdi
movq %r14, %rsi
movq %r15, %rdx
movq %rbx, %rcx
callq 0x3730
incl %r13d
jmp 0xd793
leaq 0x30(%rsp), %rdi
callq 0x36a0
leaq 0x5cd5(%rip), %rdi      # 0x13496
callq 0x3620
leaq -0x96d(%rip), %rdx      # 0xce60
leaq 0x120(%rsp), %rdi
xorl %esi, %esi
xorl %ecx, %ecx
callq 0x3730
leaq -0xc60(%rip), %rdx      # 0xcb85
leaq 0x128(%rsp), %rbx
movq %rbx, %rdi
xorl %esi, %esi
xorl %ecx, %ecx
callq 0x3730
movq (%rbx), %rdi
leaq 0x68(%rsp), %rsi
callq 0x3390
leaq 0x70(%rsp), %rdi
callq 0xea80
xorl %eax, %eax
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xf7a5(%rip), %rax      # 0x1cfd0
movq (%rax), %rcx
leaq 0x55d3(%rip), %rdi      # 0x12e08
pushq $0x20
popq %rsi
pushq $0x1
popq %rdx
callq 0x3780
pushq $0x1
popq %rdi
callq 0x3490
jmp 0xd878
jmp 0xd878
jmp 0xd878
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0xdfcc
jmp 0xd87b
jmp 0xd878
jmp 0xd878
jmp 0xd878
jmp 0xd878
jmp 0xd878
jmp 0xd878
movq %rax, %rbx
movq %r12, %rdi
callq 0x33d0
jmp 0xd87b
jmp 0xd878
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0xea80
movq %rbx, %rdi
callq 0x36d0
nop