// File: /workspace/github_cpp_makefile_star2_O1/flightaware[P]beast-splitter/beast_input_serial.cc
// Function: beast::SerialInput::try_to_connect()
void SerialInput::try_to_connect(void) {
    auto self(shared_from_this());

    std::cerr << what() << ": opening port at " << baud_rate << "bps" << std::endl;

    try {
        if (port.is_open())
            port.cancel();
        else
            port.open(path);

        port.set_option(boost::asio::serial_port_base::character_size(8));
        port.set_option(boost::asio::serial_port_base::stop_bits(boost::asio::serial_port_base::stop_bits::one));
        port.set_option(boost::asio::serial_port_base::parity(boost::asio::serial_port_base::parity::none));
        port.set_option(boost::asio::serial_port_base::baud_rate(baud_rate));

        // not_supported usually means a library build problem, ignore that
        boost::system::error_code ec;
        port.set_option(boost::asio::serial_port_base::flow_control(boost::asio::serial_port_base::flow_control::hardware), ec);
        if (ec && ec != boost::asio::error::operation_not_supported) {
            throw boost::system::system_error(ec);
        }
    } catch (const boost::system::system_error &err) {
        handle_error(err.code());
        return;
    }

    if (autobaud_rates.size() > 1) {
        autobaud_timer.expires_from_now(autobaud_interval);

        autobaud_timer.async_wait([this, self](const boost::system::error_code &ec) {
            if (!ec) {
                advance_autobaud();
            }
        });
    }

    connection_established();
    start_reading();
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x50, %rsp
movq %rdi, %rbx
leaq 0x8(%rdi), %rsi
leaq 0x40(%rsp), %rdi
callq 0x19994
movq (%rbx), %rax
leaq 0x8(%rsp), %rdi
movq %rbx, %rsi
callq *0x20(%rax)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq 0x58d87(%rip), %rdi     # 0x72fd8
callq 0xf730
movq %rax, %r14
leaq 0x36df8(%rip), %rsi     # 0x51058
movl $0x12, %edx
movq %rax, %rdi
callq 0xf730
movl 0x340(%rbx), %esi
movq %r14, %rdi
callq 0xf460
movq %rax, %r14
leaq 0x36f4e(%rip), %rsi     # 0x511d3
movl $0x3, %edx
movq %rax, %rdi
callq 0xf730
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0xf5f0
movsbl %al, %esi
movq %r14, %rdi
callq 0xf040
movq %rax, %rdi
callq 0xf470
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1a2d4
movq 0x18(%rsp), %rsi
incq %rsi
callq 0xf650
leaq 0x2d0(%rbx), %r14
cmpl $-0x1, 0x2d8(%rbx)
je 0x1a2ee
movq %r14, %rdi
callq 0x1c60c
jmp 0x1a2fd
leaq 0x2b0(%rbx), %rsi
movq %r14, %rdi
callq 0x1c6aa
leaq 0x8(%rsp), %rsi
movl $0x8, (%rsi)
movq %r14, %rdi
callq 0x1c74a
leaq 0x8(%rsp), %rsi
movl $0x0, (%rsi)
movq %r14, %rdi
callq 0x1c7f2
leaq 0x8(%rsp), %rsi
movl $0x0, (%rsi)
movq %r14, %rdi
callq 0x1c89a
movl 0x340(%rbx), %eax
leaq 0x8(%rsp), %rsi
movl %eax, (%rsi)
movq %r14, %rdi
callq 0x1c942
leaq 0x2d8(%rbx), %rsi
leaq 0x8(%rsp), %r8
movl $0x0, (%r8)
movb $0x0, 0x4(%r8)
leaq 0x55ea6(%rip), %r13     # 0x70210
movq %r13, 0x8(%r8)
leaq 0x28(%rsp), %r15
movl $0x2, (%r15)
movq (%r14), %rdi
leaq 0x4bd2(%rip), %rdx      # 0x1ef56
movq %r15, %rcx
callq 0x1ea60
cmpb $0x1, 0xc(%rsp)
jne 0x1a3b7
cmpl $0x5f, 0x8(%rsp)
jne 0x1a54b
movq 0x10(%rsp), %rax
movabsq $-0x70502de1da3a1f65, %rcx # imm = 0x8FAFD21E25C5E09B
cmpq %rcx, 0x8(%rax)
jne 0x1a54b
movq 0x328(%rbx), %rax
subq 0x320(%rbx), %rax
cmpq $0x4, %rax
jbe 0x1a50b
leaq 0x350(%rbx), %rdi
imulq $0xf4240, 0x348(%rbx), %rax # imm = 0xF4240
leaq 0x8(%rsp), %rsi
movq %rax, (%rsi)
callq 0x14326
movq %rbx, 0x28(%rsp)
movq 0x40(%rsp), %rcx
movq 0x48(%rsp), %rax
movq %rcx, 0x30(%rsp)
movq %rax, 0x38(%rsp)
testq %rax, %rax
je 0x1a421
movq 0x58b6d(%rip), %rcx     # 0x72f80
cmpb $0x0, (%rcx)
je 0x1a41d
incl 0x8(%rax)
jmp 0x1a421
lock
incl 0x8(%rax)
movq 0x350(%rbx), %r14
movq %r15, 0x8(%rsp)
movq %fs:-0x8, %rax
testq %rax, %rax
je 0x1a441
movq 0x8(%rax), %rdi
jmp 0x1a443
xorl %edi, %edi
movl $0x70, %esi
callq 0x148a2
movq %rax, %r15
leaq 0x358(%rbx), %r12
leaq 0x390(%rbx), %rsi
movq %rax, 0x10(%rsp)
xorl %eax, %eax
movq %rax, 0x18(%rsp)
movq %rax, (%r15)
leaq 0xe7c(%rip), %rcx       # 0x1b2f0
movq %rcx, 0x8(%r15)
movl %eax, 0x10(%r15)
movl %eax, 0x18(%r15)
movb $0x0, 0x1c(%r15)
movq %r13, 0x20(%r15)
movq 0x28(%rsp), %rcx
movq %rcx, 0x28(%r15)
movq 0x30(%rsp), %rcx
movq %rcx, 0x30(%r15)
movq %rax, 0x38(%r15)
movq 0x38(%rsp), %rcx
movq %rax, 0x38(%rsp)
movq %rcx, 0x38(%r15)
movq %rax, 0x30(%rsp)
movq %r15, %rdi
addq $0x40, %rdi
callq 0x15310
movq %r15, 0x18(%rsp)
movb $0x1, 0x360(%rbx)
movq 0x58(%r14), %rdi
addq $0x28, %r14
leaq 0x368(%rbx), %rcx
movq %r14, %rsi
movq %r12, %rdx
movq %r15, %r8
callq 0x1472c
leaq 0x10(%rsp), %rax
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
leaq 0x8(%rsp), %rdi
callq 0x1b56c
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x1a50b
callq 0x1581a
movq %rbx, %rdi
callq 0x12516
leaq 0x8(%rsp), %rsi
movl $0x0, (%rsi)
movb $0x0, 0x4(%rsi)
movq %r13, 0x8(%rsi)
movq %rbx, %rdi
callq 0x1a89e
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
je 0x1a53d
callq 0x1581a
addq $0x50, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movl $0x40, %edi
callq 0xf300
movq %rax, %r12
movq 0x8(%rsp), %r14
movq 0x10(%rsp), %r15
leaq 0x37cd0(%rip), %rsi     # 0x52239
movq %rax, %rdi
callq 0xfc00
leaq 0x55c58(%rip), %rax     # 0x701d0
movq %rax, (%r12)
movq %r14, 0x10(%r12)
movq %r15, 0x18(%r12)
movq %r12, %rax
addq $0x30, %rax
movq %rax, 0x20(%r12)
movq $0x0, 0x28(%r12)
movb $0x0, 0x30(%r12)
leaq 0x55c40(%rip), %rsi     # 0x701e8
leaq -0x605d(%rip), %rdx     # 0x14552
movq %r12, %rdi
callq 0xfb00
jmp 0x1a5c8
movq %rax, %r14
leaq 0x8(%rsp), %rdi
callq 0x1b56c
jmp 0x1a5d3
movq %rax, %rdi
callq 0x10886
movq %rax, %r14
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x1a673
callq 0x1581a
jmp 0x1a673
jmp 0x1a650
jmp 0x1a60d
movq %rdx, %r15
movq %rax, %r14
movq %r12, %rdi
callq 0xf4b0
jmp 0x1a613
jmp 0x1a650
jmp 0x1a650
jmp 0x1a60d
jmp 0x1a60d
jmp 0x1a60d
jmp 0x1a60d
jmp 0x1a60d
movq %rdx, %r15
movq %rax, %r14
cmpl $0x1, %r15d
jne 0x1a673
movq %r14, %rdi
callq 0xf280
movups 0x10(%rax), %xmm0
leaq 0x8(%rsp), %rsi
movups %xmm0, (%rsi)
movq %rbx, %rdi
callq 0x1a68a
callq 0xfaa0
jmp 0x1a52e
jmp 0x1a650
movq %rax, %r14
callq 0xfaa0
jmp 0x1a673
jmp 0x1a5c8
movq %rax, %r14
jmp 0x1a673
movq %rax, %r14
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1a673
movq 0x18(%rsp), %rsi
incq %rsi
callq 0xf650
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
je 0x1a682
callq 0x1581a
movq %r14, %rdi
callq 0xfb40