// File: flightaware[P]beast-splitter/beast_output.cc
// Function: beast::SocketOutput::write(modes::Message const&)
void SocketOutput::write(const modes::Message &message) {
        if (!socket.is_open())
            return; // we are shut down

        if (message.type() == modes::MessageType::STATUS) {
            // local connection settings override the upstream data
            Settings upstream = Settings(message.data()[0]);
            Settings used = settings | upstream;

            auto copy = message.data();
            copy[0] = used.to_status_byte();

            if (settings.gps_timestamps.on() && !upstream.gps_timestamps.on()) {
                // we are translating 12MHz to "GPS", set the emulation flag
                copy[2] |= 0x80; // set UTC-bugfix-and-more-bits flag
                copy[2] |= 0x20; // set emulated-timestamp flag
            }

            write_message(message.type(), message.timestamp_type(), message.timestamp(), message.signal(), copy);
        } else {
            // apply FEC if requested
            bool needs_fec = (!settings.verbatim && !settings.fec_disable && message.crc_correctable());
            write_message(message.type(), message.timestamp_type(), message.timestamp(), message.signal(), needs_fec ? message.corrected_data() : message.data());
        }
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xf0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0xa0(%rbp)
addq $0x20, %rdi
callq 0x48af0
testb $0x1, %al
jne 0x50380
jmp 0x5064e
movq -0x10(%rbp), %rdi
callq 0x13dc0
cmpl $0x4, %eax
jne 0x50549
movq -0x10(%rbp), %rdi
callq 0x13e10
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x14d30
movzbl (%rax), %esi
leaq -0x40(%rbp), %rdi
movq %rdi, -0xb8(%rbp)
callq 0x19910
movq -0xa0(%rbp), %rsi
movq -0xb8(%rbp), %rdx
addq $0x90, %rsi
leaq -0x70(%rbp), %rdi
movq %rdi, -0xb0(%rbp)
callq 0x19f70
movq -0x10(%rbp), %rdi
callq 0x13e10
movq %rax, %rsi
leaq -0x88(%rbp), %rdi
callq 0x146a0
movq -0xb0(%rbp), %rdi
callq 0x1a090
movb %al, -0xa1(%rbp)
jmp 0x5040b
xorl %eax, %eax
movl %eax, %esi
leaq -0x88(%rbp), %rdi
callq 0x144d0
movb -0xa1(%rbp), %cl
movq -0xa0(%rbp), %rdi
movb %cl, (%rax)
addq $0xa4, %rdi
callq 0x1c790
movb %al, -0xb9(%rbp)
jmp 0x5043e
movb -0xb9(%rbp), %al
testb $0x1, %al
jne 0x5044a
jmp 0x504c1
leaq -0x2c(%rbp), %rdi
callq 0x1c790
movb %al, -0xba(%rbp)
jmp 0x5045b
movb -0xba(%rbp), %al
testb $0x1, %al
jne 0x504c1
jmp 0x50467
leaq -0x88(%rbp), %rdi
movl $0x2, %esi
callq 0x144d0
movzbl (%rax), %ecx
orl $0x80, %ecx
movb %cl, (%rax)
leaq -0x88(%rbp), %rdi
movl $0x2, %esi
callq 0x144d0
movzbl (%rax), %ecx
orl $0x20, %ecx
movb %cl, (%rax)
jmp 0x504c1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
leaq -0x88(%rbp), %rdi
callq 0x14790
jmp 0x50657
movq -0x10(%rbp), %rdi
callq 0x13dc0
movl %eax, -0xc0(%rbp)
jmp 0x504d2
movq -0x10(%rbp), %rdi
callq 0x5a500
movl %eax, -0xc4(%rbp)
jmp 0x504e3
movq -0x10(%rbp), %rdi
callq 0x13df0
movq %rax, -0xd0(%rbp)
jmp 0x504f5
movq -0x10(%rbp), %rdi
callq 0x5a520
movb %al, -0xd1(%rbp)
jmp 0x50506
movq -0xd0(%rbp), %rcx
movl -0xc4(%rbp), %edx
movl -0xc0(%rbp), %esi
movq -0xa0(%rbp), %rdi
movb -0xd1(%rbp), %al
movzbl %al, %r8d
leaq -0x88(%rbp), %r9
callq 0x50670
jmp 0x50538
leaq -0x88(%rbp), %rdi
callq 0x14790
jmp 0x5064e
movq -0xa0(%rbp), %rdi
addq $0x90, %rdi
addq $0x2c, %rdi
callq 0x5a540
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, -0xd2(%rbp)
jne 0x50571
jmp 0x505a8
movq -0xa0(%rbp), %rdi
addq $0x90, %rdi
addq $0x1c, %rdi
callq 0x1b810
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, -0xd2(%rbp)
jne 0x50599
jmp 0x505a8
movq -0x10(%rbp), %rdi
callq 0x17d40
movb %al, -0xd2(%rbp)
movb -0xd2(%rbp), %al
andb $0x1, %al
movb %al, -0x95(%rbp)
movq -0x10(%rbp), %rdi
callq 0x13dc0
movl %eax, -0xe8(%rbp)
movq -0x10(%rbp), %rdi
callq 0x5a500
movl %eax, -0xe4(%rbp)
movq -0x10(%rbp), %rdi
callq 0x13df0
movq %rax, -0xe0(%rbp)
movq -0x10(%rbp), %rdi
callq 0x5a520
movb %al, -0xd3(%rbp)
testb $0x1, -0x95(%rbp)
je 0x5060e
movq -0x10(%rbp), %rdi
callq 0x5a580
movq %rax, -0xf0(%rbp)
jmp 0x5061e
movq -0x10(%rbp), %rdi
callq 0x13e10
movq %rax, -0xf0(%rbp)
movb -0xd3(%rbp), %al
movq -0xe0(%rbp), %rcx
movl -0xe4(%rbp), %edx
movl -0xe8(%rbp), %esi
movq -0xa0(%rbp), %rdi
movq -0xf0(%rbp), %r9
movzbl %al, %r8d
callq 0x50670
addq $0xf0, %rsp
popq %rbp
retq
movq -0x90(%rbp), %rdi
callq 0x12f70
nopw %cs:(%rax,%rax)