// File: tenup-coin[P]seeder/bitcoin.cpp
// Function: CNode::ProcessMessage(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, CDataStream&)
bool ProcessMessage(string strCommand, CDataStream& vRecv) {
    //printf("%s: RECV %s\n", ToString(you).c_str(), strCommand.c_str());
    if (strCommand == "version") {
      int64 nTime;
      CAddress addrMe;
      CAddress addrFrom;
      uint64 nNonce = 1;
      vRecv >> nVersion >> you.nServices >> nTime >> addrMe;
      if (nVersion == 10300) nVersion = 300;
      if (nVersion >= 106 && !vRecv.empty())
        vRecv >> addrFrom >> nNonce;
      if (nVersion >= 106 && !vRecv.empty())
        vRecv >> strSubVer;
      if (nVersion >= 209 && !vRecv.empty())
        vRecv >> nStartingHeight;
      
      if (nVersion >= 209) {
        BeginMessage("verack");
        EndMessage();
      }
      vSend.SetVersion(min(nVersion, PROTOCOL_VERSION));
      if (nVersion < 209) {
        this->vRecv.SetVersion(min(nVersion, PROTOCOL_VERSION));
        GotVersion();
      }
      return false;
    }
    
    if (strCommand == "verack") {
      this->vRecv.SetVersion(min(nVersion, PROTOCOL_VERSION));
      GotVersion();
      return false;
    }
    
    if (strCommand == "addr" && vAddr) {
      vector<CAddress> vAddrNew;
      vRecv >> vAddrNew;
       //printf("%s: got %i addresses\n", ToString(you).c_str(), (int)vAddrNew.size());
      int64 now = time(NULL);
      vector<CAddress>::iterator it = vAddrNew.begin();
      if (vAddrNew.size() > 1) {
        if (doneAfter == 0 || doneAfter > now + 1) doneAfter = now + 1;
      }
      while (it != vAddrNew.end()) {
        CAddress &addr = *it;
        //printf("%s: got address %s\n", ToString(you).c_str(), addr.ToString().c_str(), (int)(vAddr->size()));
        it++;
        if (addr.nTime <= 100000000 || addr.nTime > now + 600)
          addr.nTime = now - 5 * 86400;
        if (addr.nTime > now - 604800)
          vAddr->push_back(addr);
        //printf("%s: added address %s (#%i)\n", ToString(you).c_str(), addr.ToString().c_str(), (int)(vAddr->size()));
        if (vAddr->size() > 1000) {doneAfter = 1; return true; }
      }
      return false;
    }
    
    return false;
  }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x110, %rsp            # imm = 0x110
