// File: /workspace/github_c_makefile_star2_O0/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
subq $0x150, %rsp            # imm = 0x150
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x128(%rbp)
leaq -0x98(%rbp), %rax
movq %rax, -0xa8(%rbp)
movl $0x0, -0x9c(%rbp)
movl -0x9c(%rbp), %eax
cmpq $0x10, %rax
jae 0x15697
movq -0xa8(%rbp), %rax
movl -0x9c(%rbp), %ecx
movq $0x0, (%rax,%rcx,8)
movl -0x9c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x9c(%rbp)
jmp 0x15665
jmp 0x15699
movq -0x128(%rbp), %rax
movl 0x28(%rax), %eax
movl $0x40, %ecx
cltd
idivl %ecx
movq -0x128(%rbp), %rax
movl %edx, %ecx
movl $0x1, %edx
shlq %cl, %rdx
movq %rdx, %rcx
movl 0x28(%rax), %eax
movl $0x40, %esi
cltd
idivl %esi
cltq
orq -0x98(%rbp,%rax,8), %rcx
movq %rcx, -0x98(%rbp,%rax,8)
movl -0x14(%rbp), %edi
callq 0x14200
movq %rax, %rcx
movq -0x128(%rbp), %rax
movq %rcx, -0xb8(%rbp)
movq %rdx, -0xb0(%rbp)
movl 0x28(%rax), %edi
addl $0x1, %edi
leaq -0x98(%rbp), %rsi
xorl %eax, %eax
movl %eax, %r9d
leaq -0xb8(%rbp), %r8
movq %r9, %rdx
movq %r9, %rcx
callq 0xd450
movl %eax, -0xbc(%rbp)
cmpl $0x0, -0xbc(%rbp)
jge 0x1582e
callq 0xd060
cmpl $0x4, (%rax)
jne 0x15746
movb $0x0, -0x1(%rbp)
jmp 0x1597f
movb $0x1, -0xf5(%rbp)
movl $0x58, %edi
callq 0xd1e0
movq %rax, -0x138(%rbp)
leaq -0xe1(%rbp), %rdi
movq %rdi, -0x130(%rbp)
callq 0xd760
movq -0x130(%rbp), %rdx
leaq 0x17a32(%rip), %rsi     # 0x2d1b1
leaq -0xe0(%rbp), %rdi
callq 0xf2c0
jmp 0x1578d
callq 0xd060
movq -0x138(%rbp), %rdi
movl (%rax), %ecx
leaq -0xe0(%rbp), %rsi
movl $0x1fc, %edx            # imm = 0x1FC
callq 0x183c0
jmp 0x157ae
movq -0x138(%rbp), %rdi
movb $0x0, -0xf5(%rbp)
leaq 0x204f5(%rip), %rsi     # 0x35cb8
leaq 0x2ba6(%rip), %rdx      # 0x18370
callq 0xd720
jmp 0x15999
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xf0(%rbp)
movl %eax, -0xf4(%rbp)
jmp 0x15806
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xf0(%rbp)
movl %eax, -0xf4(%rbp)
leaq -0xe0(%rbp), %rdi
callq 0xd240
leaq -0xe1(%rbp), %rdi
callq 0xd430
testb $0x1, -0xf5(%rbp)
jne 0x1581d
jmp 0x15829
movq -0x138(%rbp), %rdi
callq 0xd2c0
jmp 0x1598d
cmpl $0x0, -0xbc(%rbp)
jne 0x15840
movb $0x0, -0x1(%rbp)
jmp 0x1597f
movq -0x128(%rbp), %rax
movl 0x28(%rax), %eax
movl $0x40, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movq -0x128(%rbp), %rax
movslq %ecx, %rcx
movq -0x98(%rbp,%rcx,8), %rcx
movq %rcx, -0x140(%rbp)
movl 0x28(%rax), %eax
movl $0x40, %ecx
cltd
idivl %ecx
movq -0x140(%rbp), %rax
movl %edx, %ecx
movl $0x1, %edx
shlq %cl, %rdx
movq %rdx, %rcx
andq %rcx, %rax
cmpq $0x0, %rax
jne 0x1597b
movb $0x1, -0x11a(%rbp)
movl $0x58, %edi
callq 0xd1e0
movq %rax, -0x150(%rbp)
leaq -0x119(%rbp), %rdi
movq %rdi, -0x148(%rbp)
callq 0xd760
movq -0x148(%rbp), %rdx
leaq 0x178df(%rip), %rsi     # 0x2d1b1
leaq -0x118(%rbp), %rdi
callq 0xf2c0
jmp 0x158e0
movq -0x150(%rbp), %rdi
leaq 0x17965(%rip), %rcx     # 0x2d253
leaq -0x118(%rbp), %rsi
movl $0x205, %edx            # imm = 0x205
callq 0x18170
jmp 0x15901
movq -0x150(%rbp), %rdi
movb $0x0, -0x11a(%rbp)
leaq 0x203a2(%rip), %rsi     # 0x35cb8
leaq 0x2a53(%rip), %rdx      # 0x18370
callq 0xd720
jmp 0x15999
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xf0(%rbp)
movl %eax, -0xf4(%rbp)
jmp 0x15956
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xf0(%rbp)
movl %eax, -0xf4(%rbp)
leaq -0x118(%rbp), %rdi
callq 0xd240
leaq -0x119(%rbp), %rdi
callq 0xd430
testb $0x1, -0x11a(%rbp)
jne 0x1596d
jmp 0x15979
movq -0x150(%rbp), %rdi
callq 0xd2c0
jmp 0x1598d
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x150, %rsp            # imm = 0x150
popq %rbp
retq
movq -0xf0(%rbp), %rdi
callq 0xd750
nopl (%rax)