// File: /workspace/github_cpp_makefile_star2_O2/MisakiFx[P]P2PDownload/./httplib.h
// Function: httplib::Server::write_response(httplib::Stream&, bool, httplib::Request const&, httplib::Response&)
inline void Server::write_response(Stream &strm, bool last_connection,
            const Request &req, Response &res) {
        assert(res.status != -1);

        if (400 <= res.status && error_handler_) { error_handler_(req, res); }

        // Response line
        strm.write_format("HTTP/1.1 %d %s\r\n", res.status,
                detail::status_message(res.status));

        // Headers
        if (last_connection || req.get_header_value("Connection") == "close") {
            res.set_header("Connection", "close");
        }

        if (!last_connection && req.get_header_value("Connection") == "Keep-Alive") {
            res.set_header("Connection", "Keep-Alive");
        }

        if (res.body.empty()) {
            if (!res.has_header("Content-Length")) {
                if (res.streamcb) {
                    // Streamed response
                    res.set_header("Transfer-Encoding", "chunked");
                } else {
                    res.set_header("Content-Length", "0");
                }
            }
        } else {
#ifdef CPPHTTPLIB_ZLIB_SUPPORT
            // TODO: 'Accpet-Encoding' has gzip, not gzip;q=0
            const auto &encodings = req.get_header_value("Accept-Encoding");
            if (encodings.find("gzip") != std::string::npos &&
                    detail::can_compress(res.get_header_value("Content-Type"))) {
                detail::compress(res.body);
                res.set_header("Content-Encoding", "gzip");
            }
#endif

            if (!res.has_header("Content-Type")) {
                res.set_header("Content-Type", "text/plain");
            }

            auto length = std::to_string(res.body.size());
            res.set_header("Content-Length", length.c_str());
        }

        detail::write_headers(strm, res);

        // Body
        if (req.method != "HEAD") {
            if (!res.body.empty()) {
                strm.write(res.body.c_str(), res.body.size());
            } else if (res.streamcb) {
                bool chunked_response = !res.has_header("Content-Length");
                uint64_t offset = 0;
                bool data_available = true;
                while (data_available) {
                    std::string chunk = res.streamcb(offset);
                    offset += chunk.size();
                    data_available = !chunk.empty();
                    // Emit chunked response header and footer for each chunk
                    if (chunked_response)
                        chunk = detail::from_i_to_hex(chunk.size()) + "\r\n" + chunk + "\r\n";
                    if (strm.write(chunk.c_str(), chunk.size()) < 0) break; // Stop on error
                }
            }
        }

        // Log
        if (logger_) { logger_(req, res); }
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movq %rdi, %rax
movq %r8, -0x30(%rbp)
movl 0x20(%r8), %edi
cmpl $-0x1, %edi
je 0x1b5b5
movq %rcx, %r13
movl %edx, %r14d
movq %rsi, %r12
movq -0x30(%rbp), %rcx
leaq 0x20(%rcx), %r15
cmpl $0x190, %edi            # imm = 0x190
movq %rax, -0x68(%rbp)
jl 0x1b28e
cmpq $0x0, 0xe0(%rax)
je 0x1b28e
movq -0x68(%rbp), %rax
leaq 0xd0(%rax), %rdi
movq %r13, %rsi
movq -0x30(%rbp), %rbx
movq %rbx, %rdx
callq 0x1c4c0
movl 0x20(%rbx), %edi
callq 0x1c5d0
leaq -0x60(%rbp), %rcx
movq %rax, (%rcx)
leaq 0x9fa4(%rip), %rsi      # 0x25245
movq %r12, %rdi
movq %r15, %rdx
callq 0x1c4d6
testb %r14b, %r14b
je 0x1b2bd
leaq 0x9e4b(%rip), %r14      # 0x25103
jmp 0x1b34d
movq %r12, -0x40(%rbp)
leaq 0x9e30(%rip), %rdx      # 0x250f8
leaq -0x60(%rbp), %r14
movq %r14, %rdi
movq %r13, %rsi
xorl %ecx, %ecx
callq 0x147d2
leaq 0x9e23(%rip), %rsi      # 0x25103
movq %r14, %rdi
callq 0xe8a4
movl %eax, %r15d
movq %r14, %rdi
callq 0x8aa8
testb %r15b, %r15b
je 0x1b30f
leaq 0x9df9(%rip), %rsi      # 0x250f8
leaq 0x9dfd(%rip), %rdx      # 0x25103
movq -0x30(%rbp), %rdi
callq 0x1424e
leaq 0x9de2(%rip), %rdx      # 0x250f8
leaq -0x60(%rbp), %r15
movq %r15, %rdi
movq %r13, %rsi
xorl %ecx, %ecx
callq 0x147d2
leaq 0x9f28(%rip), %r14      # 0x25256
movq %r15, %rdi
movq %r14, %rsi
callq 0xe8a4
movl %eax, %r12d
movq %r15, %rdi
callq 0x8aa8
testb %r12b, %r12b
movq -0x40(%rbp), %r12
je 0x1b360
leaq 0x9da4(%rip), %rsi      # 0x250f8
movq -0x30(%rbp), %rdi
movq %r14, %rdx
callq 0x1424e
movq -0x30(%rbp), %rax
cmpq $0x0, 0x60(%rax)
je 0x1b3c7
leaq 0x9715(%rip), %rsi      # 0x24a87
movq -0x30(%rbp), %rdi
callq 0x19252
testb %al, %al
jne 0x1b396
leaq 0x9701(%rip), %rsi      # 0x24a87
leaq 0x9eee(%rip), %rdx      # 0x2527b
movq -0x30(%rbp), %rdi
callq 0x1424e
movq -0x30(%rbp), %rbx
movq 0x60(%rbx), %rsi
leaq -0x60(%rbp), %r14
movq %r14, %rdi
callq 0x1c697
movq (%r14), %rdx
leaq 0x98b6(%rip), %rsi      # 0x24c6a
movq %rbx, %rdi
callq 0x1424e
leaq -0x60(%rbp), %rdi
callq 0x8aa8
jmp 0x1b410
leaq 0x989c(%rip), %rsi      # 0x24c6a
movq -0x30(%rbp), %rdi
callq 0x19252
testb %al, %al
jne 0x1b410
movq -0x30(%rbp), %rax
cmpq $0x0, 0x88(%rax)
je 0x1b3f9
leaq 0x9e71(%rip), %rsi      # 0x25261
leaq 0x9e7c(%rip), %rdx      # 0x25273
jmp 0x1b407
leaq 0x986a(%rip), %rsi      # 0x24c6a
leaq 0x969d(%rip), %rdx      # 0x24aa4
movq -0x30(%rbp), %rdi
callq 0x1424e
movq %r12, %rdi
movq -0x30(%rbp), %rsi
callq 0x1c6d9
movq %r13, -0x78(%rbp)
leaq 0x20(%r13), %rdi
leaq 0x983a(%rip), %rsi      # 0x24c65
callq 0x1c758
testb %al, %al
je 0x1b453
movq -0x30(%rbp), %rax
movq 0x60(%rax), %rdx
testq %rdx, %rdx
je 0x1b487
movq -0x30(%rbp), %rax
movq 0x58(%rax), %rsi
movq (%r12), %rax
movq %r12, %rdi
callq *0x18(%rax)
movq -0x68(%rbp), %rdi
cmpq $0x0, 0x100(%rdi)
je 0x1b475
addq $0xf0, %rdi
movq -0x78(%rbp), %rsi
movq -0x30(%rbp), %rdx
callq 0x1c81c
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq -0x30(%rbp), %rax
cmpq $0x0, 0x88(%rax)
je 0x1b453
movq -0x30(%rbp), %rdi
leaq 0x78(%rdi), %rax
movq %rax, -0x80(%rbp)
leaq 0x97c2(%rip), %rsi      # 0x24c6a
callq 0x19252
movb %al, -0x31(%rbp)
movb $0x1, %al
movq $0x0, -0x70(%rbp)
leaq -0xc0(%rbp), %r13
leaq -0xe0(%rbp), %r14
leaq -0xa0(%rbp), %r15
testb $0x1, %al
je 0x1b453
leaq -0x60(%rbp), %rdi
movq -0x80(%rbp), %rsi
movq -0x70(%rbp), %rdx
callq 0x1c766
movq -0x58(%rbp), %rdx
testq %rdx, %rdx
setne -0x32(%rbp)
movq %rdx, -0x40(%rbp)
cmpb $0x0, -0x31(%rbp)
jne 0x1b56f
movq %r13, %rdi
movq -0x40(%rbp), %rsi
callq 0x1c790
movq %r14, %rdi
movq %r13, %rsi
leaq 0x9e95(%rip), %rdx      # 0x253a7
callq 0x14719
movq %r15, %rdi
movq %r14, %rsi
leaq -0x60(%rbp), %rdx
callq 0x146f0
leaq -0x100(%rbp), %rbx
movq %rbx, %rdi
movq %r15, %rsi
leaq 0x9e6d(%rip), %rdx      # 0x253a7
callq 0x14719
leaq -0x60(%rbp), %rdi
movq %rbx, %rsi
callq 0x86c0
movq %rbx, %rdi
callq 0x8aa8
movq %r15, %rdi
callq 0x8aa8
movq %r14, %rdi
callq 0x8aa8
movq %r13, %rdi
callq 0x8aa8
movq -0x58(%rbp), %rdx
movq %r13, %rbx
movq -0x60(%rbp), %rsi
movq (%r12), %rax
movq %r12, %r13
movq %r12, %rdi
callq *0x18(%rax)
movl %eax, %r12d
movq -0x40(%rbp), %rax
addq %rax, -0x70(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x8aa8
testl %r12d, %r12d
movq %r13, %r12
movq %rbx, %r13
leaq -0xa0(%rbp), %r15
movb -0x32(%rbp), %al
jns 0x1b4cf
jmp 0x1b453
leaq 0x9c26(%rip), %rdi      # 0x251e2
leaq 0x9bdc(%rip), %rsi      # 0x2519f
leaq 0x9c29(%rip), %rcx      # 0x251f3
movl $0x630, %edx            # imm = 0x630
callq 0x8370
jmp 0x1b60b
movq %rax, %rbx
jmp 0x1b5f1
movq %rax, %rbx
jmp 0x1b5fd
jmp 0x1b60b
movq %rax, %rbx
leaq -0xa0(%rbp), %rdi
callq 0x8aa8
leaq -0xe0(%rbp), %rdi
callq 0x8aa8
leaq -0xc0(%rbp), %rdi
callq 0x8aa8
jmp 0x1b60e
movq %rax, %rbx
leaq -0x60(%rbp), %rdi
callq 0x8aa8
movq %rbx, %rdi
callq 0x8990
nop