// File: /workspace/github_c_makefile_star2_O3/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 -0x2c(%rbp), %rsi
movl $0x9, (%rsi)
movl $0x4, %edx
xorl %ecx, %ecx
callq 0x20c0
movq 0x2bd0(%rip), %rax      # 0x6fd8
movq (%rax), %rdi
callq 0x2040
xorps %xmm0, %xmm0
leaq -0x70(%rbp), %r14
movaps %xmm0, 0x10(%r14)
movaps %xmm0, (%r14)
leaq 0xc8c(%rip), %rdi       # 0x50b3
xorl %eax, %eax
callq 0x2030
leaq 0xc7b(%rip), %rdi       # 0x50b0
movq %r14, %rsi
xorl %eax, %eax
callq 0x2180
cmpl $-0x1, %eax
je 0x45f4
leaq 0xdbb(%rip), %r13       # 0x520a
leaq 0xc5d(%rip), %r15       # 0x50b3
leaq 0xc53(%rip), %r12       # 0x50b0
movb $0x0, -0x51(%rbp)
movq %r14, %rdi
callq 0x2080
movl %eax, -0x50(%rbp)
movq %r13, %rdi
cmpl $0x5, %eax
jl 0x44b5
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 -0x2c(%rbp), %rsi
xorl %ecx, %ecx
callq 0x2070
cmpl $0x0, -0x2c(%rbp)
leaq 0xd6c(%rip), %rdi       # 0x521f
jne 0x44f9
callq 0x2250
movq 0x2b17(%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 0x2180
cmpl $-0x1, %eax
jne 0x445d
jmp 0x45f4
movq 0x2ad8(%rip), %rax      # 0x6fd8
movq (%rax), %rdi
callq 0x2040
xorps %xmm0, %xmm0
leaq -0x50(%rbp), %r14
movaps %xmm0, 0x10(%r14)
movaps %xmm0, (%r14)
leaq 0xba0(%rip), %rdi       # 0x50bf
xorl %eax, %eax
callq 0x2030
leaq 0xb9d(%rip), %rdi       # 0x50ca
callq 0x2140
leaq 0xb77(%rip), %rdi       # 0x50b0
movq %r14, %rsi
xorl %eax, %eax
callq 0x2180
movl %eax, %r14d
leaq 0xb8c(%rip), %rdi       # 0x50d9
callq 0x2140
movl $0xa, %edi
callq 0x21e0
cmpl $-0x1, %r14d
je 0x45f4
leaq -0x50(%rbp), %r14
leaq 0xb3f(%rip), %r15       # 0x50b0
leaq 0xb61(%rip), %r12       # 0x50d9
movb $0x0, -0x31(%rbp)
movq %r14, %rdi
callq 0x2080
movl %eax, -0x30(%rbp)
cmpl $0x4, %eax
jg 0x45fb
leaq 0xca5(%rip), %rdi       # 0x5238
callq 0x2250
movq 0x2a39(%rip), %rax      # 0x6fd8
movq (%rax), %rdi
callq 0x2040
xorps %xmm0, %xmm0
movaps %xmm0, -0x40(%rbp)
movaps %xmm0, -0x50(%rbp)
leaq 0xb06(%rip), %rdi       # 0x50bf
xorl %eax, %eax
callq 0x2030
leaq 0xb03(%rip), %rdi       # 0x50ca
callq 0x2140
movq %r15, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x2180
movl %eax, %r13d
movq %r12, %rdi
callq 0x2140
movl $0xa, %edi
callq 0x21e0
cmpl $-0x1, %r13d
jne 0x4578
xorl %edi, %edi
callq 0x21b0
leaq -0x30(%rbp), %r14
movl $0x4, %edx
movl %ebx, %edi
movq %r14, %rsi
xorl %ecx, %ecx
callq 0x20c0
movslq (%r14), %rdx
leaq -0x50(%rbp), %rsi
movl %ebx, %edi
xorl %ecx, %ecx
callq 0x20c0
xorl %eax, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)