// File: /workspace/github_c_makefile_star2_O3/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 $0x168, %rsp            # imm = 0x168
movl %edi, %ebx
leaq -0x38(%rbp), %rdi
callq 0x34e8
leaq -0x2c(%rbp), %rsi
movl $0x4, %edx
movl %ebx, %edi
xorl %ecx, %ecx
callq 0x20a0
cmpl $-0x1, %eax
jne 0x2848
movl %ebx, %edi
callq 0x2380
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x168, %rsp            # imm = 0x168
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq -0x70(%rbp), %r14
leaq -0x2c(%rbp), %r15
leaq -0x90(%rbp), %r12
leaq -0x190(%rbp), %r13
movl -0x2c(%rbp), %edx
movl %ebx, %edi
movq %r14, %rsi
callq 0x47cc
cmpl $-0x1, %eax
je 0x282a
movl $0x4, %edx
movl %ebx, %edi
movq %r15, %rsi
xorl %ecx, %ecx
callq 0x20a0
cmpl $-0x1, %eax
je 0x282a
movl -0x2c(%rbp), %edx
movl %ebx, %edi
movq %r12, %rsi
callq 0x47cc
cmpl $-0x1, %eax
je 0x282a
movq -0x38(%rbp), %rsi
movq %r14, %rdi
callq 0x4e0c
cmpl $0x1, %eax
jne 0x28b5
movl $0x2, -0x190(%rbp)
jmp 0x28d2
movq -0x38(%rbp), %rdx
movq %r14, %rdi
movq %r12, %rsi
callq 0x396c
testl %eax, %eax
je 0x290e
movl $0x3, -0x190(%rbp)
movl $0x4, %edx
movl %ebx, %edi
movq %r13, %rsi
movl $0x4000, %ecx           # imm = 0x4000
callq 0x2100
cmpl $-0x1, %eax
je 0x282a
movl $0x4, %edx
movl %ebx, %edi
movq %r15, %rsi
xorl %ecx, %ecx
callq 0x20a0
cmpl $-0x1, %eax
jne 0x285e
jmp 0x282a
leaq -0x44(%rbp), %rsi
movl $0x1, (%rsi)
movl $0x4, %edx
movl %ebx, %edi
movl $0x4000, %ecx           # imm = 0x4000
callq 0x2100
cmpl $-0x1, %eax
je 0x282a
movq -0x38(%rbp), %rdx
leaq -0x190(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x38c4
leaq -0x3c(%rbp), %rsi
movl %eax, (%rsi)
movl $0x4, %edx
movl %ebx, %edi
movl $0x4000, %ecx           # imm = 0x4000
callq 0x2100
cmpl $-0x1, %eax
je 0x282a
movl -0x3c(%rbp), %esi
movq -0x38(%rbp), %rdx
leaq -0x190(%rbp), %rdi
callq 0x37cc
leaq -0x40(%rbp), %rsi
movl %eax, (%rsi)
movl $0x4, %edx
movl %ebx, %edi
movl $0x4000, %ecx           # imm = 0x4000
callq 0x2100
cmpl $-0x1, %eax
je 0x282a
movq -0x38(%rbp), %rdi
callq 0x2260
xorl %eax, %eax
jmp 0x2836
nopl (%rax)