// File: /workspace/github_cpp_makefile_star2_O1/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 $0x1d0, %rsp            # imm = 0x1D0
cmpl $0x4, (%rsi)
jne 0x2d25f
movq %rsi, %r15
movq %rdi, %r14
callq 0x2d6c6
movq 0x18(%r15), %rax
movsbl 0x1(%rax), %ebx
testb $0x10, (%rax)
jne 0x2d1d4
leaq 0x68(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x24ec2(%rip), %rsi     # 0x52051
leaq 0x24ebe(%rip), %rdx     # 0x52054
leaq 0x58(%rsp), %rdi
callq 0x1469c
leaq 0x10(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x24eca(%rip), %rsi     # 0x5207b
leaq 0x24edc(%rip), %rdx     # 0x52094
movq %rsp, %rdi
callq 0x1469c
leaq 0x58(%rsp), %rsi
movq %rsp, %rdx
movq %r14, %rdi
movl %ebx, %ecx
callq 0x2d942
jmp 0x2d232
movb 0x2(%rax), %cl
testb %cl, %cl
js 0x2d270
leaq 0x68(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x24ea6(%rip), %rsi     # 0x52095
leaq 0x24ea4(%rip), %rdx     # 0x5209a
leaq 0x58(%rsp), %rdi
callq 0x1469c
leaq 0x10(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x24e8a(%rip), %rsi     # 0x5209b
leaq 0x24ea4(%rip), %rdx     # 0x520bc
movq %rsp, %rdi
callq 0x1469c
leaq 0x58(%rsp), %rsi
movq %rsp, %rdx
movq %r14, %rdi
movl %ebx, %ecx
callq 0x2d942
movq (%rsp), %rdi
cmpq %r12, %rdi
je 0x2d248
movq 0x10(%rsp), %rsi
incq %rsi
callq 0xf650
movq 0x58(%rsp), %rdi
cmpq %r15, %rdi
je 0x2d25f
movq 0x68(%rsp), %rsi
incq %rsi
callq 0xf650
addq $0x1d0, %rsp            # imm = 0x1D0
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
testb $0x20, %cl
jne 0x2d2d6
leaq 0x68(%rsp), %r15
testb $0x10, %cl
jne 0x2d37a
movq %r15, -0x10(%r15)
leaq 0x24e2f(%rip), %rsi     # 0x520bd
leaq 0x24e2d(%rip), %rdx     # 0x520c2
leaq 0x58(%rsp), %rdi
callq 0x1469c
leaq 0x10(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x24e13(%rip), %rsi     # 0x520c3
leaq 0x24e31(%rip), %rdx     # 0x520e8
movq %rsp, %rdi
callq 0x1469c
leaq 0x58(%rsp), %rsi
movq %rsp, %rdx
movq %r14, %rdi
movl %ebx, %ecx
callq 0x2d942
jmp 0x2d232
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
movq $0x0, 0x30(%rsp)
testb $0x8, 0x2(%rax)
jne 0x2d335
leaq 0x68(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x24deb(%rip), %rsi     # 0x520e9
leaq 0x24e01(%rip), %rdx     # 0x52106
leaq 0x58(%rsp), %rdi
callq 0x1469c
leaq 0x20(%rsp), %rdi
leaq 0x58(%rsp), %rsi
callq 0x2e87e
movq 0x58(%rsp), %rdi
cmpq %r12, %rdi
je 0x2d335
movq 0x68(%rsp), %rsi
incq %rsi
callq 0xf650
movq 0x18(%r15), %rax
movb 0x2(%rax), %al
testb $0x2, %al
jne 0x2d3cd
leaq 0x68(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x24db2(%rip), %rsi     # 0x52107
leaq 0x24dc6(%rip), %rdx     # 0x52122
leaq 0x58(%rsp), %rdi
callq 0x1469c
leaq 0x20(%rsp), %rdi
leaq 0x58(%rsp), %rsi
callq 0x2e87e
jmp 0x2d402
movq %r15, -0x10(%r15)
leaq 0x24d10(%rip), %rsi     # 0x52095
leaq 0x24d0e(%rip), %rdx     # 0x5209a
leaq 0x58(%rsp), %rdi
callq 0x1469c
leaq 0x10(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x24cf4(%rip), %rsi     # 0x5209b
leaq 0x24d0e(%rip), %rdx     # 0x520bc
movq %rsp, %rdi
callq 0x1469c
leaq 0x58(%rsp), %rsi
movq %rsp, %rdx
movq %r14, %rdi
movl %ebx, %ecx
callq 0x2d942
jmp 0x2d232
testb $0x4, %al
jne 0x2d419
leaq 0x68(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x24d41(%rip), %rsi     # 0x52123
leaq 0x24d5c(%rip), %rdx     # 0x52145
leaq 0x58(%rsp), %rdi
callq 0x1469c
leaq 0x20(%rsp), %rdi
leaq 0x58(%rsp), %rsi
callq 0x2e87e
movq 0x58(%rsp), %rdi
cmpq %r12, %rdi
je 0x2d419
movq 0x68(%rsp), %rsi
incq %rsi
callq 0xf650
movq 0x18(%r15), %rax
testb $0x1, 0x2(%rax)
jne 0x2d46a
leaq 0x68(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x24d13(%rip), %rsi     # 0x52146
leaq 0x24d19(%rip), %rdx     # 0x52153
leaq 0x58(%rsp), %rdi
callq 0x1469c
leaq 0x20(%rsp), %rdi
leaq 0x58(%rsp), %rsi
callq 0x2e87e
movq 0x58(%rsp), %rdi
cmpq %r15, %rdi
je 0x2d46a
movq 0x68(%rsp), %rsi
incq %rsi
callq 0xf650
movq 0x20(%rsp), %rax
cmpq 0x28(%rsp), %rax
jne 0x2d4bd
leaq 0x68(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x24cce(%rip), %rsi     # 0x52154
leaq 0x24cdd(%rip), %rdx     # 0x5216a
leaq 0x58(%rsp), %rdi
callq 0x1469c
leaq 0x20(%rsp), %rdi
leaq 0x58(%rsp), %rsi
callq 0x2e87e
movq 0x58(%rsp), %rdi
cmpq %r15, %rdi
je 0x2d4bd
movq 0x68(%rsp), %rsi
incq %rsi
callq 0xf650
leaq 0x58(%rsp), %rdi
callq 0xf8a0
movq 0x20(%rsp), %r13
cmpq 0x28(%rsp), %r13
je 0x2d511
leaq 0x58(%rsp), %r15
leaq 0x24c8c(%rip), %r12     # 0x5216b
cmpq 0x20(%rsp), %r13
je 0x2d4f6
movl $0x2, %edx
movq %r15, %rdi
movq %r12, %rsi
callq 0xf730
movq (%r13), %rsi
movq 0x8(%r13), %rdx
movq %r15, %rdi
callq 0xf730
addq $0x20, %r13
cmpq 0x28(%rsp), %r13
jne 0x2d4df
leaq 0x10(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x24b30(%rip), %rsi     # 0x52051
leaq 0x24b2c(%rip), %rdx     # 0x52054
movq %rsp, %rdi
callq 0x1469c
leaq 0x60(%rsp), %rsi
leaq 0x38(%rsp), %rdi
callq 0xfa50
movq %rsp, %rsi
leaq 0x38(%rsp), %rdx
movq %r14, %rdi
movl %ebx, %ecx
callq 0x2d942
leaq 0x48(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2d56c
movq 0x48(%rsp), %rsi
incq %rsi
callq 0xf650
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x2d582
movq 0x10(%rsp), %rsi
incq %rsi
callq 0xf650
movq 0x459e7(%rip), %rsi     # 0x72f70
leaq 0x58(%rsp), %rdi
callq 0xf370
leaq 0xc8(%rsp), %rdi
callq 0xf1f0
leaq 0x20(%rsp), %rdi
callq 0x2e09a
jmp 0x2d25f
jmp 0x2d5e1
jmp 0x2d64c
jmp 0x2d5bd
jmp 0x2d64c
movq %rax, %rbx
movq 0x58(%rsp), %rdi
cmpq %r15, %rdi
jne 0x2d5f2
jmp 0x2d6b4
jmp 0x2d64c
jmp 0x2d657
jmp 0x2d5e1
jmp 0x2d657
jmp 0x2d672
jmp 0x2d64c
movq %rax, %rbx
movq 0x58(%rsp), %rdi
cmpq %r12, %rdi
je 0x2d6b4
movq 0x68(%rsp), %rsi
incq %rsi
callq 0xf650
jmp 0x2d6b4
jmp 0x2d672
jmp 0x2d68e
jmp 0x2d64c
jmp 0x2d68e
movq %rax, %rbx
leaq 0x48(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2d632
movq 0x48(%rsp), %rsi
incq %rsi
callq 0xf650
jmp 0x2d632
movq %rax, %rbx
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x2d696
movq 0x10(%rsp), %rsi
incq %rsi
callq 0xf650
jmp 0x2d696
jmp 0x2d693
movq %rax, %rbx
jmp 0x2d6b4
jmp 0x2d657
jmp 0x2d672
jmp 0x2d68e
movq %rax, %rbx
movq (%rsp), %rdi
cmpq %r12, %rdi
je 0x2d675
movq 0x10(%rsp), %rsi
incq %rsi
callq 0xf650
jmp 0x2d675
movq %rax, %rbx
movq 0x58(%rsp), %rdi
cmpq %r15, %rdi
je 0x2d6be
movq 0x68(%rsp), %rsi
incq %rsi
callq 0xf650
jmp 0x2d6be
movq %rax, %rbx
jmp 0x2d6be
movq %rax, %rbx
movq 0x458d3(%rip), %rsi     # 0x72f70
leaq 0x58(%rsp), %rdi
callq 0xf370
leaq 0xc8(%rsp), %rdi
callq 0xf1f0
leaq 0x20(%rsp), %rdi
callq 0x2e09a
movq %rbx, %rdi
callq 0xfb40