// File: /workspace/github_cpp_makefile_star2_O2/flightaware[P]beast-splitter/status_writer.cc
// Function: splitter::StatusWriter::write_status_file(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, int)
void StatusWriter::write_status_file(const std::string &gps_color, const std::string &gps_message, int pps_offset) {
        // This is simple enough we don't bother with a JSON library.
        // NB: we assume that the status messages do not need escaping.

        auto unix_epoch = std::chrono::system_clock::from_time_t(0);
        auto now = std::chrono::system_clock::now();
        auto expiry = now + timeout_interval * 2;

        std::ofstream outf(temppath, std::ios::out | std::ios::trunc);
        outf << "{" << std::endl;

        if (input) {
            std::string radio_color = (input->is_connected() ? "green" : "red");
            std::string radio_message = (input->is_connected() ? "Connected to receiver" : "Not connected to receiver");

            outf << "  \"radio\"    : {" << std::endl;
            outf << "    \"status\"  : \"" << (input->is_connected() ? "green" : "red") << "\"," << std::endl;
            outf << "    \"message\" : \"" << (input->is_connected() ? "Connected to receiver" : "Not connected to receiver") << "\"" << std::endl;
            outf << "  }," << std::endl;
        }

        if (!gps_color.empty()) {
            outf << "  \"gps\"      : {" << std::endl;
            outf << "    \"status\"     : \"" << gps_color << "\"," << std::endl;
            if (pps_offset != -9999) {
                outf << "    \"pps_offset\" : " << pps_offset << "," << std::endl;
            }
            outf << "    \"message\"    : \"" << gps_message << "\"" << std::endl;
            outf << "  }," << std::endl;
        }

        outf << "  \"time\"     : " << std::chrono::duration_cast<std::chrono::milliseconds>(now - unix_epoch).count() << "," << std::endl;
        outf << "  \"expiry\"   : " << std::chrono::duration_cast<std::chrono::milliseconds>(expiry - unix_epoch).count() << "," << std::endl;
        outf << "  \"interval\" : " << std::chrono::duration_cast<std::chrono::milliseconds>(timeout_interval).count() << std::endl;
        outf << "}" << std::endl;
        outf.close();

        if (outf) {
            std::rename(temppath.c_str(), path.c_str());
        }
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x268, %rsp            # imm = 0x268
movl %ecx, 0xc(%rsp)
movq %rdx, 0x18(%rsp)
movq %rsi, %r13
movq %rdi, %rbx
callq 0xf070
movq %rax, 0x10(%rsp)
imulq $0x1e8480, 0x10(%rbx), %rax # imm = 0x1E8480
movq %rax, 0x20(%rsp)
leaq 0x58(%rbx), %rsi
leaq 0x68(%rsp), %r12
pushq $0x30
popq %rdx
movq %r12, %rdi
callq 0xfd00
leaq 0x1dd2a(%rip), %rsi     # 0x452da
movq %r12, %rdi
callq 0xf610
movq %rax, %rdi
callq 0xf310
movq 0x28(%rbx), %rax
testq %rax, %rax
je 0x27711
cmpl $0x0, 0x50(%rax)
leaq 0x1dbad(%rip), %rbp     # 0x45185
leaq 0x1db62(%rip), %r14     # 0x45141
movq %r14, %rsi
cmovneq %rbp, %rsi
cmpb $0x0, 0x230(%rax)
cmoveq %r14, %rsi
leaq 0x48(%rsp), %rdi
leaq 0x28(%rsp), %rdx
callq 0x13c2e
movq 0x28(%rbx), %rax
cmpl $0x0, 0x50(%rax)
leaq 0x1dc4f(%rip), %r12     # 0x4525e
leaq 0x1dc5e(%rip), %r15     # 0x45274
movq %r15, %rsi
cmovneq %r12, %rsi
cmpb $0x0, 0x230(%rax)
cmoveq %r15, %rsi
leaq 0x28(%rsp), %rdi
leaq 0xb(%rsp), %rdx
callq 0x13c2e
leaq 0x1dc50(%rip), %rsi     # 0x4528e
leaq 0x68(%rsp), %rdi
callq 0xf610
movq %rax, %rdi
callq 0xf310
leaq 0x1dc48(%rip), %rsi     # 0x4529f
leaq 0x68(%rsp), %rdi
callq 0xf610
movq 0x28(%rbx), %rcx
cmpl $0x0, 0x50(%rcx)
cmoveq %r14, %rbp
cmpb $0x0, 0x230(%rcx)
cmoveq %r14, %rbp
movq %rax, %rdi
movq %rbp, %rsi
callq 0xf610
leaq 0x1dc27(%rip), %rsi     # 0x452b1
movq %rax, %rdi
callq 0xf610
movq %rax, %rdi
callq 0xf310
leaq 0x1dc13(%rip), %rsi     # 0x452b4
leaq 0x68(%rsp), %rdi
callq 0xf610
movq 0x28(%rbx), %rcx
cmpl $0x0, 0x50(%rcx)
cmoveq %r15, %r12
cmpb $0x0, 0x230(%rcx)
cmoveq %r15, %r12
movq %rax, %rdi
movq %r12, %rsi
callq 0xf610
leaq 0x1dc1b(%rip), %rsi     # 0x452ef
movq %rax, %rdi
callq 0xf610
movq %rax, %rdi
callq 0xf310
leaq 0x1dbdb(%rip), %rsi     # 0x452c6
leaq 0x68(%rsp), %rdi
callq 0xf610
movq %rax, %rdi
callq 0xf310
leaq 0x28(%rsp), %rdi
callq 0xfd68
leaq 0x48(%rsp), %rdi
callq 0xfd68
cmpq $0x0, 0x8(%r13)
je 0x277f4
leaq 0x1dba8(%rip), %rsi     # 0x452cb
leaq 0x68(%rsp), %rdi
callq 0xf610
movq %rax, %rdi
callq 0xf310
leaq 0x1dba0(%rip), %rsi     # 0x452dc
leaq 0x68(%rsp), %rdi
callq 0xf610
movq %rax, %rdi
movq %r13, %rsi
callq 0xf590
leaq 0x1db59(%rip), %rsi     # 0x452b1
movq %rax, %rdi
callq 0xf610
movq %rax, %rdi
callq 0xf310
cmpl $0xffffd8f1, 0xc(%rsp)  # imm = 0xFFFFD8F1
je 0x277a6
leaq 0x1db78(%rip), %rsi     # 0x452f1
leaq 0x68(%rsp), %rdi
callq 0xf610
movq %rax, %rdi
movl 0xc(%rsp), %esi
callq 0xfb60
leaq 0x1db1c(%rip), %rsi     # 0x452b2
movq %rax, %rdi
callq 0xf610
movq %rax, %rdi
callq 0xf310
leaq 0x1db58(%rip), %rsi     # 0x45305
leaq 0x68(%rsp), %rdi
callq 0xf610
movq %rax, %rdi
movq 0x18(%rsp), %rsi
callq 0xf590
leaq 0x1db24(%rip), %rsi     # 0x452ef
movq %rax, %rdi
callq 0xf610
movq %rax, %rdi
callq 0xf310
leaq 0x1dae4(%rip), %rsi     # 0x452c6
leaq 0x68(%rsp), %rdi
callq 0xf610
movq %rax, %rdi
callq 0xf310
leaq 0x1db1f(%rip), %rsi     # 0x4531a
leaq 0x68(%rsp), %rdi
callq 0xf610
movq %rax, %rdi
movl $0xf4240, %ecx          # imm = 0xF4240
movq 0x10(%rsp), %rax
cqto
idivq %rcx
movq %rax, %rsi
callq 0xf5f0
leaq 0x1da8c(%rip), %rsi     # 0x452b2
movq %rax, %rdi
callq 0xf610
movq %rax, %rdi
callq 0xf310
leaq 0x1daed(%rip), %rsi     # 0x4532a
leaq 0x68(%rsp), %rdi
callq 0xf610
movq %rax, %rdi
movq 0x20(%rsp), %rax
addq 0x10(%rsp), %rax
movl $0xf4240, %ecx          # imm = 0xF4240
cqto
idivq %rcx
movq %rax, %rsi
callq 0xf5f0
leaq 0x1da45(%rip), %rsi     # 0x452b2
movq %rax, %rdi
callq 0xf610
movq %rax, %rdi
callq 0xf310
leaq 0x1dab6(%rip), %rsi     # 0x4533a
leaq 0x68(%rsp), %rdi
callq 0xf610
movq 0x10(%rbx), %rsi
movq %rax, %rdi
callq 0xf5f0
movq %rax, %rdi
callq 0xf310
leaq 0x1daa1(%rip), %rsi     # 0x4534a
leaq 0x68(%rsp), %rdi
callq 0xf610
movq %rax, %rdi
callq 0xf310
leaq 0x68(%rsp), %rdi
callq 0xf960
movq 0x68(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x88(%rsp,%rax)
jne 0x278e5
movq 0x38(%rbx), %rsi
movq 0x58(%rbx), %rdi
callq 0xf3f0
leaq 0x68(%rsp), %rdi
callq 0xf9b0
addq $0x268, %rsp            # imm = 0x268
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x2791b
jmp 0x27927
jmp 0x27927
jmp 0x27927
jmp 0x27927
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0xfd68
leaq 0x48(%rsp), %rdi
callq 0xfd68
jmp 0x2792a
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
callq 0xf9b0
movq %rbx, %rdi
callq 0xfba0