// File: /workspace/github_cpp_makefile_star2_O1/flightaware[P]beast-splitter/beast_output.cc
// Function: beast::SocketOutput::write_message(modes::MessageType, modes::TimestampType, unsigned long, unsigned char, std::vector<unsigned char, std::allocator<unsigned char>> const&)
void SocketOutput::write_message(modes::MessageType type, modes::TimestampType timestamp_type, std::uint64_t timestamp, std::uint8_t signal, const helpers::bytebuf &data) {
        if (timestamp_type == modes::TimestampType::TWELVEMEG && !settings.radarcape.off() && settings.gps_timestamps.on()) {
            // GPS timestamps were explicitly requested
            // scale 12MHz to pseudo-GPS
            std::uint64_t ns = timestamp * 1000ULL / 12ULL;
            std::uint64_t seconds = (ns / 1000000000ULL) % 86400;
            std::uint64_t nanos = ns % 1000000000ULL;
            timestamp = (seconds << 30) | nanos;
        } else if (timestamp_type == modes::TimestampType::GPS && (settings.radarcape.off() || settings.gps_timestamps.off())) {
            // beast output or 12MHz timestamps were explicitly requested
            // scale GPS to 12MHz
            std::uint64_t seconds = timestamp >> 30;
            std::uint64_t nanos = timestamp & 0x3FFFFFFF;
            std::uint64_t ns = seconds * 1000000000ULL + nanos;
            timestamp = ns * 12ULL / 1000ULL;
        }

        // if gps_timestamps is DONTCARE, we just use whatever is provided

        if (settings.binary_format) {
            write_binary(type, timestamp, signal, data);
        } else if (settings.avrmlat) {
            if (type != modes::MessageType::STATUS && type != modes::MessageType::POSITION)
                write_avrmlat(timestamp, data);
        } else {
            if (type != modes::MessageType::STATUS && type != modes::MessageType::POSITION)
                write_avr(data);
        }
    }

// Assembly:
cmpl $0x2, %edx
je 0x260d1
cmpl $0x1, %edx
jne 0x26114
cmpl $0x0, 0x90(%rdi)
js 0x260cc
cmpl $0x0, 0xa4(%rdi)
jle 0x260cc
imulq $0x3e8, %rcx, %rcx      # imm = 0x3E8
movabsq $-0x5555555555555555, %rdx # imm = 0xAAAAAAAAAAAAAAAB
movq %rcx, %rax
mulq %rdx
movq %rdx, %r10
movabsq $-0x48bf80fe61b9cde1, %rdx # imm = 0xB7407F019E46321F
movq %rcx, %rax
mulq %rdx
shrq $0x3, %r10
movq %rdx, %rcx
shrq $0x21, %rcx
movabsq $0xc22e4506728a, %rdx   # imm = 0xC22E4506728A
movq %rcx, %rax
mulq %rdx
imulq $0x15180, %rdx, %rax    # imm = 0x15180
subq %rax, %rcx
movabsq $0x112e0be826d694b3, %rdx # imm = 0x112E0BE826D694B3
movq %r10, %rax
mulq %rdx
shrq $0x1a, %rdx
imulq $0x3b9aca00, %rdx, %rax # imm = 0x3B9ACA00
subq %rax, %r10
shlq $0x1e, %rcx
orq %r10, %rcx
jmp 0x26114
cmpl $0x2, %edx
jne 0x26114
cmpl $0x0, 0x90(%rdi)
js 0x260e3
cmpl $0x0, 0xa4(%rdi)
jns 0x26114
movq %rcx, %rax
shrq $0x1e, %rax
imulq $-0x4653600, %rax, %rax # imm = 0xFB9ACA00
addq %rcx, %rax
shlq $0x2, %rax
leaq (%rax,%rax,2), %rax
shrq $0x3, %rax
movabsq $0x20c49ba5e353f7cf, %rcx # imm = 0x20C49BA5E353F7CF
mulq %rcx
movq %rdx, %rcx
shrq $0x4, %rcx
cmpl $0x0, 0x94(%rdi)
js 0x2612e
movzbl %r8b, %eax
movq %rcx, %rdx
movl %eax, %ecx
movq %r9, %r8
jmp 0x26158
addl $-0x6, %esi
cmpl $0x0, 0x9c(%rdi)
js 0x2614a
cmpl $-0x3, %esi
ja 0x26157
movq %rcx, %rsi
movq %r9, %rdx
jmp 0x26450
cmpl $-0x3, %esi
ja 0x26157
movq %r9, %rsi
jmp 0x266f4
retq