// File: /workspace/github_c_makefile_star2_O3/VeeeectorPan[P]MyNetdisk/SourceFile/client_cd.c
// Function: client_cd
int client_cd(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 ctl_num;
    ret = recv(client_fd,&ctl_num,sizeof(int),0);
    DISCON_CHECK(ret,0,client_fd);
    char mysql_oper[256];
    if(ctl_num == CD_BACK)
    {
        sprintf(mysql_oper,"select parent_id from File where file_id=%d;",file_id);
    }
    else
    {
        int len;
        ret = recv(client_fd,&len,sizeof(int),0);
        DISCON_CHECK(ret,0,client_fd);
        char file_name[32] = {0};
        ret = recv_client_all(client_fd,file_name,len);
        DISCON_CHECK(ret,-1,client_fd);
        sprintf(mysql_oper,"select file_id from File where parent_id=%d and file_name='%s' and file_type='d';",file_id,file_name);
    }
    int queryResult = mysql_query(connect,mysql_oper);
    if(queryResult)
    {
        printf("%s\n",mysql_error(connect));
        return -1;
    }
    MYSQL_ROW row;
    MYSQL_RES* res;
    res = mysql_use_result(connect);
    row = mysql_fetch_row(res);
    if(row == NULL)
    {
        ctl_num = CD_FAIL;
    }
    else
    {
        ctl_num = CD_SUCCESS;
    }
    ret = send(client_fd,&ctl_num,sizeof(int),MSG_NOSIGNAL);
    DISCON_CHECK(ret,-1,client_fd);
    if(ctl_num == CD_SUCCESS)
    {
        file_id = atoi(row[0]);
        ret = send(client_fd,&file_id,sizeof(int),MSG_NOSIGNAL);
        DISCON_CHECK(ret,-1,client_fd);
    }
    mysql_free_result(res);
    mysql_close(connect);
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x138, %rsp            # imm = 0x138
movl %edi, %ebx
leaq -0x28(%rbp), %rdi
callq 0x34e8
leaq -0x20(%rbp), %rsi
movl $0x4, %edx
movl %ebx, %edi
xorl %ecx, %ecx
callq 0x20a0
testl %eax, %eax
je 0x2660
leaq -0x1c(%rbp), %rsi
movl $0x4, %edx
movl %ebx, %edi
xorl %ecx, %ecx
callq 0x20a0
testl %eax, %eax
je 0x2660
cmpl $0x0, -0x1c(%rbp)
je 0x25e6
leaq -0x2c(%rbp), %rsi
movl $0x4, %edx
movl %ebx, %edi
xorl %ecx, %ecx
callq 0x20a0
testl %eax, %eax
je 0x2660
xorps %xmm0, %xmm0
leaq -0x50(%rbp), %rsi
movaps %xmm0, 0x10(%rsi)
movaps %xmm0, (%rsi)
movl -0x2c(%rbp), %edx
movl %ebx, %edi
callq 0x47cc
cmpl $-0x1, %eax
je 0x2660
movl -0x20(%rbp), %edx
leaq 0x2a5f(%rip), %rsi      # 0x5031
leaq -0x150(%rbp), %rdi
leaq -0x50(%rbp), %rcx
xorl %eax, %eax
callq 0x2060
jmp 0x25fe
movl -0x20(%rbp), %edx
leaq 0x2a14(%rip), %rsi      # 0x5004
leaq -0x150(%rbp), %rdi
xorl %eax, %eax
callq 0x2060
movq -0x28(%rbp), %rdi
leaq -0x150(%rbp), %rsi
callq 0x2140
movq -0x28(%rbp), %rdi
testl %eax, %eax
je 0x2625
callq 0x20b0
movq %rax, %rdi
callq 0x22f0
jmp 0x2667
callq 0x2340
movq %rax, %r14
movq %rax, %rdi
callq 0x2200
movq %rax, %r15
cmpq $0x1, %rax
movl $0x3, %eax
sbbl $0x0, %eax
leaq -0x1c(%rbp), %rsi
movl %eax, (%rsi)
movl $0x4, %edx
movl %ebx, %edi
movl $0x4000, %ecx           # imm = 0x4000
callq 0x2100
cmpl $-0x1, %eax
jne 0x267a
movl %ebx, %edi
callq 0x2380
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x3, -0x1c(%rbp)
jne 0x26a4
movq (%r15), %rdi
callq 0x2300
leaq -0x20(%rbp), %rsi
movl %eax, (%rsi)
movl $0x4, %edx
movl %ebx, %edi
movl $0x4000, %ecx           # imm = 0x4000
callq 0x2100
cmpl $-0x1, %eax
je 0x2660
movq %r14, %rdi
callq 0x21f0
movq -0x28(%rbp), %rdi
callq 0x2260
xorl %eax, %eax
jmp 0x266c
nopl (%rax)