// File: /workspace/github_c_makefile_star2_O2/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 $0x58, %rsp
leaq -0x30(%rbp), %rsi
movl $0x9, (%rsi)
pushq $0x4
popq %rdx
movl %edi, -0x2c(%rbp)
xorl %ecx, %ecx
callq 0x20c0
leaq 0xecc(%rip), %r12       # 0x50b3
leaq 0xec2(%rip), %r15       # 0x50b0
leaq -0x80(%rbp), %rbx
leaq 0x1011(%rip), %r14      # 0x520a
movq 0x2dd8(%rip), %rax      # 0x6fd8
movq (%rax), %rdi
callq 0x2040
xorps %xmm0, %xmm0
movaps %xmm0, -0x70(%rbp)
movaps %xmm0, -0x80(%rbp)
movq %r12, %rdi
xorl %eax, %eax
callq 0x2030
movq %r15, %rdi
movq %rbx, %rsi
xorl %eax, %eax
callq 0x2190
cmpl $-0x1, %eax
je 0x4372
movb $0x0, -0x61(%rbp)
movq %rbx, %rdi
callq 0x2080
movl %eax, -0x60(%rbp)
movq %r14, %rdi
cmpl $0x5, %eax
jl 0x429f
movl -0x2c(%rbp), %r14d
movl %r14d, %edi
leaq -0x60(%rbp), %rsi
movq %r12, %r13
pushq $0x4
popq %r12
movq %r12, %rdx
xorl %ecx, %ecx
callq 0x20c0
movslq -0x60(%rbp), %rdx
movl %r14d, %edi
movq %rbx, %rsi
xorl %ecx, %ecx
callq 0x20c0
movl %r14d, %edi
leaq -0x30(%rbp), %rsi
movq %r12, %rdx
movq %r13, %r12
leaq 0xf7f(%rip), %r14       # 0x520a
xorl %ecx, %ecx
callq 0x2070
cmpl $0x0, -0x30(%rbp)
leaq 0xf82(%rip), %rdi       # 0x521f
jne 0x42a9
callq 0x2260
jmp 0x41f9
leaq 0xe0f(%rip), %rbx       # 0x50bf
leaq -0x60(%rbp), %r13
leaq 0xe1e(%rip), %r14       # 0x50d9
pushq $0xa
popq %r15
movq 0x2d12(%rip), %rax      # 0x6fd8
movq (%rax), %rdi
callq 0x2040
xorps %xmm0, %xmm0
movaps %xmm0, -0x50(%rbp)
movaps %xmm0, -0x60(%rbp)
movq %rbx, %rdi
xorl %eax, %eax
callq 0x2030
leaq 0xde0(%rip), %rdi       # 0x50ca
callq 0x2140
leaq 0xdba(%rip), %rdi       # 0x50b0
movq %r13, %rsi
xorl %eax, %eax
callq 0x2190
movl %eax, %r12d
movq %r14, %rdi
callq 0x2140
movl %r15d, %edi
callq 0x21f0
cmpl $-0x1, %r12d
je 0x4372
movb $0x0, -0x41(%rbp)
movq %r13, %rdi
callq 0x2080
movl %eax, -0x34(%rbp)
cmpl $0x4, %eax
jg 0x433b
leaq 0xf04(%rip), %rdi       # 0x5238
callq 0x2260
jmp 0x42bf
leaq -0x34(%rbp), %r14
pushq $0x4
popq %rdx
movl -0x2c(%rbp), %ebx
movl %ebx, %edi
movq %r14, %rsi
xorl %ecx, %ecx
callq 0x20c0
movslq (%r14), %rdx
leaq -0x60(%rbp), %rsi
movl %ebx, %edi
xorl %ecx, %ecx
callq 0x20c0
xorl %eax, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %edi, %edi
callq 0x21c0
nopl (%rax)