// File: /workspace/github_cpp_makefile_star2_O3/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 0xe080
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 0xec70
leaq 0x24616(%rip), %rsi     # 0x5023a
movl $0x1, %edx
movq %r12, %rdi
callq 0xe730
movq 0x68(%rsp), %rax
addq -0x18(%rax), %r12
movq %r12, %rdi
movl $0xa, %esi
callq 0xe5f0
movsbl %al, %esi
leaq 0x68(%rsp), %rdi
callq 0xe040
movq %rax, %rdi
callq 0xe470
movq 0x28(%rbx), %rax
testq %rax, %rax
je 0x2bec8
cmpl $0x0, 0x50(%rax)
setne %cl
andb 0x230(%rax), %cl
leaq 0x24468(%rip), %r14     # 0x500e5
leaq 0x2441d(%rip), %r12     # 0x500a1
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 0x134ac
movq 0x28(%rbx), %rax
cmpl $0x0, 0x50(%rax)
setne %cl
andb 0x230(%rax), %cl
leaq 0x244fd(%rip), %rax     # 0x501be
leaq 0x2450c(%rip), %rbp     # 0x501d4
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 0x134ac
leaq 0x244f7(%rip), %rsi     # 0x501ee
leaq 0x68(%rsp), %r15
movl $0x10, %edx
movq %r15, %rdi
callq 0xe730
movq 0x68(%rsp), %rax
addq -0x18(%rax), %r15
movq %r15, %rdi
movl $0xa, %esi
callq 0xe5f0
movsbl %al, %esi
leaq 0x68(%rsp), %rdi
callq 0xe040
movq %rax, %rdi
callq 0xe470
leaq 0x244c4(%rip), %rsi     # 0x501ff
leaq 0x68(%rsp), %rdi
movl $0x11, %edx
callq 0xe730
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 0xe730
leaq 0x24493(%rip), %rsi     # 0x50211
leaq 0x68(%rsp), %r15
movl $0x2, %edx
movq %r15, %rdi
callq 0xe730
movq 0x68(%rsp), %rax
addq -0x18(%rax), %r15
movq %r15, %rdi
movl $0xa, %esi
callq 0xe5f0
movsbl %al, %esi
leaq 0x68(%rsp), %rdi
callq 0xe040
movq %rax, %rdi
callq 0xe470
leaq 0x24452(%rip), %rsi     # 0x50214
leaq 0x68(%rsp), %rdi
movl $0x11, %edx
callq 0xe730
movq 0x28(%rbx), %rax
cmpl $0x0, 0x50(%rax)
setne %cl
andb 0x230(%rax), %cl
leaq 0x243d5(%rip), %rax     # 0x501be
cmovneq %rax, %rbp
xorb $0x1, %cl
movzbl %cl, %eax
leaq 0x15(,%rax,4), %rdx
leaq 0x68(%rsp), %rdi
movq %rbp, %rsi
callq 0xe730
leaq 0x24440(%rip), %rsi     # 0x5024f
leaq 0x68(%rsp), %r15
movl $0x1, %edx
movq %r15, %rdi
callq 0xe730
movq 0x68(%rsp), %rax
addq -0x18(%rax), %r15
movq %r15, %rdi
movl $0xa, %esi
callq 0xe5f0
movsbl %al, %esi
leaq 0x68(%rsp), %rdi
callq 0xe040
movq %rax, %rdi
callq 0xe470
leaq 0x243d3(%rip), %rsi     # 0x50226
leaq 0x68(%rsp), %r15
movl $0x4, %edx
movq %r15, %rdi
callq 0xe730
movq 0x68(%rsp), %rax
addq -0x18(%rax), %r15
movq %r15, %rdi
movl $0xa, %esi
callq 0xe5f0
movsbl %al, %esi
leaq 0x68(%rsp), %rdi
callq 0xe040
movq %rax, %rdi
callq 0xe470
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x2beac
movq 0x38(%rsp), %rsi
incq %rsi
callq 0xe650
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x2bec8
movq 0x58(%rsp), %rsi
incq %rsi
callq 0xe650
cmpq $0x0, 0x8(%r13)
je 0x2c09a
leaq 0x24351(%rip), %rsi     # 0x5022b
leaq 0x68(%rsp), %r15
movl $0x10, %edx
movq %r15, %rdi
callq 0xe730
movq 0x68(%rsp), %rax
addq -0x18(%rax), %r15
movq %r15, %rdi
movl $0xa, %esi
callq 0xe5f0
movsbl %al, %esi
leaq 0x68(%rsp), %rdi
callq 0xe040
movq %rax, %rdi
callq 0xe470
leaq 0x2431e(%rip), %rsi     # 0x5023c
leaq 0x68(%rsp), %rdi
movl $0x14, %edx
callq 0xe730
movq (%r13), %rsi
movq 0x8(%r13), %rdx
leaq 0x68(%rsp), %rdi
callq 0xe730
movq %rax, %r12
leaq 0x242c8(%rip), %rsi     # 0x50211
movl $0x2, %edx
movq %rax, %rdi
callq 0xe730
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0xe5f0
movsbl %al, %esi
movq %r12, %rdi
callq 0xe040
movq %rax, %rdi
callq 0xe470
cmpl $0xffffd8f1, 0xc(%rsp)  # imm = 0xFFFFD8F1
je 0x2bfeb
leaq 0x242c2(%rip), %rsi     # 0x50251
leaq 0x68(%rsp), %rdi
movl $0x13, %edx
callq 0xe730
leaq 0x68(%rsp), %rdi
movl 0xc(%rsp), %esi
callq 0xeb10
movq %rax, %r12
leaq 0x2425c(%rip), %rsi     # 0x50212
movl $0x1, %edx
movq %rax, %rdi
callq 0xe730
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0xe5f0
movsbl %al, %esi
movq %r12, %rdi
callq 0xe040
movq %rax, %rdi
callq 0xe470
leaq 0x24273(%rip), %rsi     # 0x50265
leaq 0x68(%rsp), %rdi
movl $0x14, %edx
callq 0xe730
movq 0x18(%rsp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
leaq 0x68(%rsp), %rdi
callq 0xe730
movq %rax, %r12
leaq 0x2422e(%rip), %rsi     # 0x5024f
movl $0x1, %edx
movq %rax, %rdi
callq 0xe730
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0xe5f0
movsbl %al, %esi
movq %r12, %rdi
callq 0xe040
movq %rax, %rdi
callq 0xe470
leaq 0x241c9(%rip), %rsi     # 0x50226
leaq 0x68(%rsp), %r15
movl $0x4, %edx
movq %r15, %rdi
callq 0xe730
movq 0x68(%rsp), %rax
addq -0x18(%rax), %r15
movq %r15, %rdi
movl $0xa, %esi
callq 0xe5f0
movsbl %al, %esi
leaq 0x68(%rsp), %rdi
callq 0xe040
movq %rax, %rdi
callq 0xe470
leaq 0x241d9(%rip), %rsi     # 0x5027a
leaq 0x68(%rsp), %rdi
movl $0xf, %edx
callq 0xe730
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 0xe5e0
movq %rax, %r12
leaq 0x2412e(%rip), %rsi     # 0x50212
movl $0x1, %edx
movq %rax, %rdi
callq 0xe730
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0xe5f0
movsbl %al, %esi
movq %r12, %rdi
callq 0xe040
movq %rax, %rdi
callq 0xe470
leaq 0x2416a(%rip), %rsi     # 0x5028a
leaq 0x68(%rsp), %rdi
movl $0xf, %edx
callq 0xe730
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 0xe5e0
movq %rax, %r14
leaq 0x240b4(%rip), %rsi     # 0x50212
movl $0x1, %edx
movq %rax, %rdi
callq 0xe730
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0xe5f0
movsbl %al, %esi
movq %r14, %rdi
callq 0xe040
movq %rax, %rdi
callq 0xe470
leaq 0x24101(%rip), %rsi     # 0x5029a
leaq 0x68(%rsp), %rdi
movl $0xf, %edx
callq 0xe730
movq 0x10(%rbx), %rsi
leaq 0x68(%rsp), %rdi
callq 0xe5e0
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0xe5f0
movsbl %al, %esi
movq %r14, %rdi
callq 0xe040
movq %rax, %rdi
callq 0xe470
leaq 0x240c3(%rip), %rsi     # 0x502aa
leaq 0x68(%rsp), %r14
movl $0x1, %edx
movq %r14, %rdi
callq 0xe730
movq 0x68(%rsp), %rax
addq -0x18(%rax), %r14
movq %r14, %rdi
movl $0xa, %esi
callq 0xe5f0
movsbl %al, %esi
leaq 0x68(%rsp), %rdi
callq 0xe040
movq %rax, %rdi
callq 0xe470
leaq 0x68(%rsp), %rdi
callq 0xe940
movq 0x68(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x88(%rsp,%rax)
jne 0x2c24e
movq 0x38(%rbx), %rsi
movq 0x58(%rbx), %rdi
callq 0xe3e0
movq 0x44cfb(%rip), %rax     # 0x70f50
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 0xe550
leaq 0x160(%rsp), %rdi
callq 0xe1f0
addq $0x268, %rsp            # imm = 0x268
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x2c2be
jmp 0x2c2dc
jmp 0x2c2dc
jmp 0x2c2dc
jmp 0x2c2dc
movq %rax, %rbx
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x2c2be
movq 0x38(%rsp), %rsi
incq %rsi
callq 0xe650
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x2c2df
movq 0x58(%rsp), %rsi
incq %rsi
callq 0xe650
jmp 0x2c2df
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
callq 0xe990
movq %rbx, %rdi
callq 0xeb40
nop