// File: /workspace/github_cpp_makefile_star2_O1/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 0xf080
movq %rax, 0x10(%rsp)
imulq $0x1e8480, 0x10(%rbx), %rax # imm = 0x1E8480
movq %rax, 0x20(%rsp)
leaq 0x58(%rbx), %rsi
leaq 0x68(%rsp), %r12
movq %r12, %rdi
movl $0x30, %edx
callq 0xfc70
leaq 0x24854(%rip), %rsi     # 0x521ea
movl $0x1, %edx
movq %r12, %rdi
callq 0xf730
movq 0x68(%rsp), %rax
addq -0x18(%rax), %r12
movq %r12, %rdi
movl $0xa, %esi
callq 0xf5f0
movsbl %al, %esi
leaq 0x68(%rsp), %rdi
callq 0xf040
movq %rax, %rdi
callq 0xf470
movq 0x28(%rbx), %rax
testq %rax, %rax
je 0x2dc3a
cmpl $0x0, 0x50(%rax)
setne %cl
andb 0x230(%rax), %cl
leaq 0x246a6(%rip), %r14     # 0x52095
leaq 0x2465b(%rip), %r12     # 0x52051
movq %r12, %rsi
cmovneq %r14, %rsi
leaq 0x58(%rsp), %rax
movq %rax, -0x10(%rax)
movzbl %cl, %eax
leaq (%rsi,%rax,2), %rdx
addq $0x3, %rdx
leaq 0x48(%rsp), %rdi
callq 0x1469c
movq 0x28(%rbx), %rax
cmpl $0x0, 0x50(%rax)
setne %cl
andb 0x230(%rax), %cl
leaq 0x2473b(%rip), %rax     # 0x5216e
leaq 0x2474a(%rip), %rbp     # 0x52184
movq %rbp, %rsi
cmovneq %rax, %rsi
leaq 0x38(%rsp), %rax
movq %rax, -0x10(%rax)
xorb $0x1, %cl
movzbl %cl, %eax
leaq (%rsi,%rax,4), %rdx
addq $0x15, %rdx
leaq 0x28(%rsp), %rdi
callq 0x1469c
leaq 0x24735(%rip), %rsi     # 0x5219e
leaq 0x68(%rsp), %r15
movl $0x10, %edx
movq %r15, %rdi
callq 0xf730
movq 0x68(%rsp), %rax
addq -0x18(%rax), %r15
movq %r15, %rdi
movl $0xa, %esi
callq 0xf5f0
movsbl %al, %esi
leaq 0x68(%rsp), %rdi
callq 0xf040
movq %rax, %rdi
callq 0xf470
leaq 0x24702(%rip), %rsi     # 0x521af
leaq 0x68(%rsp), %rdi
movl $0x11, %edx
callq 0xf730
movq 0x28(%rbx), %rax
cmpl $0x0, 0x50(%rax)
setne %cl
andb 0x230(%rax), %cl
cmovneq %r14, %r12
movzbl %cl, %eax
leaq 0x3(,%rax,2), %rdx
leaq 0x68(%rsp), %rdi
movq %r12, %rsi
callq 0xf730
leaq 0x246d1(%rip), %rsi     # 0x521c1
leaq 0x68(%rsp), %r15
movl $0x2, %edx
movq %r15, %rdi
callq 0xf730
movq 0x68(%rsp), %rax
addq -0x18(%rax), %r15
movq %r15, %rdi
movl $0xa, %esi
callq 0xf5f0
movsbl %al, %esi
leaq 0x68(%rsp), %rdi
callq 0xf040
movq %rax, %rdi
callq 0xf470
leaq 0x24690(%rip), %rsi     # 0x521c4
leaq 0x68(%rsp), %rdi
movl $0x11, %edx
callq 0xf730
movq 0x28(%rbx), %rax
cmpl $0x0, 0x50(%rax)
setne %cl
andb 0x230(%rax), %cl
leaq 0x24613(%rip), %rax     # 0x5216e
cmovneq %rax, %rbp
xorb $0x1, %cl
movzbl %cl, %eax
leaq 0x15(,%rax,4), %rdx
leaq 0x68(%rsp), %rdi
movq %rbp, %rsi
callq 0xf730
leaq 0x2467e(%rip), %rsi     # 0x521ff
leaq 0x68(%rsp), %r15
movl $0x1, %edx
movq %r15, %rdi
callq 0xf730
movq 0x68(%rsp), %rax
addq -0x18(%rax), %r15
movq %r15, %rdi
movl $0xa, %esi
callq 0xf5f0
movsbl %al, %esi
leaq 0x68(%rsp), %rdi
callq 0xf040
movq %rax, %rdi
callq 0xf470
leaq 0x24611(%rip), %rsi     # 0x521d6
leaq 0x68(%rsp), %r15
movl $0x4, %edx
movq %r15, %rdi
callq 0xf730
movq 0x68(%rsp), %rax
addq -0x18(%rax), %r15
movq %r15, %rdi
movl $0xa, %esi
callq 0xf5f0
movsbl %al, %esi
leaq 0x68(%rsp), %rdi
callq 0xf040
movq %rax, %rdi
callq 0xf470
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x2dc1e
movq 0x38(%rsp), %rsi
incq %rsi
callq 0xf650
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x2dc3a
movq 0x58(%rsp), %rsi
incq %rsi
callq 0xf650
cmpq $0x0, 0x8(%r13)
je 0x2de0c
leaq 0x2458f(%rip), %rsi     # 0x521db
leaq 0x68(%rsp), %r15
movl $0x10, %edx
movq %r15, %rdi
callq 0xf730
movq 0x68(%rsp), %rax
addq -0x18(%rax), %r15
movq %r15, %rdi
movl $0xa, %esi
callq 0xf5f0
movsbl %al, %esi
leaq 0x68(%rsp), %rdi
callq 0xf040
movq %rax, %rdi
callq 0xf470
leaq 0x2455c(%rip), %rsi     # 0x521ec
leaq 0x68(%rsp), %rdi
movl $0x14, %edx
callq 0xf730
movq (%r13), %rsi
movq 0x8(%r13), %rdx
leaq 0x68(%rsp), %rdi
callq 0xf730
movq %rax, %r12
leaq 0x24506(%rip), %rsi     # 0x521c1
movl $0x2, %edx
movq %rax, %rdi
callq 0xf730
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0xf5f0
movsbl %al, %esi
movq %r12, %rdi
callq 0xf040
movq %rax, %rdi
callq 0xf470
cmpl $0xffffd8f1, 0xc(%rsp)  # imm = 0xFFFFD8F1
je 0x2dd5d
leaq 0x24500(%rip), %rsi     # 0x52201
leaq 0x68(%rsp), %rdi
movl $0x13, %edx
callq 0xf730
leaq 0x68(%rsp), %rdi
movl 0xc(%rsp), %esi
callq 0xfb10
movq %rax, %r12
leaq 0x2449a(%rip), %rsi     # 0x521c2
movl $0x1, %edx
movq %rax, %rdi
callq 0xf730
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0xf5f0
movsbl %al, %esi
movq %r12, %rdi
callq 0xf040
movq %rax, %rdi
callq 0xf470
leaq 0x244b1(%rip), %rsi     # 0x52215
leaq 0x68(%rsp), %rdi
movl $0x14, %edx
callq 0xf730
movq 0x18(%rsp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
leaq 0x68(%rsp), %rdi
callq 0xf730
movq %rax, %r12
leaq 0x2446c(%rip), %rsi     # 0x521ff
movl $0x1, %edx
movq %rax, %rdi
callq 0xf730
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0xf5f0
movsbl %al, %esi
movq %r12, %rdi
callq 0xf040
movq %rax, %rdi
callq 0xf470
leaq 0x24407(%rip), %rsi     # 0x521d6
leaq 0x68(%rsp), %r15
movl $0x4, %edx
movq %r15, %rdi
callq 0xf730
movq 0x68(%rsp), %rax
addq -0x18(%rax), %r15
movq %r15, %rdi
movl $0xa, %esi
callq 0xf5f0
movsbl %al, %esi
leaq 0x68(%rsp), %rdi
callq 0xf040
movq %rax, %rdi
callq 0xf470
leaq 0x24417(%rip), %rsi     # 0x5222a
leaq 0x68(%rsp), %rdi
movl $0xf, %edx
callq 0xf730
movabsq $0x431bde82d7b634db, %r14 # imm = 0x431BDE82D7B634DB
movq 0x10(%rsp), %rax
imulq %r14
movq %rdx, %rsi
shrq $0x3f, %rsi
sarq $0x12, %rdx
addq %rdx, %rsi
leaq 0x68(%rsp), %rdi
callq 0xf5e0
movq %rax, %r12
leaq 0x2436c(%rip), %rsi     # 0x521c2
movl $0x1, %edx
movq %rax, %rdi
callq 0xf730
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0xf5f0
movsbl %al, %esi
movq %r12, %rdi
callq 0xf040
movq %rax, %rdi
callq 0xf470
leaq 0x243a8(%rip), %rsi     # 0x5223a
leaq 0x68(%rsp), %rdi
movl $0xf, %edx
callq 0xf730
movq 0x20(%rsp), %rax
addq 0x10(%rsp), %rax
imulq %r14
movq %rdx, %rsi
shrq $0x3f, %rsi
sarq $0x12, %rdx
addq %rdx, %rsi
leaq 0x68(%rsp), %rdi
callq 0xf5e0
movq %rax, %r14
leaq 0x242f2(%rip), %rsi     # 0x521c2
movl $0x1, %edx
movq %rax, %rdi
callq 0xf730
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0xf5f0
movsbl %al, %esi
movq %r14, %rdi
callq 0xf040
movq %rax, %rdi
callq 0xf470
leaq 0x2433f(%rip), %rsi     # 0x5224a
leaq 0x68(%rsp), %rdi
movl $0xf, %edx
callq 0xf730
movq 0x10(%rbx), %rsi
leaq 0x68(%rsp), %rdi
callq 0xf5e0
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0xf5f0
movsbl %al, %esi
movq %r14, %rdi
callq 0xf040
movq %rax, %rdi
callq 0xf470
leaq 0x24301(%rip), %rsi     # 0x5225a
leaq 0x68(%rsp), %r14
movl $0x1, %edx
movq %r14, %rdi
callq 0xf730
movq 0x68(%rsp), %rax
addq -0x18(%rax), %r14
movq %r14, %rdi
movl $0xa, %esi
callq 0xf5f0
movsbl %al, %esi
leaq 0x68(%rsp), %rdi
callq 0xf040
movq %rax, %rdi
callq 0xf470
leaq 0x68(%rsp), %rdi
callq 0xf940
movq 0x68(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x88(%rsp,%rax)
jne 0x2dfc0
movq 0x38(%rbx), %rsi
movq 0x58(%rbx), %rdi
callq 0xf3e0
movq 0x44f89(%rip), %rax     # 0x72f50
movq (%rax), %rcx
movq 0x18(%rax), %rax
leaq 0x70(%rsp), %rdi
movq %rcx, -0x8(%rdi)
movq -0x18(%rcx), %rcx
movq %rax, 0x68(%rsp,%rcx)
callq 0xf550
leaq 0x160(%rsp), %rdi
callq 0xf1f0
addq $0x268, %rsp            # imm = 0x268
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x2e030
jmp 0x2e04e
jmp 0x2e04e
jmp 0x2e04e
jmp 0x2e04e
movq %rax, %rbx
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x2e030
movq 0x38(%rsp), %rsi
incq %rsi
callq 0xf650
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x2e051
movq 0x58(%rsp), %rsi
incq %rsi
callq 0xf650
jmp 0x2e051
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
callq 0xf990
movq %rbx, %rdi
callq 0xfb40
nop