// File: /workspace/github_c_makefile_star2_O1/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 0x40b1(%rip), %r13      # 0x6fd8
movq (%r13), %rdi
callq 0x2040
xorps %xmm0, %xmm0
leaq -0x70(%rbp), %r12
movaps %xmm0, 0x10(%r12)
movaps %xmm0, (%r12)
leaq 0x216a(%rip), %rdi      # 0x50b3
xorl %eax, %eax
callq 0x2030
leaq 0x2159(%rip), %r14      # 0x50b0
movq %r14, %rdi
movq %r12, %rsi
xorl %eax, %eax
callq 0x2170
movq (%r13), %rdi
callq 0x2040
leaq 0x214b(%rip), %rdi      # 0x50bf
xorl %eax, %eax
callq 0x2030
leaq 0x2148(%rip), %rdi      # 0x50ca
callq 0x2130
leaq -0x50(%rbp), %r13
movq %r14, %rdi
movq %r13, %rsi
xorl %eax, %eax
callq 0x2170
leaq 0x213a(%rip), %rdi      # 0x50d9
callq 0x2130
movl $0xa, %edi
callq 0x21d0
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 0x3060
cmpl $0x3, %eax
je 0x3046
cmpl $0x2, %eax
jne 0x304f
leaq 0x20c4(%rip), %rdi      # 0x5108
jmp 0x3056
leaq 0x209b(%rip), %rdi      # 0x50e8
jmp 0x3056
leaq 0x20c6(%rip), %rdi      # 0x511c
callq 0x2240
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)