// File: /workspace/github_c_makefile_star2_O2/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 0x3434
leaq -0x20(%rbp), %rsi
pushq $0x4
popq %rdx
movl %ebx, %edi
xorl %ecx, %ecx
callq 0x20a0
testl %eax, %eax
je 0x2622
leaq -0x1c(%rbp), %rsi
pushq $0x4
popq %rdx
movl %ebx, %edi
xorl %ecx, %ecx
callq 0x20a0
testl %eax, %eax
je 0x2622
cmpl $0x0, -0x1c(%rbp)
je 0x25ac
leaq -0x2c(%rbp), %rsi
pushq $0x4
popq %rdx
movl %ebx, %edi
xorl %ecx, %ecx
callq 0x20a0
testl %eax, %eax
je 0x2622
xorps %xmm0, %xmm0
leaq -0x50(%rbp), %rsi
movaps %xmm0, 0x10(%rsi)
movaps %xmm0, (%rsi)
movl -0x2c(%rbp), %edx
movl %ebx, %edi
callq 0x45cc
cmpl $-0x1, %eax
je 0x2622
movl -0x20(%rbp), %edx
leaq 0x2a99(%rip), %rsi      # 0x5031
leaq -0x150(%rbp), %rdi
leaq -0x50(%rbp), %rcx
xorl %eax, %eax
callq 0x2060
jmp 0x25c4
movl -0x20(%rbp), %edx
leaq 0x2a4e(%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 0x25eb
callq 0x20b0
movq %rax, %rdi
callq 0x22f0
jmp 0x2629
callq 0x2340
movq %rax, %r14
movq %rax, %rdi
callq 0x2200
movq %rax, %r15
cmpq $0x1, %rax
pushq $0x3
popq %rax
sbbl $0x0, %eax
leaq -0x1c(%rbp), %rsi
movl %eax, (%rsi)
pushq $0x4
popq %rdx
movl %ebx, %edi
movl $0x4000, %ecx           # imm = 0x4000
callq 0x2100
cmpl $-0x1, %eax
jne 0x263a
movl %ebx, %edi
callq 0x2380
pushq $-0x1
popq %rax
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x3, -0x1c(%rbp)
jne 0x2662
movq (%r15), %rdi
callq 0x2300
leaq -0x20(%rbp), %rsi
movl %eax, (%rsi)
pushq $0x4
popq %rdx
movl %ebx, %edi
movl $0x4000, %ecx           # imm = 0x4000
callq 0x2100
cmpl $-0x1, %eax
je 0x2622
movq %r14, %rdi
callq 0x21f0
movq -0x28(%rbp), %rdi
callq 0x2260
xorl %eax, %eax
jmp 0x262c
nop