// File: tenup-coin[P]seeder/main.cpp
// Function: ThreadDumper
void* ThreadDumper(void*) {
  int count = 0;
  do {
    Sleep(100000 << count); // First 100s, than 200s, 400s, 800s, 1600s, and then 3200s forever
    if (count < 5)
        count++;
    {
      vector<CAddrReport> v = db.GetAll();
      sort(v.begin(), v.end(), StatCompare);
      FILE *f = fopen("dnsseed.dat.new","w+");
      if (f) {
        {
          CAutoFile cf(f);
          cf << db;
        }
        rename("dnsseed.dat.new", "dnsseed.dat");
      }
      FILE *d = fopen("dnsseed.dump", "w");
      fprintf(d, "# address                                        good  lastSuccess    %%(2h)   %%(8h)   %%(1d)   %%(7d)  %%(30d)  blocks      svcs  version\n");
      double stat[5]={0,0,0,0,0};
      for (vector<CAddrReport>::const_iterator it = v.begin(); it < v.end(); it++) {
        CAddrReport rep = *it;
        fprintf(d, "%-47s  %4d  %11" PRId64 "  %6.2f%% %6.2f%% %6.2f%% %6.2f%% %6.2f%%  %6i  %08" PRIx64 "  %5i \"%s\"\n", rep.ip.ToString().c_str(), (int)rep.fGood, rep.lastSuccess, 100.0*rep.uptime[0], 100.0*rep.uptime[1], 100.0*rep.uptime[2], 100.0*rep.uptime[3], 100.0*rep.uptime[4], rep.blocks, rep.services, rep.clientVersion, rep.clientSubVersion.c_str());
        stat[0] += rep.uptime[0];
        stat[1] += rep.uptime[1];
        stat[2] += rep.uptime[2];
        stat[3] += rep.uptime[3];
        stat[4] += rep.uptime[4];
      }
      fclose(d);
      FILE *ff = fopen("dnsstats.log", "a");
      fprintf(ff, "%llu %g %g %g %g %g\n", (unsigned long long)(time(NULL)), stat[0], stat[1], stat[2], stat[3], stat[4]);
      fclose(ff);
    }
  } while(1);
  return nullptr;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x210, %rsp            # imm = 0x210
movq %rdi, -0x8(%rbp)
movl $0x0, -0xc(%rbp)
movl -0xc(%rbp), %ecx
movl $0x186a0, %edi          # imm = 0x186A0
shll %cl, %edi
callq 0x22b60
cmpl $0x5, -0xc(%rbp)
jge 0x230b4
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
leaq 0x274ed(%rip), %rsi     # 0x4a5a8
leaq -0x28(%rbp), %rdi
movq %rdi, -0x170(%rbp)
callq 0x24f10
movq -0x170(%rbp), %rdi
callq 0x25150
movq -0x170(%rbp), %rdi
movq %rax, -0x30(%rbp)
callq 0x25180
movq %rax, -0x38(%rbp)
movq -0x30(%rbp), %rdi
movq -0x38(%rbp), %rsi
leaq -0x11a(%rip), %rdx      # 0x22fe0
callq 0x25100
jmp 0x23101
leaq 0x10a60(%rip), %rdi     # 0x33b68
leaq 0x10a69(%rip), %rsi     # 0x33b78
callq 0x4590
movq %rax, -0x178(%rbp)
jmp 0x2311d
movq -0x178(%rbp), %rax
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
je 0x231a3
movq -0x50(%rbp), %rsi
leaq -0x68(%rbp), %rdi
movl $0x2, %edx
movl $0x11500, %ecx          # imm = 0x11500
callq 0x251b0
jmp 0x23148
leaq 0x27459(%rip), %rsi     # 0x4a5a8
leaq -0x68(%rbp), %rdi
callq 0x25210
jmp 0x2315a
leaq -0x68(%rbp), %rdi
callq 0x252c0
leaq 0x109fe(%rip), %rdi     # 0x33b68
leaq 0x10a0a(%rip), %rsi     # 0x33b7b
callq 0x42e0
jmp 0x231a3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x23547
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x252c0
jmp 0x23547
leaq 0x109dd(%rip), %rdi     # 0x33b87
leaq 0x109c5(%rip), %rsi     # 0x33b76
callq 0x4590
movq %rax, -0x180(%rbp)
jmp 0x231bf
movq -0x180(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rdi
leaq 0x109bf(%rip), %rsi     # 0x33b94
movb $0x0, %al
callq 0x4700
leaq -0xa0(%rbp), %rdi
xorl %esi, %esi
movl $0x28, %edx
callq 0x4270
leaq -0x28(%rbp), %rdi
callq 0x25150
movq %rax, -0xb0(%rbp)
leaq -0xa8(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x252f0
leaq -0x28(%rbp), %rdi
callq 0x25180
movq %rax, -0xb8(%rbp)
leaq -0xa8(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
callq 0x25330
testb $0x1, %al
jne 0x2323e
jmp 0x23490
leaq -0xa8(%rbp), %rdi
callq 0x25370
movq %rax, %rsi
leaq -0x138(%rbp), %rdi
callq 0x25390
jmp 0x2325b
movq -0x70(%rbp), %rax
movq %rax, -0x188(%rbp)
leaq -0x158(%rbp), %rdi
leaq -0x138(%rbp), %rsi
callq 0x15040
jmp 0x2327b
leaq -0x158(%rbp), %rdi
callq 0x41e0
movq %rax, -0x1e0(%rbp)
movb -0xc8(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x1d4(%rbp)
movq -0xd0(%rbp), %rax
movq %rax, -0x1d0(%rbp)
movsd 0x107b3(%rip), %xmm0    # 0x33a68
mulsd -0x118(%rbp), %xmm0
movsd %xmm0, -0x1c8(%rbp)
movsd 0x1079b(%rip), %xmm0    # 0x33a68
mulsd -0x110(%rbp), %xmm0
movsd %xmm0, -0x1c0(%rbp)
movsd 0x10783(%rip), %xmm0    # 0x33a68
mulsd -0x108(%rbp), %xmm0
movsd %xmm0, -0x1b8(%rbp)
movsd 0x1076b(%rip), %xmm0    # 0x33a68
mulsd -0x100(%rbp), %xmm0
movsd %xmm0, -0x1b0(%rbp)
movsd 0x10753(%rip), %xmm0    # 0x33a68
mulsd -0xf8(%rbp), %xmm0
movsd %xmm0, -0x1a8(%rbp)
movl -0x120(%rbp), %eax
movl %eax, -0x19c(%rbp)
movq -0xc0(%rbp), %rax
movq %rax, -0x198(%rbp)
movl -0x124(%rbp), %eax
movl %eax, -0x18c(%rbp)
leaq -0x138(%rbp), %rdi
addq $0x48, %rdi
callq 0x41e0
movq -0x188(%rbp), %rdi
movq -0x1e0(%rbp), %rdx
movl -0x1d4(%rbp), %ecx
movq -0x1d0(%rbp), %r8
movsd -0x1c8(%rbp), %xmm0
movsd -0x1c0(%rbp), %xmm1
movsd -0x1b8(%rbp), %xmm2
movsd -0x1b0(%rbp), %xmm3
movsd -0x1a8(%rbp), %xmm4
movl -0x19c(%rbp), %r9d
movq -0x198(%rbp), %r11
movl -0x18c(%rbp), %r10d
leaq 0x10867(%rip), %rsi     # 0x33c21
movq %r11, (%rsp)
movl %r10d, 0x8(%rsp)
movq %rax, 0x10(%rsp)
movb $0x5, %al
callq 0x4700
leaq -0x158(%rbp), %rdi
callq 0x42f0
movsd -0x118(%rbp), %xmm0
addsd -0xa0(%rbp), %xmm0
movsd %xmm0, -0xa0(%rbp)
movsd -0x110(%rbp), %xmm0
addsd -0x98(%rbp), %xmm0
movsd %xmm0, -0x98(%rbp)
movsd -0x108(%rbp), %xmm0
addsd -0x90(%rbp), %xmm0
movsd %xmm0, -0x90(%rbp)
movsd -0x100(%rbp), %xmm0
addsd -0x88(%rbp), %xmm0
movsd %xmm0, -0x88(%rbp)
movsd -0xf8(%rbp), %xmm0
addsd -0x80(%rbp), %xmm0
movsd %xmm0, -0x80(%rbp)
leaq -0x138(%rbp), %rdi
callq 0x25400
leaq -0xa8(%rbp), %rdi
xorl %esi, %esi
callq 0x25420
movq %rax, -0x160(%rbp)
jmp 0x23212
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x138(%rbp), %rdi
callq 0x25400
jmp 0x23547
movq -0x70(%rbp), %rdi
callq 0x44d0
jmp 0x2349b
leaq 0x107d1(%rip), %rdi     # 0x33c73
leaq 0xfd14(%rip), %rsi      # 0x331bd
callq 0x4590
movq %rax, -0x1e8(%rbp)
jmp 0x234b7
movq -0x1e8(%rbp), %rax
movq %rax, -0x168(%rbp)
movq -0x168(%rbp), %rax
movq %rax, -0x1f0(%rbp)
xorl %eax, %eax
movl %eax, %edi
callq 0x44a0
movq -0x1f0(%rbp), %rdi
movq %rax, %rdx
movsd -0xa0(%rbp), %xmm0
movsd -0x98(%rbp), %xmm1
movsd -0x90(%rbp), %xmm2
movsd -0x88(%rbp), %xmm3
movsd -0x80(%rbp), %xmm4
leaq 0x1076e(%rip), %rsi     # 0x33c80
movb $0x5, %al
callq 0x4700
movq -0x168(%rbp), %rdi
callq 0x44d0
jmp 0x23527
leaq -0x28(%rbp), %rdi
callq 0x25460
movb $0x1, %al
testb $0x1, %al
jne 0x23096
jmp 0x2353c
xorl %eax, %eax
addq $0x210, %rsp            # imm = 0x210
popq %rbp
retq
leaq -0x28(%rbp), %rdi
callq 0x25460
movq -0x40(%rbp), %rdi
callq 0x47f0
nopl (%rax)