// File: /workspace/github_cpp_makefile_star2_O1/jBlinden[P]private-codis/./socket.h
// Function: CSocket::Receive(void*, int, int)
int Receive(void* pBuf, int nLen, int nFlags = 0) {
    struct timespec start, stop;
    clock_gettime( CLOCK_REALTIME, &start);

    bytesReceived += nLen;

    char* p = (char*) pBuf;
    int n = nLen;
    int ret = 0;
    while (n > 0) {
      ret = recv(m_hSock, p, n, 0);
      if (ret < 0) {
        if (errno == EAGAIN) {
          cout << "socket recv eror: EAGAIN" << endl;
          usleep(200);
          continue;
        } else {
          cout << "socket recv error: " << errno << endl;
          
          clock_gettime( CLOCK_REALTIME, &stop);
          networkTime += (stop.tv_sec - start.tv_sec) * BILLION + stop.tv_nsec - start.tv_nsec;
          return ret;
        }
      } else if (ret == 0) {
        clock_gettime( CLOCK_REALTIME, &stop);
        networkTime += (stop.tv_sec - start.tv_sec) * BILLION + stop.tv_nsec - start.tv_nsec;
        return ret;
      }
      p += ret;
      n -= ret;
    }
    clock_gettime( CLOCK_REALTIME, &stop);
    networkTime += (stop.tv_sec - start.tv_sec) * BILLION + stop.tv_nsec - start.tv_nsec;
    return nLen;
  }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x18(%rsp), %rsi
xorl %edi, %edi
callq 0x21f0
movl %ebp, 0xc(%rsp)
movslq %ebp, %rax
movq %rbx, 0x10(%rsp)
addq %rax, 0x10(%rbx)
testl %eax, %eax
setg %bl
jle 0x55b6
movq 0x3ac4(%rip), %r15      # 0x8fd8
movl 0xc(%rsp), %eax
movl %eax, %r13d
movl %r13d, %r13d
movq 0x10(%rsp), %rax
movl (%rax), %edi
movq %r14, %rsi
movq %r13, %rdx
xorl %ecx, %ecx
callq 0x20d0
movq %rax, %rbp
testl %ebp, %ebp
jns 0x5593
callq 0x2050
cmpl $0xb, (%rax)
jne 0x55d3
movl $0x18, %edx
movq %r15, %rdi
leaq 0xdcd(%rip), %rsi       # 0x6323
callq 0x22c0
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x2230
movsbl %al, %esi
movq %r15, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2170
movl $0xc8, %edi
callq 0x2330
testb $0x1, %bl
jne 0x551e
jmp 0x55b6
je 0x566b
movl %ebp, %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
addq %rax, %r14
movl %r13d, %eax
subl %ebp, %eax
testl %eax, %eax
setg %bl
subl %ebp, %r13d
jg 0x551b
leaq 0x28(%rsp), %r14
xorl %edi, %edi
movq %r14, %rsi
callq 0x21f0
movq (%r14), %rax
subq 0x18(%rsp), %rax
movl 0xc(%rsp), %ebx
jmp 0x5640
movq %rax, %r12
movq 0x39fb(%rip), %r14      # 0x8fd8
leaq 0xd58(%rip), %rsi       # 0x633c
movl $0x13, %edx
movq %r14, %rdi
callq 0x22c0
movl (%r12), %esi
movq %r14, %rdi
callq 0x23e0
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2230
movsbl %al, %esi
movq %r14, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2170
leaq 0x28(%rsp), %r14
xorl %edi, %edi
movq %r14, %rsi
callq 0x21f0
movq (%r14), %rax
subq 0x18(%rsp), %rax
movl %ebp, %ebx
imulq $0x3b9aca00, %rax, %rax # imm = 0x3B9ACA00
addq 0x30(%rsp), %rax
subq 0x20(%rsp), %rax
movq 0x10(%rsp), %rcx
addq %rax, 0x18(%rcx)
movl %ebx, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %ebx, %ebx
leaq 0x28(%rsp), %r14
xorl %edi, %edi
movq %r14, %rsi
callq 0x21f0
movq (%r14), %rax
subq 0x18(%rsp), %rax
jmp 0x5640