// File: /workspace/github_c_makefile_star2_O1/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 0x3530
leaq -0x20(%rbp), %rsi
movl $0x4, %edx
movl %ebx, %edi
xorl %ecx, %ecx
callq 0x20a0
testl %eax, %eax
je 0x265e
leaq -0x1c(%rbp), %rsi
movl $0x4, %edx
movl %ebx, %edi
xorl %ecx, %ecx
callq 0x20a0
testl %eax, %eax
je 0x265e
cmpl $0x0, -0x1c(%rbp)
je 0x25d5
leaq -0x2c(%rbp), %rsi
movl $0x4, %edx
movl %ebx, %edi
xorl %ecx, %ecx
callq 0x20a0
testl %eax, %eax
je 0x265e
xorps %xmm0, %xmm0
leaq -0x50(%rbp), %rsi
movaps %xmm0, 0x10(%rsi)
movaps %xmm0, (%rsi)
movl -0x2c(%rbp), %edx
movl %ebx, %edi
callq 0x481c
movl %eax, %r14d
cmpl $-0x1, %eax
je 0x25ef
movl -0x20(%rbp), %edx
leaq 0x2a70(%rip), %rsi      # 0x5031
leaq -0x150(%rbp), %rdi
leaq -0x50(%rbp), %rcx
xorl %eax, %eax
callq 0x2060
jmp 0x25f6
movl -0x20(%rbp), %edx
leaq 0x2a25(%rip), %rsi      # 0x5004
leaq -0x150(%rbp), %rdi
xorl %eax, %eax
callq 0x2060
jmp 0x25fc
movl %ebx, %edi
callq 0x2370
cmpl $-0x1, %r14d
je 0x2665
movq -0x28(%rbp), %rdi
leaq -0x150(%rbp), %rsi
callq 0x2140
movq -0x28(%rbp), %rdi
testl %eax, %eax
je 0x2623
callq 0x20b0
movq %rax, %rdi
callq 0x22e0
jmp 0x2665
callq 0x2330
movq %rax, %r14
movq %rax, %rdi
callq 0x21f0
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 0x2678
movl %ebx, %edi
callq 0x2370
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x3, -0x1c(%rbp)
jne 0x26a2
movq (%r15), %rdi
callq 0x22f0
leaq -0x20(%rbp), %rsi
movl %eax, (%rsi)
movl $0x4, %edx
movl %ebx, %edi
movl $0x4000, %ecx           # imm = 0x4000
callq 0x2100
cmpl $-0x1, %eax
je 0x265e
movq %r14, %rdi
callq 0x21e0
movq -0x28(%rbp), %rdi
callq 0x2250
xorl %eax, %eax
jmp 0x266a
nop