// File: /workspace/github_c_makefile_star2_O3/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 $0x1b8, %rsp            # imm = 0x1B8
leal 0x1(%rdi), %eax
movq %rax, %rcx
shlq $0x8, %rcx
subq %rax, %rcx
addq $0xf, %rcx
movabsq $0x1fffffffff0, %r14    # imm = 0x1FFFFFFFFF0
andq %rcx, %r14
movq %rsp, %r15
movq %r15, %rbx
subq %r14, %rbx
movq %rbx, %rsp
movq %rbx, %rdx
callq 0x121c
addq $0xff, %rbx
negq %r14
cmpb $0x0, 0xff(%r15,%r14)
je 0x1397
movq %rbx, %rdi
callq 0x1060
cmpb $0x2f, -0x1(%rax,%rbx)
je 0x13a0
movq %rbx, %rdi
callq 0x1060
movw $0x2f, (%rbx,%rax)
jmp 0x13a0
movb $0x0, 0x2(%rbx)
movw $0x2f2e, (%rbx)         # imm = 0x2F2E
movq %rbx, %rdi
callq 0x1040
testq %rax, %rax
je 0x1529
movq %rax, %r14
leaq 0xc52(%rip), %rdi       # 0x200d
movq %rbx, %rsi
xorl %eax, %eax
callq 0x1070
movq %r14, %rdi
callq 0x1090
testq %rax, %rax
je 0x14c9
movq %rax, %r13
leaq -0x1e0(%rbp), %r15
movq $0x0, -0x40(%rbp)
movq $0x0, -0x38(%rbp)
movl $0x0, -0x2c(%rbp)
movq $0x0, -0x48(%rbp)
movq %r15, %rdi
movq %rbx, %rsi
callq 0x1030
leaq 0x13(%r13), %r12
movq %r15, %rdi
movq %r12, %rsi
callq 0x10b0
movq %r15, %rdi
leaq -0xd8(%rbp), %rsi
callq 0x1080
cmpl $-0x1, %eax
je 0x1524
leaq -0x80(%rbp), %rdi
callq 0x1050
leaq 0xbdc(%rip), %rdi       # 0x201d
movq %rax, %rsi
xorl %eax, %eax
callq 0x1070
cmpb $0x4, 0x12(%r13)
jne 0x1474
leaq 0xbcb(%rip), %rdi       # 0x2024
xorl %eax, %eax
callq 0x1070
incl -0x2c(%rbp)
movq -0x40(%rbp), %rax
addq -0xa8(%rbp), %rax
movq %rax, -0x40(%rbp)
jmp 0x14a2
movq -0xa8(%rbp), %rsi
leaq 0xbb0(%rip), %rdi       # 0x2032
xorl %eax, %eax
callq 0x1070
movq -0x48(%rbp), %rax
incl %eax
movq %rax, -0x48(%rbp)
movq -0x38(%rbp), %rax
addq -0xa8(%rbp), %rax
movq %rax, -0x38(%rbp)
leaq 0xb90(%rip), %rdi       # 0x2039
movq %r12, %rsi
xorl %eax, %eax
callq 0x1070
movq %r14, %rdi
callq 0x1090
movq %rax, %r13
testq %rax, %rax
jne 0x13ff
jmp 0x14e8
movq $0x0, -0x48(%rbp)
movl $0x0, -0x2c(%rbp)
movq $0x0, -0x38(%rbp)
movq $0x0, -0x40(%rbp)
leaq 0xb51(%rip), %rdi       # 0x2040
movq -0x48(%rbp), %rsi
movq -0x38(%rbp), %rdx
xorl %eax, %eax
callq 0x1070
leaq 0xb59(%rip), %rdi       # 0x205e
movl -0x2c(%rbp), %esi
movq -0x40(%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
callq 0x1100
callq 0x1117