// File: /workspace/github_c_makefile_star2_O0/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
subq $0x140, %rsp            # imm = 0x140
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
movl $0x800, %esi            # imm = 0x800
movb $0x0, %al
callq 0x4370
movl %eax, -0x14(%rbp)
cmpl $-0x1, -0x14(%rbp)
jne 0x1263c
movq -0x8(%rbp), %rax
movl $0x194, 0x78(%rax)      # imm = 0x194
jmp 0x128a2
movq -0x10(%rbp), %rdi
callq 0x12570
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
jne 0x12666
movq -0x8(%rbp), %rax
movl $0x1f4, 0x78(%rax)      # imm = 0x1F4
movl -0x14(%rbp), %edi
callq 0x48f0
jmp 0x128aa
leaq -0x30(%rbp), %rdi
movl -0x34(%rbp), %edx
leaq 0x1de1(%rip), %rsi      # 0x14455
movb $0x0, %al
callq 0x4110
movl -0x34(%rbp), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x90(%rax)
movq -0x8(%rbp), %rax
movl 0x90(%rax), %eax
movl %eax, %edi
callq 0x46a0
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x88(%rax)
movq -0x8(%rbp), %rax
cmpq $0x0, 0x88(%rax)
jne 0x126cd
movq -0x8(%rbp), %rax
movl $0x1f4, 0x78(%rax)      # imm = 0x1F4
movl -0x14(%rbp), %edi
callq 0x48f0
jmp 0x128aa
movq -0x8(%rbp), %rax
movl $0xc8, 0x78(%rax)
movq -0x8(%rbp), %rax
movq 0x80(%rax), %rax
movq %rax, -0x118(%rbp)
movq -0x10(%rbp), %rdi
callq 0x12190
movq %rax, -0x80(%rbp)
leaq 0x3948(%rip), %rsi      # 0x16046
leaq -0x78(%rbp), %rdi
movq %rdi, -0x110(%rbp)
leaq -0x80(%rbp), %rdx
callq 0x12e30
movq -0x118(%rbp), %rdi
movq -0x110(%rbp), %rsi
callq 0xafb0
movb %dl, -0x101(%rbp)
movq %rax, -0x100(%rbp)
jmp 0x12734
movb -0x101(%rbp), %al
movq -0x100(%rbp), %rcx
movq %rcx, -0xa0(%rbp)
movb %al, -0x98(%rbp)
leaq -0x78(%rbp), %rdi
callq 0xb0d0
movq -0x8(%rbp), %rax
movq 0x80(%rax), %rax
movq %rax, -0x138(%rbp)
leaq 0x38e3(%rip), %rsi      # 0x16053
leaq -0xe0(%rbp), %rdi
movq %rdi, -0x130(%rbp)
leaq -0x30(%rbp), %rdx
callq 0x12f10
movq -0x138(%rbp), %rdi
movq -0x130(%rbp), %rsi
callq 0xafb0
movb %dl, -0x121(%rbp)
movq %rax, -0x120(%rbp)
jmp 0x127a9
movb -0x121(%rbp), %al
movq -0x120(%rbp), %rcx
movq %rcx, -0xf0(%rbp)
movb %al, -0xe8(%rbp)
leaq -0xe0(%rbp), %rdi
callq 0xb0d0
movl -0x14(%rbp), %edi
movq -0x8(%rbp), %rax
movq 0x88(%rax), %rsi
movl $0x400, %edx            # imm = 0x400
callq 0x46f0
movl %eax, -0xf4(%rbp)
cmpl $0x0, %eax
jle 0x12857
movq -0x8(%rbp), %rdi
callq 0x4720
movq -0x8(%rbp), %rdi
addq $0xb8, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x4780
movq -0x8(%rbp), %rdi
callq 0x4390
jmp 0x127cf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
leaq -0x78(%rbp), %rdi
callq 0xb0d0
jmp 0x128b3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
leaq -0xe0(%rbp), %rdi
callq 0xb0d0
jmp 0x128b3
cmpl $-0x1, -0xf4(%rbp)
jne 0x128a0
leaq 0x37fb(%rip), %rdi      # 0x16062
callq 0x4410
movq -0x8(%rbp), %rax
movq 0x88(%rax), %rdi
callq 0x45f0
movq -0x8(%rbp), %rax
movq $0x0, 0x88(%rax)
movq -0x8(%rbp), %rax
movl $0x1f4, 0x78(%rax)      # imm = 0x1F4
movl -0x14(%rbp), %edi
callq 0x48f0
jmp 0x128aa
jmp 0x128a2
movl -0x14(%rbp), %edi
callq 0x48f0
addq $0x140, %rsp            # imm = 0x140
popq %rbp
retq
movq -0x88(%rbp), %rdi
callq 0x4830
nop