// File: /workspace/github_c_makefile_star2_O3/VeeeectorPan[P]MyNetdisk/SourceFile/factory_init.c
// Function: thread_func
void* thread_func(void* p)
{
    factory_t *p_fact = (factory_t*)p;
    struct Queue_node* node = NULL;
    int client_fd = 0;
    int ctl_no;
    int epoll_fd = p_fact->epoll_fd;
    while(1)
    {
        pthread_mutex_lock(&p_fact->mutex);
        if(p_fact->que.que_size == 0)
        {
            pthread_cond_wait(&p_fact->cond,&p_fact->mutex);
        }
        int ret = que_pop(&p_fact->que,&node);
        pthread_mutex_unlock(&p_fact->mutex);
        if(ret == 0)
        {
            client_fd = node->client_fd;
            ctl_no = node->ctl_no;
            printf("client_fd = %d, ctl_No = %d\n",client_fd,ctl_no);
            free(node);
            switch(ctl_no)
            {
            case CTL_REGISTER:
                puts("sign up!");
                ret = client_register(client_fd);
                break;
            case CTL_LOGIN:
                ret = client_login(client_fd);
                break;
            case CTL_LS:
                ret = client_ls(client_fd);
                break;
            case CTL_CD:
                ret = client_cd(client_fd);
                break;
            case CTL_PWD:
                ret = client_pwd(client_fd);
                break;
            case CTL_PUT:
                ret = client_put(client_fd);
                break;
            case CTL_GET:
                ret = client_get(client_fd);
                break;
            case CTL_RM:
                ret = client_rm(client_fd);
                break;
            case CTL_MKDIR:
                ret = client_mkdir(client_fd);
                break;
            }
            if(ret != -1 && ctl_no != CTL_GET && ctl_no != CTL_PUT)
                add_fd_to_epoll(epoll_fd,client_fd,EPOLLIN);
        }
    }
    pthread_exit(NULL);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %r14
leaq -0x30(%rbp), %r13
movq $0x0, (%r13)
movl 0x8(%rdi), %eax
movl %eax, -0x34(%rbp)
leaq 0x38(%rdi), %r12
leaq 0x20(%rdi), %rax
movq %rax, -0x48(%rbp)
leaq 0x60(%rdi), %rax
movq %rax, -0x40(%rbp)
movq %r12, %rdi
callq 0x22b0
cmpl $0x0, 0x24(%r14)
jne 0x3644
movq -0x40(%rbp), %rdi
movq %r12, %rsi
callq 0x22e0
movq -0x48(%rbp), %rdi
movq %r13, %rsi
callq 0x4753
movl %eax, %ebx
movq %r12, %rdi
callq 0x2170
testl %ebx, %ebx
jne 0x3629
movq %r14, %r13
movq -0x30(%rbp), %rax
movl (%rax), %r15d
movl 0x4(%rax), %r14d
xorl %ebx, %ebx
leaq 0x1e0b(%rip), %rdi      # 0x5480
movl %r15d, %esi
movl %r14d, %edx
xorl %eax, %eax
callq 0x2040
movq -0x30(%rbp), %rdi
callq 0x2220
leal -0x1(%r14), %eax
cmpl $0x9, %eax
ja 0x3718
leaq 0x1d95(%rip), %rcx      # 0x5434
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl %r15d, %edi
callq 0x29ac
jmp 0x3716
movl %r15d, %edi
callq 0x3188
jmp 0x3716
movl %r15d, %edi
callq 0x33f4
jmp 0x3716
movl %r15d, %edi
callq 0x2538
jmp 0x3716
movl %r15d, %edi
callq 0x2b3c
jmp 0x3716
leaq 0x1dbc(%rip), %rdi      # 0x549d
callq 0x22f0
movl %r15d, %edi
callq 0x3190
jmp 0x3716
movl %r15d, %edi
callq 0x2ccc
jmp 0x3702
movl %r15d, %edi
callq 0x26bc
movq %r13, %r14
leaq -0x30(%rbp), %r13
jmp 0x3629
movl %r15d, %edi
callq 0x27f4
movl %eax, %ebx
addl $-0x6, %r14d
cmpl $-0x3, %r14d
movq %r13, %r14
leaq -0x30(%rbp), %r13
ja 0x3629
cmpl $-0x1, %ebx
je 0x3629
movl -0x34(%rbp), %edi
movl %r15d, %esi
movl $0x1, %edx
callq 0x24bc
jmp 0x3629
nop