// File: /workspace/github_c_makefile_star2_O2/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
andq $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 0x3584
movq -0x40(%rbp), %rdi
movq %r12, %rsi
callq 0x22e0
movq -0x48(%rbp), %rdi
movq %r13, %rsi
callq 0x4550
movl %eax, %ebx
movq %r12, %rdi
callq 0x2170
testl %ebx, %ebx
jne 0x3569
movq %r14, %r13
movq -0x30(%rbp), %rax
movl (%rax), %r15d
movl 0x4(%rax), %r14d
xorl %ebx, %ebx
leaq 0x1ecb(%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 0x364a
leaq 0x1e59(%rip), %rcx      # 0x5434
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl %r15d, %edi
callq 0x2930
jmp 0x3648
movl %r15d, %edi
callq 0x30e4
jmp 0x3648
movl %r15d, %edi
callq 0x3340
jmp 0x3648
movl %r15d, %edi
callq 0x2504
jmp 0x3648
movl %r15d, %edi
callq 0x2ab0
jmp 0x3648
leaq 0x1e80(%rip), %rdi      # 0x549d
callq 0x22f0
movl %r15d, %edi
callq 0x30ec
jmp 0x3648
movl %r15d, %edi
callq 0x2c30
jmp 0x3648
movl %r15d, %edi
callq 0x2678
jmp 0x3648
movl %r15d, %edi
callq 0x27a8
movl %eax, %ebx
addl $-0x6, %r14d
cmpl $-0x3, %r14d
movq %r13, %r14
leaq -0x30(%rbp), %r13
ja 0x3569
cmpl $-0x1, %ebx
je 0x3569
movl -0x34(%rbp), %edi
movl %r15d, %esi
pushq $0x1
popq %rdx
callq 0x248c
jmp 0x3569
nop