// File: /workspace/github_c_makefile_star2_O1/VeeeectorPan[P]MyNetdisk/clientSrc/sign_up.c
// Function: sign_up
int sign_up(int sock_fd)
{
    int ctl_num = CTL_REGISTER;
    send(sock_fd,&ctl_num,sizeof(int),0);

    int ret;
    char user_name[32];
    while(1)
    {
        rewind(stdin);
        memset(user_name,0,sizeof(user_name));
        printf("user name: ");
        ret = scanf("%s",user_name);
        if(ret == -1)
            exit(0);
        user_name[31] = '\0';
        int len = strlen(user_name);
        if(len < 5)
        {
            puts("user name too short!");
            continue;
        }
        send(sock_fd,&len,sizeof(int),0);
        send(sock_fd,user_name,len,0);
        recv(sock_fd,&ctl_num,sizeof(int),0);
        if(ctl_num == USER_NAME_NO_AVAIABLE)
        {
            puts("user name has been used!");
            continue;
        }
        else
            break;
    }
    char user_passwd[32];
    while(1)
    {
        rewind(stdin);
        memset(user_passwd,0,sizeof(user_name));
        printf("password: ");
        system("stty raw -echo");
        ret = scanf("%s",user_passwd);
        system("stty -raw echo");
        printf("\n");
        if(ret == -1)
            exit(0);
        user_passwd[31] = '\0';
        int len = strlen(user_passwd);
        if(len < 5)
        {
            puts("password too short!");
            continue;
        }
        send(sock_fd,&len,sizeof(int),0);
        send(sock_fd,user_passwd,len,0);
        break;
    }
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %edi, %ebx
leaq -0x30(%rbp), %rsi
movl $0x9, (%rsi)
movl $0x4, %edx
xorl %ecx, %ecx
callq 0x20c0
movq 0x2b9c(%rip), %rax      # 0x6fd8
movq (%rax), %rdi
callq 0x2040
xorps %xmm0, %xmm0
leaq -0x70(%rbp), %r14
movaps %xmm0, 0x10(%r14)
movaps %xmm0, (%r14)
leaq 0xc58(%rip), %rdi       # 0x50b3
xorl %eax, %eax
callq 0x2030
leaq 0xc47(%rip), %rdi       # 0x50b0
movq %r14, %rsi
xorl %eax, %eax
callq 0x2170
cmpl $-0x1, %eax
je 0x4528
leaq 0xd87(%rip), %r13       # 0x520a
leaq 0xc29(%rip), %r15       # 0x50b3
leaq 0xc1f(%rip), %r12       # 0x50b0
movb $0x0, -0x51(%rbp)
movq %r14, %rdi
callq 0x2080
movl %eax, -0x50(%rbp)
movq %r13, %rdi
cmpl $0x5, %eax
jl 0x44e9
movl $0x4, %edx
movl %ebx, %edi
leaq -0x50(%rbp), %rsi
xorl %ecx, %ecx
callq 0x20c0
movslq -0x50(%rbp), %rdx
movl %ebx, %edi
movq %r14, %rsi
xorl %ecx, %ecx
callq 0x20c0
movl $0x4, %edx
movl %ebx, %edi
leaq -0x30(%rbp), %rsi
xorl %ecx, %ecx
callq 0x2070
cmpl $0x0, -0x30(%rbp)
leaq 0xd38(%rip), %rdi       # 0x521f
jne 0x452f
callq 0x2240
movq 0x2ae3(%rip), %rax      # 0x6fd8
movq (%rax), %rdi
callq 0x2040
xorps %xmm0, %xmm0
movaps %xmm0, -0x60(%rbp)
movaps %xmm0, -0x70(%rbp)
movq %r15, %rdi
xorl %eax, %eax
callq 0x2030
movq %r12, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x2170
cmpl $-0x1, %eax
jne 0x4491
xorl %edi, %edi
callq 0x21a0
leaq 0xb7a(%rip), %r12       # 0x50b0
leaq -0x50(%rbp), %r13
leaq 0xb98(%rip), %r14       # 0x50d9
movq 0x2a90(%rip), %rax      # 0x6fd8
movq (%rax), %rdi
callq 0x2040
xorps %xmm0, %xmm0
movaps %xmm0, -0x40(%rbp)
movaps %xmm0, -0x50(%rbp)
leaq 0xb5d(%rip), %rdi       # 0x50bf
xorl %eax, %eax
callq 0x2030
leaq 0xb5a(%rip), %rdi       # 0x50ca
callq 0x2130
movq %r12, %rdi
movq %r13, %rsi
xorl %eax, %eax
callq 0x2170
movl %eax, %r15d
movq %r14, %rdi
callq 0x2130
movl $0xa, %edi
callq 0x21d0
cmpl $-0x1, %r15d
je 0x4528
movb $0x0, -0x31(%rbp)
movq %r13, %rdi
callq 0x2080
movq %rax, %r15
movl %r15d, -0x2c(%rbp)
cmpl $0x4, %r15d
jg 0x45c4
leaq 0xc7b(%rip), %rdi       # 0x5238
callq 0x2240
jmp 0x45e6
movl $0x4, %edx
movl %ebx, %edi
leaq -0x2c(%rbp), %rsi
xorl %ecx, %ecx
callq 0x20c0
movslq -0x2c(%rbp), %rdx
movl %ebx, %edi
movq %r13, %rsi
xorl %ecx, %ecx
callq 0x20c0
cmpl $0x5, %r15d
jl 0x4541
xorl %eax, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)