// File: /workspace/github_cpp_makefile_star2_O1/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 0xdecb(%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 0xefc2
leaq 0x5b8f(%rip), %rdi      # 0x13cc3
xorl %eax, %eax
callq 0x3050
movq 0xd8(%rsp), %rbx
cmpq %r15, %rbx
je 0xe181
leaq 0x5b95(%rip), %r14      # 0x13ce4
cmpq 0xd8(%rsp), %rbx
je 0xe163
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 0xe14f
movl $0xa, %edi
callq 0x3530
movq 0xa8(%rsp), %rsi
testq %rsi, %rsi
je 0xe20d
leaq 0x20(%rsp), %rdi
movl $0x235a, %edx           # imm = 0x235A
xorl %ecx, %ecx
callq 0x9de4
leaq 0x20(%rsp), %rdi
callq 0x790e
testb %al, %al
je 0xe20d
leaq 0x38(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0xa07a
leaq 0x48(%rsp), %rbx
movq -0x10(%rbx), %rsi
leaq 0x5b14(%rip), %rdi      # 0x13cea
xorl %eax, %eax
callq 0x3050
movq -0x10(%rbx), %rdi
cmpq %rbx, %rdi
je 0xe1eb
callq 0x33d0
movzwl 0x30(%rsp), %eax
movw %ax, 0x10(%rsp)
movups 0x20(%rsp), %xmm0
movups %xmm0, (%rsp)
movl $0x3, %edi
movl $0x5, %esi
callq 0x7897
movq 0xb0(%rsp), %rsi
testq %rsi, %rsi
je 0xe28f
leaq 0x20(%rsp), %rdi
movl $0x235a, %edx           # imm = 0x235A
xorl %ecx, %ecx
callq 0x9de4
leaq 0x20(%rsp), %rdi
callq 0x790e
testb %al, %al
je 0xe28f
leaq 0x38(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0xa07a
leaq 0x48(%rsp), %rbx
movq -0x10(%rbx), %rsi
leaq 0x5aa9(%rip), %rdi      # 0x13d01
xorl %eax, %eax
callq 0x3050
movq -0x10(%rbx), %rdi
cmpq %rbx, %rdi
je 0xe26d
callq 0x33d0
movzwl 0x30(%rsp), %eax
movw %ax, 0x10(%rsp)
movups 0x20(%rsp), %xmm0
movups %xmm0, (%rsp)
movl $0x1, %edi
movl $0x5, %esi
callq 0x7897
movq 0xb8(%rsp), %rsi
testq %rsi, %rsi
je 0xe311
leaq 0x20(%rsp), %rdi
movl $0x235a, %edx           # imm = 0x235A
xorl %ecx, %ecx
callq 0x9de4
leaq 0x20(%rsp), %rdi
callq 0x790e
testb %al, %al
je 0xe311
leaq 0x38(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0xa07a
leaq 0x48(%rsp), %rbx
movq -0x10(%rbx), %rsi
leaq 0x5a3f(%rip), %rdi      # 0x13d19
xorl %eax, %eax
callq 0x3050
movq -0x10(%rbx), %rdi
cmpq %rbx, %rdi
je 0xe2ef
callq 0x33d0
movzwl 0x30(%rsp), %eax
movw %ax, 0x10(%rsp)
movups 0x20(%rsp), %xmm0
movups %xmm0, (%rsp)
movl $0x2, %edi
movl $0x5, %esi
callq 0x7897
cmpl $0x0, 0x84(%rsp)
je 0xe349
leaq 0x5f26(%rip), %rdi      # 0x14248
callq 0x35b0
leaq 0xe086(%rip), %rax      # 0x1c3b4
movl $0xe9fdc490, (%rax)     # imm = 0xE9FDC490
leaq 0xe355(%rip), %rax      # 0x1c690
movq %rax, 0xe076(%rip)      # 0x1c3b8
movb $0x1, 0xe137(%rip)      # 0x1c480
movq 0x98(%rsp), %r14
testq %r14, %r14
jne 0xe362
leaq 0x5efa(%rip), %rdi      # 0x14257
callq 0x35b0
testq %r14, %r14
je 0xe376
cmpq $0x0, 0xa0(%rsp)
je 0xe675
testq %r14, %r14
je 0xe38a
cmpq $0x0, 0x90(%rsp)
je 0xe67a
leaq 0x574a(%rip), %rdi      # 0x13adb
leaq 0x4ebb(%rip), %rsi      # 0x13253
callq 0x3460
testq %rax, %rax
je 0xe44c
movq %rax, %rbx
leaq 0x59c9(%rip), %rdi      # 0x13d79
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 0xe0ad(%rip), %rsi      # 0x1c488
callq 0xf25a
cmpl $0x0, 0x88(%rsp)
je 0xe3f6
leaq 0xe1ef(%rip), %rdi      # 0x1c5e0
callq 0xcbf8
cmpl $0x0, 0x8c(%rsp)
sete %cl
leaq 0xe080(%rip), %rdx      # 0x1c488
movq 0x58(%rdx), %rax
addq $0x48, %rdx
cmpq %rdx, %rax
sete %dl
orb %cl, %dl
jne 0xe436
leaq 0xe0af(%rip), %rbx      # 0x1c4d0
movq $0x0, 0x60(%rax)
movq %rax, %rdi
callq 0x32c0
cmpq %rbx, %rax
jne 0xe421
leaq 0x5e46(%rip), %rdi      # 0x14283
callq 0x35b0
leaq 0x38(%rsp), %rdi
callq 0xfeee
testq %r14, %r14
je 0xe565
movl 0x7c(%rsp), %r8d
movl 0x80(%rsp), %esi
movq 0xa0(%rsp), %rdx
movq 0x98(%rsp), %rcx
leaq 0x5918(%rip), %rdi      # 0x13d90
xorl %eax, %eax
callq 0x3050
movq 0xe18a(%rip), %rax      # 0x1c610
cmpq %rax, 0xe18b(%rip)      # 0x1c618
je 0xe496
movq %rax, 0xe182(%rip)      # 0x1c618
cmpl $0x0, 0x80(%rsp)
jle 0xe559
xorl %ebx, %ebx
leaq 0x78(%rsp), %r14
leaq 0x38(%rsp), %r12
leaq -0xbca(%rip), %r13      # 0xd8ed
leaq 0x20(%rsp), %rbp
movl $0xa8, %edi
callq 0x3400
movq %rax, %r15
movq %rax, %rdi
movq %r14, %rsi
movl %ebx, %edx
callq 0xf2ea
movq %r15, 0x38(%rsp)
movq 0xe136(%rip), %rsi      # 0x1c618
cmpq 0xe137(%rip), %rsi      # 0x1c620
je 0xe4f8
movq %r15, (%rsi)
addq $0x8, 0xe122(%rip)      # 0x1c618
jmp 0xe507
leaq 0xe111(%rip), %rdi      # 0x1c610
movq %r12, %rdx
callq 0x12602
movq 0xe102(%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 0xe4bc
leaq 0x5d23(%rip), %rdi      # 0x14283
callq 0x35b0
leaq 0x5856(%rip), %rdi      # 0x13dc2
xorl %r13d, %r13d
xorl %eax, %eax
callq 0x3050
leaq -0x730(%rip), %rdx      # 0xde4d
leaq 0x100(%rsp), %rdi
xorl %esi, %esi
xorl %ecx, %ecx
callq 0x36a0
leaq 0x5cee(%rip), %rdi      # 0x14283
callq 0x35b0
movl 0x78(%rsp), %esi
leaq 0x5830(%rip), %rdi      # 0x13dd5
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 0xe5fe
leaq -0x1118(%rip), %rbx     # 0xd4bc
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 0xe5e3
leaq 0x38(%rsp), %rdi
callq 0x3620
leaq 0x5c74(%rip), %rdi      # 0x14283
callq 0x35b0
leaq -0x919(%rip), %rdx      # 0xdd02
leaq 0xf0(%rsp), %rdi
xorl %esi, %esi
xorl %ecx, %ecx
callq 0x36a0
leaq -0xd0e(%rip), %rdx      # 0xd925
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 0x10436
xorl %eax, %eax
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x3787
callq 0x37ac
jmp 0xe6b7
jmp 0xe6b7
jmp 0xe6b7
jmp 0xe696
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0xfeee
jmp 0xe6ba
movq %rax, %rdi
callq 0x50b0
jmp 0xe6b7
jmp 0xe6b7
jmp 0xe6b7
jmp 0xe6b7
jmp 0xe6b7
movq %rax, %rbx
movq %r15, %rdi
callq 0x33d0
jmp 0xe6ba
jmp 0xe6b7
movq %rax, %rbx
leaq 0xc0(%rsp), %rdi
callq 0x10436
movq %rbx, %rdi
callq 0x3650
nop