// File: /workspace/github_cpp_makefile_star2_O2/flightaware[P]beast-splitter/beast_input_serial.cc
// Function: beast::SerialInput::start_reading(boost::system::error_code const&)
void SerialInput::start_reading(const boost::system::error_code &ec) {
    if (ec) {
        assert(ec == boost::asio::error::operation_aborted);
        return;
    }

    auto self(std::static_pointer_cast<SerialInput>(shared_from_this()));
    std::shared_ptr<helpers::bytebuf> buf;

    buf.swap(readbuf);
    if (buf) {
        buf->resize(read_buffer_size);
    } else {
        buf = std::make_shared<helpers::bytebuf>(read_buffer_size);
    }

    read_timer.expires_from_now(read_interval);
    port.async_read_some(boost::asio::buffer(*buf), [this, self, buf](const boost::system::error_code &ec, std::size_t len) {
        if (ec) {
            readbuf = buf;
            handle_error(ec);
        } else {
            buf->resize(len);
            parse_input(*buf);
            check_framing_errors();
            readbuf = buf;

            // If we didn't get a full-ish buffer, then wait a bit before the next read so we don't
            // spin reading only a few bytes each time.

            // (unfortunately, boost::asio's edge-triggered epoll still gets woken repeatedly each time a
            // little more data arrives, but at least we don't have to do a bunch of work on every one of
            // those)
            if (len < read_buffer_size * 3 / 4) {
                read_timer.async_wait(std::bind(&SerialInput::start_reading, self, std::placeholders::_1));
            } else {
                start_reading();
            }
        }
    });
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
cmpb $0x1, 0x4(%rsi)
jne 0x18ed6
movq %rsi, %rbx
pushq $0x7d
popq %rdi
callq 0x15246
leaq 0x10(%rsp), %rsi
movq %rax, (%rsi)
movq %rdx, 0x8(%rsi)
movq %rbx, %rdi
callq 0x1a65d
testb %al, %al
jne 0x190ca
leaq 0x2b323(%rip), %rdi     # 0x441e1
leaq 0x2b348(%rip), %rsi     # 0x4420d
leaq 0x2b357(%rip), %rcx     # 0x44223
movl $0xae, %edx
callq 0xf460
movq %rdi, %r14
leaq 0x8(%rdi), %rsi
leaq 0x10(%rsp), %rbx
movq %rbx, %rdi
callq 0x1824e
leaq 0x50(%rsp), %rdi
movq %rbx, %rsi
callq 0x1a68b
leaq 0x18(%rsp), %rdi
callq 0x14e02
movq 0x430(%r14), %rdi
leaq 0x48(%rsp), %rcx
movq %rdi, -0x8(%rcx)
xorps %xmm0, %xmm0
movq 0x438(%r14), %rax
movups %xmm0, 0x430(%r14)
movq %rax, (%rcx)
testq %rdi, %rdi
je 0x18f39
movq 0x2a0(%r14), %rsi
callq 0x1a6a8
jmp 0x18f63
leaq 0x2a0(%r14), %rsi
leaq 0x10(%rsp), %rdi
callq 0x1a38b
leaq 0x40(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x1c822
leaq 0x18(%rsp), %rdi
callq 0x14e02
imulq $0xf4240, 0x2a8(%r14), %rax # imm = 0xF4240
leaq 0x10(%rsp), %r15
movq %rax, (%r15)
leaq 0x3c0(%r14), %rdi
movq %r15, %rsi
callq 0x13964
leaq 0x40(%rsp), %r12
movq (%r12), %rax
movq (%rax), %rbx
movq 0x8(%rax), %r13
leaq 0x18(%rsp), %rdi
movq %r14, -0x8(%rdi)
leaq 0x50(%rsp), %rsi
callq 0x1b42a
leaq 0x28(%rsp), %rdi
movq %r12, %rsi
callq 0x14e7e
movq 0x2d0(%r14), %r12
movq %r15, 0x60(%rsp)
movl $0xa8, %edi
movq %r15, %rsi
xorl %eax, %eax
callq 0x13dbd
movq %rax, %r15
xorl %eax, %eax
xorl %ebp, %ebp
subq %rbx, %r13
sete %bpl
cmovneq %rbx, %rax
movq %r15, 0x68(%rsp)
movl 0x2d8(%r14), %ecx
andq $0x0, (%r15)
leaq 0xef5(%rip), %rdx       # 0x19eee
movq %rdx, 0x8(%r15)
andl $0x0, 0x10(%r15)
movups 0x58(%r12), %xmm0
movups %xmm0, 0x18(%r15)
andq $0x0, 0x28(%r15)
addq $0x28, %r12
leaq 0x22cd(%rip), %rdx      # 0x1b2ea
movq %rdx, 0x30(%r15)
movl %ecx, 0x38(%r15)
movq %rax, 0x40(%r15)
movq %r13, 0x48(%r15)
movaps 0x10(%rsp), %xmm0
movups %xmm0, 0x50(%r15)
xorps %xmm1, %xmm1
movaps 0x20(%rsp), %xmm0
movups %xmm1, 0x18(%rsp)
movups %xmm0, 0x60(%r15)
movq 0x30(%rsp), %rax
andq $0x0, 0x30(%rsp)
movq %rax, 0x70(%r15)
andq $0x0, 0x28(%rsp)
leaq 0x2e8(%r14), %rsi
addq $0x2d8, %r14            # imm = 0x2D8
movq %r15, %rdi
addq $0x78, %rdi
callq 0x14776
movq %r15, 0x70(%rsp)
movl %ebp, (%rsp)
pushq $0x1
popq %r9
movq %r12, %rdi
movq %r14, %rsi
xorl %edx, %edx
movq %r15, %rcx
xorl %r8d, %r8d
callq 0x1a842
leaq 0x68(%rsp), %rax
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
leaq 0x60(%rsp), %rdi
callq 0x19ede
leaq 0x10(%rsp), %rdi
callq 0x194b0
leaq 0x48(%rsp), %rdi
callq 0x14e02
leaq 0x58(%rsp), %rdi
callq 0x14e02
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x190fb
jmp 0x190fb
movq %rax, %r14
leaq 0x60(%rsp), %rdi
callq 0x19ede
jmp 0x190ef
movq %rax, %r14
leaq 0x10(%rsp), %rdi
callq 0x194b0
jmp 0x190fe
movq %rax, %r14
leaq 0x48(%rsp), %rdi
callq 0x14e02
leaq 0x58(%rsp), %rdi
callq 0x14e02
movq %r14, %rdi
callq 0xfba0