// File: /workspace/github_c_makefile_star2_O0/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
subq $0x170, %rsp            # imm = 0x170
movl %edi, -0x8(%rbp)
leaq -0x10(%rbp), %rdi
callq 0x3c20
movl -0x8(%rbp), %edi
leaq -0x14(%rbp), %rsi
movl $0x4, %edx
xorl %ecx, %ecx
callq 0x20b0
movl %eax, -0x18(%rbp)
cmpl $0x0, -0x18(%rbp)
jne 0x2587
movl -0x8(%rbp), %edi
callq 0x2380
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x2789
movl -0x8(%rbp), %edi
leaq -0x1c(%rbp), %rsi
movl $0x4, %edx
xorl %ecx, %ecx
callq 0x20b0
movl %eax, -0x18(%rbp)
cmpl $0x0, -0x18(%rbp)
jne 0x25b7
movl -0x8(%rbp), %edi
callq 0x2380
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x2789
cmpl $0x0, -0x1c(%rbp)
jne 0x25da
leaq -0x120(%rbp), %rdi
movl -0x14(%rbp), %edx
leaq 0x4a36(%rip), %rsi      # 0x7004
movb $0x0, %al
callq 0x2070
jmp 0x2671
movl -0x8(%rbp), %edi
leaq -0x124(%rbp), %rsi
movl $0x4, %edx
xorl %ecx, %ecx
callq 0x20b0
movl %eax, -0x18(%rbp)
cmpl $0x0, -0x18(%rbp)
jne 0x260d
movl -0x8(%rbp), %edi
callq 0x2380
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x2789
leaq -0x150(%rbp), %rdi
xorl %esi, %esi
movl $0x20, %edx
callq 0x2140
movl -0x8(%rbp), %edi
leaq -0x150(%rbp), %rsi
movl -0x124(%rbp), %edx
callq 0x5cb0
movl %eax, -0x18(%rbp)
cmpl $-0x1, -0x18(%rbp)
jne 0x2652
movl -0x8(%rbp), %edi
callq 0x2380
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x2789
leaq -0x120(%rbp), %rdi
movl -0x14(%rbp), %edx
leaq -0x150(%rbp), %rcx
leaq 0x49c7(%rip), %rsi      # 0x7031
movb $0x0, %al
callq 0x2070
movq -0x10(%rbp), %rdi
leaq -0x120(%rbp), %rsi
callq 0x2150
movl %eax, -0x154(%rbp)
cmpl $0x0, -0x154(%rbp)
je 0x26b6
movq -0x10(%rbp), %rdi
callq 0x20c0
movq %rax, %rsi
leaq 0x49e3(%rip), %rdi      # 0x7086
movb $0x0, %al
callq 0x2040
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x2789
movq -0x10(%rbp), %rdi
callq 0x2350
movq %rax, -0x168(%rbp)
movq -0x168(%rbp), %rdi
callq 0x2200
movq %rax, -0x160(%rbp)
cmpq $0x0, -0x160(%rbp)
jne 0x26ec
movl $0x2, -0x1c(%rbp)
jmp 0x26f3
movl $0x3, -0x1c(%rbp)
movl -0x8(%rbp), %edi
leaq -0x1c(%rbp), %rsi
movl $0x4, %edx
movl $0x4000, %ecx           # imm = 0x4000
callq 0x2110
movl %eax, -0x18(%rbp)
cmpl $-0x1, -0x18(%rbp)
jne 0x2723
movl -0x8(%rbp), %edi
callq 0x2380
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x2789
cmpl $0x3, -0x1c(%rbp)
jne 0x276d
movq -0x160(%rbp), %rax
movq (%rax), %rdi
callq 0x2310
movl %eax, -0x14(%rbp)
movl -0x8(%rbp), %edi
leaq -0x14(%rbp), %rsi
movl $0x4, %edx
movl $0x4000, %ecx           # imm = 0x4000
callq 0x2110
movl %eax, -0x18(%rbp)
cmpl $-0x1, -0x18(%rbp)
jne 0x276b
movl -0x8(%rbp), %edi
callq 0x2380
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x2789
jmp 0x276d
movq -0x168(%rbp), %rdi
callq 0x21f0
movq -0x10(%rbp), %rdi
callq 0x2260
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x170, %rsp            # imm = 0x170
popq %rbp
retq
nopw %cs:(%rax,%rax)
nop