// File: tenup-coin[P]seeder/bitcoin.cpp
// Function: CNode::Run()
bool Run() {
    bool res = true;
    if (!ConnectSocket(you, sock)) return false;
    PushVersion();
    Send();
    int64 now;
    while (now = time(NULL), ban == 0 && (doneAfter == 0 || doneAfter > now) && sock != INVALID_SOCKET) {
      char pchBuf[0x10000];
      fd_set set;
      FD_ZERO(&set);
      FD_SET(sock,&set);
      struct timeval wa;
      if (doneAfter) {
        wa.tv_sec = doneAfter - now;
        wa.tv_usec = 0;
      } else {
        wa.tv_sec = GetTimeout();
        wa.tv_usec = 0;
      }
      int ret = select(sock+1, &set, NULL, &set, &wa);
      if (ret != 1) {
        if (!doneAfter) res = false;
        break;
      }
      int nBytes = recv(sock, pchBuf, sizeof(pchBuf), 0);
      int nPos = vRecv.size();
      if (nBytes > 0) {
        vRecv.resize(nPos + nBytes);
        memcpy(&vRecv[nPos], pchBuf, nBytes);
      } else if (nBytes == 0) {
         //printf("%s: BAD (connection closed prematurely)\n", ToString(you).c_str());
        res = false;
        break;
      } else {
         //printf("%s: BAD (connection error)\n", ToString(you).c_str());
        res = false;
        break;
      }
      ProcessMessages();
      Send();
    }
    if (sock == INVALID_SOCKET) res = false;
    close(sock);
    sock = INVALID_SOCKET;
    return (ban == 0) && res;
  }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x100e0, %rsp          # imm = 0x100E0
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rsi
movq %rsi, -0x100d8(%rbp)
movb $0x1, -0x11(%rbp)
movq %rsi, %rdi
addq $0xa8, %rdi
leaq 0x437d9(%rip), %rax     # 0x4a4a8
movl (%rax), %edx
callq 0x10470
testb $0x1, %al
jne 0x6ce3
movb $0x0, -0x1(%rbp)
jmp 0x6f9c
movq -0x100d8(%rbp), %rdi
callq 0x7580
movq -0x100d8(%rbp), %rdi
callq 0x77a0
xorl %eax, %eax
movl %eax, %edi
callq 0x44a0
movq -0x100d8(%rbp), %rcx
movq %rax, -0x20(%rbp)
xorl %eax, %eax
cmpl $0x0, 0x98(%rcx)
movb %al, -0x100d9(%rbp)
jne 0x6d60
movq -0x100d8(%rbp), %rax
cmpq $0x0, 0xa0(%rax)
je 0x6d4d
movq -0x100d8(%rbp), %rax
movq 0xa0(%rax), %rcx
xorl %eax, %eax
cmpq -0x20(%rbp), %rcx
movb %al, -0x100d9(%rbp)
jle 0x6d60
movq -0x100d8(%rbp), %rax
cmpl $-0x1, (%rax)
setne %al
movb %al, -0x100d9(%rbp)
movb -0x100d9(%rbp), %al
testb $0x1, %al
jne 0x6d6f
jmp 0x6f4c
jmp 0x6d71
leaq -0x100a0(%rbp), %rax
movq %rax, -0x100b0(%rbp)
movl $0x0, -0x100a4(%rbp)
movl -0x100a4(%rbp), %eax
cmpq $0x10, %rax
jae 0x6dbb
movq -0x100b0(%rbp), %rax
movl -0x100a4(%rbp), %ecx
movq $0x0, (%rax,%rcx,8)
movl -0x100a4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x100a4(%rbp)
jmp 0x6d89
jmp 0x6dbd
movq -0x100d8(%rbp), %rax
movl (%rax), %ecx
andl $0x3f, %ecx
movl %ecx, %ecx
movl $0x1, %edx
shlq %cl, %rdx
movl (%rax), %ecx
shrl $0x6, %ecx
movl %ecx, %ecx
orq -0x100a0(%rbp,%rcx,8), %rdx
movq %rdx, -0x100a0(%rbp,%rcx,8)
cmpq $0x0, 0xa0(%rax)
je 0x6e1a
movq -0x100d8(%rbp), %rax
movq 0xa0(%rax), %rax
subq -0x20(%rbp), %rax
movq %rax, -0x100c0(%rbp)
movq $0x0, -0x100b8(%rbp)
jmp 0x6e3a
movq -0x100d8(%rbp), %rdi
callq 0x7890
cltq
movq %rax, -0x100c0(%rbp)
movq $0x0, -0x100b8(%rbp)
movq -0x100d8(%rbp), %rax
movl (%rax), %edi
addl $0x1, %edi
leaq -0x100a0(%rbp), %rcx
xorl %eax, %eax
movl %eax, %edx
leaq -0x100c0(%rbp), %r8
movq %rcx, %rsi
callq 0x44c0
movl %eax, -0x100c4(%rbp)
cmpl $0x1, -0x100c4(%rbp)
je 0x6e89
movq -0x100d8(%rbp), %rax
cmpq $0x0, 0xa0(%rax)
jne 0x6e84
movb $0x0, -0x11(%rbp)
jmp 0x6f4c
movq -0x100d8(%rbp), %rax
movl (%rax), %edi
leaq -0x10020(%rbp), %rsi
movl $0x10000, %edx          # imm = 0x10000
xorl %ecx, %ecx
callq 0x4180
movq -0x100d8(%rbp), %rdi
movl %eax, -0x100c8(%rbp)
addq $0x30, %rdi
callq 0x78d0
movl %eax, -0x100cc(%rbp)
cmpl $0x0, -0x100c8(%rbp)
jle 0x6f1a
movq -0x100d8(%rbp), %rdi
addq $0x30, %rdi
movl -0x100cc(%rbp), %eax
addl -0x100c8(%rbp), %eax
movslq %eax, %rsi
xorl %edx, %edx
callq 0x7900
movq -0x100d8(%rbp), %rdi
addq $0x30, %rdi
movslq -0x100cc(%rbp), %rsi
callq 0x7940
movq %rax, %rdi
leaq -0x10020(%rbp), %rsi
movslq -0x100c8(%rbp), %rdx
callq 0x4420
jmp 0x6f2f
cmpl $0x0, -0x100c8(%rbp)
jne 0x6f29
movb $0x0, -0x11(%rbp)
jmp 0x6f4c
movb $0x0, -0x11(%rbp)
jmp 0x6f4c
movq -0x100d8(%rbp), %rdi
callq 0x7970
movq -0x100d8(%rbp), %rdi
callq 0x77a0
jmp 0x6cfb
movq -0x100d8(%rbp), %rax
cmpl $-0x1, (%rax)
jne 0x6f5c
movb $0x0, -0x11(%rbp)
movq -0x100d8(%rbp), %rax
movl (%rax), %edi
callq 0x48c0
movq -0x100d8(%rbp), %rcx
movl $0xffffffff, (%rcx)     # imm = 0xFFFFFFFF
xorl %eax, %eax
cmpl $0x0, 0x98(%rcx)
movb %al, -0x100da(%rbp)
jne 0x6f91
movb -0x11(%rbp), %al
movb %al, -0x100da(%rbp)
movb -0x100da(%rbp), %al
andb $0x1, %al
movb %al, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x100e0, %rsp          # imm = 0x100E0
popq %rbp
retq
nopw (%rax,%rax)