// File: /workspace/github_c_makefile_star2_O1/icysunlight[P]miniftpd/ftpproto.c
// Function: transfer_list
void transfer_list(int datafd,const char* pathname)
{

    DIR* dir = opendir(pathname);
    if (NULL == dir)
       ERR_EXIT("opendir error");

    struct dirent* entry;
    while ( NULL != (entry = readdir(dir)))
    {
        if ('.' == entry->d_name[0]) 
            continue;

        struct stat fbuf;
        if (-1 == lstat(entry->d_name,&fbuf))
                ERR_EXIT("lstat error");

        char fstatbuf[1024] = {0};
        int off = 0;
        char per[11] = "----------";
        getfileper(&fbuf,per);
        per[10] = '\0';
        off += sprintf(fstatbuf + off,"%s",per);
        off += sprintf(fstatbuf + off," %d",(int)fbuf.st_nlink);
        off += sprintf(fstatbuf + off," %d",fbuf.st_gid);
        off += sprintf(fstatbuf + off," %d",fbuf.st_uid);
        off += sprintf(fstatbuf + off," %d",(int)fbuf.st_size);

        struct tm* tm = gmtime(&fbuf.st_atime);
        char strtime[128];
        strftime(strtime,128,"%b %d %H:%M",tm);
        off += sprintf(fstatbuf + off," %s",strtime);
        off += sprintf(fstatbuf + off," %s",entry->d_name);

        if ( 'l' == per[0] )
        {
            char lcontent[128] = {0};
            readlink(entry->d_name,lcontent,128);
            off += sprintf(fstatbuf + off," -> %s",lcontent);
        }

        off += sprintf(fstatbuf + off,"\r\n");
        writen(datafd,fstatbuf,off);
        fstatbuf[off + 1] = '\0';
        //printf("%s\n",fstatbuf);
    }

    closedir(dir);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x5b8, %rsp            # imm = 0x5B8
movl %edi, 0xc(%rsp)
movq %rsi, %rdi
callq 0x3140
testq %rax, %rax
je 0x5209
movq %rax, %r12
movq %rax, %rdi
callq 0x3380
testq %rax, %rax
je 0x51ea
movq %rax, %rbp
leaq 0xa0(%rsp), %rbx
leaq 0x130(%rsp), %r13
cmpb $0x2e, 0x13(%rbp)
je 0x51d6
addq $0x13, %rbp
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x3290
cmpl $-0x1, %eax
je 0x5204
movl $0x400, %edx            # imm = 0x400
movq %r13, %rdi
xorl %esi, %esi
callq 0x3220
movabsq $0x2d2d2d2d2d2d2d2d, %rax # imm = 0x2D2D2D2D2D2D2D2D
movq %rax, 0x10(%rsp)
movl $0x2d2d2d, 0x17(%rsp)   # imm = 0x2D2D2D
movq %rbx, %rdi
leaq 0x10(%rsp), %rbx
movq %rbx, %rsi
callq 0x4eb2
movb $0x0, 0x1a(%rsp)
movq %r13, %rdi
movq %rbx, %rsi
callq 0x3160
movq %r13, %r15
subq %r13, %rax
movslq %eax, %rbx
leaq (%rsp,%rbx), %rdi
addq $0x130, %rdi            # imm = 0x130
movl 0xb0(%rsp), %edx
leaq 0x3287(%rip), %r13      # 0x82d7
movq %r13, %rsi
xorl %eax, %eax
callq 0x34c0
addl %eax, %ebx
movslq %ebx, %rbx
leaq (%rsp,%rbx), %rdi
addq $0x130, %rdi            # imm = 0x130
movl 0xc0(%rsp), %edx
movq %r13, %rsi
xorl %eax, %eax
callq 0x34c0
addl %eax, %ebx
movslq %ebx, %rbx
leaq (%rsp,%rbx), %rdi
addq $0x130, %rdi            # imm = 0x130
movl 0xbc(%rsp), %edx
movq %r13, %rsi
xorl %eax, %eax
callq 0x34c0
addl %eax, %ebx
movslq %ebx, %rbx
leaq (%rsp,%rbx), %rdi
addq $0x130, %rdi            # imm = 0x130
movl 0xd0(%rsp), %edx
movq %r13, %rsi
xorl %eax, %eax
callq 0x34c0
addl %eax, %ebx
leaq 0xe8(%rsp), %rdi
callq 0x3480
movl $0x80, %esi
leaq 0x530(%rsp), %r13
movq %r13, %rdi
leaq 0x31f8(%rip), %rdx      # 0x82db
movq %rax, %rcx
callq 0x3410
movslq %ebx, %rbx
leaq (%rsp,%rbx), %rdi
addq $0x130, %rdi            # imm = 0x130
leaq 0x31ea(%rip), %r14      # 0x82ea
movq %r14, %rsi
movq %r13, %rdx
xorl %eax, %eax
callq 0x34c0
addl %eax, %ebx
movslq %ebx, %rbx
leaq (%rsp,%rbx), %rdi
addq $0x130, %rdi            # imm = 0x130
movq %r14, %rsi
movq %rbp, %rdx
xorl %eax, %eax
callq 0x34c0
addl %eax, %ebx
cmpb $0x6c, 0x10(%rsp)
jne 0x519a
xorps %xmm0, %xmm0
movaps %xmm0, 0x90(%rsp)
movaps %xmm0, 0x80(%rsp)
movaps %xmm0, 0x70(%rsp)
movaps %xmm0, 0x60(%rsp)
movaps %xmm0, 0x50(%rsp)
movaps %xmm0, 0x40(%rsp)
movaps %xmm0, 0x30(%rsp)
movaps %xmm0, 0x20(%rsp)
movl $0x80, %edx
movq %rbp, %rdi
leaq 0x20(%rsp), %r14
movq %r14, %rsi
callq 0x30e0
movslq %ebx, %rbx
leaq (%rsp,%rbx), %rdi
addq $0x130, %rdi            # imm = 0x130
leaq 0x3159(%rip), %rsi      # 0x82e7
movq %r14, %rdx
xorl %eax, %eax
callq 0x34c0
addl %eax, %ebx
movslq %ebx, %rbx
xorl %ebp, %ebp
movb %bpl, 0x132(%rsp,%rbx)
movw $0xa0d, 0x130(%rsp,%rbx) # imm = 0xA0D
leal 0x2(%rbx), %eax
movslq %eax, %rdx
movl 0xc(%rsp), %edi
movq %r15, %r13
movq %r15, %rsi
callq 0x4465
movb %bpl, 0x133(%rsp,%rbx)
leaq 0xa0(%rsp), %rbx
movq %r12, %rdi
callq 0x3380
movq %rax, %rbp
testq %rax, %rax
jne 0x4fc6
movq %r12, %rdi
callq 0x3270
addq $0x5b8, %rsp            # imm = 0x5B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x37b6
callq 0x37cb