// File: /workspace/github_c_makefile_star2_O3/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 0x4047
movl (%r12), %ebx
shrl $0x8, %ebx
movl %ebx, %edi
callq 0x4176
leaq 0x37da(%rip), %rsi      # 0x76d8
leaq 0x37de(%rip), %rdx      # 0x76e3
leaq -0x1270(%rbp), %r13
movq %r13, %rdi
movl %ebx, %ecx
movq %rax, %r8
xorl %eax, %eax
callq 0x23e0
leaq 0x37ca(%rip), %rsi      # 0x76ec
leaq 0x37d2(%rip), %rcx      # 0x76fb
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 0x37b7(%rip), %rdx      # 0x7707
leaq -0x270(%rbp), %rbx
movl $0x200, %esi            # imm = 0x200
movq %rbx, %rdi
movq %rax, %rcx
callq 0x2360
leaq 0x37b3(%rip), %rsi      # 0x7721
movq %r13, %rdi
movq %r13, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x23e0
testb $0xf, (%r12)
movq -0x30(%rbp), %r13
je 0x3fbf
leaq 0x37e2(%rip), %rsi      # 0x7772
leaq -0x1270(%rbp), %rbx
movq %rbx, %rdi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x23e0
movq 0x20e8(%r13), %rcx
leaq 0x37db(%rip), %rsi      # 0x778d
movq %rbx, %rdi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x23e0
testq %r15, %r15
je 0x3fdf
leaq 0x3779(%rip), %rsi      # 0x7744
leaq -0x1270(%rbp), %rdi
movq %rdi, %rdx
movq %r15, %rcx
xorl %eax, %eax
callq 0x23e0
testq %r14, %r14
js 0x3fff
leaq 0x376e(%rip), %rsi      # 0x7759
leaq -0x1270(%rbp), %rdi
movq %rdi, %rdx
movq %r14, %rcx
xorl %eax, %eax
callq 0x23e0
testb $0x30, (%r12)
je 0x412f
addq $0x10, %r12
leaq -0x70(%rbp), %rbx
movq %r12, %rdi
movq %rbx, %rsi
callq 0x2080
leaq 0x36e3(%rip), %rdx      # 0x7707
leaq -0x270(%rbp), %r14
movl $0x200, %esi            # imm = 0x200
movq %r14, %rdi
movq %rbx, %rcx
callq 0x2360
leaq 0x3767(%rip), %rsi      # 0x77a9
jmp 0x411b
movl %r13d, %edi
callq 0x4176
leaq 0x3682(%rip), %rsi      # 0x76d8
leaq 0x3686(%rip), %rdx      # 0x76e3
leaq -0x1270(%rbp), %r12
movq %r12, %rdi
movl %r13d, %ecx
movq %rax, %r8
xorl %eax, %eax
callq 0x23e0
leaq 0x3671(%rip), %rsi      # 0x76ec
leaq 0x3679(%rip), %rcx      # 0x76fb
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 0x365e(%rip), %rdx      # 0x7707
leaq -0x270(%rbp), %r13
movl $0x200, %esi            # imm = 0x200
movq %r13, %rdi
movq %rax, %rcx
callq 0x2360
leaq 0x365a(%rip), %rsi      # 0x7721
movq %r12, %rdi
movq %r12, %rdx
movq %r13, %rcx
xorl %eax, %eax
callq 0x23e0
leaq 0x3650(%rip), %rsi      # 0x772e
movq %r12, %rdi
movq %r12, %rdx
xorl %eax, %eax
callq 0x23e0
testq %r15, %r15
je 0x410b
leaq 0x364d(%rip), %rsi      # 0x7744
leaq -0x1270(%rbp), %rdi
movq %rdi, %rdx
movq %r15, %rcx
xorl %eax, %eax
callq 0x23e0
testq %r14, %r14
movq -0x30(%rbp), %r13
js 0x412f
leaq 0x363e(%rip), %rsi      # 0x7759
leaq -0x1270(%rbp), %rdi
movq %rdi, %rdx
movq %r14, %rcx
xorl %eax, %eax
callq 0x23e0
leaq 0x3684(%rip), %rsi      # 0x77ba
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 0x59fa
addq $0x1248, %rsp           # imm = 0x1248
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq