// File: /workspace/github_c_makefile_star2_O2/ttoobne[P]bohttpd/src/http/http.c
// Function: serve_headers
static int serve_headers(http_request_t* rq, http_headers_out_t* out, char* mime_type, off_t length, unsigned errstatus) {
    char headers[MAXMSG] = { '\0' };
    char buf[MAXLINE] = { '\0' };
    struct tm tm;
    time_t now;
    size_t size;

    if (out == NULL) {
        sprintf(headers, "%s %u %s\r\n", PROTOCOL, errstatus, get_shortmsg(errstatus));

        sprintf(headers, "%sServer: %s\r\n", headers, SERVER_NAME);

        now = time((time_t *)0);
        strftime(buf, MAXLINE, "%a, %d %b %Y %H:%M:%S GMT", gmtime(&now));
        sprintf(headers, "%sDate: %s\r\n", headers, buf);

        sprintf(headers, "%sConnection: close\r\n", headers);

        if (mime_type) {
            sprintf(headers, "%sContent-type: %s\r\n", headers, mime_type);
        }

        if (length >= 0) {
            sprintf(headers, "%sContent-length: %lld\r\n", headers, (long long)length);
        }

        sprintf(headers, "%s\r\n", headers);
    } else {
        sprintf(headers, "%s %u %s\r\n", PROTOCOL, out->status, get_shortmsg(out->status));

        sprintf(headers, "%sServer: %s\r\n", headers, SERVER_NAME);

        now = time((time_t *)0);
        strftime(buf, MAXLINE, "%a, %d %b %Y %H:%M:%S GMT", gmtime(&now));
        sprintf(headers, "%sDate: %s\r\n", headers, buf);

        if (out->keep_alive) {
            sprintf(headers, "%sConnection: keep-alive\r\n", headers);
            sprintf(headers, "%sKeep-Alive: timeout=%lu\r\n", headers, rq->timeout);
        }

        if (mime_type) {
            sprintf(headers, "%sContent-type: %s\r\n", headers, mime_type);
        }

        if (length >= 0) {
            sprintf(headers, "%sContent-length: %lld\r\n", headers, (long long)length);
        }

        if (out->if_modified) {
            localtime_r(&(out->mtime), &tm);
            strftime(buf, MAXLINE, "%a, %d %b %Y %H:%M:%S GMT", &tm);
            sprintf(headers, "%sLast-Modified: %s\r\n", headers, buf);
        }

        sprintf(headers, "%s\r\n", headers);
    }

    size = rio_writen(rq->fd, headers, strlen(headers));

    if (size < 0) {
        log_error("send headers error.");
        return -1;
    }

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1248, %rsp           # imm = 0x1248
movl %r8d, %r13d
movq %rcx, %r14
movq %rdx, %r15
movq %rsi, %r12
movq %rdi, -0x30(%rbp)
leaq -0x1270(%rbp), %rdi
movl $0x1000, %edx           # imm = 0x1000
xorl %esi, %esi
callq 0x21b0
leaq -0x270(%rbp), %rdi
movl $0x200, %edx            # imm = 0x200
xorl %esi, %esi
callq 0x21b0
testq %r12, %r12
je 0x3ce4
movl (%r12), %ebx
shrl $0x8, %ebx
movl %ebx, %edi
callq 0x3e13
leaq 0x2b3d(%rip), %rsi      # 0x66d8
leaq 0x2b41(%rip), %rdx      # 0x66e3
leaq -0x1270(%rbp), %r13
movq %r13, %rdi
movl %ebx, %ecx
movq %rax, %r8
xorl %eax, %eax
callq 0x23e0
leaq 0x2b2d(%rip), %rsi      # 0x66ec
leaq 0x2b35(%rip), %rcx      # 0x66fb
movq %r13, %rdi
movq %r13, %rdx
xorl %eax, %eax
callq 0x23e0
xorl %edi, %edi
callq 0x2290
leaq -0x38(%rbp), %rdi
movq %rax, (%rdi)
callq 0x23a0
leaq 0x2b1a(%rip), %rdx      # 0x6707
leaq -0x270(%rbp), %rbx
movl $0x200, %esi            # imm = 0x200
movq %rbx, %rdi
movq %rax, %rcx
callq 0x2360
leaq 0x2b16(%rip), %rsi      # 0x6721
movq %r13, %rdi
movq %r13, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x23e0
testb $0xf, (%r12)
movq -0x30(%rbp), %r13
je 0x3c5c
leaq 0x2b45(%rip), %rsi      # 0x6772
leaq -0x1270(%rbp), %rbx
movq %rbx, %rdi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x23e0
movq 0x20e8(%r13), %rcx
leaq 0x2b3e(%rip), %rsi      # 0x678d
movq %rbx, %rdi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x23e0
testq %r15, %r15
je 0x3c7c
leaq 0x2adc(%rip), %rsi      # 0x6744
leaq -0x1270(%rbp), %rdi
movq %rdi, %rdx
movq %r15, %rcx
xorl %eax, %eax
callq 0x23e0
testq %r14, %r14
js 0x3c9c
leaq 0x2ad1(%rip), %rsi      # 0x6759
leaq -0x1270(%rbp), %rdi
movq %rdi, %rdx
movq %r14, %rcx
xorl %eax, %eax
callq 0x23e0
testb $0x30, (%r12)
je 0x3dcc
addq $0x10, %r12
leaq -0x70(%rbp), %rbx
movq %r12, %rdi
movq %rbx, %rsi
callq 0x2080
leaq 0x2a46(%rip), %rdx      # 0x6707
leaq -0x270(%rbp), %r14
movl $0x200, %esi            # imm = 0x200
movq %r14, %rdi
movq %rbx, %rcx
callq 0x2360
leaq 0x2aca(%rip), %rsi      # 0x67a9
jmp 0x3db8
movl %r13d, %edi
callq 0x3e13
leaq 0x29e5(%rip), %rsi      # 0x66d8
leaq 0x29e9(%rip), %rdx      # 0x66e3
leaq -0x1270(%rbp), %r12
movq %r12, %rdi
movl %r13d, %ecx
movq %rax, %r8
xorl %eax, %eax
callq 0x23e0
leaq 0x29d4(%rip), %rsi      # 0x66ec
leaq 0x29dc(%rip), %rcx      # 0x66fb
movq %r12, %rdi
movq %r12, %rdx
xorl %eax, %eax
callq 0x23e0
xorl %edi, %edi
callq 0x2290
leaq -0x38(%rbp), %rdi
movq %rax, (%rdi)
callq 0x23a0
leaq 0x29c1(%rip), %rdx      # 0x6707
leaq -0x270(%rbp), %r13
movl $0x200, %esi            # imm = 0x200
movq %r13, %rdi
movq %rax, %rcx
callq 0x2360
leaq 0x29bd(%rip), %rsi      # 0x6721
movq %r12, %rdi
movq %r12, %rdx
movq %r13, %rcx
xorl %eax, %eax
callq 0x23e0
leaq 0x29b3(%rip), %rsi      # 0x672e
movq %r12, %rdi
movq %r12, %rdx
xorl %eax, %eax
callq 0x23e0
testq %r15, %r15
je 0x3da8
leaq 0x29b0(%rip), %rsi      # 0x6744
leaq -0x1270(%rbp), %rdi
movq %rdi, %rdx
movq %r15, %rcx
xorl %eax, %eax
callq 0x23e0
testq %r14, %r14
movq -0x30(%rbp), %r13
js 0x3dcc
leaq 0x29a1(%rip), %rsi      # 0x6759
leaq -0x1270(%rbp), %rdi
movq %rdi, %rdx
movq %r14, %rcx
xorl %eax, %eax
callq 0x23e0
leaq 0x29e7(%rip), %rsi      # 0x67ba
leaq -0x1270(%rbp), %rbx
movq %rbx, %rdi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x23e0
movl (%r13), %r14d
movq %rbx, %rdi
callq 0x2130
movl %r14d, %edi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x5540
addq $0x1248, %rsp           # imm = 0x1248
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq