// File: /workspace/github_c_makefile_star2_O2/VeeeectorPan[P]MyNetdisk/SourceFile/client_login.c
// Function: client_login
int client_login(int client_fd)
{
    MYSQL* connect;
    connect_mysql(&connect);
    int length;
    int ret;
    char user_name[32];
    char user_passwd[32];
    while(1)
    {
        ret = recv(client_fd,&length,sizeof(int),0);
        DISCON_CHECK(ret,-1,client_fd);
        ret = recv_client_all(client_fd,user_name,length);
        DISCON_CHECK(ret,-1,client_fd);
        ret = recv(client_fd,&length,sizeof(int),0);
        DISCON_CHECK(ret,-1,client_fd);
        ret = recv_client_all(client_fd,user_passwd,length);
        DISCON_CHECK(ret,-1,client_fd);
        ret = user_name_avaiable(user_name,connect);
        if(ret == 1)
        {
            int ctl_num = USER_NAME_NOTEX;
            ret = send(client_fd,&ctl_num,sizeof(int),MSG_NOSIGNAL);
            DISCON_CHECK(ret,-1,client_fd);
            continue;
        }
        if(is_match(user_name,user_passwd,connect) != 0)
        {
            int ctl_num = PASSWD_MISMATCHED;
            ret = send(client_fd,&ctl_num,sizeof(int),MSG_NOSIGNAL);
            DISCON_CHECK(ret,-1,client_fd);
            continue;
        }
        else
            break;
    }
    int ctl_num = LOGIN_SUCCESS;
    ret = send(client_fd,&ctl_num,sizeof(int),MSG_NOSIGNAL);
    DISCON_CHECK(ret,-1,client_fd);
    char mysql_oper[256];
    int user_id = get_user_id(mysql_oper,user_name,connect);
    ret = send(client_fd,&user_id,sizeof(int),MSG_NOSIGNAL);
    DISCON_CHECK(ret,-1,client_fd);
    int file_id = get_file_id(mysql_oper,user_id,connect);
    ret = send(client_fd,&file_id,sizeof(int),MSG_NOSIGNAL);
    DISCON_CHECK(ret,-1,client_fd);
    mysql_close(connect);
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x158, %rsp            # imm = 0x158
movl %edi, %ebx
leaq -0x30(%rbp), %rdi
callq 0x3434
leaq -0x34(%rbp), %r14
pushq $0x4
popq %r15
leaq -0x60(%rbp), %r12
leaq -0x80(%rbp), %r13
movl %ebx, %edi
movq %r14, %rsi
movq %r15, %rdx
xorl %ecx, %ecx
callq 0x20a0
cmpl $-0x1, %eax
je 0x2907
movl -0x34(%rbp), %edx
movl %ebx, %edi
movq %r12, %rsi
callq 0x45cc
cmpl $-0x1, %eax
je 0x2907
movl %ebx, %edi
movq %r14, %rsi
movq %r15, %rdx
xorl %ecx, %ecx
callq 0x20a0
cmpl $-0x1, %eax
je 0x2907
movl -0x34(%rbp), %edx
movl %ebx, %edi
movq %r13, %rsi
callq 0x45cc
cmpl $-0x1, %eax
je 0x2907
movq -0x30(%rbp), %rsi
movq %r12, %rdi
callq 0x4c0c
cmpl $0x1, %eax
jne 0x2850
movl $0x2, -0x180(%rbp)
jmp 0x286d
movq -0x30(%rbp), %rdx
movq %r12, %rdi
movq %r13, %rsi
callq 0x3884
testl %eax, %eax
je 0x288e
movl $0x3, -0x180(%rbp)
movl %ebx, %edi
leaq -0x180(%rbp), %rsi
movq %r15, %rdx
movl $0x4000, %ecx           # imm = 0x4000
callq 0x2100
cmpl $-0x1, %eax
jne 0x27d7
jmp 0x2907
leaq -0x40(%rbp), %rsi
movl $0x1, (%rsi)
pushq $0x4
popq %rdx
movl %ebx, %edi
movl $0x4000, %ecx           # imm = 0x4000
callq 0x2100
cmpl $-0x1, %eax
je 0x2907
movq -0x30(%rbp), %rdx
leaq -0x180(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x37dc
leaq -0x38(%rbp), %rsi
movl %eax, (%rsi)
pushq $0x4
popq %rdx
movl %ebx, %edi
movl $0x4000, %ecx           # imm = 0x4000
callq 0x2100
cmpl $-0x1, %eax
je 0x2907
movl -0x38(%rbp), %esi
movq -0x30(%rbp), %rdx
leaq -0x180(%rbp), %rdi
callq 0x36f8
leaq -0x3c(%rbp), %rsi
movl %eax, (%rsi)
pushq $0x4
popq %rdx
movl %ebx, %edi
movl $0x4000, %ecx           # imm = 0x4000
callq 0x2100
cmpl $-0x1, %eax
jne 0x2923
movl %ebx, %edi
callq 0x2380
pushq $-0x1
popq %rax
addq $0x158, %rsp            # imm = 0x158
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq -0x30(%rbp), %rdi
callq 0x2260
xorl %eax, %eax
jmp 0x2911