// File: /workspace/github_c_makefile_star2_O2/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)
pushq $0x4
popq %rdx
xorl %ebx, %ebx
xorl %ecx, %ecx
callq 0x20c0
movq 0x4143(%rip), %r14      # 0x6fd8
movq (%r14), %rdi
callq 0x2040
xorps %xmm0, %xmm0
leaq -0x70(%rbp), %r13
movaps %xmm0, 0x10(%r13)
movaps %xmm0, (%r13)
leaq 0x21fe(%rip), %rdi      # 0x50b3
xorl %eax, %eax
callq 0x2030
leaq 0x21ed(%rip), %r12      # 0x50b0
movq %r12, %rdi
movq %r13, %rsi
xorl %eax, %eax
callq 0x2190
movq (%r14), %rdi
callq 0x2040
leaq 0x21e0(%rip), %rdi      # 0x50bf
xorl %eax, %eax
callq 0x2030
leaq 0x21dd(%rip), %rdi      # 0x50ca
callq 0x2140
leaq -0x50(%rbp), %rsi
movq %r12, %rdi
movq %rsi, %r14
xorl %eax, %eax
callq 0x2190
leaq 0x21cf(%rip), %rdi      # 0x50d9
callq 0x2140
pushq $0xa
popq %rdi
callq 0x21f0
movb %bl, 0x1f(%r13)
movb %bl, 0x1f(%r14)
movq %r13, %rdi
callq 0x2080
leaq -0x30(%rbp), %r12
movl %eax, (%r12)
movl %r15d, %edi
movq %r12, %rsi
pushq $0x4
popq %r14
movq %r14, %rdx
xorl %ecx, %ecx
callq 0x20c0
movslq (%r12), %rdx
movl %r15d, %edi
movq %r13, %rsi
xorl %ecx, %ecx
callq 0x20c0
leaq -0x50(%rbp), %r13
movq %r13, %rdi
callq 0x2080
movl %eax, (%r12)
movl %r15d, %edi
movq %r12, %rsi
movq %r14, %rdx
xorl %ecx, %ecx
callq 0x20c0
movslq (%r12), %rdx
movl %r15d, %edi
movq %r13, %rsi
xorl %ecx, %ecx
callq 0x20c0
movl %r15d, %edi
leaq -0x2c(%rbp), %r14
movq %r14, %rsi
pushq $0x4
popq %rdx
xorl %ecx, %ecx
callq 0x2070
movl (%r14), %eax
cmpl $0x1, %eax
je 0x2fcc
cmpl $0x3, %eax
je 0x2fb4
cmpl $0x2, %eax
jne 0x2fbd
leaq 0x2156(%rip), %rdi      # 0x5108
jmp 0x2fc4
leaq 0x212d(%rip), %rdi      # 0x50e8
jmp 0x2fc4
leaq 0x2158(%rip), %rdi      # 0x511c
callq 0x2260
pushq $-0x1
popq %rbx
movl %ebx, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)