// File: /workspace/github_c_makefile_star2_O1/VeeeectorPan[P]MyNetdisk/SourceFile/client_mkdir.c
// Function: client_mkdir
int client_mkdir(int client_fd)
{
    MYSQL* connect;
    connect_mysql(&connect);
    int file_id;
    int ret = recv(client_fd,&file_id,sizeof(int),0);
    DISCON_CHECK(ret,0,client_fd);
    int user_id;
    ret = recv(client_fd,&user_id,sizeof(int),0);
    DISCON_CHECK(ret,0,client_fd);
    char file_name[32] = {0};
    int len;
    ret = recv(client_fd,&len,sizeof(int),0);
    DISCON_CHECK(ret,0,client_fd);
    ret = recv_client_all(client_fd,file_name,len);
    DISCON_CHECK(ret,-1,client_fd);
    char mysql_oper[256];
    sprintf(mysql_oper,"select * from File where user_id=%d and parent_id=%d and file_name='%s'",user_id,file_id
            ,file_name);
    unsigned int queryRet = mysql_query(connect,mysql_oper);
    if(queryRet)
    {
        printf("Mysql query error: %s\n",mysql_error(connect));
        return -1;
    }
    MYSQL_RES* res;
    res = mysql_store_result(connect);
    if(mysql_num_rows(res) == 0)
    {
        int flag = FILE_NAME_AVAIABLE;
        ret = send(client_fd,&flag,sizeof(int),MSG_NOSIGNAL);
        DISCON_CHECK(ret,-1,client_fd);
    }
    else
    {
        int flag= FILE_NAME_NO_AVAIABLE;
        ret = send(client_fd,&flag,sizeof(int),MSG_NOSIGNAL);
        DISCON_CHECK(ret,-1,client_fd);
        return 0;
    }
    mysql_free_result(res);
    sprintf(mysql_oper,"insert into File(parent_id,file_name,user_id,file_type) values(%d,'%s',%d,'d');"
            ,file_id,file_name,user_id);
    insert_to_mysql(mysql_oper,connect);
    mysql_close(connect);
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x140, %rsp            # imm = 0x140
movl %edi, %ebx
leaq -0x20(%rbp), %rdi
callq 0x3530
leaq -0x18(%rbp), %rsi
movl $0x4, %edx
movl %ebx, %edi
xorl %ecx, %ecx
callq 0x20a0
testl %eax, %eax
je 0x2c75
leaq -0x14(%rbp), %rsi
movl $0x4, %edx
movl %ebx, %edi
xorl %ecx, %ecx
callq 0x20a0
testl %eax, %eax
je 0x2c75
xorps %xmm0, %xmm0
movaps %xmm0, -0x40(%rbp)
movaps %xmm0, -0x50(%rbp)
leaq -0x28(%rbp), %rsi
movl $0x4, %edx
movl %ebx, %edi
xorl %ecx, %ecx
callq 0x20a0
testl %eax, %eax
je 0x2c75
movl -0x28(%rbp), %edx
leaq -0x50(%rbp), %rsi
movl %ebx, %edi
callq 0x481c
cmpl $-0x1, %eax
je 0x2c75
movl -0x14(%rbp), %edx
movl -0x18(%rbp), %ecx
leaq 0x24ef(%rip), %rsi      # 0x50cd
leaq -0x150(%rbp), %r14
leaq -0x50(%rbp), %r8
movq %r14, %rdi
xorl %eax, %eax
callq 0x2060
movq -0x20(%rbp), %rdi
movq %r14, %rsi
callq 0x2140
movq -0x20(%rbp), %rdi
testl %eax, %eax
je 0x2c1f
callq 0x20b0
leaq 0x2502(%rip), %rdi      # 0x5115
movq %rax, %rsi
xorl %eax, %eax
callq 0x2040
jmp 0x2c7c
callq 0x2120
movq %rax, %r14
movq %rax, %rdi
callq 0x2190
leaq -0x24(%rbp), %rsi
testq %rax, %rax
je 0x2c59
movl $0x0, (%rsi)
movl $0x4, %edx
movl %ebx, %edi
movl $0x4000, %ecx           # imm = 0x4000
callq 0x2100
xorl %r14d, %r14d
cmpl $-0x1, %eax
je 0x2c75
jmp 0x2c82
movl $0x1, (%rsi)
movl $0x4, %edx
movl %ebx, %edi
movl $0x4000, %ecx           # imm = 0x4000
callq 0x2100
cmpl $-0x1, %eax
jne 0x2c91
movl %ebx, %edi
callq 0x2370
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
movl %r14d, %eax
addq $0x140, %rsp            # imm = 0x140
popq %rbx
popq %r14
popq %rbp
retq
movq %r14, %rdi
callq 0x21e0
movl -0x18(%rbp), %edx
movl -0x14(%rbp), %r8d
leaq 0x2485(%rip), %rsi      # 0x512c
xorl %r14d, %r14d
leaq -0x150(%rbp), %rbx
leaq -0x50(%rbp), %rcx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x2060
movq -0x20(%rbp), %rsi
movq %rbx, %rdi
callq 0x3970
movq -0x20(%rbp), %rdi
callq 0x2250
jmp 0x2c82
nop