// File: /workspace/github_c_makefile_star2_O2/sszllzss[P]webSocket_Libevent_ThreadPool/ev_httpd_test.c
// Function: serve_file(httpChilent_t*, char const*)
void serve_file(struct httpChilent_t *  client, const char *filename)
{
    int fp = open(filename,O_RDONLY|O_NONBLOCK);
    char num[20];
    if (fp == -1)
    {
        client->resqonse.resqonseCode = HTTP_NOTFOUND;
    }
    else
    {
        int len = getFileSize(filename);
        if(len == 0)
        {
            client->resqonse.resqonseCode = HTTP_INTERNAL;
            close(fp);
            return;
        }
        sprintf(num,"%d",len);
        client->resqonse.Resqonse_data_len = len;
        client->resqonse.resqonse_data = (char *)malloc(client->resqonse.Resqonse_data_len);
        if(client->resqonse.resqonse_data == NULL)
        {
            client->resqonse.resqonseCode = HTTP_INTERNAL;
            close(fp);
            return;
        }
        client->resqonse.resqonseCode = HTTP_OK;
        client->resqonse.HeadParameter->insert(HaedParameteMapPairi("Content-Type", getFileType(filename)));
        client->resqonse.HeadParameter->insert(HaedParameteMapPairi("Content-Length",num));
        int rec;
        while((rec = read(fp, client->resqonse.resqonse_data, 1024)) >0)
        {
            pthread_mutex_lock(&client->lock);
            gettimeofday(&client->final_optime,NULL);
            pthread_mutex_unlock(&client->lock);
        }
        if(rec == -1)
        {
            perror("rev");
            free(client->resqonse.resqonse_data);
            client->resqonse.resqonse_data = NULL;
            client->resqonse.resqonseCode = HTTP_INTERNAL;
            close(fp);
            return;
        }
    }
    close(fp);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x60, %rsp
movq %rsi, %r15
movq %rdi, %rbx
movq %rsi, %rdi
movl $0x800, %esi            # imm = 0x800
xorl %eax, %eax
callq 0x3300
movl %eax, %r14d
cmpl $-0x1, %eax
je 0x965c
movq %r15, %rdi
callq 0x94c9
testl %eax, %eax
je 0x9641
movl %eax, %r12d
leaq 0xed8(%rip), %rsi       # 0xa43c
leaq -0x40(%rbp), %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0x30f0
movl %r12d, 0x90(%rbx)
movl %r12d, %edi
callq 0x35d0
movq %rax, 0x88(%rbx)
testq %rax, %rax
je 0x9641
movl $0xc8, 0x78(%rbx)
movq 0x80(%rbx), %r12
movq %r15, %rdi
callq 0x9200
leaq -0x28(%rbp), %rdx
movq %rax, (%rdx)
leaq 0x2a15(%rip), %rsi      # 0xbfc9
leaq -0x80(%rbp), %r15
movq %r15, %rdi
callq 0x9a48
movq %r12, %rdi
movq %r15, %rsi
callq 0x78a2
leaq -0x80(%rbp), %rdi
callq 0x7472
movq 0x80(%rbx), %r15
leaq 0x29f4(%rip), %rsi      # 0xbfd6
leaq -0x80(%rbp), %r12
leaq -0x40(%rbp), %rdx
movq %r12, %rdi
callq 0x9a8e
movq %r15, %rdi
movq %r12, %rsi
callq 0x78a2
leaq -0x80(%rbp), %rdi
callq 0x7472
leaq 0xb8(%rbx), %r15
movq 0x88(%rbx), %rsi
movl $0x400, %edx            # imm = 0x400
movl %r14d, %edi
callq 0x3620
testl %eax, %eax
jle 0x9665
movq %rbx, %rdi
callq 0x3650
movq %r15, %rdi
xorl %esi, %esi
callq 0x36c0
movq %rbx, %rdi
callq 0x3320
jmp 0x960d
movl $0x1f4, 0x78(%rbx)      # imm = 0x1F4
movl %r14d, %edi
addq $0x60, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x3810
movl $0x194, 0x78(%rbx)      # imm = 0x194
jmp 0x966a
cmpl $-0x1, %eax
je 0x967f
movl %r14d, %edi
callq 0x3810
addq $0x60, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x295f(%rip), %rdi      # 0xbfe5
callq 0x3380
movq 0x88(%rbx), %rdi
callq 0x3520
andq $0x0, 0x88(%rbx)
movl $0x1f4, 0x78(%rbx)      # imm = 0x1F4
jmp 0x966a
jmp 0x96aa
movq %rax, %rbx
leaq -0x80(%rbp), %rdi
callq 0x7472
movq %rbx, %rdi
callq 0x3770