// File: /workspace/github_cpp_makefile_star2_O2/flightaware[P]beast-splitter/status_writer.cc
// Function: splitter::StatusWriter::write(modes::Message const&)
void StatusWriter::write(const modes::Message &message) {
        if (message.type() != modes::MessageType::STATUS)
            return;

        reset_timeout();

        const auto &data = message.data();

        // 0: settings, including:
        //    10: 1=GPS timestamps, 0=12MHz timestamps
        // 1: signed timestamp offset at last PPS edge, 15ns units
        // 2: GPS status
        //    80: 1=UTC, 0=UTC+1; if 0, other bits are unused
        //    40: unused
        //    20: 1=timestamp from FPGA, 0=timestamp from GPS
        //    10: 1=degradation <= 45ms, 0=degradation > 45ms
        //    08: 1=UTC time, 0=GPS time
        //    04: 1=good sats, 0=not enough good sats
        //    02: 1=tracking sats, 0=no sats
        //    01: 1=antenna OK, 0=antenna fault

        int pps_offset = (std::int8_t)data[1];

        if (!(data[0] & 0x10)) {
            // 12MHz mode
            write_status_file("red", "Not in GPS timestamp mode", pps_offset);
            return;
        }

        if (!(data[2] & 0x80)) {
            // Old style message. Assume it's good if abs(degradation) < 45ms
            if (pps_offset <= 3 || pps_offset >= -3) {
                write_status_file("green", "Receiver synchronized to GPS time", pps_offset);
            } else {
                write_status_file("amber", "Receiver more than 45ns from GPS time", pps_offset);
            }
            return;
        }

        // New style message

        if (!(data[2] & 0x20)) {
            // FPGA is using GPS time
            if (data[2] & 0x10) {
                write_status_file("green", "Receiver synchronized to GPS time", pps_offset);
            } else {
                write_status_file("amber", "Receiver more than 45ns from GPS time", pps_offset);
            }
            return;
        }

        // FPGA is not using GPS time, work out why.

        std::vector<std::string> status_messages;
        if (!(data[2] & 0x08)) {
            status_messages.push_back("GPS/UTC time offset not known");
        }

        if (!(data[2] & 0x02)) {
            status_messages.push_back("Not tracking any satellites");
        } else if (!(data[2] & 0x04)) {
            status_messages.push_back("Not tracking sufficient satellites");
        }

        if (!(data[2] & 0x01)) {
            status_messages.push_back("Antenna fault");
        }

        if (status_messages.empty()) {
            status_messages.push_back("Unrecognized GPS fault");
        }

        std::ostringstream status_buffer;
        for (auto i = status_messages.begin(); i != status_messages.end(); ++i) {
            if (i != status_messages.begin())
                status_buffer << "; ";
            status_buffer << *i;
        }

        write_status_file("red", status_buffer.str(), pps_offset);
    }

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1e0, %rsp            # imm = 0x1E0
cmpl $0x4, (%rsi)
jne 0x2708a
movq %rsi, %r15
movq %rdi, %r14
callq 0x27392
movq 0x18(%r15), %rax
movsbl 0x1(%rax), %ebx
testb $0x10, (%rax)
jne 0x2702f
leaq 0x1e14d(%rip), %rsi     # 0x45141
leaq 0x68(%rsp), %rdi
leaq 0x48(%rsp), %rdx
callq 0x13c2e
leaq 0x1e161(%rip), %rsi     # 0x4516b
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rdx
callq 0x13c2e
leaq 0x68(%rsp), %rsi
leaq 0x10(%rsp), %rdx
movq %r14, %rdi
movl %ebx, %ecx
callq 0x2755e
jmp 0x27076
movb 0x2(%rax), %cl
testb %cl, %cl
js 0x2709b
leaq 0x1e148(%rip), %rsi     # 0x45185
leaq 0x68(%rsp), %rdi
leaq 0x48(%rsp), %rdx
callq 0x13c2e
leaq 0x1e138(%rip), %rsi     # 0x4518b
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rdx
callq 0x13c2e
leaq 0x68(%rsp), %rsi
leaq 0x10(%rsp), %rdx
movq %r14, %rdi
movl %ebx, %ecx
callq 0x2755e
leaq 0x10(%rsp), %rdi
callq 0xfd68
leaq 0x68(%rsp), %rdi
callq 0xfd68
addq $0x1e0, %rsp            # imm = 0x1E0
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
testb $0x20, %cl
jne 0x270eb
testb $0x10, %cl
jne 0x27161
leaq 0x1e0fd(%rip), %rsi     # 0x451ad
leaq 0x68(%rsp), %rdi
leaq 0x48(%rsp), %rdx
callq 0x13c2e
leaq 0x1e0ed(%rip), %rsi     # 0x451b3
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rdx
callq 0x13c2e
leaq 0x68(%rsp), %rsi
leaq 0x10(%rsp), %rdx
movq %r14, %rdi
movl %ebx, %ecx
callq 0x2755e
jmp 0x27076
andq $0x0, 0x40(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
movb 0x2(%rax), %al
testb $0x8, %al
jne 0x27136
leaq 0x1e0d2(%rip), %rsi     # 0x451d9
leaq 0x68(%rsp), %rdi
leaq 0x10(%rsp), %rdx
callq 0x13c2e
leaq 0x30(%rsp), %rdi
leaq 0x68(%rsp), %rsi
callq 0x2813c
leaq 0x68(%rsp), %rdi
callq 0xfd68
movq 0x18(%r15), %rax
movb 0x2(%rax), %al
testb $0x2, %al
jne 0x271a6
leaq 0x1e0b6(%rip), %rsi     # 0x451f7
leaq 0x68(%rsp), %rdi
leaq 0x10(%rsp), %rdx
callq 0x13c2e
leaq 0x30(%rsp), %rdi
leaq 0x68(%rsp), %rsi
callq 0x2813c
jmp 0x271cf
leaq 0x1e01d(%rip), %rsi     # 0x45185
leaq 0x68(%rsp), %rdi
leaq 0x48(%rsp), %rdx
callq 0x13c2e
leaq 0x1e00d(%rip), %rsi     # 0x4518b
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rdx
callq 0x13c2e
leaq 0x68(%rsp), %rsi
leaq 0x10(%rsp), %rdx
movq %r14, %rdi
movl %ebx, %ecx
callq 0x2755e
jmp 0x27076
testb $0x4, %al
jne 0x271d9
leaq 0x1e062(%rip), %rsi     # 0x45213
leaq 0x68(%rsp), %rdi
leaq 0x10(%rsp), %rdx
callq 0x13c2e
leaq 0x30(%rsp), %rdi
leaq 0x68(%rsp), %rsi
callq 0x2813c
leaq 0x68(%rsp), %rdi
callq 0xfd68
movq 0x18(%r15), %rax
testb $0x1, 0x2(%rax)
jne 0x27212
leaq 0x1e04c(%rip), %rsi     # 0x45236
leaq 0x68(%rsp), %rdi
leaq 0x10(%rsp), %rdx
callq 0x13c2e
leaq 0x30(%rsp), %rdi
leaq 0x68(%rsp), %rsi
callq 0x2813c
leaq 0x68(%rsp), %rdi
callq 0xfd68
movq 0x30(%rsp), %rax
cmpq 0x38(%rsp), %rax
jne 0x2724d
leaq 0x1e01f(%rip), %rsi     # 0x45244
leaq 0x68(%rsp), %rdi
leaq 0x10(%rsp), %rdx
callq 0x13c2e
leaq 0x30(%rsp), %rdi
leaq 0x68(%rsp), %rsi
callq 0x2813c
leaq 0x68(%rsp), %rdi
callq 0xfd68
leaq 0x68(%rsp), %rdi
callq 0xf8b0
movq 0x30(%rsp), %r15
leaq 0x68(%rsp), %r12
leaq 0x1dff3(%rip), %r13     # 0x4525b
cmpq 0x38(%rsp), %r15
je 0x27292
cmpq 0x30(%rsp), %r15
je 0x27281
movq %r12, %rdi
movq %r13, %rsi
callq 0xf610
movq %r12, %rdi
movq %r15, %rsi
callq 0xf590
addq $0x20, %r15
jmp 0x27268
leaq 0x1dea8(%rip), %rsi     # 0x45141
leaq 0x10(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0x13c2e
leaq 0x70(%rsp), %rsi
leaq 0x48(%rsp), %rdi
callq 0xfa70
leaq 0x10(%rsp), %rsi
leaq 0x48(%rsp), %rdx
movq %r14, %rdi
movl %ebx, %ecx
callq 0x2755e
leaq 0x48(%rsp), %rdi
callq 0xfd68
leaq 0x10(%rsp), %rdi
callq 0xfd68
leaq 0x68(%rsp), %rdi
callq 0xf150
leaq 0x30(%rsp), %rdi
callq 0x279ce
jmp 0x2708a
jmp 0x2730e
jmp 0x27345
jmp 0x2730e
jmp 0x27345
jmp 0x2730e
jmp 0x27345
jmp 0x27350
jmp 0x2730e
jmp 0x27350
jmp 0x2735f
jmp 0x27345
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
callq 0xfd68
jmp 0x27380
jmp 0x2735f
jmp 0x2736e
jmp 0x27345
jmp 0x2736e
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0xfd68
jmp 0x27337
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0xfd68
jmp 0x27376
jmp 0x27373
movq %rax, %rbx
jmp 0x27380
jmp 0x27350
jmp 0x2735f
jmp 0x2736e
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0xfd68
jmp 0x27362
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
callq 0xfd68
jmp 0x2738a
movq %rax, %rbx
jmp 0x2738a
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
callq 0xf150
leaq 0x30(%rsp), %rdi
callq 0x279ce
movq %rbx, %rdi
callq 0xfba0