// File: /workspace/github_cpp_makefile_star2_O3/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
movl $0x1, %esi
movl $0xd, %edi
callq 0x3470
movq 0xe0b5(%rip), %rax      # 0x1bf90
movq (%rax), %rdi
xorl %r14d, %r14d
xorl %esi, %esi
callq 0x3560
movabsq $0x3500000060, %rax     # imm = 0x3500000060
leaq 0xc8(%rsp), %r15
movq %rax, -0x50(%r15)
movl $0x4, -0x48(%r15)
movl $0x0, (%r15)
movq %r14, 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)
movq %r14, 0x20(%r15)
leaq 0x78(%rsp), %rdi
movl %ebp, %esi
movq %rbx, %rdx
callq 0xedbe
leaq 0x5d89(%rip), %rdi      # 0x13cd3
xorl %eax, %eax
callq 0x3050
movq 0xd8(%rsp), %rbx
cmpq %r15, %rbx
je 0xdf97
leaq 0x5d8f(%rip), %r14      # 0x13cf4
cmpq 0xd8(%rsp), %rbx
je 0xdf79
movl $0x2c, %edi
callq 0x3530
movq 0x20(%rbx), %rsi
movq %r14, %rdi
xorl %eax, %eax
callq 0x3050
movq %rbx, %rdi
callq 0x3450
movq %rax, %rbx
cmpq %r15, %rax
jne 0xdf65
movl $0xa, %edi
callq 0x3530
movq 0xa8(%rsp), %rsi
testq %rsi, %rsi
je 0xe023
leaq 0x20(%rsp), %rdi
movl $0x235a, %edx           # imm = 0x235A
xorl %ecx, %ecx
callq 0x9c76
leaq 0x20(%rsp), %rdi
callq 0x7850
testb %al, %al
je 0xe023
leaq 0x38(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x9f0c
leaq 0x48(%rsp), %rbx
movq -0x10(%rbx), %rsi
leaq 0x5d0e(%rip), %rdi      # 0x13cfa
xorl %eax, %eax
callq 0x3050
movq -0x10(%rbx), %rdi
cmpq %rbx, %rdi
je 0xe001
callq 0x33d0
movzwl 0x30(%rsp), %eax
movw %ax, 0x10(%rsp)
movups 0x20(%rsp), %xmm0
movups %xmm0, (%rsp)
movl $0x3, %edi
movl $0x5, %esi
callq 0x77d9
movq 0xb0(%rsp), %rsi
testq %rsi, %rsi
je 0xe0a5
leaq 0x20(%rsp), %rdi
movl $0x235a, %edx           # imm = 0x235A
xorl %ecx, %ecx
callq 0x9c76
leaq 0x20(%rsp), %rdi
callq 0x7850
testb %al, %al
je 0xe0a5
leaq 0x38(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x9f0c
leaq 0x48(%rsp), %rbx
movq -0x10(%rbx), %rsi
leaq 0x5ca3(%rip), %rdi      # 0x13d11
xorl %eax, %eax
callq 0x3050
movq -0x10(%rbx), %rdi
cmpq %rbx, %rdi
je 0xe083
callq 0x33d0
movzwl 0x30(%rsp), %eax
movw %ax, 0x10(%rsp)
movups 0x20(%rsp), %xmm0
movups %xmm0, (%rsp)
movl $0x1, %edi
movl $0x5, %esi
callq 0x77d9
movq 0xb8(%rsp), %rsi
testq %rsi, %rsi
je 0xe127
leaq 0x20(%rsp), %rdi
movl $0x235a, %edx           # imm = 0x235A
xorl %ecx, %ecx
callq 0x9c76
leaq 0x20(%rsp), %rdi
callq 0x7850
testb %al, %al
je 0xe127
leaq 0x38(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x9f0c
leaq 0x48(%rsp), %rbx
movq -0x10(%rbx), %rsi
leaq 0x5c39(%rip), %rdi      # 0x13d29
xorl %eax, %eax
callq 0x3050
movq -0x10(%rbx), %rdi
cmpq %rbx, %rdi
je 0xe105
callq 0x33d0
movzwl 0x30(%rsp), %eax
movw %ax, 0x10(%rsp)
movups 0x20(%rsp), %xmm0
movups %xmm0, (%rsp)
movl $0x2, %edi
movl $0x5, %esi
callq 0x77d9
cmpl $0x0, 0x84(%rsp)
je 0xe15f
leaq 0x6120(%rip), %rdi      # 0x14258
callq 0x35b0
leaq 0xe270(%rip), %rax      # 0x1c3b4
movl $0xe9fdc490, (%rax)     # imm = 0xE9FDC490
leaq 0xe53f(%rip), %rax      # 0x1c690
movq %rax, 0xe260(%rip)      # 0x1c3b8
movb $0x1, 0xe321(%rip)      # 0x1c480
movq 0x98(%rsp), %r14
testq %r14, %r14
je 0xe18b
cmpq $0x0, 0xa0(%rsp)
je 0xe482
cmpq $0x0, 0x90(%rsp)
jne 0xe197
callq 0x3787
leaq 0x60d5(%rip), %rdi      # 0x14267
callq 0x35b0
leaq 0x594d(%rip), %rdi      # 0x13aeb
leaq 0x50ae(%rip), %rsi      # 0x13253
callq 0x3460
testq %rax, %rax
je 0xe259
movq %rax, %rbx
leaq 0x5bcc(%rip), %rdi      # 0x13d89
xorl %eax, %eax
callq 0x3050
leaq 0x38(%rsp), %rdi
movq %rbx, (%rdi)
movl $0x11500, 0x10(%rdi)    # imm = 0x11500
movabsq $0x200050000, %rax      # imm = 0x200050000
movq %rax, 0x8(%rdi)
leaq 0xe2a0(%rip), %rsi      # 0x1c488
callq 0xf04c
cmpl $0x0, 0x88(%rsp)
je 0xe203
leaq 0xe3e2(%rip), %rdi      # 0x1c5e0
callq 0xc9fe
cmpl $0x0, 0x8c(%rsp)
sete %cl
leaq 0xe273(%rip), %rdx      # 0x1c488
movq 0x58(%rdx), %rax
addq $0x48, %rdx
cmpq %rdx, %rax
sete %dl
orb %cl, %dl
jne 0xe243
leaq 0xe2a2(%rip), %rbx      # 0x1c4d0
movq $0x0, 0x60(%rax)
movq %rax, %rdi
callq 0x32c0
cmpq %rbx, %rax
jne 0xe22e
leaq 0x6049(%rip), %rdi      # 0x14293
callq 0x35b0
leaq 0x38(%rsp), %rdi
callq 0xfcba
testq %r14, %r14
je 0xe372
movl 0x7c(%rsp), %r8d
movl 0x80(%rsp), %esi
movq 0xa0(%rsp), %rdx
movq 0x98(%rsp), %rcx
leaq 0x5b1b(%rip), %rdi      # 0x13da0
xorl %eax, %eax
callq 0x3050
movq 0xe37d(%rip), %rax      # 0x1c610
cmpq %rax, 0xe37e(%rip)      # 0x1c618
je 0xe2a3
movq %rax, 0xe375(%rip)      # 0x1c618
cmpl $0x0, 0x80(%rsp)
jle 0xe366
xorl %ebx, %ebx
leaq 0x78(%rsp), %r14
leaq 0x38(%rsp), %r12
leaq -0xbe7(%rip), %r13      # 0xd6dd
leaq 0x20(%rsp), %rbp
movl $0xa8, %edi
callq 0x3400
movq %rax, %r15
movq %rax, %rdi
movq %r14, %rsi
movl %ebx, %edx
callq 0xf0d2
movq %r15, 0x38(%rsp)
movq 0xe329(%rip), %rsi      # 0x1c618
cmpq 0xe32a(%rip), %rsi      # 0x1c620
je 0xe305
movq %r15, (%rsi)
addq $0x8, 0xe315(%rip)      # 0x1c618
jmp 0xe314
leaq 0xe304(%rip), %rdi      # 0x1c610
movq %r12, %rdx
callq 0x1235e
movq 0xe2f5(%rip), %rax      # 0x1c610
movq (%rax,%rbx,8), %rcx
movq %rbp, %rdi
xorl %esi, %esi
movq %r13, %rdx
callq 0x36a0
movl $0x2e, %edi
callq 0x3530
movq $0x0, 0x38(%rsp)
movq $0x1312d00, 0x40(%rsp)  # imm = 0x1312D00
movq %r12, %rdi
xorl %esi, %esi
callq 0x3100
incq %rbx
movslq 0x80(%rsp), %rax
cmpq %rax, %rbx
jl 0xe2c9
leaq 0x5f26(%rip), %rdi      # 0x14293
callq 0x35b0
leaq 0x5a59(%rip), %rdi      # 0x13dd2
xorl %r13d, %r13d
xorl %eax, %eax
callq 0x3050
leaq -0x72f(%rip), %rdx      # 0xdc5b
leaq 0x100(%rsp), %rdi
xorl %esi, %esi
xorl %ecx, %ecx
callq 0x36a0
leaq 0x5ef1(%rip), %rdi      # 0x14293
callq 0x35b0
movl 0x78(%rsp), %esi
leaq 0x5a33(%rip), %rdi      # 0x13de5
xorl %eax, %eax
callq 0x3050
leaq 0x38(%rsp), %rbx
movq %rbx, %rdi
callq 0x3490
movl $0x20000, %esi          # imm = 0x20000
movq %rbx, %rdi
callq 0x3520
cmpl $0x0, 0x78(%rsp)
jle 0xe40b
leaq -0x1111(%rip), %rbx     # 0xd2d0
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 0x36a0
incl %r13d
cmpl 0x78(%rsp), %r13d
jl 0xe3f0
leaq 0x38(%rsp), %rdi
callq 0x3620
leaq 0x5e77(%rip), %rdi      # 0x14293
callq 0x35b0
leaq -0x92b(%rip), %rdx      # 0xdafd
leaq 0xf0(%rsp), %rdi
xorl %esi, %esi
xorl %ecx, %ecx
callq 0x36a0
leaq -0xd2b(%rip), %rdx      # 0xd715
leaq 0xf8(%rsp), %rbx
movq %rbx, %rdi
xorl %esi, %esi
xorl %ecx, %ecx
callq 0x36a0
movq (%rbx), %rdi
leaq 0x70(%rsp), %rsi
callq 0x3390
leaq 0xc0(%rsp), %rdi
callq 0x10200
xorl %eax, %eax
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x37ac
jmp 0xe4bf
jmp 0xe4bf
jmp 0xe4bf
jmp 0xe49e
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0xfcba
jmp 0xe4c2
movq %rax, %rdi
callq 0x5036
jmp 0xe4bf
jmp 0xe4bf
jmp 0xe4bf
jmp 0xe4bf
jmp 0xe4bf
movq %rax, %rbx
movq %r15, %rdi
callq 0x33d0
jmp 0xe4c2
jmp 0xe4bf
movq %rax, %rbx
leaq 0xc0(%rsp), %rdi
callq 0x10200
movq %rbx, %rdi
callq 0x3650
nop