// File: 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
movq %rsp, %rbp
subq $0x460, %rsp            # imm = 0x460
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x2f0(%rbp)
xorl %eax, %eax
movl %eax, %edi
callq 0x625d0
movq %rax, -0x28(%rbp)
callq 0x120b0
movq -0x2f0(%rbp), %rdi
movq %rax, -0x30(%rbp)
addq $0x10, %rdi
movl $0x2, -0x44(%rbp)
leaq -0x44(%rbp), %rsi
callq 0x3b040
movq %rax, -0x40(%rbp)
leaq -0x30(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x62630
movq %rax, %rcx
movq -0x2f0(%rbp), %rax
movq %rcx, -0x38(%rbp)
addq $0x58, %rax
movq %rax, -0x2e8(%rbp)
movl $0x10, %edi
movl $0x20, %esi
callq 0x62680
movq -0x2e8(%rbp), %rsi
movl %eax, %edx
leaq -0x248(%rbp), %rdi
movq %rdi, -0x2e0(%rbp)
callq 0x13110
movq -0x2e0(%rbp), %rdi
leaq 0x53b55(%rip), %rsi     # 0xb535e
callq 0x12800
movq %rax, -0x2d8(%rbp)
jmp 0x61817
movq -0x2d8(%rbp), %rdi
movq 0xa96f3(%rip), %rsi     # 0x10af18
callq 0x128b0
jmp 0x6182c
movq -0x2f0(%rbp), %rdi
addq $0x28, %rdi
callq 0x62360
testb $0x1, %al
jne 0x61845
jmp 0x61b95
movq -0x2f0(%rbp), %rdi
addq $0x28, %rdi
callq 0x62380
movq %rax, %rdi
callq 0x623a0
movb %al, -0x2f1(%rbp)
jmp 0x61865
movb -0x2f1(%rbp), %dl
leaq 0x53997(%rip), %rcx     # 0xb5209
leaq 0x5394c(%rip), %rax     # 0xb51c5
testb $0x1, %dl
cmovneq %rcx, %rax
movq %rax, -0x308(%rbp)
leaq -0x279(%rbp), %rdi
movq %rdi, -0x300(%rbp)
callq 0x12fa0
movq -0x308(%rbp), %rsi
movq -0x300(%rbp), %rdx
leaq -0x278(%rbp), %rdi
callq 0x22350
jmp 0x618b6
leaq -0x279(%rbp), %rdi
callq 0x128f0
movq -0x2f0(%rbp), %rdi
addq $0x28, %rdi
callq 0x62380
movq %rax, %rdi
callq 0x623a0
movb %al, -0x309(%rbp)
jmp 0x618e2
movb -0x309(%rbp), %dl
leaq 0x539f3(%rip), %rcx     # 0xb52e2
leaq 0x53a02(%rip), %rax     # 0xb52f8
testb $0x1, %dl
cmovneq %rcx, %rax
movq %rax, -0x320(%rbp)
leaq -0x2a1(%rbp), %rdi
movq %rdi, -0x318(%rbp)
callq 0x12fa0
movq -0x320(%rbp), %rsi
movq -0x318(%rbp), %rdx
leaq -0x2a0(%rbp), %rdi
callq 0x22350
jmp 0x61933
leaq -0x2a1(%rbp), %rdi
callq 0x128f0
leaq 0x539cc(%rip), %rsi     # 0xb5312
leaq -0x248(%rbp), %rdi
callq 0x12800
movq %rax, -0x328(%rbp)
jmp 0x6195b
movq -0x328(%rbp), %rdi
movq 0xa95af(%rip), %rsi     # 0x10af18
callq 0x128b0
jmp 0x61970
leaq 0x539ac(%rip), %rsi     # 0xb5323
leaq -0x248(%rbp), %rdi
callq 0x12800
movq %rax, -0x330(%rbp)
jmp 0x6198c
movq -0x2f0(%rbp), %rdi
addq $0x28, %rdi
callq 0x62380
movq %rax, %rdi
callq 0x623a0
movb %al, -0x331(%rbp)
jmp 0x619ac
movq -0x330(%rbp), %rdi
movb -0x331(%rbp), %cl
leaq 0x53849(%rip), %rax     # 0xb5209
leaq 0x537fe(%rip), %rsi     # 0xb51c5
testb $0x1, %cl
cmovneq %rax, %rsi
callq 0x12800
movq %rax, -0x340(%rbp)
jmp 0x619dc
movq -0x340(%rbp), %rdi
leaq 0x5394b(%rip), %rsi     # 0xb5335
callq 0x12800
movq %rax, -0x348(%rbp)
jmp 0x619f8
movq -0x348(%rbp), %rdi
movq 0xa9512(%rip), %rsi     # 0x10af18
callq 0x128b0
jmp 0x61a0d
leaq 0x53924(%rip), %rsi     # 0xb5338
leaq -0x248(%rbp), %rdi
callq 0x12800
movq %rax, -0x350(%rbp)
jmp 0x61a29
movq -0x2f0(%rbp), %rdi
addq $0x28, %rdi
callq 0x62380
movq %rax, %rdi
callq 0x623a0
movb %al, -0x351(%rbp)
jmp 0x61a49
movq -0x350(%rbp), %rdi
movb -0x351(%rbp), %cl
leaq 0x53885(%rip), %rax     # 0xb52e2
leaq 0x53894(%rip), %rsi     # 0xb52f8
testb $0x1, %cl
cmovneq %rax, %rsi
callq 0x12800
movq %rax, -0x360(%rbp)
jmp 0x61a79
movq -0x360(%rbp), %rdi
leaq 0x538ec(%rip), %rsi     # 0xb5373
callq 0x12800
movq %rax, -0x368(%rbp)
jmp 0x61a95
movq -0x368(%rbp), %rdi
movq 0xa9475(%rip), %rsi     # 0x10af18
callq 0x128b0
jmp 0x61aaa
leaq 0x53899(%rip), %rsi     # 0xb534a
leaq -0x248(%rbp), %rdi
callq 0x12800
movq %rax, -0x370(%rbp)
jmp 0x61ac6
movq -0x370(%rbp), %rdi
movq 0xa9444(%rip), %rsi     # 0x10af18
callq 0x128b0
jmp 0x61adb
leaq -0x2a0(%rbp), %rdi
callq 0x13198
leaq -0x278(%rbp), %rdi
callq 0x13198
jmp 0x61b95
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x250(%rbp)
movl %eax, -0x254(%rbp)
jmp 0x6200f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x250(%rbp)
movl %eax, -0x254(%rbp)
leaq -0x279(%rbp), %rdi
callq 0x128f0
jmp 0x6200f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x250(%rbp)
movl %eax, -0x254(%rbp)
jmp 0x61b84
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x250(%rbp)
movl %eax, -0x254(%rbp)
leaq -0x2a1(%rbp), %rdi
callq 0x128f0
jmp 0x61b84
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x250(%rbp)
movl %eax, -0x254(%rbp)
leaq -0x2a0(%rbp), %rdi
callq 0x13198
leaq -0x278(%rbp), %rdi
callq 0x13198
jmp 0x6200f
movq -0x10(%rbp), %rdi
callq 0x12e80
testb $0x1, %al
jne 0x61d46
leaq 0x537a2(%rip), %rsi     # 0xb534f
leaq -0x248(%rbp), %rdi
callq 0x12800
movq %rax, -0x378(%rbp)
jmp 0x61bc2
movq -0x378(%rbp), %rdi
movq 0xa9348(%rip), %rsi     # 0x10af18
callq 0x128b0
jmp 0x61bd7
leaq 0x53782(%rip), %rsi     # 0xb5360
leaq -0x248(%rbp), %rdi
callq 0x12800
movq %rax, -0x380(%rbp)
jmp 0x61bf3
movq -0x380(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x12770
movq %rax, -0x388(%rbp)
jmp 0x61c0c
movq -0x388(%rbp), %rdi
leaq 0x5371b(%rip), %rsi     # 0xb5335
callq 0x12800
movq %rax, -0x390(%rbp)
jmp 0x61c28
movq -0x390(%rbp), %rdi
movq 0xa92e2(%rip), %rsi     # 0x10af18
callq 0x128b0
jmp 0x61c3d
cmpl $0xffffd8f1, -0x1c(%rbp) # imm = 0xFFFFD8F1
je 0x61cad
leaq 0x53728(%rip), %rsi     # 0xb5375
leaq -0x248(%rbp), %rdi
callq 0x12800
movq %rax, -0x398(%rbp)
jmp 0x61c62
movq -0x398(%rbp), %rdi
movl -0x1c(%rbp), %esi
callq 0x12f20
movq %rax, -0x3a0(%rbp)
jmp 0x61c7a
movq -0x3a0(%rbp), %rdi
leaq 0x536ae(%rip), %rsi     # 0xb5336
callq 0x12800
movq %rax, -0x3a8(%rbp)
jmp 0x61c96
movq -0x3a8(%rbp), %rdi
movq 0xa9274(%rip), %rsi     # 0x10af18
callq 0x128b0
jmp 0x61cab
jmp 0x61cad
leaq 0x536d5(%rip), %rsi     # 0xb5389
leaq -0x248(%rbp), %rdi
callq 0x12800
movq %rax, -0x3b0(%rbp)
jmp 0x61cc9
movq -0x3b0(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x12770
movq %rax, -0x3b8(%rbp)
jmp 0x61ce2
movq -0x3b8(%rbp), %rdi
leaq 0x53683(%rip), %rsi     # 0xb5373
callq 0x12800
movq %rax, -0x3c0(%rbp)
jmp 0x61cfe
movq -0x3c0(%rbp), %rdi
movq 0xa920c(%rip), %rsi     # 0x10af18
callq 0x128b0
jmp 0x61d13
leaq 0x53630(%rip), %rsi     # 0xb534a
leaq -0x248(%rbp), %rdi
callq 0x12800
movq %rax, -0x3c8(%rbp)
jmp 0x61d2f
movq -0x3c8(%rbp), %rdi
movq 0xa91db(%rip), %rsi     # 0x10af18
callq 0x128b0
jmp 0x61d44
jmp 0x61d46
leaq 0x53651(%rip), %rsi     # 0xb539e
leaq -0x248(%rbp), %rdi
callq 0x12800
movq %rax, -0x3d0(%rbp)
jmp 0x61d62
leaq -0x30(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x626d0
movq %rax, -0x3d8(%rbp)
jmp 0x61d78
movq -0x3d8(%rbp), %rax
movq %rax, -0x2b8(%rbp)
leaq -0x2b8(%rbp), %rdi
callq 0x626a0
movq %rax, -0x3e0(%rbp)
jmp 0x61d9b
movq -0x3e0(%rbp), %rax
movq %rax, -0x2b0(%rbp)
leaq -0x2b0(%rbp), %rdi
callq 0x24580
movq %rax, -0x3e8(%rbp)
jmp 0x61dbe
movq -0x3e8(%rbp), %rsi
movq -0x3d0(%rbp), %rdi
callq 0x13020
movq %rax, -0x3f0(%rbp)
jmp 0x61dda
movq -0x3f0(%rbp), %rdi
leaq 0x5354e(%rip), %rsi     # 0xb5336
callq 0x12800
movq %rax, -0x3f8(%rbp)
jmp 0x61df6
movq -0x3f8(%rbp), %rdi
movq 0xa9114(%rip), %rsi     # 0x10af18
callq 0x128b0
jmp 0x61e0b
leaq 0x5359c(%rip), %rsi     # 0xb53ae
leaq -0x248(%rbp), %rdi
callq 0x12800
movq %rax, -0x400(%rbp)
jmp 0x61e27
leaq -0x38(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x626d0
movq %rax, -0x408(%rbp)
jmp 0x61e3d
movq -0x408(%rbp), %rax
movq %rax, -0x2c8(%rbp)
leaq -0x2c8(%rbp), %rdi
callq 0x626a0
movq %rax, -0x410(%rbp)
jmp 0x61e60
movq -0x410(%rbp), %rax
movq %rax, -0x2c0(%rbp)
leaq -0x2c0(%rbp), %rdi
callq 0x24580
movq %rax, -0x418(%rbp)
jmp 0x61e83
movq -0x418(%rbp), %rsi
movq -0x400(%rbp), %rdi
callq 0x13020
movq %rax, -0x420(%rbp)
jmp 0x61e9f
movq -0x420(%rbp), %rdi
leaq 0x53489(%rip), %rsi     # 0xb5336
callq 0x12800
movq %rax, -0x428(%rbp)
jmp 0x61ebb
movq -0x428(%rbp), %rdi
movq 0xa904f(%rip), %rsi     # 0x10af18
callq 0x128b0
jmp 0x61ed0
leaq 0x534e7(%rip), %rsi     # 0xb53be
leaq -0x248(%rbp), %rdi
callq 0x12800
movq %rax, -0x430(%rbp)
jmp 0x61eec
movq -0x2f0(%rbp), %rdi
addq $0x10, %rdi
callq 0x62720
movq %rax, -0x438(%rbp)
jmp 0x61f05
movq -0x438(%rbp), %rax
movq %rax, -0x2d0(%rbp)
leaq -0x2d0(%rbp), %rdi
callq 0x24580
movq %rax, -0x440(%rbp)
jmp 0x61f28
movq -0x440(%rbp), %rsi
movq -0x430(%rbp), %rdi
callq 0x13020
movq %rax, -0x448(%rbp)
jmp 0x61f44
movq -0x448(%rbp), %rdi
movq 0xa8fc6(%rip), %rsi     # 0x10af18
callq 0x128b0
jmp 0x61f59
leaq 0x5346e(%rip), %rsi     # 0xb53ce
leaq -0x248(%rbp), %rdi
callq 0x12800
movq %rax, -0x450(%rbp)
jmp 0x61f75
movq -0x450(%rbp), %rdi
movq 0xa8f95(%rip), %rsi     # 0x10af18
callq 0x128b0
jmp 0x61f8a
leaq -0x248(%rbp), %rdi
callq 0x12c70
jmp 0x61f98
movq -0x248(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x248(%rbp,%rax), %rdi
callq 0x12aa0
movb %al, -0x451(%rbp)
jmp 0x61fb8
movb -0x451(%rbp), %al
testb $0x1, %al
jne 0x61fc4
jmp 0x61ffa
movq -0x2f0(%rbp), %rdi
addq $0x58, %rdi
callq 0x12390
movq -0x2f0(%rbp), %rdi
movq %rax, -0x460(%rbp)
addq $0x38, %rdi
callq 0x12390
movq -0x460(%rbp), %rdi
movq %rax, %rsi
callq 0x12560
leaq -0x248(%rbp), %rdi
callq 0x12cf0
addq $0x460, %rsp            # imm = 0x460
popq %rbp
retq
leaq -0x248(%rbp), %rdi
callq 0x12cf0
movq -0x250(%rbp), %rdi
callq 0x12f70
nopw (%rax,%rax)