// File: /workspace/github_c_makefile_star2_O1/patriciogonzalezvivo[P]tprint/include/serial/unix.cc
// Function: serial::Serial::SerialImpl::waitReadable(unsigned int)
bool
Serial::SerialImpl::waitReadable (uint32_t timeout)
{
  // Setup a select call to block for serial data or a timeout
  fd_set readfds;
  FD_ZERO (&readfds);
  FD_SET (fd_, &readfds);
  timespec timeout_ts (timespec_from_ms (timeout));
  int r = pselect (fd_ + 1, &readfds, NULL, NULL, &timeout_ts, NULL);

  if (r < 0) {
    // Select was interrupted
    if (errno == EINTR) {
      return false;
    }
    // Otherwise there was some error
    THROW (IOException, errno);
  }
  // Timeout occurred
  if (r == 0) {
    return false;
  }
  // This shouldn't happen, if r > 0 our fd has to be in the list!
  if (!FD_ISSET (fd_, &readfds)) {
    THROW (IOException, "select reports ready to read, but our fd isn't"
           " in the list, this shouldn't happen!");
  }
  // Data available to read.
  return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0xd0, %rsp
movl %esi, %eax
movq %rdi, %rbx
xorps %xmm0, %xmm0
leaq -0xf0(%rbp), %rsi
movaps %xmm0, 0x70(%rsi)
movaps %xmm0, 0x60(%rsi)
movaps %xmm0, 0x50(%rsi)
movaps %xmm0, 0x40(%rsi)
movaps %xmm0, 0x30(%rsi)
movaps %xmm0, 0x20(%rsi)
movaps %xmm0, 0x10(%rsi)
movaps %xmm0, (%rsi)
movl 0x28(%rdi), %edi
leal 0x3f(%rdi), %edx
testl %edi, %edi
cmovnsl %edi, %edx
movl %edx, %r8d
andl $-0x40, %r8d
movl %edi, %ecx
subl %r8d, %ecx
movl $0x1, %r8d
shlq %cl, %r8
sarl $0x6, %edx
movslq %edx, %rcx
orq %r8, -0xf0(%rbp,%rcx,8)
movl %eax, %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
movsd 0x14af6(%rip), %xmm1    # 0x21168
movapd %xmm0, %xmm2
divsd %xmm1, %xmm2
cvttsd2si %xmm2, %rax
xorps %xmm2, %xmm2
cvtsi2sd %rax, %xmm2
mulsd %xmm1, %xmm2
subsd %xmm2, %xmm0
mulsd 0x14ac9(%rip), %xmm0    # 0x21160
cvttsd2si %xmm0, %rcx
leaq -0x70(%rbp), %r8
movq %rax, (%r8)
movq %rcx, 0x8(%r8)
incl %edi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r9d, %r9d
callq 0x8370
testl %eax, %eax
js 0xc746
je 0xc750
movl 0x28(%rbx), %ecx
leal 0x3f(%rcx), %eax
testl %ecx, %ecx
cmovnsl %ecx, %eax
sarl $0x6, %eax
cltq
movq -0xf0(%rbp,%rax,8), %rdx
movb $0x1, %al
btq %rcx, %rdx
jb 0xc752
movl $0x58, %edi
callq 0x81a0
movq %rax, %rbx
leaq -0x30(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0x14b12(%rip), %rsi     # 0x21212
leaq 0x14b21(%rip), %rdx     # 0x21228
leaq -0x40(%rbp), %rdi
callq 0x9f82
movb $0x1, %r15b
leaq 0x14b9a(%rip), %rcx     # 0x212b4
leaq -0x40(%rbp), %rsi
movq %rbx, %rdi
movl $0x205, %edx            # imm = 0x205
callq 0xe3c0
xorl %r15d, %r15d
leaq 0x1b583(%rip), %rsi     # 0x27cb8
leaq 0x1e86(%rip), %rdx      # 0xe5c2
movq %rbx, %rdi
callq 0x85c0
jmp 0xc7c2
callq 0x8060
cmpl $0x4, (%rax)
jne 0xc762
xorl %eax, %eax
addq $0xd0, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
movl $0x58, %edi
callq 0x81a0
movq %rax, %rbx
leaq -0x50(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0x14a90(%rip), %rsi     # 0x21212
leaq 0x14a9f(%rip), %rdx     # 0x21228
leaq -0x60(%rbp), %rdi
callq 0x9f82
movl (%r14), %ecx
movb $0x1, %r15b
leaq -0x60(%rbp), %rsi
movq %rbx, %rdi
movl $0x1fc, %edx            # imm = 0x1FC
callq 0xe614
xorl %r15d, %r15d
leaq 0x1b505(%rip), %rsi     # 0x27cb8
leaq 0x1e08(%rip), %rdx      # 0xe5c2
movq %rbx, %rdi
callq 0x85c0
movq %rax, %r14
movq -0x60(%rbp), %rdi
cmpq %r12, %rdi
je 0xc7f6
movq -0x50(%rbp), %rsi
jmp 0xc7e6
jmp 0xc7f0
movq %rax, %r14
movq -0x40(%rbp), %rdi
cmpq %r12, %rdi
je 0xc7f6
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x8320
jmp 0xc7f6
movq %rax, %r14
movb $0x1, %r15b
testb %r15b, %r15b
je 0xc803
movq %rbx, %rdi
callq 0x8250
movq %r14, %rdi
callq 0x8600
nop