// File: /workspace/github_c_makefile_star2_O1/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 0x4009
movl (%r12), %ebx
shrl $0x8, %ebx
movl %ebx, %edi
callq 0x4138
leaq 0x3818(%rip), %rsi      # 0x76d8
leaq 0x381c(%rip), %rdx      # 0x76e3
leaq -0x1270(%rbp), %r13
movq %r13, %rdi
movl %ebx, %ecx
movq %rax, %r8
xorl %eax, %eax
callq 0x23e0
leaq 0x3808(%rip), %rsi      # 0x76ec
leaq 0x3810(%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 0x37f5(%rip), %rdx      # 0x7707
leaq -0x270(%rbp), %rbx
movl $0x200, %esi            # imm = 0x200
movq %rbx, %rdi
movq %rax, %rcx
callq 0x2360
leaq 0x37f1(%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 0x3f81
leaq 0x3820(%rip), %rsi      # 0x7772
leaq -0x1270(%rbp), %rbx
movq %rbx, %rdi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x23e0
movq 0x20e8(%r13), %rcx
leaq 0x3819(%rip), %rsi      # 0x778d
movq %rbx, %rdi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x23e0
testq %r15, %r15
je 0x3fa1
leaq 0x37b7(%rip), %rsi      # 0x7744
leaq -0x1270(%rbp), %rdi
movq %rdi, %rdx
movq %r15, %rcx
xorl %eax, %eax
callq 0x23e0
testq %r14, %r14
js 0x3fc1
leaq 0x37ac(%rip), %rsi      # 0x7759
leaq -0x1270(%rbp), %rdi
movq %rdi, %rdx
movq %r14, %rcx
xorl %eax, %eax
callq 0x23e0
testb $0x30, (%r12)
je 0x40f1
addq $0x10, %r12
leaq -0x70(%rbp), %rbx
movq %r12, %rdi
movq %rbx, %rsi
callq 0x2080
leaq 0x3721(%rip), %rdx      # 0x7707
leaq -0x270(%rbp), %r14
movl $0x200, %esi            # imm = 0x200
movq %r14, %rdi
movq %rbx, %rcx
callq 0x2360
leaq 0x37a5(%rip), %rsi      # 0x77a9
jmp 0x40dd
movl %r13d, %edi
callq 0x4138
leaq 0x36c0(%rip), %rsi      # 0x76d8
leaq 0x36c4(%rip), %rdx      # 0x76e3
leaq -0x1270(%rbp), %r12
movq %r12, %rdi
movl %r13d, %ecx
movq %rax, %r8
xorl %eax, %eax
callq 0x23e0
leaq 0x36af(%rip), %rsi      # 0x76ec
leaq 0x36b7(%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 0x369c(%rip), %rdx      # 0x7707
leaq -0x270(%rbp), %r13
movl $0x200, %esi            # imm = 0x200
movq %r13, %rdi
movq %rax, %rcx
callq 0x2360
leaq 0x3698(%rip), %rsi      # 0x7721
movq %r12, %rdi
movq %r12, %rdx
movq %r13, %rcx
xorl %eax, %eax
callq 0x23e0
leaq 0x368e(%rip), %rsi      # 0x772e
movq %r12, %rdi
movq %r12, %rdx
xorl %eax, %eax
callq 0x23e0
testq %r15, %r15
je 0x40cd
leaq 0x368b(%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 0x40f1
leaq 0x367c(%rip), %rsi      # 0x7759
leaq -0x1270(%rbp), %rdi
movq %rdi, %rdx
movq %r14, %rcx
xorl %eax, %eax
callq 0x23e0
leaq 0x36c2(%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 0x5877
addq $0x1248, %rsp           # imm = 0x1248
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq