// File: /workspace/github_c_makefile_star2_O1/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 %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rsi, %r12
movq %rdi, %r14
movq %rsi, %rdi
movl $0x800, %esi            # imm = 0x800
xorl %eax, %eax
callq 0x32f0
movl %eax, %ebx
cmpl $-0x1, %eax
je 0x9db2
movq %r12, %rdi
callq 0x9bac
testl %eax, %eax
je 0x9dbc
movl %eax, %r13d
leaq 0x17f2(%rip), %rsi      # 0xb43c
leaq -0x90(%rbp), %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0x30f0
leaq 0x78(%r14), %r15
movl %r13d, 0x90(%r14)
movl %r13d, %edi
callq 0x35a0
movq %rax, 0x88(%r14)
testq %rax, %rax
je 0x9dc6
movq %r15, -0x30(%rbp)
movl $0xc8, 0x78(%r14)
movq 0x80(%r14), %r13
movq %r12, %rdi
callq 0x9920
leaq -0x78(%rbp), %rdx
movq %rax, (%rdx)
leaq 0x3341(%rip), %rsi      # 0xcfe7
leaq -0x70(%rbp), %r12
movq %r12, %rdi
callq 0xa160
movq %r13, %rdi
movq %r12, %rsi
callq 0x8268
leaq -0x40(%rbp), %r15
movq -0x10(%r15), %rdi
cmpq %r15, %rdi
je 0x9cd6
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x3460
leaq -0x60(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x9cef
movq -0x60(%rbp), %rsi
incq %rsi
callq 0x3460
movq 0x80(%r14), %r12
leaq 0x32f7(%rip), %rsi      # 0xcff4
leaq -0x70(%rbp), %r13
leaq -0x90(%rbp), %rdx
movq %r13, %rdi
callq 0xa1d2
movq %r12, %rdi
movq %r13, %rsi
callq 0x8268
movq -0x50(%rbp), %rdi
cmpq %r15, %rdi
je 0x9d30
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x3460
leaq 0x88(%r14), %r12
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
movq -0x30(%rbp), %r15
je 0x9d54
movq -0x60(%rbp), %rsi
incq %rsi
callq 0x3460
movq (%r12), %rsi
movl $0x400, %edx            # imm = 0x400
movl %ebx, %edi
callq 0x35f0
testl %eax, %eax
jle 0x9da0
leaq 0xb8(%r14), %r13
movq %r14, %rdi
callq 0x3620
movq %r13, %rdi
xorl %esi, %esi
callq 0x3690
movq %r14, %rdi
callq 0x3310
movq 0x88(%r14), %rsi
movl $0x400, %edx            # imm = 0x400
movl %ebx, %edi
callq 0x35f0
testl %eax, %eax
jg 0x9d6f
cmpl $-0x1, %eax
jne 0x9dcd
movq %r12, %rdi
movq %r15, %rsi
callq 0x4079
jmp 0x9dcd
movl $0x194, 0x78(%r14)      # imm = 0x194
jmp 0x9dcd
movl $0x1f4, 0x78(%r14)      # imm = 0x1F4
jmp 0x9dcd
movl $0x1f4, (%r15)          # imm = 0x1F4
movl %ebx, %edi
callq 0x37e0
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x9de5
movq %rax, %rbx
leaq -0x70(%rbp), %rdi
callq 0x7e24
movq %rbx, %rdi
callq 0x3740