// File: /workspace/github_cpp_makefile_star2_O1/plasma-umass[P]simplesocket/simplesocket.cpp
// Function: simplesocket::recvNBytes(void*, int, bool)
ssize_t simplesocket::recvNBytes(void* data, int size, bool lessOk){
  if (size<=0) return 0;
  int ret, nRecv = 0;
  int toRecv = size;
  do{
    if (_timeout > 0){
      ret = descriptorReady (_socketfd, _timeout);
      if (ret < 0){
	assert(errno > 0 && errno!=EINTR);
	close();
	return -errno;
      } else if (ret == 0) return (ssize_t)TIMEOUT_ERR;
    }
    if (_debug) cerr << "Descriptor ready, reading .. " << endl;
    ret = recv(_socketfd, data, toRecv, 0);
    if (_debug) cerr << "Recv returned error of .. " << ret << endl;
    if (ret<0 && errno == EINTR) continue;
    else if (ret<0) {
      assert(errno > 0);
      close();
      return -errno;
    } else if (ret == 0)  {
      _seenEof = true; 
      close();
      /* Close your side, abort connection */
      break; /* Other side send a fin, tell caller */
      /* Break with whatever data we could receive */
    } else {
      data = (void*) ((unsigned long) data + ret);
      toRecv -= ret;
      nRecv += ret;
    }
  } while(toRecv > 0 && !lessOk);
  return nRecv;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %ecx, 0xc(%rsp)
xorl %r14d, %r14d
testl %edx, %edx
jle 0x3450
movl %edx, %r15d
movq %rsi, %r12
movq %rdi, %rbx
movq %rdi, 0x10(%rsp)
movl 0x1d8(%rbx), %edx
testl %edx, %edx
jle 0x32e7
movl 0x10(%rbx), %esi
callq 0x31cc
testl %eax, %eax
js 0x33e2
je 0x340d
cmpb $0x1, 0x1dc(%rbx)
jne 0x3333
movl $0x1d, %edx
movq 0x2cf4(%rip), %rbp      # 0x5ff0
movq %rbp, %rdi
leaq 0xe8d(%rip), %rsi       # 0x4193
callq 0x2260
movq (%rbp), %rax
movq -0x18(%rax), %rdi
addq %rbp, %rdi
movl $0xa, %esi
callq 0x2200
movsbl %al, %esi
movq %rbp, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2160
movl 0x10(%rbx), %edi
movl %r15d, %edx
movq %r12, %rsi
xorl %ecx, %ecx
callq 0x20a0
movq %rax, %rbp
cmpb $0x1, 0x1dc(%rbx)
jne 0x33a9
movl $0x1a, %edx
movq 0x2c95(%rip), %r13      # 0x5ff0
movq %r13, %rdi
leaq 0xe4c(%rip), %rsi       # 0x41b1
callq 0x2260
movq %r13, %rdi
movl %ebp, %esi
callq 0x2330
movq %r14, %r13
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2200
movsbl %al, %esi
movq %r14, %rdi
movq %r13, %r14
movq 0x10(%rsp), %rbx
callq 0x2030
movq %rax, %rdi
callq 0x2160
testl %ebp, %ebp
js 0x33c1
je 0x3416
movl %ebp, %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
addq %rax, %r12
subl %ebp, %r15d
addl %ebp, %r14d
jmp 0x33d0
callq 0x2040
movq %rax, %rbp
movl (%rax), %eax
cmpl $0x4, %eax
jne 0x3432
testl %r15d, %r15d
jle 0x342d
cmpb $0x0, 0xc(%rsp)
je 0x32c7
jmp 0x342d
callq 0x2040
movq %rax, %r14
movl (%rax), %eax
testl %eax, %eax
jle 0x3462
cmpl $0x4, %eax
je 0x3462
movl 0x10(%rbx), %edi
testl %edi, %edi
jle 0x3408
callq 0x2370
movl $0xffffffff, 0x10(%rbx) # imm = 0xFFFFFFFF
movslq (%r14), %r14
jmp 0x344d
movq $-0x2, %r14
jmp 0x3450
movb $0x1, 0x15(%rbx)
movl 0x10(%rbx), %edi
testl %edi, %edi
jle 0x342d
callq 0x2370
movl $0xffffffff, 0x10(%rbx) # imm = 0xFFFFFFFF
movl %r14d, %r14d
jmp 0x3450
testl %eax, %eax
jle 0x3481
movl 0x10(%rbx), %edi
testl %edi, %edi
jle 0x3449
callq 0x2370
movl $0xffffffff, 0x10(%rbx) # imm = 0xFFFFFFFF
movslq (%rbp), %r14
negq %r14
movq %r14, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xcdc(%rip), %rdi       # 0x4145
leaq 0xc98(%rip), %rsi       # 0x4108
leaq 0xce8(%rip), %rcx       # 0x415f
movl $0x42, %edx
callq 0x2150
leaq 0xd44(%rip), %rdi       # 0x41cc
leaq 0xc79(%rip), %rsi       # 0x4108
leaq 0xcc9(%rip), %rcx       # 0x415f
movl $0x4c, %edx
callq 0x2150