// File: /workspace/github_cpp_makefile_star2_O1/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 0xe826(%rip), %rax      # 0x1cfa0
movq (%rax), %rdi
xorl %r14d, %r14d
xorl %esi, %esi
callq 0x3590
movsd 0x62d1(%rip), %xmm0     # 0x14a60
leaq 0xf8(%rsp), %r15
movups %xmm0, -0x80(%r15)
movl $0x4, -0x70(%r15)
xorps %xmm0, %xmm0
movups %xmm0, -0x6c(%r15)
movups %xmm0, -0x5c(%r15)
movups %xmm0, -0x50(%r15)
leaq 0x66fe(%rip), %rax      # 0x14ebb
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 0x78(%rsp), %rdi
movl %ebp, %esi
movq %rbx, %rdx
callq 0xf884
leaq 0x653d(%rip), %rdi      # 0x14d3a
xorl %eax, %eax
callq 0x3050
movq 0x108(%rsp), %rbx
cmpq %r15, %rbx
je 0xe84a
leaq 0x6543(%rip), %r14      # 0x14d5b
cmpq 0x108(%rsp), %rbx
je 0xe82c
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 0xe818
movl $0xa, %edi
callq 0x3550
movq 0xb0(%rsp), %rsi
testq %rsi, %rsi
je 0xe8d6
leaq 0x20(%rsp), %rdi
movl $0x235a, %edx           # imm = 0x235A
xorl %ecx, %ecx
callq 0xa460
leaq 0x20(%rsp), %rdi
callq 0x7f76
testb %al, %al
je 0xe8d6
leaq 0x38(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0xa6f6
leaq 0x48(%rsp), %rbx
movq -0x10(%rbx), %rsi
leaq 0x64c2(%rip), %rdi      # 0x14d61
xorl %eax, %eax
callq 0x3050
movq -0x10(%rbx), %rdi
cmpq %rbx, %rdi
je 0xe8b4
callq 0x33c0
movzwl 0x30(%rsp), %eax
movw %ax, 0x10(%rsp)
movups 0x20(%rsp), %xmm0
movups %xmm0, (%rsp)
movl $0x3, %edi
movl $0x5, %esi
callq 0x7eff
movq 0xc0(%rsp), %rsi
testq %rsi, %rsi
je 0xe958
leaq 0x20(%rsp), %rdi
movl $0x235a, %edx           # imm = 0x235A
xorl %ecx, %ecx
callq 0xa460
leaq 0x20(%rsp), %rdi
callq 0x7f76
testb %al, %al
je 0xe958
leaq 0x38(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0xa6f6
leaq 0x48(%rsp), %rbx
movq -0x10(%rbx), %rsi
leaq 0x6457(%rip), %rdi      # 0x14d78
xorl %eax, %eax
callq 0x3050
movq -0x10(%rbx), %rdi
cmpq %rbx, %rdi
je 0xe936
callq 0x33c0
movzwl 0x30(%rsp), %eax
movw %ax, 0x10(%rsp)
movups 0x20(%rsp), %xmm0
movups %xmm0, (%rsp)
movl $0x1, %edi
movl $0x5, %esi
callq 0x7eff
movq 0xc8(%rsp), %rsi
testq %rsi, %rsi
je 0xe9da
leaq 0x20(%rsp), %rdi
movl $0x235a, %edx           # imm = 0x235A
xorl %ecx, %ecx
callq 0xa460
leaq 0x20(%rsp), %rdi
callq 0x7f76
testb %al, %al
je 0xe9da
leaq 0x38(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0xa6f6
leaq 0x48(%rsp), %rbx
movq -0x10(%rbx), %rsi
leaq 0x63ed(%rip), %rdi      # 0x14d90
xorl %eax, %eax
callq 0x3050
movq -0x10(%rbx), %rdi
cmpq %rbx, %rdi
je 0xe9b8
callq 0x33c0
movzwl 0x30(%rsp), %eax
movw %ax, 0x10(%rsp)
movups 0x20(%rsp), %xmm0
movups %xmm0, (%rsp)
movl $0x2, %edi
movl $0x5, %esi
callq 0x7eff
cmpl $0x0, 0x8c(%rsp)
je 0xea12
leaq 0x6a3b(%rip), %rdi      # 0x15426
callq 0x35e0
leaq 0xe9ed(%rip), %rax      # 0x1d3e4
movl $0xefc0f2cd, (%rax)     # imm = 0xEFC0F2CD
leaq 0xed3c(%rip), %rax      # 0x1d740
movq %rax, 0xe9dd(%rip)      # 0x1d3e8
movb $0x1, 0xea9e(%rip)      # 0x1d4b0
movl 0x80(%rsp), %esi
testl %esi, %esi
je 0xea3d
leaq 0x6384(%rip), %rdi      # 0x14da8
xorl %eax, %eax
callq 0x3050
movzwl 0x80(%rsp), %eax
leaq 0xea68(%rip), %rcx      # 0x1d4a2
movw %ax, (%rcx)
movq 0xd0(%rsp), %rsi
testq %rsi, %rsi
je 0xeaa2
leaq 0x636a(%rip), %rdi      # 0x14dbb
xorl %eax, %eax
callq 0x3050
leaq 0xe985(%rip), %r15      # 0x1d3e4
leaq 0x6365(%rip), %rbx      # 0x14dcb
leaq 0x38(%rsp), %r14
xorl %r12d, %r12d
movl $0x0, 0x38(%rsp)
movq 0xd0(%rsp), %rdi
addq %r12, %rdi
movq %rbx, %rsi
movq %r14, %rdx
xorl %eax, %eax
callq 0x33e0
movb 0x38(%rsp), %al
movb %al, (%r15)
addq $0x2, %r12
incq %r15
cmpq $0x8, %r12
jne 0xea6e
movl 0x84(%rsp), %esi
testl %esi, %esi
je 0xeacb
leaq 0x631b(%rip), %rdi      # 0x14dcf
xorl %eax, %eax
callq 0x3050
movl 0x84(%rsp), %eax
leaq 0xe9db(%rip), %rcx      # 0x1d4a4
movl %eax, (%rcx)
movq 0xd8(%rsp), %rax
cmpq 0xe0(%rsp), %rax
je 0xeb27
leaq 0x6951(%rip), %rdi      # 0x15435
callq 0x35e0
movq 0xd8(%rsp), %rax
movups 0xe0(%rsp), %xmm0
movq 0xece0(%rip), %rcx      # 0x1d7e0
movq %rcx, 0xd8(%rsp)
movups 0xecd9(%rip), %xmm1     # 0x1d7e8
movups %xmm1, 0xe0(%rsp)
movq %rax, 0xecc2(%rip)      # 0x1d7e0
movups %xmm0, 0xecc3(%rip)     # 0x1d7e8
jmp 0xeb62
movq 0xe8ba(%rip), %rsi      # 0x1d3e8
movq (%rsi), %rax
cmpb $0x0, (%rax)
je 0xeb62
movl $0x20, %r14d
leaq 0xec9d(%rip), %rbx      # 0x1d7e0
movq %rbx, %rdi
callq 0xfd9e
movq 0xe896(%rip), %rsi      # 0x1d3e8
movq (%rsi,%r14), %rax
addq %r14, %rsi
addq $0x20, %r14
cmpb $0x0, (%rax)
jne 0xeb43
movq 0xa0(%rsp), %r14
testq %r14, %r14
jne 0xeb7b
leaq 0x68d4(%rip), %rdi      # 0x1544a
callq 0x35e0
testq %r14, %r14
je 0xeb8f
cmpq $0x0, 0xa8(%rsp)
je 0xee9e
testq %r14, %r14
je 0xeba3
cmpq $0x0, 0x98(%rsp)
je 0xeea3
leaq 0x5f41(%rip), %rdi      # 0x14aeb
leaq 0x56a8(%rip), %rsi      # 0x14259
callq 0x3460
testq %rax, %rax
je 0xec65
movq %rax, %rbx
leaq 0x6267(%rip), %rdi      # 0x14e30
xorl %eax, %eax
callq 0x3050
leaq 0x38(%rsp), %rdi
movq %rbx, (%rdi)
movl $0x11180, 0x10(%rdi)    # imm = 0x11180
movabsq $0x200050000, %rax      # imm = 0x200050000
movq %rax, 0x8(%rdi)
leaq 0xe8c4(%rip), %rsi      # 0x1d4b8
callq 0xfddc
cmpl $0x0, 0x90(%rsp)
je 0xec0f
leaq 0xea06(%rip), %rdi      # 0x1d610
callq 0xd2c4
cmpl $0x0, 0x94(%rsp)
sete %cl
leaq 0xe897(%rip), %rdx      # 0x1d4b8
movq 0x58(%rdx), %rax
addq $0x48, %rdx
cmpq %rdx, %rax
sete %dl
orb %cl, %dl
jne 0xec4f
leaq 0xe8c6(%rip), %rbx      # 0x1d500
movq $0x0, 0x60(%rax)
movq %rax, %rdi
callq 0x32b0
cmpq %rbx, %rax
jne 0xec3a
leaq 0x6820(%rip), %rdi      # 0x15476
callq 0x35e0
leaq 0x38(%rsp), %rdi
callq 0x10a8a
testq %r14, %r14
je 0xed7e
movl 0x7c(%rsp), %r8d
movl 0x88(%rsp), %esi
movq 0xa8(%rsp), %rdx
movq 0xa0(%rsp), %rcx
leaq 0x61b6(%rip), %rdi      # 0x14e47
xorl %eax, %eax
callq 0x3050
movq 0xe9a1(%rip), %rax      # 0x1d640
cmpq %rax, 0xe9a2(%rip)      # 0x1d648
je 0xecaf
movq %rax, 0xe999(%rip)      # 0x1d648
cmpl $0x0, 0x88(%rsp)
jle 0xed72
xorl %ebx, %ebx
leaq 0x78(%rsp), %r14
leaq 0x38(%rsp), %r12
leaq -0xcff(%rip), %r13      # 0xdfd1
leaq 0x20(%rsp), %rbp
movl $0xb0, %edi
callq 0x3400
movq %rax, %r15
movq %rax, %rdi
movq %r14, %rsi
movl %ebx, %edx
callq 0xfe6c
movq %r15, 0x38(%rsp)
movq 0xe94d(%rip), %rsi      # 0x1d648
cmpq 0xe94e(%rip), %rsi      # 0x1d650
je 0xed11
movq %r15, (%rsi)
addq $0x8, 0xe939(%rip)      # 0x1d648
jmp 0xed20
leaq 0xe928(%rip), %rdi      # 0x1d640
movq %r12, %rdx
callq 0x135d8
movq 0xe919(%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, 0x38(%rsp)
movq $0x1312d00, 0x40(%rsp)  # imm = 0x1312D00
movq %r12, %rdi
xorl %esi, %esi
callq 0x3100
incq %rbx
movslq 0x88(%rsp), %rax
cmpq %rax, %rbx
jl 0xecd5
leaq 0x66fd(%rip), %rdi      # 0x15476
callq 0x35e0
leaq 0x60f4(%rip), %rdi      # 0x14e79
xorl %r13d, %r13d
xorl %eax, %eax
callq 0x3050
leaq -0x865(%rip), %rdx      # 0xe531
leaq 0x130(%rsp), %rdi
xorl %esi, %esi
xorl %ecx, %ecx
callq 0x36f0
leaq 0x66c8(%rip), %rdi      # 0x15476
callq 0x35e0
movl 0x78(%rsp), %esi
leaq 0x60ce(%rip), %rdi      # 0x14e8c
xorl %eax, %eax
callq 0x3050
leaq 0x38(%rsp), %rbx
movq %rbx, %rdi
callq 0x3490
movl $0x20000, %esi          # imm = 0x20000
movq %rbx, %rdi
callq 0x3540
cmpl $0x0, 0x78(%rsp)
jle 0xee17
leaq -0x1265(%rip), %rbx     # 0xdb88
leaq 0x70(%rsp), %r14
leaq 0x38(%rsp), %r15
leaq 0x78(%rsp), %r12
movq %r14, %rdi
movq %r15, %rsi
movq %rbx, %rdx
movq %r12, %rcx
callq 0x36f0
incl %r13d
cmpl 0x78(%rsp), %r13d
jl 0xedfc
leaq 0x38(%rsp), %rdi
callq 0x3660
leaq 0x664e(%rip), %rdi      # 0x15476
callq 0x35e0
leaq -0xa4e(%rip), %rdx      # 0xe3e6
leaq 0x120(%rsp), %rdi
xorl %esi, %esi
xorl %ecx, %ecx
callq 0x36f0
leaq -0xe43(%rip), %rdx      # 0xe009
leaq 0x128(%rsp), %rbx
movq %rbx, %rdi
xorl %esi, %esi
xorl %ecx, %ecx
callq 0x36f0
movq (%rbx), %rdi
leaq 0x70(%rsp), %rsi
callq 0x3380
leaq 0xd8(%rsp), %rbx
leaq 0xf0(%rsp), %rdi
callq 0x1122c
movq %rbx, %rdi
callq 0xf7c4
xorl %eax, %eax
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x37e7
callq 0x380c
jmp 0xeee2
jmp 0xeee2
jmp 0xeee2
jmp 0xeebf
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x10a8a
jmp 0xeee5
movq %rax, %rdi
callq 0x56f0
jmp 0xeee2
jmp 0xeee2
jmp 0xeee2
jmp 0xeee2
jmp 0xeee2
jmp 0xeee2
movq %rax, %rbx
movq %r15, %rdi
callq 0x33c0
jmp 0xeee5
jmp 0xeee2
movq %rax, %rbx
leaq 0xf0(%rsp), %rdi
callq 0x1122c
leaq 0xd8(%rsp), %rdi
callq 0xf7c4
movq %rbx, %rdi
callq 0x3690
nop