movq %rsi, -0xf0(%rbp)
movq %rdi, %rax
movq -0xf0(%rbp), %rdi
movq %rdi, -0xe8(%rbp)
movq %rax, -0x10(%rbp)
movq %rdi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0xe0(%rbp)
leaq 0x27a5b(%rip), %rsi     # 0x3302c
callq 0xdba0
testb $0x1, %al
jne 0xb5df
jmp 0xb7ac
leaq -0x50(%rbp), %rdi
callq 0x188a0
leaq -0x78(%rbp), %rdi
callq 0x188a0
movq -0xe0(%rbp), %rsi
movq $0x1, -0x80(%rbp)
movq -0x20(%rbp), %rdi
addq $0x60, %rsi
callq 0xdbd0
movq -0xe0(%rbp), %rsi
movq %rax, %rdi
addq $0xa8, %rsi
addq $0x18, %rsi
callq 0xdc10
movq %rax, %rdi
leaq -0x28(%rbp), %rsi
callq 0xdc50
movq %rax, %rdi
leaq -0x50(%rbp), %rsi
callq 0xdc90
movq -0xe0(%rbp), %rax
cmpl $0x283c, 0x60(%rax)     # imm = 0x283C
jne 0xb65d
movq -0xe0(%rbp), %rax
movl $0x12c, 0x60(%rax)      # imm = 0x12C
movq -0xe0(%rbp), %rax
cmpl $0x6a, 0x60(%rax)
jl 0xb690
movq -0x20(%rbp), %rdi
callq 0xa300
testb $0x1, %al
jne 0xb690
movq -0x20(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0xdc90
movq %rax, %rdi
leaq -0x80(%rbp), %rsi
callq 0xdc10
movq -0xe0(%rbp), %rax
cmpl $0x6a, 0x60(%rax)
jl 0xb6be
movq -0x20(%rbp), %rdi
callq 0xa300
testb $0x1, %al
jne 0xb6be
movq -0xe0(%rbp), %rsi
movq -0x20(%rbp), %rdi
addq $0x68, %rsi
callq 0xdcd0
movq -0xe0(%rbp), %rax
cmpl $0xd1, 0x60(%rax)
jl 0xb6f2
movq -0x20(%rbp), %rdi
callq 0xa300
testb $0x1, %al
jne 0xb6f2
movq -0xe0(%rbp), %rsi
movq -0x20(%rbp), %rdi
addq $0x88, %rsi
callq 0xdbd0
movq -0xe0(%rbp), %rax
cmpl $0xd1, 0x60(%rax)
jl 0xb721
movq -0xe0(%rbp), %rdi
leaq 0x27af9(%rip), %rsi     # 0x33209
callq 0x8010
movq -0xe0(%rbp), %rdi
callq 0x81d0
movq -0xe0(%rbp), %rdi
movq %rdi, %rax
addq $0x8, %rax
movq %rax, -0xf8(%rbp)
addq $0x60, %rdi
leaq 0x27b2f(%rip), %rsi     # 0x33270
callq 0xdd10
movq -0xf8(%rbp), %rdi
movl (%rax), %esi
callq 0x7100
movq -0xe0(%rbp), %rax
cmpl $0xd1, 0x60(%rax)
jge 0xb7a3
movq -0xe0(%rbp), %rdi
movq %rdi, %rax
addq $0x30, %rax
movq %rax, -0x100(%rbp)
addq $0x60, %rdi
leaq 0x27aec(%rip), %rsi     # 0x33270
callq 0xdd10
movq -0x100(%rbp), %rdi
movl (%rax), %esi
callq 0x7100
movq -0xe0(%rbp), %rdi
callq 0xdd50
movb $0x0, -0x1(%rbp)
jmp 0xba43
movq -0xe8(%rbp), %rdi
leaq 0x27a4f(%rip), %rsi     # 0x33209
callq 0xdba0
testb $0x1, %al
jne 0xb7c5
jmp 0xb80d
movq -0xe0(%rbp), %rdi
movq %rdi, %rax
addq $0x30, %rax
movq %rax, -0x108(%rbp)
addq $0x60, %rdi
leaq 0x27a8b(%rip), %rsi     # 0x33270
callq 0xdd10
movq -0x108(%rbp), %rdi
movl (%rax), %esi
callq 0x7100
movq -0xe0(%rbp), %rdi
callq 0xdd50
movb $0x0, -0x1(%rbp)
jmp 0xba43
movq -0xe8(%rbp), %rdi
leaq 0x27a1b(%rip), %rsi     # 0x33236
callq 0xdba0
testb $0x1, %al
jne 0xb829
jmp 0xba3f
movq -0xe0(%rbp), %rax
cmpq $0x0, 0x90(%rax)
je 0xba3f
leaq -0x98(%rbp), %rdi
movq %rdi, -0x110(%rbp)
callq 0xdde0
movq -0x110(%rbp), %rsi
movq -0x20(%rbp), %rdi
callq 0xde00
jmp 0xb863
xorl %eax, %eax
movl %eax, %edi
callq 0x44a0
movq %rax, -0xb0(%rbp)
leaq -0x98(%rbp), %rdi
callq 0xde40
movq %rax, -0xb8(%rbp)
leaq -0x98(%rbp), %rdi
callq 0xde70
cmpq $0x1, %rax
jbe 0xb907
movq -0xe0(%rbp), %rax
cmpq $0x0, 0xa0(%rax)
je 0xb8c7
movq -0xe0(%rbp), %rax
movq 0xa0(%rax), %rax
movq -0xb0(%rbp), %rcx
addq $0x1, %rcx
cmpq %rcx, %rax
jle 0xb905
movq -0xe0(%rbp), %rax
movq -0xb0(%rbp), %rcx
addq $0x1, %rcx
movq %rcx, 0xa0(%rax)
jmp 0xb905
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
leaq -0x98(%rbp), %rdi
callq 0xdfe0
jmp 0xba51
jmp 0xb907
jmp 0xb909
leaq -0x98(%rbp), %rdi
callq 0xdee0
movq %rax, -0xc0(%rbp)
leaq -0xb8(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
callq 0xdea0
testb $0x1, %al
jne 0xb938
jmp 0xba23
leaq -0xb8(%rbp), %rdi
callq 0xdf10
movq %rax, -0xc8(%rbp)
leaq -0xb8(%rbp), %rdi
xorl %esi, %esi
callq 0xdf30
movq %rax, -0xd0(%rbp)
movq -0xc8(%rbp), %rax
cmpl $0x5f5e100, 0x20(%rax)  # imm = 0x5F5E100
jbe 0xb98d
movq -0xc8(%rbp), %rax
movl 0x20(%rax), %eax
movq -0xb0(%rbp), %rcx
addq $0x258, %rcx            # imm = 0x258
cmpq %rcx, %rax
jle 0xb9a6
movq -0xb0(%rbp), %rax
subq $0x69780, %rax          # imm = 0x69780
movl %eax, %ecx
movq -0xc8(%rbp), %rax
movl %ecx, 0x20(%rax)
movq -0xc8(%rbp), %rax
movl 0x20(%rax), %eax
movq -0xb0(%rbp), %rcx
subq $0x93a80, %rcx          # imm = 0x93A80
cmpq %rcx, %rax
jle 0xb9e1
movq -0xe0(%rbp), %rax
movq 0x90(%rax), %rdi
movq -0xc8(%rbp), %rsi
callq 0xdf70
jmp 0xb9df
jmp 0xb9e1
movq -0xe0(%rbp), %rax
movq 0x90(%rax), %rdi
callq 0xde70
cmpq $0x3e8, %rax            # imm = 0x3E8
jbe 0xba1e
movq -0xe0(%rbp), %rax
movq $0x1, 0xa0(%rax)
movb $0x1, -0x1(%rbp)
movl $0x1, -0xd4(%rbp)
jmp 0xba31
jmp 0xb909
movb $0x0, -0x1(%rbp)
movl $0x1, -0xd4(%rbp)
leaq -0x98(%rbp), %rdi
callq 0xdfe0
jmp 0xba43
movb $0x0, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x110, %rsp            # imm = 0x110
popq %rbp
retq
movq -0xa0(%rbp), %rdi
callq 0x47f0
nopl (%rax)