// File: /workspace/github_c_makefile_star2_O3/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 0x9d18
movq %r12, %rdi
callq 0x9b10
testl %eax, %eax
je 0x9d36
movl %eax, %r13d
leaq 0x188e(%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 0x9d40
movq %r15, -0x30(%rbp)
movl $0xc8, 0x78(%r14)
movq 0x80(%r14), %r13
movq %r12, %rdi
callq 0x9884
leaq -0x78(%rbp), %rdx
movq %rax, (%rdx)
leaq 0x33bf(%rip), %rsi      # 0xcfc9
leaq -0x70(%rbp), %r12
movq %r12, %rdi
callq 0xa0d4
movq %r13, %rdi
movq %r12, %rsi
callq 0x8204
leaq -0x40(%rbp), %r15
movq -0x10(%r15), %rdi
cmpq %r15, %rdi
je 0x9c3a
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x3460
leaq -0x60(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x9c53
movq -0x60(%rbp), %rsi
incq %rsi
callq 0x3460
movq 0x80(%r14), %r12
leaq 0x3375(%rip), %rsi      # 0xcfd6
leaq -0x70(%rbp), %r13
leaq -0x90(%rbp), %rdx
movq %r13, %rdi
callq 0xa146
movq %r12, %rdi
movq %r13, %rsi
callq 0x8204
movq -0x50(%rbp), %rdi
cmpq %r15, %rdi
je 0x9c94
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 0x9cb8
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 0x9d04
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 0x9cd3
cmpl $-0x1, %eax
jne 0x9d20
movq %r12, %rdi
movq %r15, %rsi
movl %ebx, %edx
callq 0x4142
jmp 0x9d27
movl $0x194, 0x78(%r14)      # imm = 0x194
movl %ebx, %edi
callq 0x37e0
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x1f4, 0x78(%r14)      # imm = 0x1F4
jmp 0x9d47
movl $0x1f4, (%r15)          # imm = 0x1F4
movl %ebx, %edi
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x37e0
jmp 0x9d5e
movq %rax, %rbx
leaq -0x70(%rbp), %rdi
callq 0x7dc0
movq %rbx, %rdi
callq 0x3740