// File: /workspace/github_cpp_makefile_star2_O3/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 0x19534
cmpl $0x7d, (%rsi)
jne 0x19515
movq 0x8(%rsi), %rax
movabsq $-0x70502de1da3a1f65, %rcx # imm = 0x8FAFD21E25C5E09B
cmpq %rcx, 0x8(%rax)
je 0x19810
leaq 0x35ca5(%rip), %rdi     # 0x4f1c1
leaq 0x35cca(%rip), %rsi     # 0x4f1ed
leaq 0x35cd9(%rip), %rcx     # 0x4f203
movl $0xae, %edx
callq 0xe440
movq %rdi, %r15
leaq 0x8(%rdi), %rsi
leaq 0x10(%rsp), %rbx
movq %rbx, %rdi
callq 0x185ac
movq (%rbx), %rbp
movq 0x8(%rbx), %rbx
testq %rbx, %rbx
je 0x1957b
movq 0x57a25(%rip), %rax     # 0x70f80
cmpb $0x0, (%rax)
je 0x19568
incl 0x8(%rbx)
movq %rbx, %rdi
jmp 0x19576
lock
incl 0x8(%rbx)
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x1957b
callq 0x14590
movq 0x430(%r15), %r12
movq 0x438(%r15), %r13
xorps %xmm0, %xmm0
movups %xmm0, 0x430(%r15)
testq %r12, %r12
movq %rbx, 0x38(%rsp)
je 0x1961d
movq 0x2a0(%r15), %rsi
movq %r12, %rdi
callq 0x1b56a
movq %r13, %r14
movq %rbp, %r13
imulq $0xf4240, 0x2a8(%r15), %rax # imm = 0xF4240
leaq 0x10(%rsp), %rsi
movq %rax, (%rsi)
leaq 0x3c0(%r15), %rdi
movq %r14, 0x8(%rsp)
callq 0x13140
movq (%r12), %rbp
movq 0x8(%r12), %rax
xorl %ecx, %ecx
movq %rax, 0x60(%rsp)
subq %rbp, %rax
movq %rax, 0x70(%rsp)
cmovneq %rbp, %rcx
movq %rcx, 0x68(%rsp)
movq %r15, 0x10(%rsp)
movq %r13, 0x18(%rsp)
movq %rbx, 0x20(%rsp)
testq %rbx, %rbx
je 0x1967f
movq 0x5796d(%rip), %rax     # 0x70f80
cmpb $0x0, (%rax)
je 0x1967b
incl 0x8(%rbx)
jmp 0x1967f
leaq 0x2a0(%r15), %rcx
leaq 0x18(%rsp), %rdi
movq $0x0, -0x8(%rdi)
leaq 0x10(%rsp), %rsi
leaq 0x40(%rsp), %rdx
callq 0x1c4f0
movq 0x10(%rsp), %r12
movq 0x18(%rsp), %r14
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
testq %r13, %r13
je 0x195b0
movq %r13, %rdi
callq 0x14590
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x195b0
callq 0x14590
jmp 0x195b0
lock
incl 0x8(%rbx)
movq %r12, 0x28(%rsp)
movq %r14, 0x30(%rsp)
testq %r14, %r14
je 0x196a5
movq 0x578eb(%rip), %rax     # 0x70f80
cmpb $0x0, (%rax)
je 0x196a0
incl 0x8(%r14)
jmp 0x196a5
lock
incl 0x8(%r14)
movq 0x2d0(%r15), %rbx
leaq 0x10(%rsp), %rax
movq %rax, 0x40(%rsp)
movq %fs:-0x8, %rax
testq %rax, %rax
je 0x196ca
movq 0x8(%rax), %rdi
jmp 0x196cc
xorl %edi, %edi
movl $0xa8, %esi
callq 0x136c4
movq %rax, %r12
leaq 0x2d8(%r15), %r13
addq $0x2e8, %r15            # imm = 0x2E8
leaq 0x28(%rbx), %rax
movq %rax, 0x58(%rsp)
xorl %r14d, %r14d
cmpq %rbp, 0x60(%rsp)
sete %r14b
movq %r12, 0x48(%rsp)
movl (%r13), %eax
xorl %ecx, %ecx
movq %rcx, (%r12)
leaq 0x1454(%rip), %rdx      # 0x1ab66
movq %rdx, 0x8(%r12)
movl $0x0, 0x10(%r12)
movups 0x58(%rbx), %xmm0
movups %xmm0, 0x18(%r12)
movq %rcx, 0x28(%r12)
leaq 0x2bd2(%rip), %rdx      # 0x1c308
movq %rdx, 0x30(%r12)
movl %eax, 0x38(%r12)
movq 0x68(%rsp), %rax
movq %rax, 0x40(%r12)
movq 0x70(%rsp), %rax
movq %rax, 0x48(%r12)
movaps 0x10(%rsp), %xmm0
movups %xmm0, 0x50(%r12)
xorps %xmm1, %xmm1
movaps 0x20(%rsp), %xmm0
movups %xmm1, 0x18(%rsp)
movups %xmm0, 0x60(%r12)
movq 0x30(%rsp), %rax
movq %rcx, 0x30(%rsp)
movq %rax, 0x70(%r12)
movq %rcx, 0x28(%rsp)
movq %r12, %rdi
addq $0x78, %rdi
movq %r15, %rsi
callq 0x140a4
movq %r12, 0x50(%rsp)
movl %r14d, (%rsp)
movq 0x58(%rsp), %rdi
movq %r13, %rsi
xorl %edx, %edx
movq %r12, %rcx
xorl %r8d, %r8d
movl $0x1, %r9d
callq 0x1b7c8
leaq 0x48(%rsp), %rax
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
leaq 0x40(%rsp), %rdi
callq 0x1ae56
movq 0x38(%rsp), %rbx
movq 0x8(%rsp), %r14
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x197e7
callq 0x14590
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x197f6
callq 0x14590
testq %r14, %r14
je 0x19803
movq %r14, %rdi
callq 0x14590
testq %rbx, %rbx
je 0x19810
movq %rbx, %rdi
callq 0x14590
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x19821
movq %rax, %r15
movq %r13, 0x8(%rsp)
jmp 0x19856
jmp 0x1983c
movq %rax, %r15
leaq 0x40(%rsp), %rdi
callq 0x1ae56
jmp 0x19847
movq %rax, %rdi
callq 0xf7cb
movq %rax, %r15
leaq 0x10(%rsp), %rdi
callq 0x19dc6
jmp 0x19856
movq %rax, %r15
cmpq $0x0, 0x8(%rsp)
je 0x19868
movq 0x8(%rsp), %rdi
callq 0x14590
cmpq $0x0, 0x38(%rsp)
je 0x1987a
movq 0x38(%rsp), %rdi
callq 0x14590
movq %r15, %rdi
callq 0xeb40