// File: /workspace/github_c_makefile_star2_O0/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
subq $0x1e0, %rsp            # imm = 0x1E0
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl -0x8(%rbp), %eax
incl %eax
movq %rsp, %rcx
movq %rcx, -0x18(%rbp)
movq %rax, %rcx
shlq $0x8, %rcx
subq %rax, %rcx
addq $0xf, %rcx
movabsq $0x1fffffffff0, %rdx    # imm = 0x1FFFFFFFFF0
andq %rdx, %rcx
movq %rsp, %rdx
subq %rcx, %rdx
movq %rdx, -0x1e0(%rbp)
movq %rdx, %rsp
movq %rax, -0x20(%rbp)
movl -0x8(%rbp), %edi
movq -0x10(%rbp), %rsi
callq 0x1200
movq -0x1e0(%rbp), %rdi
addq $0xff, %rdi
leaq 0xc2a(%rip), %rsi       # 0x203f
callq 0x1080
cmpl $0x0, %eax
jne 0x143b
movq -0x1e0(%rbp), %rdi
addq $0xff, %rdi
leaq 0xbd0(%rip), %rsi       # 0x2004
callq 0x1030
jmp 0x1485
movq -0x1e0(%rbp), %rdi
addq $0xff, %rdi
callq 0x1060
movq %rax, %rcx
movq -0x1e0(%rbp), %rax
subq $0x1, %rcx
movsbl 0xff(%rax,%rcx), %eax
cmpl $0x2f, %eax
je 0x1483
movq -0x1e0(%rbp), %rdi
addq $0xff, %rdi
leaq 0xb87(%rip), %rsi       # 0x2005
callq 0x10d0
jmp 0x1485
movq -0x1e0(%rbp), %rdi
addq $0xff, %rdi
callq 0x1040
movq %rax, -0x28(%rbp)
cmpq $0x0, %rax
jne 0x14b5
leaq 0xb5e(%rip), %rdi       # 0x2007
callq 0x10c0
xorl %edi, %edi
callq 0x10e0
movq -0x1e0(%rbp), %rsi
addq $0xff, %rsi
leaq 0xb43(%rip), %rdi       # 0x200d
movb $0x0, %al
callq 0x1070
movl $0x0, -0x1c4(%rbp)
movl $0x0, -0x1c8(%rbp)
movq $0x0, -0x1d0(%rbp)
movq $0x0, -0x1d8(%rbp)
movq -0x28(%rbp), %rdi
callq 0x10a0
movq %rax, -0x30(%rbp)
cmpq $0x0, %rax
je 0x1621
movq -0x1e0(%rbp), %rsi
leaq -0x1c0(%rbp), %rdi
addq $0xff, %rsi
callq 0x1030
leaq -0x1c0(%rbp), %rdi
movq -0x30(%rbp), %rsi
addq $0x13, %rsi
callq 0x10d0
leaq -0x1c0(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
callq 0x1090
cmpl $-0x1, %eax
jne 0x156b
leaq 0xab9(%rip), %rdi       # 0x2018
callq 0x10c0
xorl %edi, %edi
callq 0x10e0
leaq -0xc0(%rbp), %rdi
addq $0x58, %rdi
callq 0x1050
movq %rax, %rsi
leaq 0xa98(%rip), %rdi       # 0x201d
movb $0x0, %al
callq 0x1070
movq -0x30(%rbp), %rax
movzbl 0x12(%rax), %eax
cmpl $0x4, %eax
jne 0x15cd
leaq 0xa84(%rip), %rdi       # 0x2024
movb $0x0, %al
callq 0x1070
movl -0x1c8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c8(%rbp)
movq -0x90(%rbp), %rax
addq -0x1d8(%rbp), %rax
movq %rax, -0x1d8(%rbp)
jmp 0x1606
movq -0x90(%rbp), %rsi
leaq 0xa57(%rip), %rdi       # 0x2032
movb $0x0, %al
callq 0x1070
movl -0x1c4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c4(%rbp)
movq -0x90(%rbp), %rax
addq -0x1d0(%rbp), %rax
movq %rax, -0x1d0(%rbp)
movq -0x30(%rbp), %rsi
addq $0x13, %rsi
leaq 0xa24(%rip), %rdi       # 0x2039
movb $0x0, %al
callq 0x1070
jmp 0x14fb
movl -0x1c4(%rbp), %esi
movq -0x1d0(%rbp), %rdx
leaq 0xa0b(%rip), %rdi       # 0x2040
movb $0x0, %al
callq 0x1070
movl -0x1c8(%rbp), %esi
movq -0x1d8(%rbp), %rdx
leaq 0xa0e(%rip), %rdi       # 0x205e
movb $0x0, %al
callq 0x1070
movl $0x0, -0x4(%rbp)
movq -0x18(%rbp), %rax
movq %rax, %rsp
movl -0x4(%rbp), %eax
movq %rbp, %rsp
popq %rbp
retq