// File: /workspace/github_cpp_makefile_star2_O2/aman-agrawal[P]Terminal-based-file-explorer/list.cpp
// Function: list[abi:cxx11](char*, char)
vector<pair<string, char>> list(char* str,char d) {            //function definition begin
    clear();        //clear terminal
    vector<pair<string, char>> filename;
    DIR *mydir;
    struct dirent **myfile;
    struct stat mystat;
    char buf[512];
    struct passwd *pw;
    struct group  *gr;

    int total_files = scandir(str, &myfile, NULL, alphasort);

    for(int i=0; i<total_files; i++) {


        string name = myfile[i]->d_name;
        stat(name.c_str(), &mystat);

        string strTemp(str);    //concatenate path to string
        strTemp = strTemp+"/"+name;

        cout << name<<"  ";     //filename

        cout<< mystat.st_size<<"    ";       //file size

        pw = getpwuid(mystat.st_uid);
        gr = getgrgid(mystat.st_gid);

        cout << pw->pw_name << " " << gr->gr_name << " ";   //ownername nd groupname

        char d= (S_ISDIR(mystat.st_mode)) ? 'd' : '-';
        filename.push_back(make_pair(strTemp, d));

        char ur= (mystat.st_mode & S_IRUSR) ? 'r' : '-';
        char  uw= (mystat.st_mode & S_IWUSR) ? 'w' : '-';
        char ue = (mystat.st_mode & S_IXUSR) ? 'x' : '-';

        char gr= (mystat.st_mode & S_IRGRP) ? 'r' : '-';
        char gw= (mystat.st_mode & S_IWGRP) ? 'w' : '-';
        char ge = (mystat.st_mode & S_IXGRP) ? 'x' : '-';

        char oread = (mystat.st_mode & S_IROTH) ? 'r' : '-';
        char ow = (mystat.st_mode & S_IWOTH) ? 'w' : '-';
        char oe = (mystat.st_mode & S_IXOTH) ? 'x' : '-';
        
        cout << d;                          //print whether it is directory or file
        cout << ur << uw << ue;
        cout << gr << gw << ge;
        cout << oread << ow << oe<<"   ";

        cout << ctime(&mystat.st_mtime);    //print time
    }
    return filename;   
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x158, %rsp            # imm = 0x158
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x39d6(%rip), %rdi      # 0x6030
xorl %r15d, %r15d
xorl %eax, %eax
callq 0x2030
pxor %xmm0, %xmm0
movdqu %xmm0, (%rbx)
movq %rbx, 0x18(%rsp)
andq $0x0, 0x10(%rbx)
movq 0x694b(%rip), %rcx      # 0x8fc8
leaq 0x38(%rsp), %rsi
movq %r14, 0x28(%rsp)
movq %r14, %rdi
xorl %edx, %edx
callq 0x2050
testl %eax, %eax
cmovlel %r15d, %eax
movq 0x6932(%rip), %r13      # 0x8fd0
xorl %ecx, %ecx
movq %rax, 0x20(%rsp)
cmpq %rcx, %rax
je 0x29b1
movq 0x38(%rsp), %rax
movq %rcx, 0x30(%rsp)
movq (%rax,%rcx,8), %rsi
addq $0x13, %rsi
leaq 0x60(%rsp), %rdi
leaq 0x80(%rsp), %rbx
movq %rbx, %rdx
callq 0x2a22
movq 0x60(%rsp), %rdi
leaq 0xc8(%rsp), %rsi
callq 0x21e0
leaq 0x40(%rsp), %r14
movq %r14, %rdi
movq 0x28(%rsp), %rsi
movq %rbx, %rdx
callq 0x2a22
leaq 0xa8(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
leaq 0x3a4f(%rip), %rdx      # 0x6160
callq 0x2a7c
leaq 0x80(%rsp), %r14
movq %r14, %rdi
movq %r15, %rsi
leaq 0x60(%rsp), %rbx
movq %rbx, %rdx
callq 0x2a5d
leaq 0x40(%rsp), %rdi
movq %r14, %rsi
callq 0x2290
movq %r14, %rdi
callq 0x2418
movq %r15, %rdi
callq 0x2418
movq %r13, %rdi
movq %rbx, %rsi
callq 0x21d0
movq %rax, %rdi
leaq 0x3a7d(%rip), %rsi      # 0x61e0
callq 0x2210
movq 0xf8(%rsp), %rsi
movq %r13, %rdi
callq 0x2200
movq %rax, %rdi
leaq 0x3a5c(%rip), %rsi      # 0x61de
callq 0x2210
movl 0xe4(%rsp), %edi
callq 0x2280
movq %rax, %rbx
movl 0xe8(%rsp), %edi
callq 0x2390
movq %rax, %r15
movq (%rbx), %rsi
movq %r13, %rdi
callq 0x2210
movq %rax, %rdi
leaq 0x3a27(%rip), %rsi      # 0x61e1
callq 0x2210
movq (%r15), %rsi
movq %rax, %rdi
callq 0x2210
movq %rax, %rdi
leaq 0x3a0d(%rip), %rsi      # 0x61e1
callq 0x2210
movl 0xe0(%rsp), %eax
movl $0xf000, %ecx           # imm = 0xF000
andl %ecx, %eax
pushq $0x64
popq %r13
cmpl $0x4000, %eax           # imm = 0x4000
je 0x27f6
pushq $0x2d
popq %r13
leaq 0x80(%rsp), %rbx
movq %rbx, %rdi
leaq 0x40(%rsp), %rsi
callq 0x22c0
movb %r13b, 0xa0(%rsp)
movq 0x18(%rsp), %rdi
movq %rbx, %rsi
callq 0x2bd8
movq %rbx, %rdi
callq 0x2418
movl 0xe0(%rsp), %ebp
movd %ebp, %xmm0
pshufd $0x0, %xmm0, %xmm0      # xmm0 = xmm0[0,0,0,0]
movdqa %xmm0, %xmm1
pand 0x37cc(%rip), %xmm1     # 0x6010
pand 0x37d4(%rip), %xmm0     # 0x6020
pxor %xmm2, %xmm2
pcmpeqd %xmm2, %xmm0
pcmpeqd %xmm2, %xmm1
packssdw %xmm0, %xmm1
packsswb %xmm1, %xmm1
pmovmskb %xmm1, %eax
pushq $0x2d
popq %r12
testb $-0x80, %al
jne 0x2870
pushq $0x77
popq %r12
pushq $0x2d
popq %r15
testb $0x40, %al
jne 0x287c
pushq $0x78
popq %r15
pushq $0x2d
popq %rbx
testb $0x20, %al
jne 0x2886
pushq $0x72
popq %rbx
pushq $0x2d
popq %r14
testb $0x10, %al
jne 0x2892
pushq $0x77
popq %r14
pushq $0x2d
popq %rcx
movl %ecx, 0x14(%rsp)
testb $0x8, %al
jne 0x28a4
pushq $0x78
popq %rcx
movl %ecx, 0x14(%rsp)
pushq $0x2d
popq %rcx
movl %ecx, 0x10(%rsp)
testb $0x4, %al
jne 0x28b6
pushq $0x72
popq %rcx
movl %ecx, 0x10(%rsp)
pushq $0x2d
popq %rcx
movl %ecx, 0xc(%rsp)
testb $0x2, %al
jne 0x28c8
pushq $0x77
popq %rcx
movl %ecx, 0xc(%rsp)
pushq $0x2d
popq %rcx
movl %ecx, 0x8(%rsp)
testb $0x1, %al
jne 0x28da
pushq $0x78
popq %rax
movl %eax, 0x8(%rsp)
movzbl %r13b, %esi
movq 0x66eb(%rip), %r13      # 0x8fd0
movq %r13, %rdi
callq 0x2270
btl $0x8, %ebp
pushq $0x2d
popq %rsi
jae 0x28f9
pushq $0x72
popq %rsi
movq %r13, %rdi
callq 0x2270
movzbl %r12b, %esi
movq %rax, %rdi
callq 0x2270
movzbl %r15b, %esi
movq %rax, %rdi
callq 0x2270
movzbl %bl, %esi
movq %r13, %rdi
callq 0x2270
movzbl %r14b, %esi
movq %rax, %rdi
callq 0x2270
movzbl 0x14(%rsp), %esi
movq %rax, %rdi
callq 0x2270
movzbl 0x10(%rsp), %esi
movq %r13, %rdi
callq 0x2270
movzbl 0xc(%rsp), %esi
movq %rax, %rdi
callq 0x2270
movzbl 0x8(%rsp), %esi
movq %rax, %rdi
callq 0x2270
movq %rax, %rdi
leaq 0x3871(%rip), %rsi      # 0x61df
callq 0x2210
leaq 0x120(%rsp), %rdi
callq 0x20d0
movq %r13, %rdi
movq %rax, %rsi
callq 0x2210
leaq 0x40(%rsp), %rdi
callq 0x2418
leaq 0x60(%rsp), %rdi
callq 0x2418
movq 0x30(%rsp), %rcx
incq %rcx
movq 0x20(%rsp), %rax
jmp 0x26a5
movq 0x18(%rsp), %rax
addq $0x158, %rsp            # imm = 0x158
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x29ca
movq %rax, %rbx
jmp 0x2a10
movq %rax, %rbx
jmp 0x2a06
jmp 0x29f9
movq %rax, %rbx
leaq 0xa8(%rsp), %rdi
jmp 0x29f0
jmp 0x29f9
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
callq 0x2418
jmp 0x29fc
jmp 0x29f9
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x2418
leaq 0x60(%rsp), %rdi
callq 0x2418
movq 0x18(%rsp), %rdi
callq 0x2ab4
movq %rbx, %rdi
callq 0x23b0