// File: /workspace/github_cpp_makefile_star2_O2/CoinBlack[P]blackcoin-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 read_set, except_set;
      FD_ZERO(&read_set);
      FD_ZERO(&except_set);
      FD_SET(sock,&read_set);
      FD_SET(sock,&except_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, &read_set, NULL, &except_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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x10118, %rsp          # imm = 0x10118
movq %rdi, %rbx
addq $0xa8, %rdi
leaq 0x18972(%rip), %rax     # 0x1d410
movl (%rax), %edx
movq %rbx, %rsi
callq 0x735e
testb %al, %al
je 0x4c06
movq %rbx, %rdi
callq 0x4d10
movq %rbx, %rdi
callq 0x4e74
leaq 0x30(%rbx), %r14
movq %rsp, %r13
leaq 0x110(%rsp), %rbp
xorl %edi, %edi
callq 0x33c0
movb $0x1, %r12b
cmpl $0x0, 0x98(%rbx)
jne 0x4c16
movq 0xa0(%rbx), %rsi
testq %rsi, %rsi
setne %cl
movq %rsi, %rdx
subq %rax, %rdx
setle %al
testb %al, %cl
jne 0x4c16
movl (%rbx), %ecx
cmpl $-0x1, %ecx
je 0x4c16
xorl %eax, %eax
cmpq $0x10, %rax
je 0x4b25
andq $0x0, 0x90(%rsp,%rax,8)
incq %rax
jmp 0x4b11
xorl %eax, %eax
cmpq $0x10, %rax
je 0x4b38
andq $0x0, 0x10(%rsp,%rax,8)
incq %rax
jmp 0x4b27
pushq $0x1
popq %rax
shlq %cl, %rax
movl %ecx, %edi
shrl $0x6, %edi
orq %rax, 0x90(%rsp,%rdi,8)
orq %rax, 0x10(%rsp,%rdi,8)
testq %rsi, %rsi
je 0x4b61
movq %rdx, (%rsp)
andq $0x0, 0x8(%rsp)
jmp 0x4b77
movq %rbx, %rdi
callq 0x4ece
cltq
movq %rax, (%rsp)
andq $0x0, 0x8(%rsp)
movl (%rbx), %ecx
incl %ecx
movl %ecx, %edi
leaq 0x90(%rsp), %rsi
xorl %edx, %edx
leaq 0x10(%rsp), %rcx
movq %r13, %r8
callq 0x33e0
cmpl $0x1, %eax
jne 0x4c0a
movl (%rbx), %edi
xorl %r12d, %r12d
movl $0x10000, %edx          # imm = 0x10000
movq %rbp, %rsi
xorl %ecx, %ecx
callq 0x3130
movq %rax, %r15
testl %r15d, %r15d
jle 0x4c16
movl 0x48(%rbx), %eax
addq 0x30(%rbx), %rax
movq 0x38(%rbx), %r12
subq %rax, %r12
leal (%r12,%r15), %eax
movslq %eax, %rsi
movq %r14, %rdi
xorl %edx, %edx
callq 0x4ee8
movslq %r12d, %rax
movl 0x48(%rbx), %edi
addq 0x30(%rbx), %rdi
addq %rax, %rdi
andl $0x7fffffff, %r15d      # imm = 0x7FFFFFFF
movq %rbp, %rsi
movq %r15, %rdx
callq 0x3350
movq %rbx, %rdi
callq 0x4f00
movq %rbx, %rdi
callq 0x4e74
jmp 0x4acf
xorl %eax, %eax
jmp 0x4c37
cmpq $0x0, 0xa0(%rbx)
setne %r12b
movl (%rbx), %edi
cmpl $-0x1, %edi
setne %bpl
callq 0x37a0
orl $-0x1, (%rbx)
cmpl $0x0, 0x98(%rbx)
sete %al
andb %bpl, %al
andb %r12b, %al
addq $0x10118, %rsp          # imm = 0x10118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop