// File: /workspace/github_c_makefile_star2_O0/VeeeectorPan[P]MyNetdisk/SourceFile/client_ls.c
// Function: client_ls
int client_ls(int client_fd)
{
    int file_id;
    MYSQL* connect;
    connect_mysql(&connect);
    int ret = recv(client_fd,&file_id,sizeof(int),0);
    DISCON_CHECK(ret,0,client_fd);
    char mysql_oper[256];
    sprintf(mysql_oper,"select file_type,file_size,file_name from File where parent_id=%d;",file_id);
    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);
    char buf[256];
    while(row != NULL)
    {
        memset(buf,0,sizeof(buf));
        buf[0] = *row[0];
        int file_size;
        if(row[1] != NULL)
            file_size = atoi(row[1]);
        else
            file_size = 0;
        memcpy(buf + 1,(const char*)&file_size,sizeof(int));
        sprintf(buf + 5,"%s",row[2]);
        int len = 5 + strlen(buf + 5);
        ret = send(client_fd,&len,sizeof(int),MSG_NOSIGNAL);
        DISCON_CHECK(ret,-1,client_fd);
        ret = send(client_fd,buf,len,MSG_NOSIGNAL);
        DISCON_CHECK(ret,-1,client_fd);
        row = mysql_fetch_row(res);
    }
    mysql_free_result(res);
    mysql_close(connect);

    int ctl_num = LS_FIN;
    ret = send(client_fd,&ctl_num,sizeof(int),MSG_NOSIGNAL);
    DISCON_CHECK(ret,-1,client_fd);
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x250, %rsp            # imm = 0x250
movl %edi, -0x8(%rbp)
leaq -0x18(%rbp), %rdi
callq 0x3c20
movl -0x8(%rbp), %edi
leaq -0xc(%rbp), %rsi
movl $0x4, %edx
xorl %ecx, %ecx
callq 0x20b0
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
jne 0x2be7
movl -0x8(%rbp), %edi
callq 0x2380
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x2df0
leaq -0x120(%rbp), %rdi
movl -0xc(%rbp), %edx
leaq 0x4492(%rip), %rsi      # 0x708a
movb $0x0, %al
callq 0x2070
movq -0x18(%rbp), %rdi
leaq -0x120(%rbp), %rsi
callq 0x2150
movl %eax, -0x124(%rbp)
cmpl $0x0, -0x124(%rbp)
je 0x2c44
movq -0x18(%rbp), %rdi
callq 0x20c0
movq %rax, %rsi
leaq 0x4455(%rip), %rdi      # 0x7086
movb $0x0, %al
callq 0x2040
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x2df0
movq -0x18(%rbp), %rdi
callq 0x2350
movq %rax, -0x138(%rbp)
movq -0x138(%rbp), %rdi
callq 0x2200
movq %rax, -0x130(%rbp)
cmpq $0x0, -0x130(%rbp)
je 0x2d97
leaq -0x240(%rbp), %rdi
xorl %esi, %esi
movl $0x100, %edx            # imm = 0x100
callq 0x2140
movq -0x130(%rbp), %rax
movq (%rax), %rax
movb (%rax), %al
movb %al, -0x240(%rbp)
movq -0x130(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x2cc0
movq -0x130(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x2310
movl %eax, -0x244(%rbp)
jmp 0x2cca
movl $0x0, -0x244(%rbp)
movl -0x244(%rbp), %eax
movl %eax, -0x23f(%rbp)
leaq -0x240(%rbp), %rdi
addq $0x5, %rdi
movq -0x130(%rbp), %rax
movq 0x10(%rax), %rdx
leaq 0x464a(%rip), %rsi      # 0x733d
movb $0x0, %al
callq 0x2070
leaq -0x240(%rbp), %rdi
addq $0x5, %rdi
callq 0x20d0
addq $0x5, %rax
movl %eax, -0x248(%rbp)
movl -0x8(%rbp), %edi
leaq -0x248(%rbp), %rsi
movl $0x4, %edx
movl $0x4000, %ecx           # imm = 0x4000
callq 0x2110
movl %eax, -0x1c(%rbp)
cmpl $-0x1, -0x1c(%rbp)
jne 0x2d4a
movl -0x8(%rbp), %edi
callq 0x2380
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x2df0
movl -0x8(%rbp), %edi
leaq -0x240(%rbp), %rsi
movslq -0x248(%rbp), %rdx
movl $0x4000, %ecx           # imm = 0x4000
callq 0x2110
movl %eax, -0x1c(%rbp)
cmpl $-0x1, -0x1c(%rbp)
jne 0x2d7f
movl -0x8(%rbp), %edi
callq 0x2380
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x2df0
movq -0x138(%rbp), %rdi
callq 0x2200
movq %rax, -0x130(%rbp)
jmp 0x2c67
movq -0x138(%rbp), %rdi
callq 0x21f0
movq -0x18(%rbp), %rdi
callq 0x2260
movl $0x0, -0x24c(%rbp)
movl -0x8(%rbp), %edi
leaq -0x24c(%rbp), %rsi
movl $0x4, %edx
movl $0x4000, %ecx           # imm = 0x4000
callq 0x2110
movl %eax, -0x1c(%rbp)
cmpl $-0x1, -0x1c(%rbp)
jne 0x2de9
movl -0x8(%rbp), %edi
callq 0x2380
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x2df0
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x250, %rsp            # imm = 0x250
popq %rbp
retq
nopl (%rax)