// File: /workspace/github_cpp_makefile_star2_O3/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 0x4986(%rip), %rdi      # 0x8030
xorl %eax, %eax
callq 0x3040
pxor %xmm0, %xmm0
movdqu %xmm0, (%rbx)
movq %rbx, 0x28(%rsp)
movq $0x0, 0x10(%rbx)
movq 0x78fb(%rip), %rcx      # 0xafc8
leaq 0xc0(%rsp), %rsi
movq %r14, 0xb0(%rsp)
movq %r14, %rdi
xorl %edx, %edx
callq 0x3060
testl %eax, %eax
jle 0x3c24
leaq 0x58(%rsp), %r12
leaq 0x98(%rsp), %r15
leaq 0x10(%rsp), %r13
movl %eax, %eax
movq %rax, 0xa8(%rsp)
xorl %ecx, %ecx
movq 0xc0(%rsp), %rax
movq %rcx, 0xb8(%rsp)
movq (%rax,%rcx,8), %rbx
leaq 0x13(%rbx), %r14
movq %r12, 0x48(%rsp)
movq %r14, %rdi
callq 0x3100
leaq (%rbx,%rax), %rdx
addq $0x13, %rdx
leaq 0x48(%rsp), %rdi
movq %r14, %rsi
callq 0x3e0a
movq 0x48(%rsp), %rdi
leaq 0xc8(%rsp), %rsi
callq 0x31e0
leaq 0x68(%rsp), %rdi
movq 0xb0(%rsp), %rsi
movq %rsp, %rbx
movq %rbx, %rdx
callq 0x3cd8
leaq 0x88(%rsp), %r14
movq %r15, 0x88(%rsp)
movq 0x68(%rsp), %rsi
movq 0x70(%rsp), %rdx
addq %rsi, %rdx
movq %r14, %rdi
callq 0x3d74
movq %r14, %rdi
leaq 0x49c0(%rip), %rsi      # 0x8160
callq 0x33e0
movq 0x48(%rsp), %rsi
movq 0x50(%rsp), %rdx
movq %r14, %rdi
callq 0x30b0
movq %r13, (%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x37d8
movq %rdx, (%rsp)
movq (%rcx), %rdx
movq %rdx, 0x10(%rsp)
jmp 0x37e2
movdqu (%rcx), %xmm0
movdqu %xmm0, (%r13)
movq 0x8(%rax), %rdx
movq %rdx, 0x8(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x68(%rsp), %rdi
movq %rbx, %rsi
callq 0x3290
movq (%rsp), %rdi
cmpq %r13, %rdi
je 0x381d
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3220
movq 0x88(%rsp), %rdi
cmpq %r15, %rdi
je 0x383a
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x3220
movq 0x48(%rsp), %rsi
movq 0x50(%rsp), %rdx
movq 0x7785(%rip), %rdi      # 0xafd0
callq 0x3270
movl $0x2, %edx
movq %rax, %rdi
leaq 0x4981(%rip), %rsi      # 0x81e0
callq 0x3270
movq 0xf8(%rsp), %rsi
movq 0x775d(%rip), %rdi      # 0xafd0
callq 0x31f0
movl $0x4, %edx
movq %rax, %rdi
leaq 0x4957(%rip), %rsi      # 0x81de
callq 0x3270
movl 0xe4(%rsp), %edi
callq 0x3280
movq %rax, %r14
movl 0xe8(%rsp), %edi
callq 0x3370
movq %rax, %rbp
movq (%r14), %r14
testq %r14, %r14
je 0x38ce
movq %r14, %rdi
callq 0x3100
movq 0x770f(%rip), %rdi      # 0xafd0
movq %r14, %rsi
movq %rax, %rdx
callq 0x3270
jmp 0x38ec
movq 0x76fb(%rip), %rcx      # 0xafd0
movq (%rcx), %rax
movq -0x18(%rax), %rax
leaq (%rcx,%rax), %rdi
movl 0x20(%rcx,%rax), %esi
orl $0x1, %esi
callq 0x3380
movl $0x1, %edx
movq 0x76d8(%rip), %rdi      # 0xafd0
leaq 0x48e2(%rip), %rsi      # 0x81e1
callq 0x3270
movq (%rbp), %r14
testq %r14, %r14
je 0x3929
movq %r14, %rdi
callq 0x3100
movq 0x76b4(%rip), %rdi      # 0xafd0
movq %r14, %rsi
movq %rax, %rdx
callq 0x3270
jmp 0x3947
movq 0x76a0(%rip), %rcx      # 0xafd0
movq (%rcx), %rax
movq -0x18(%rax), %rax
leaq (%rcx,%rax), %rdi
movl 0x20(%rcx,%rax), %esi
orl $0x1, %esi
callq 0x3380
movl $0x1, %edx
movq 0x767d(%rip), %rdi      # 0xafd0
leaq 0x4887(%rip), %rsi      # 0x81e1
callq 0x3270
movl 0xe0(%rsp), %eax
movl $0xf000, %ecx           # imm = 0xF000
andl %ecx, %eax
cmpl $0x4000, %eax           # imm = 0x4000
movl $0x2d, %r12d
movl $0x64, %eax
cmovel %eax, %r12d
movq %r13, (%rsp)
movq 0x68(%rsp), %rsi
movq 0x70(%rsp), %rdx
addq %rsi, %rdx
movq %rbx, %rdi
callq 0x3d74
movb %r12b, 0x20(%rsp)
movq 0x28(%rsp), %rdi
movq %rbx, %rsi
callq 0x3ea0
movq (%rsp), %rdi
cmpq %r13, %rdi
je 0x39c2
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3220
movl 0xe0(%rsp), %eax
movl %eax, 0x44(%rsp)
movd %eax, %xmm0
pshufd $0x0, %xmm0, %xmm0      # xmm0 = xmm0[0,0,0,0]
movdqa %xmm0, %xmm1
pand 0x462e(%rip), %xmm1     # 0x8010
pand 0x4636(%rip), %xmm0     # 0x8020
pxor %xmm2, %xmm2
pcmpeqd %xmm2, %xmm0
pcmpeqd %xmm2, %xmm1
packssdw %xmm0, %xmm1
packsswb %xmm1, %xmm1
pmovmskb %xmm1, %eax
testb $-0x80, %al
movl $0x77, %ebx
movl $0x2d, %ecx
cmovnel %ecx, %ebx
testb $0x40, %al
movl $0x78, %r14d
cmovnel %ecx, %r14d
testb $0x20, %al
movl $0x72, %ebp
cmovnel %ecx, %ebp
testb $0x10, %al
movl $0x77, %r15d
cmovnel %ecx, %r15d
testb $0x8, %al
movl $0x78, %edx
cmovnel %ecx, %edx
movl %edx, 0x40(%rsp)
testb $0x4, %al
movl $0x72, %edx
cmovnel %ecx, %edx
movl %edx, 0x3c(%rsp)
testb $0x2, %al
movl $0x77, %edx
cmovnel %ecx, %edx
movl %edx, 0x38(%rsp)
testb $0x1, %al
movl $0x78, %eax
cmovnel %ecx, %eax
movl %eax, 0x34(%rsp)
movb %r12b, (%rsp)
movl $0x1, %edx
movq 0x7555(%rip), %rdi      # 0xafd0
movq %rsp, %r13
movq %r13, %rsi
leaq 0x58(%rsp), %r12
callq 0x3270
btl $0x8, 0x44(%rsp)
movl $0x72, %eax
movl $0x2d, %ecx
cmovael %ecx, %eax
movb %al, (%rsp)
movl $0x1, %edx
movq 0x7523(%rip), %rdi      # 0xafd0
movq %r13, %rsi
callq 0x3270
movb %bl, (%rsp)
movl $0x1, %edx
movq %rax, %rdi
movq %r13, %rsi
callq 0x3270
movb %r14b, (%rsp)
movl $0x1, %edx
movq %rax, %rdi
movq %r13, %rsi
callq 0x3270
movb %bpl, (%rsp)
movl $0x1, %edx
movq 0x74e4(%rip), %rdi      # 0xafd0
movq %r13, %rsi
callq 0x3270
movb %r15b, (%rsp)
movl $0x1, %edx
movq %rax, %rdi
movq %r13, %rsi
callq 0x3270
movl 0x40(%rsp), %ecx
movb %cl, (%rsp)
movl $0x1, %edx
movq %rax, %rdi
movq %r13, %rsi
callq 0x3270
movl 0x3c(%rsp), %eax
movb %al, (%rsp)
movl $0x1, %edx
movq 0x749e(%rip), %rdi      # 0xafd0
movq %r13, %rsi
callq 0x3270
movl 0x38(%rsp), %ecx
movb %cl, (%rsp)
movl $0x1, %edx
movq %rax, %rdi
movq %r13, %rsi
callq 0x3270
movl 0x34(%rsp), %ecx
movb %cl, (%rsp)
movl $0x1, %edx
movq %rax, %rdi
movq %r13, %rsi
callq 0x3270
movl $0x3, %edx
movq %rax, %rdi
leaq 0x4668(%rip), %rsi      # 0x81df
callq 0x3270
leaq 0x120(%rsp), %rdi
callq 0x30e0
testq %rax, %rax
je 0x3bad
movq %rax, %r14
movq %rax, %rdi
callq 0x3100
movq 0x7430(%rip), %rdi      # 0xafd0
movq %r14, %rsi
movq %rax, %rdx
callq 0x3270
jmp 0x3bcb
movq 0x741c(%rip), %rcx      # 0xafd0
movq (%rcx), %rax
movq -0x18(%rax), %rax
leaq (%rcx,%rax), %rdi
movl 0x20(%rcx,%rax), %esi
orl $0x1, %esi
callq 0x3380
movq 0x68(%rsp), %rdi
leaq 0x78(%rsp), %rax
cmpq %rax, %rdi
je 0x3be7
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x3220
movq 0x48(%rsp), %rdi
cmpq %r12, %rdi
leaq 0x98(%rsp), %r15
leaq 0x10(%rsp), %r13
je 0x3c0b
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x3220
movq 0xb8(%rsp), %rcx
incq %rcx
cmpq %rcx, 0xa8(%rsp)
jne 0x370d
movq 0x28(%rsp), %rax
addq $0x158, %rsp            # imm = 0x158
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x3c3d
movq %rax, %r14
jmp 0x3cc5
movq %rax, %r14
jmp 0x3cae
jmp 0x3c68
jmp 0x3c4e
movq %rax, %r14
movq 0x88(%rsp), %rdi
cmpq %r15, %rdi
je 0x3c86
movq 0x98(%rsp), %rsi
jmp 0x3c7e
movq %rax, %r14
jmp 0x3c86
movq %rax, %r14
movq (%rsp), %rdi
cmpq %r13, %rdi
je 0x3c86
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3220
leaq 0x58(%rsp), %r12
jmp 0x3c92
jmp 0x3c8f
movq %rax, %r14
movq 0x68(%rsp), %rdi
leaq 0x78(%rsp), %rax
cmpq %rax, %rdi
je 0x3cae
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x3220
movq 0x48(%rsp), %rdi
cmpq %r12, %rdi
je 0x3cc5
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x3220
movq 0x28(%rsp), %rdi
callq 0x3d16
movq %r14, %rdi
callq 0x33a0
nop