// File: /workspace/github_cpp_makefile_star2_O2/tenup-coin[P]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] = 0x90;
      pchMessageStart[1] = 0xc4;
      pchMessageStart[2] = 0xfd;
      pchMessageStart[3] = 0xe9;
      seeds = testnet_seeds;
      fTestNet = true;
  }
  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 $0x108, %rsp            # imm = 0x108
movq %rsi, %rbx
movl %edi, %ebp
pushq $0xd
popq %rdi
pushq $0x1
popq %rsi
callq 0x3480
movq 0x10081(%rip), %rax     # 0x1cf90
movq (%rax), %rdi
xorl %esi, %esi
callq 0x35a0
movabsq $0x3500000060, %rax     # imm = 0x3500000060
leaq 0xc8(%rsp), %r15
movq %rax, -0x50(%r15)
movl $0x4, -0x48(%r15)
andl $0x0, (%r15)
andq $0x0, 0x8(%r15)
xorps %xmm0, %xmm0
movups %xmm0, -0x44(%r15)
movups %xmm0, -0x34(%r15)
movups %xmm0, -0x24(%r15)
movups %xmm0, -0x18(%r15)
movq %r15, 0x10(%r15)
movq %r15, 0x18(%r15)
andq $0x0, 0x20(%r15)
leaq 0x78(%rsp), %rdi
movl %ebp, %esi
movq %rbx, %rdx
callq 0xdd0c
leaq 0x5d59(%rip), %rdi      # 0x12cd3
xorl %eax, %eax
callq 0x3050
movq 0xd8(%rsp), %r14
leaq 0x5d64(%rip), %rbx      # 0x12cf4
pushq $0x2c
popq %rbp
cmpq %r15, %r14
je 0xcfc4
cmpq 0xd8(%rsp), %r14
je 0xcfa9
movl %ebp, %edi
callq 0x3570
movq 0x20(%r14), %rsi
movq %rbx, %rdi
xorl %eax, %eax
callq 0x3050
movq %r14, %rdi
callq 0x3460
movq %rax, %r14
jmp 0xcf93
pushq $0xa
popq %rdi
callq 0x3570
movq 0xa8(%rsp), %rsi
testq %rsi, %rsi
je 0xd043
leaq 0x20(%rsp), %rdi
movl $0x235a, %edx           # imm = 0x235A
xorl %ecx, %ecx
callq 0x8c32
leaq 0x20(%rsp), %rdi
callq 0x6f7c
testb %al, %al
je 0xd043
leaq 0x40(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x8ea0
leaq 0x40(%rsp), %rbx
movq (%rbx), %rsi
leaq 0x5ce4(%rip), %rdi      # 0x12cfa
xorl %eax, %eax
callq 0x3050
movq %rbx, %rdi
callq 0x31d0
movzwl 0x30(%rsp), %eax
movw %ax, 0x10(%rsp)
movups 0x20(%rsp), %xmm0
movups %xmm0, (%rsp)
pushq $0x3
popq %rdi
pushq $0x5
popq %rsi
callq 0x6f05
movq 0xb0(%rsp), %rsi
testq %rsi, %rsi
je 0xd0ba
leaq 0x20(%rsp), %rdi
movl $0x235a, %edx           # imm = 0x235A
xorl %ecx, %ecx
callq 0x8c32
leaq 0x20(%rsp), %rdi
callq 0x6f7c
testb %al, %al
je 0xd0ba
leaq 0x40(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x8ea0
leaq 0x40(%rsp), %rbx
movq (%rbx), %rsi
leaq 0x5c84(%rip), %rdi      # 0x12d11
xorl %eax, %eax
callq 0x3050
movq %rbx, %rdi
callq 0x31d0
movzwl 0x30(%rsp), %eax
movw %ax, 0x10(%rsp)
movups 0x20(%rsp), %xmm0
movups %xmm0, (%rsp)
pushq $0x1
popq %rdi
pushq $0x5
popq %rsi
callq 0x6f05
movq 0xb8(%rsp), %rsi
testq %rsi, %rsi
je 0xd131
leaq 0x20(%rsp), %rdi
movl $0x235a, %edx           # imm = 0x235A
xorl %ecx, %ecx
callq 0x8c32
leaq 0x20(%rsp), %rdi
callq 0x6f7c
testb %al, %al
je 0xd131
leaq 0x40(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x8ea0
leaq 0x40(%rsp), %rbx
movq (%rbx), %rsi
leaq 0x5c25(%rip), %rdi      # 0x12d29
xorl %eax, %eax
callq 0x3050
movq %rbx, %rdi
callq 0x31d0
movzwl 0x30(%rsp), %eax
movw %ax, 0x10(%rsp)
movups 0x20(%rsp), %xmm0
movups %xmm0, (%rsp)
pushq $0x2
popq %rdi
pushq $0x5
popq %rsi
callq 0x6f05
cmpl $0x0, 0x84(%rsp)
je 0xd169
leaq 0x6116(%rip), %rdi      # 0x13258
callq 0x35f0
leaq 0x10296(%rip), %rax     # 0x1d3e4
movl $0xe9fdc490, (%rax)     # imm = 0xE9FDC490
leaq 0x10565(%rip), %rax     # 0x1d6c0
movq %rax, 0x10286(%rip)     # 0x1d3e8
movb $0x1, 0x10347(%rip)     # 0x1d4b0
movq 0x98(%rsp), %r14
testq %r14, %r14
je 0xd1a8
cmpq $0x0, 0xa0(%rsp)
je 0xd424
cmpq $0x0, 0x90(%rsp)
jne 0xd1b4
movq 0xfe29(%rip), %rax      # 0x1cfc0
movq (%rax), %rcx
leaq 0x5bc1(%rip), %rdi      # 0x12d62
pushq $0x26
jmp 0xd437
leaq 0x60b8(%rip), %rdi      # 0x13267
callq 0x35f0
leaq 0x5930(%rip), %rdi      # 0x12aeb
leaq 0x5057(%rip), %rsi      # 0x12219
callq 0x3470
testq %rax, %rax
je 0xd248
movq %rax, %rbx
leaq 0x5bb3(%rip), %rdi      # 0x12d89
xorl %eax, %eax
callq 0x3050
leaq 0x40(%rsp), %rdi
movq %rbx, (%rdi)
movl $0x11500, 0x10(%rdi)    # imm = 0x11500
movabsq $0x200050000, %rax      # imm = 0x200050000
movq %rax, 0x8(%rdi)
leaq 0x102b7(%rip), %rsi     # 0x1d4b8
callq 0xe202
cmpl $0x0, 0x88(%rsp)
je 0xd21c
leaq 0x103f9(%rip), %rdi     # 0x1d610
callq 0xba5c
cmpl $0x0, 0x8c(%rsp)
je 0xd232
leaq 0x1028b(%rip), %rdi     # 0x1d4b8
callq 0xe286
leaq 0x605a(%rip), %rdi      # 0x13293
callq 0x35f0
leaq 0x40(%rsp), %rdi
callq 0xdbc0
testq %r14, %r14
je 0xd320
movl 0x7c(%rsp), %r8d
movl 0x80(%rsp), %esi
movq 0xa0(%rsp), %rdx
movq 0x98(%rsp), %rcx
leaq 0x5b2c(%rip), %rdi      # 0x12da0
xorl %eax, %eax
callq 0x3050
movq 0x103be(%rip), %rax     # 0x1d640
cmpq %rax, 0x103bf(%rip)     # 0x1d648
je 0xd292
movq %rax, 0x103b6(%rip)     # 0x1d648
xorl %ebx, %ebx
leaq -0xa0d(%rip), %r13      # 0xc88e
leaq 0x20(%rsp), %rbp
pushq $0x2e
popq %r14
pushq $0x14
popq %r15
movslq 0x80(%rsp), %rax
cmpq %rax, %rbx
jge 0xd314
movl $0xa8, %edi
callq 0x3410
movq %rax, %r12
movq %rax, %rdi
leaq 0x78(%rsp), %rsi
movl %ebx, %edx
callq 0xe2a8
movq %r12, 0x40(%rsp)
leaq 0x10363(%rip), %rdi     # 0x1d640
leaq 0x40(%rsp), %rsi
callq 0x10d2e
movq 0x10352(%rip), %rax     # 0x1d640
movq (%rax,%rbx,8), %rcx
movq %rbp, %rdi
xorl %esi, %esi
movq %r13, %rdx
callq 0x36e0
movl %r14d, %edi
callq 0x3570
movl %r15d, %edi
callq 0xc667
incq %rbx
jmp 0xd2a8
leaq 0x5f78(%rip), %rdi      # 0x13293
callq 0x35f0
leaq 0x5aab(%rip), %rdi      # 0x12dd2
xorl %r13d, %r13d
xorl %eax, %eax
callq 0x3050
leaq -0x665(%rip), %rdx      # 0xccd3
leaq 0x100(%rsp), %rdi
xorl %esi, %esi
xorl %ecx, %ecx
callq 0x36e0
leaq 0x5f43(%rip), %rdi      # 0x13293
callq 0x35f0
leaq 0x78(%rsp), %rbx
movl (%rbx), %esi
leaq 0x5a82(%rip), %rdi      # 0x12de5
xorl %eax, %eax
callq 0x3050
leaq 0x40(%rsp), %r14
movq %r14, %rdi
callq 0x34a0
movl $0x20000, %esi          # imm = 0x20000
movq %r14, %rdi
callq 0x3540
leaq -0xebb(%rip), %r15      # 0xc4d0
leaq 0x38(%rsp), %r12
cmpl 0x78(%rsp), %r13d
jge 0xd3ad
movq %r12, %rdi
movq %r14, %rsi
movq %r15, %rdx
movq %rbx, %rcx
callq 0x36e0
incl %r13d
jmp 0xd390
leaq 0x40(%rsp), %rdi
callq 0x3660
leaq 0x5ed5(%rip), %rdi      # 0x13293
callq 0x35f0
leaq -0x829(%rip), %rdx      # 0xcba1
leaq 0xf0(%rsp), %rdi
xorl %esi, %esi
xorl %ecx, %ecx
callq 0x36e0
leaq -0xb1c(%rip), %rdx      # 0xc8c6
leaq 0xf8(%rsp), %rbx
movq %rbx, %rdi
xorl %esi, %esi
xorl %ecx, %ecx
callq 0x36e0
movq (%rbx), %rdi
leaq 0x38(%rsp), %rsi
callq 0x33a0
leaq 0xc0(%rsp), %rdi
callq 0xf40e
xorl %eax, %eax
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xfb95(%rip), %rax      # 0x1cfc0
movq (%rax), %rcx
leaq 0x590c(%rip), %rdi      # 0x12d41
pushq $0x20
popq %rsi
pushq $0x1
popq %rdx
callq 0x3720
pushq $0x1
popq %rdi
callq 0x3490
jmp 0xd476
jmp 0xd476
jmp 0xd476
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0xdbc0
jmp 0xd479
jmp 0xd476
jmp 0xd476
jmp 0xd476
jmp 0xd476
jmp 0xd476
movq %rax, %rbx
movq %r12, %rdi
callq 0x33e0
jmp 0xd479
jmp 0xd476
movq %rax, %rbx
leaq 0xc0(%rsp), %rdi
callq 0xf40e
movq %rbx, %rdi
callq 0x3690