// File: /workspace/github_c_makefile_star2_O3/VeeeectorPan[P]MyNetdisk/clientSrc/login.c
// Function: login
int login(int sock_fd)
{
    char user_name[32];
    char user_passwd[32];
    int ctl_num = CTL_LOGIN;
    send(sock_fd,&ctl_num,sizeof(int),0);
    while(1)
    {
        rewind(stdin);
        memset(user_name,0,sizeof(user_name));
        memset(user_name,0,sizeof(user_passwd));
        printf("user name: ");
        scanf("%s",user_name);
        rewind(stdin);
        printf("password: ");
        system("stty raw -echo");
        scanf("%s",user_passwd);
        system("stty -raw echo");
        printf("\n");
        user_name[31] = '\0';
        user_passwd[31] = '\0';
        int len = strlen(user_name);
        send(sock_fd,&len,sizeof(int),0);
        send(sock_fd,user_name,len,0);
        len = strlen(user_passwd);
        send(sock_fd,&len,sizeof(int),0);
        send(sock_fd,user_passwd,len,0);
        recv(sock_fd,&ctl_num,sizeof(int),0);
        switch(ctl_num)
        {
        case PASSWD_MISMATCHED:
            puts("incorrect password or user name");
            return -1;
        case USER_NAME_NOTEX:
            puts("user name not exist");
            return -1;
        case LOGIN_SUCCESS:
            return 0;
        default:
            puts("unknown error");
            return -1;
        }
    }
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %edi, %r15d
leaq -0x2c(%rbp), %rsi
movl $0xa, (%rsi)
xorl %ebx, %ebx
movl $0x4, %edx
xorl %ecx, %ecx
callq 0x20c0
movq 0x40e5(%rip), %r13      # 0x6fd8
movq (%r13), %rdi
callq 0x2040
xorps %xmm0, %xmm0
leaq -0x70(%rbp), %r12
movaps %xmm0, 0x10(%r12)
movaps %xmm0, (%r12)
leaq 0x219e(%rip), %rdi      # 0x50b3
xorl %eax, %eax
callq 0x2030
leaq 0x218d(%rip), %r14      # 0x50b0
movq %r14, %rdi
movq %r12, %rsi
xorl %eax, %eax
callq 0x2180
movq (%r13), %rdi
callq 0x2040
leaq 0x217f(%rip), %rdi      # 0x50bf
xorl %eax, %eax
callq 0x2030
leaq 0x217c(%rip), %rdi      # 0x50ca
callq 0x2140
leaq -0x50(%rbp), %r13
movq %r14, %rdi
movq %r13, %rsi
xorl %eax, %eax
callq 0x2180
leaq 0x216e(%rip), %rdi      # 0x50d9
callq 0x2140
movl $0xa, %edi
callq 0x21e0
movb %bl, 0x1f(%r12)
movb %bl, 0x1f(%r13)
movq %r12, %rdi
callq 0x2080
leaq -0x30(%rbp), %r14
movl %eax, (%r14)
movl $0x4, %edx
movl %r15d, %edi
movq %r14, %rsi
xorl %ecx, %ecx
callq 0x20c0
movslq (%r14), %rdx
movl %r15d, %edi
movq %r12, %rsi
xorl %ecx, %ecx
callq 0x20c0
movq %r13, %rdi
callq 0x2080
movl %eax, (%r14)
movl $0x4, %edx
movl %r15d, %edi
movq %r14, %rsi
xorl %ecx, %ecx
callq 0x20c0
movslq (%r14), %rdx
movl %r15d, %edi
movq %r13, %rsi
xorl %ecx, %ecx
callq 0x20c0
movl $0x4, %edx
movl %r15d, %edi
leaq -0x2c(%rbp), %r14
movq %r14, %rsi
xorl %ecx, %ecx
callq 0x2070
movl (%r14), %eax
cmpl $0x1, %eax
je 0x302c
cmpl $0x3, %eax
je 0x3012
cmpl $0x2, %eax
jne 0x301b
leaq 0x20f8(%rip), %rdi      # 0x5108
jmp 0x3022
leaq 0x20cf(%rip), %rdi      # 0x50e8
jmp 0x3022
leaq 0x20fa(%rip), %rdi      # 0x511c
callq 0x2250
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movl %ebx, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)