// File: /workspace/github_c_makefile_star2_O2/CSerxzm[P]WindowstoLinuxInterface/src/DIR.c
// Function: main
int main(int argc, char**argv){
    
    char lines[argc+1][255];
    predealLine(argc, argv, lines);

    DIR* fd;
    struct dirent* fp;
    struct stat buf;
    char temp[255];

    if(strcmp(lines[1], "")==0){
        strcpy(lines[1], "./");
    }
    else if(lines[1][strlen(lines[1])-1]!='/'){
        strcat(lines[1],"/");
    }
    if((fd=opendir(lines[1]))==NULL){
        perror("fail!");
        exit(0);
    }
    printf("%s 目录\n", lines[1]);
    int file_num=0;
    int dir_num=0;
    long long file_size=0;
    long long dir_size=0;
    while((fp=readdir(fd))!=NULL){
        strcpy(temp, lines[1]);
        strcat(temp, fp->d_name);
        if(stat(temp, &buf)==-1){
            perror("stat");
            exit(0);
        }

        printf("%.12s ",ctime(&buf.st_mtime));
        if(fp->d_type==DT_DIR){
            printf("        <DIR>");
            dir_num++;
            dir_size+=buf.st_size;
        }
        else{
            printf("\t%10ld", buf.st_size);
            file_num++;
            file_size+=buf.st_size;
        }
            
        printf("   %s\n", fp->d_name);

    }
    printf("%12d 个文件 %12lld 字节\n",file_num,file_size);
    printf("%12d 个目录 %12lld 字节\n",dir_num,dir_size);
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1a8, %rsp            # imm = 0x1A8
leal 0x1(%rdi), %eax
movq %rsp, %rbx
imulq $0xff, %rax, %r14
addq $0xf, %r14
andq $-0x10, %r14
movq %rbx, %r15
subq %r14, %r15
movq %r15, %rsp
movq %r15, %rdx
callq 0x11ec
addq $0xff, %r15
negq %r14
cmpb $0x0, 0xff(%rbx,%r14)
je 0x1334
movq %r15, %rdi
callq 0x1060
cmpb $0x2f, -0x1(%rax,%r15)
je 0x133f
movq %r15, %rdi
callq 0x1060
movw $0x2f, (%r15,%rax)
jmp 0x133f
movb $0x0, 0x2(%r15)
movw $0x2f2e, (%r15)         # imm = 0x2F2E
movq %r15, %rdi
callq 0x1040
movq %rax, -0x40(%rbp)
testq %rax, %rax
je 0x1499
leaq 0xcb2(%rip), %rdi       # 0x200d
movq %r15, %rsi
xorl %eax, %eax
callq 0x1070
leaq -0x1d0(%rbp), %rbx
movl $0x0, -0x2c(%rbp)
movl $0x0, -0x30(%rbp)
xorl %r14d, %r14d
movq $0x0, -0x38(%rbp)
movq -0x40(%rbp), %rdi
callq 0x1090
testq %rax, %rax
je 0x144c
movq %rax, %r12
movq %rbx, %rdi
movq %r15, %r13
movq %r15, %rsi
callq 0x1030
leaq 0x13(%r12), %r15
movq %rbx, %rdi
movq %r15, %rsi
callq 0x10b0
movq %rbx, %rdi
leaq -0xd0(%rbp), %rsi
callq 0x1080
cmpl $-0x1, %eax
je 0x1486
leaq -0x78(%rbp), %rdi
callq 0x1050
leaq 0xc3d(%rip), %rdi       # 0x201d
movq %rax, %rsi
xorl %eax, %eax
callq 0x1070
cmpb $0x4, 0x12(%r12)
jne 0x1414
leaq 0xc2b(%rip), %rdi       # 0x2024
xorl %eax, %eax
callq 0x1070
incl -0x30(%rbp)
movq -0x38(%rbp), %rax
addq -0xa0(%rbp), %rax
movq %rax, -0x38(%rbp)
jmp 0x1433
movq -0xa0(%rbp), %rsi
leaq 0xc10(%rip), %rdi       # 0x2032
xorl %eax, %eax
callq 0x1070
incl -0x2c(%rbp)
addq -0xa0(%rbp), %r14
leaq 0xbff(%rip), %rdi       # 0x2039
movq %r15, %rsi
xorl %eax, %eax
callq 0x1070
movq %r13, %r15
jmp 0x1385
leaq 0xbed(%rip), %rdi       # 0x2040
movl -0x2c(%rbp), %esi
movq %r14, %rdx
xorl %eax, %eax
callq 0x1070
leaq 0xbf7(%rip), %rdi       # 0x205e
movl -0x30(%rbp), %esi
movq -0x38(%rbp), %rdx
xorl %eax, %eax
callq 0x1070
xorl %eax, %eax
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xb8b(%rip), %rdi       # 0x2018
callq 0x10a0
xorl %edi, %edi
callq 0x10c0
leaq 0xb67(%rip), %rdi       # 0x2007
jmp 0x148d