// File: /workspace/github_cpp_makefile_star2_O3/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 0x185ac
movq (%rbx), %rax
movq %rsp, %rdi
movq %rbx, %rsi
callq *0x20(%rax)
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
movq 0x5811a(%rip), %rdi     # 0x70fd8
callq 0xe730
movq %rax, %r14
leaq 0x3621b(%rip), %rsi     # 0x4f0e8
movl $0x12, %edx
movq %rax, %rdi
callq 0xe730
movl 0x340(%rbx), %esi
movq %r14, %rdi
callq 0xe460
movq %rax, %r14
leaq 0x36371(%rip), %rsi     # 0x4f263
movl $0x3, %edx
movq %rax, %rdi
callq 0xe730
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0xe5f0
movsbl %al, %esi
movq %r14, %rdi
callq 0xe040
movq %rax, %rdi
callq 0xe470
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x18f41
movq 0x10(%rsp), %rsi
incq %rsi
callq 0xe650
leaq 0x2d0(%rbx), %r14
cmpl $-0x1, 0x2d8(%rbx)
je 0x18f5b
movq %r14, %rdi
callq 0x1b1a0
jmp 0x18f6a
leaq 0x2b0(%rbx), %rsi
movq %r14, %rdi
callq 0x1b22a
movq %rsp, %rsi
movl $0x8, (%rsi)
movq %r14, %rdi
callq 0x1b2ca
movq %rsp, %rsi
movl $0x0, (%rsi)
movq %r14, %rdi
callq 0x1b372
movq %rsp, %rsi
movl $0x0, (%rsi)
movq %r14, %rdi
callq 0x1b41a
movl 0x340(%rbx), %eax
movq %rsp, %rsi
movl %eax, (%rsi)
movq %r14, %rdi
callq 0x1b4c2
leaq 0x2d8(%rbx), %rsi
movq %rsp, %r8
movl $0x0, (%r8)
movb $0x0, 0x4(%r8)
leaq 0x55363(%rip), %r13     # 0x6e330
movq %r13, 0x8(%r8)
leaq 0x20(%rsp), %r15
movl $0x2, (%r15)
movq (%r14), %rdi
leaq 0x48b5(%rip), %rdx      # 0x1d89c
movq %r15, %rcx
callq 0x1d3ba
cmpb $0x1, 0x4(%rsp)
jne 0x19019
cmpl $0x5f, (%rsp)
jne 0x19195
movq 0x8(%rsp), %rax
movabsq $-0x70502de1da3a1f65, %rcx # imm = 0x8FAFD21E25C5E09B
cmpq %rcx, 0x8(%rax)
jne 0x19195
movq 0x328(%rbx), %rax
subq 0x320(%rbx), %rax
cmpq $0x4, %rax
jbe 0x19157
leaq 0x350(%rbx), %rdi
imulq $0xf4240, 0x348(%rbx), %rax # imm = 0xF4240
movq %rsp, %rsi
movq %rax, (%rsi)
callq 0x13140
movq %rbx, 0x20(%rsp)
movq 0x40(%rsp), %rcx
movq 0x48(%rsp), %rax
movq %rcx, 0x28(%rsp)
movq %rax, 0x30(%rsp)
testq %rax, %rax
je 0x19081
movq 0x57f0d(%rip), %rcx     # 0x70f80
cmpb $0x0, (%rcx)
je 0x1907d
incl 0x8(%rax)
jmp 0x19081
lock
incl 0x8(%rax)
movq 0x350(%rbx), %r14
movq %r15, (%rsp)
movq %fs:-0x8, %rax
testq %rax, %rax
je 0x190a0
movq 0x8(%rax), %rdi
jmp 0x190a2
xorl %edi, %edi
movl $0x70, %esi
callq 0x136c4
movq %rax, %r15
leaq 0x358(%rbx), %r12
leaq 0x390(%rbx), %rsi
movq %rax, 0x8(%rsp)
xorl %eax, %eax
movq %rax, (%r15)
leaq 0xe74(%rip), %rcx       # 0x19f42
movq %rcx, 0x8(%r15)
movl %eax, 0x10(%r15)
movl %eax, 0x18(%r15)
movb $0x0, 0x1c(%r15)
movq %r13, 0x20(%r15)
movaps 0x20(%rsp), %xmm0
movups %xmm0, 0x28(%r15)
movq 0x30(%rsp), %rcx
movq %rax, 0x30(%rsp)
movq %rcx, 0x38(%r15)
movq %rax, 0x28(%rsp)
movq %r15, %rdi
addq $0x40, %rdi
callq 0x140a4
movq %r15, 0x10(%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 0x13542
leaq 0x8(%rsp), %rax
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movq %rsp, %rdi
callq 0x1a1b6
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x19157
callq 0x14590
movq %rbx, %rdi
callq 0x113ee
movq %rsp, %rsi
movl $0x0, (%rsi)
movb $0x0, 0x4(%rsi)
movq %r13, 0x8(%rsi)
movq %rbx, %rdi
callq 0x194e4
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
je 0x19187
callq 0x14590
addq $0x50, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movl $0x40, %edi
callq 0xe300
movq %rax, %r12
movq (%rsp), %r14
movq 0x8(%rsp), %r15
leaq 0x370d7(%rip), %rsi     # 0x50289
movq %rax, %rdi
callq 0xec00
leaq 0x5512f(%rip), %rax     # 0x6e2f0
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 0x55117(%rip), %rsi     # 0x6e308
leaq -0x5e94(%rip), %rdx     # 0x13364
movq %r12, %rdi
callq 0xeb00
jmp 0x1920f
movq %rax, %r14
movq %rsp, %rdi
callq 0x1a1b6
jmp 0x1921a
movq %rax, %rdi
callq 0xf7cb
movq %rax, %r14
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x192b8
callq 0x14590
jmp 0x192b8
jmp 0x19295
jmp 0x19254
movq %rdx, %r15
movq %rax, %r14
movq %r12, %rdi
callq 0xe4b0
jmp 0x1925a
jmp 0x19295
jmp 0x19295
jmp 0x19254
jmp 0x19254
jmp 0x19254
jmp 0x19254
jmp 0x19254
movq %rdx, %r15
movq %rax, %r14
cmpl $0x1, %r15d
jne 0x192b8
movq %r14, %rdi
callq 0xe280
movups 0x10(%rax), %xmm0
movq %rsp, %rsi
movups %xmm0, (%rsi)
movq %rbx, %rdi
callq 0x192d0
callq 0xeaa0
jmp 0x19178
jmp 0x19295
movq %rax, %r14
callq 0xeaa0
jmp 0x192b8
jmp 0x1920f
movq %rax, %r14
jmp 0x192b8
movq %rax, %r14
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x192b8
movq 0x10(%rsp), %rsi
incq %rsi
callq 0xe650
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
je 0x192c7
callq 0x14590
movq %r14, %rdi
callq 0xeb40
nop