// File: danish241194[P]Linux-Terminal-Based-File-Explorer/start_page.cpp
// Function: print_dirs(int, int)
void print_dirs(int j,int limit_y){



	n=scandir(path.c_str(),&namelist,NULL,alphasort);

	real_clean();
	change_mode_to(mode_num);
	nn=n;
	n--;
	init_Screen();
		pathshow();
	gotoxy(start_x,start_y);

	int numbers=j+1;
	int ini=j;
	if(nn<limit_y){
		limit_y=nn;
	}
	gotoxy(start_x,start_y);


	while(ini<limit_y){

	
	printf(" %d ",numbers);
	if((int)namelist[ini]->d_type==4){
		printf("\x1B[36m");
	}
	string cc = namelist[ini]->d_name;
	if(cc.size()>25){
		cc=cc.substr(0,22);
		printf("%s...",cc.c_str());
	}
	else{

		printf("%s",namelist[ini]->d_name);

	}	
	if((int)namelist[ini]->d_type==4){
		printf("\x1B[0m");

	}



	 struct stat fileStat;
	 string pp = path+"/"+namelist[ini]->d_name;
	 if(stat(pp.c_str(),&fileStat) < 0)    
	 {     
	    	return;
	 }


	 printf("\033[%d;28H",ini-j+3);
	
	 float sizedata =(int)fileStat.st_size;
	 if((sizedata/1024)>=1){
		sizedata = (sizedata/1024);
			     if((sizedata/1024)>=1){
					sizedata = (sizedata/1024);
						
			     if((sizedata/1024)>=1){
					sizedata = (sizedata/1024);
					 printf(" %.1fGB",sizedata);
					
			    }else{
				    printf(" %.0fMB",sizedata);
				}		
					
			    }else{
				    printf(" %.0fKB",sizedata);
				}		
		}else{
			    printf(" %.0fB",sizedata);

	}
	
	    printf("\033[%d;%dH", ini-j+3,36 ); 
		
		string permissions="";
		if(S_ISDIR(fileStat.st_mode)){
			permissions="d";
		}else{
			permissions="-";
			
		}
	
		
		if(fileStat.st_mode & 256){
			permissions+="r";
		}else{
			permissions+="-";
		}
		if(fileStat.st_mode & 128){
			permissions+="w";
		}else{
			permissions+="-";
		}
		if(fileStat.st_mode & 64){
			permissions+="x";
		}else{
			permissions+="-";
		}
		if(fileStat.st_mode & 32){
			permissions+="r";
		}else{
			permissions+="-";
		}
		if(fileStat.st_mode & 16){
			permissions+="w";
		}else{
			permissions+="-";
		}
		if(fileStat.st_mode & 8){
			permissions+="x";
		}else{
			permissions+="-";
		}   
		if(fileStat.st_mode & 4){
			permissions+="r";
		}else{
			permissions+="-";
		}
		if(fileStat.st_mode & 2){
			permissions+="w";
		}else{
			permissions+="-";
		}
		if(fileStat.st_mode & 1){
			permissions+="x";
		}else{
			permissions+="-";
		} 
		cout<<permissions;

	   	 struct passwd *pw = getpwuid(fileStat.st_uid);
	    	struct group  *gr = getgrgid(fileStat.st_gid);
	    

	   	 printf("\033[%d;%dH", ini-j+3,50);  
	   	 printf("%s %s",gr->gr_name,pw->pw_name);
	    
		printf("\033[%d;%dH", ini-j+3,65 );  
		string ss = ctime(&fileStat.st_mtime);

	    	cout<<" "<<ss.substr(4,12); 

		cout<<"\n";

	   
	    	numbers++;
	    	ini++;
		
	}
	gotoxy(start_x,start_y);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x210, %rsp            # imm = 0x210
movl %edi, -0x4(%rbp)
movl %esi, -0x8(%rbp)
leaq 0x127e0(%rip), %rdi     # 0x174d8
callq 0x3140
movq %rax, %rdi
leaq 0x12831(%rip), %rsi     # 0x17538
xorl %eax, %eax
movl %eax, %edx
movq 0x122ae(%rip), %rcx     # 0x16fc0
callq 0x3090
movl %eax, 0x128e7(%rip)     # 0x17604
callq 0x3f30
movl 0x12928(%rip), %edi     # 0x17650
callq 0x4480
movl 0x128d1(%rip), %eax     # 0x17604
movl %eax, 0x128c7(%rip)     # 0x17600
movl 0x128c5(%rip), %eax     # 0x17604
addl $-0x1, %eax
movl %eax, 0x128bc(%rip)     # 0x17604
callq 0x6990
callq 0x3c70
movl 0x125cc(%rip), %esi     # 0x17324
movl 0x125ca(%rip), %edx     # 0x17328
leaq 0xd2e3(%rip), %rdi      # 0x12048
movb $0x0, %al
callq 0x3070
movl -0x4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
movl -0x4(%rbp), %eax
movl %eax, -0x10(%rbp)
movl 0x1287f(%rip), %eax     # 0x17600
cmpl -0x8(%rbp), %eax
jge 0x4d8f
movl 0x12874(%rip), %eax     # 0x17600
movl %eax, -0x8(%rbp)
movl 0x1258f(%rip), %esi     # 0x17324
movl 0x1258d(%rip), %edx     # 0x17328
leaq 0xd2a6(%rip), %rdi      # 0x12048
movb $0x0, %al
callq 0x3070
movl -0x10(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0x566e
movl -0xc(%rbp), %esi
leaq 0xd2c5(%rip), %rdi      # 0x12084
movb $0x0, %al
callq 0x3070
movq 0x1276b(%rip), %rax     # 0x17538
movslq -0x10(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movzbl 0x12(%rax), %eax
cmpl $0x4, %eax
jne 0x4dec
leaq 0xd2a4(%rip), %rdi      # 0x12089
movb $0x0, %al
callq 0x3070
movq 0x12745(%rip), %rax     # 0x17538
movslq -0x10(%rbp), %rcx
movq (%rax,%rcx,8), %rax
addq $0x13, %rax
movq %rax, -0x1d0(%rbp)
leaq -0x31(%rbp), %rdi
movq %rdi, -0x1c8(%rbp)
callq 0x3580
movq -0x1d0(%rbp), %rsi
movq -0x1c8(%rbp), %rdx
leaq -0x30(%rbp), %rdi
callq 0xe090
jmp 0x4e2f
leaq -0x31(%rbp), %rdi
callq 0x3360
leaq -0x30(%rbp), %rdi
callq 0x3200
cmpq $0x19, %rax
jbe 0x4ed6
xorl %eax, %eax
movl %eax, %edx
leaq -0x68(%rbp), %rdi
leaq -0x30(%rbp), %rsi
movl $0x16, %ecx
callq 0x3320
jmp 0x4e63
leaq -0x30(%rbp), %rdi
movq %rdi, -0x1d8(%rbp)
leaq -0x68(%rbp), %rsi
movq %rsi, -0x1e0(%rbp)
callq 0x3400
movq -0x1e0(%rbp), %rdi
callq 0x3628
movq -0x1d8(%rbp), %rdi
callq 0x3140
movq %rax, %rsi
leaq 0xd69c(%rip), %rdi      # 0x1253c
xorl %eax, %eax
callq 0x3070
jmp 0x4ea9
jmp 0x4efb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x31(%rbp), %rdi
callq 0x3360
jmp 0x5691
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x5663
movq 0x1265b(%rip), %rax     # 0x17538
movslq -0x10(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
addq $0x13, %rsi
leaq 0xd678(%rip), %rdi      # 0x12568
xorl %eax, %eax
callq 0x3070
jmp 0x4ef9
jmp 0x4efb
movq 0x12636(%rip), %rax     # 0x17538
movslq -0x10(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movzbl 0x12(%rax), %eax
cmpl $0x4, %eax
jne 0x4f25
leaq 0xd22a(%rip), %rdi      # 0x12144
xorl %eax, %eax
callq 0x3070
jmp 0x4f23
jmp 0x4f25
leaq 0x125ac(%rip), %rsi     # 0x174d8
leaq 0xd126(%rip), %rdx      # 0x12059
leaq -0x138(%rbp), %rdi
callq 0xe2a0
jmp 0x4f41
movq 0x125f0(%rip), %rax     # 0x17538
movslq -0x10(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
addq $0x13, %rdx
leaq -0x118(%rbp), %rdi
leaq -0x138(%rbp), %rsi
callq 0xe320
jmp 0x4f69
leaq -0x138(%rbp), %rdi
callq 0x3628
leaq -0x118(%rbp), %rdi
callq 0x3140
movq %rax, %rdi
leaq -0xf8(%rbp), %rsi
callq 0x32a0
cmpl $0x0, %eax
jge 0x4fc1
movl $0x1, -0x13c(%rbp)
jmp 0x55d4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x138(%rbp), %rdi
callq 0x3628
jmp 0x5663
movl -0x10(%rbp), %esi
movl -0x4(%rbp), %eax
subl %eax, %esi
addl $0x3, %esi
leaq 0xd0bc(%rip), %rdi      # 0x1208f
xorl %eax, %eax
callq 0x3070
jmp 0x4fdc
movq -0xc8(%rbp), %rax
cvtsi2ss %eax, %xmm0
movss %xmm0, -0x140(%rbp)
movss -0x140(%rbp), %xmm0
movss 0xd009(%rip), %xmm1     # 0x12008
divss %xmm1, %xmm0
movss 0xcff9(%rip), %xmm1     # 0x12004
ucomiss %xmm1, %xmm0
jb 0x511d
movss -0x140(%rbp), %xmm0
movss 0xcfe4(%rip), %xmm1     # 0x12008
divss %xmm1, %xmm0
movss %xmm0, -0x140(%rbp)
movss -0x140(%rbp), %xmm0
movss 0xcfc8(%rip), %xmm1     # 0x12008
divss %xmm1, %xmm0
movss 0xcfb8(%rip), %xmm1     # 0x12004
ucomiss %xmm1, %xmm0
jb 0x50fd
movss -0x140(%rbp), %xmm0
movss 0xcfa3(%rip), %xmm1     # 0x12008
divss %xmm1, %xmm0
movss %xmm0, -0x140(%rbp)
movss -0x140(%rbp), %xmm0
movss 0xcf87(%rip), %xmm1     # 0x12008
divss %xmm1, %xmm0
movss 0xcf77(%rip), %xmm1     # 0x12004
ucomiss %xmm1, %xmm0
jb 0x50dd
movss -0x140(%rbp), %xmm0
movss 0xcf6a(%rip), %xmm1     # 0x1200c
mulss %xmm1, %xmm0
movss %xmm0, -0x140(%rbp)
movss -0x140(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0xd481(%rip), %rdi      # 0x12542
movb $0x1, %al
callq 0x3070
jmp 0x50ca
jmp 0x50fb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x5657
movss -0x140(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0xd45a(%rip), %rdi      # 0x1254a
movb $0x1, %al
callq 0x3070
jmp 0x50f9
jmp 0x50fb
jmp 0x511b
movss -0x140(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0xd442(%rip), %rdi      # 0x12552
movb $0x1, %al
callq 0x3070
jmp 0x5119
jmp 0x511b
jmp 0x513b
movss -0x140(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0xd42a(%rip), %rdi      # 0x1255a
movb $0x1, %al
callq 0x3070
jmp 0x5139
jmp 0x513b
movl -0x10(%rbp), %esi
movl -0x4(%rbp), %eax
subl %eax, %esi
addl $0x3, %esi
leaq 0xcefb(%rip), %rdi      # 0x12048
xorl %eax, %eax
movl $0x24, %edx
callq 0x3070
jmp 0x515b
leaq -0x161(%rbp), %rdi
movq %rdi, -0x1e8(%rbp)
callq 0x3580
movq -0x1e8(%rbp), %rdx
leaq 0xcf63(%rip), %rsi      # 0x120df
leaq -0x160(%rbp), %rdi
callq 0xe090
jmp 0x518a
leaq -0x161(%rbp), %rdi
callq 0x3360
movl -0xe0(%rbp), %eax
andl $0xf000, %eax           # imm = 0xF000
cmpl $0x4000, %eax           # imm = 0x4000
jne 0x51ed
leaq 0xd3d2(%rip), %rsi      # 0x12581
leaq -0x160(%rbp), %rdi
callq 0x3450
jmp 0x51bd
jmp 0x5204
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x161(%rbp), %rdi
callq 0x3360
jmp 0x5657
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x564b
leaq 0xd36d(%rip), %rsi      # 0x12561
leaq -0x160(%rbp), %rdi
callq 0x3450
jmp 0x5202
jmp 0x5204
movl -0xe0(%rbp), %eax
andl $0x100, %eax            # imm = 0x100
cmpl $0x0, %eax
je 0x522b
leaq 0xcf3a(%rip), %rsi      # 0x12155
leaq -0x160(%rbp), %rdi
callq 0x32d0
jmp 0x5229
jmp 0x5242
leaq 0xd32f(%rip), %rsi      # 0x12561
leaq -0x160(%rbp), %rdi
callq 0x32d0
jmp 0x5240
jmp 0x5242
movl -0xe0(%rbp), %eax
andl $0x80, %eax
cmpl $0x0, %eax
je 0x5269
leaq 0xce81(%rip), %rsi      # 0x120da
leaq -0x160(%rbp), %rdi
callq 0x32d0
jmp 0x5267
jmp 0x5280
leaq 0xd2f1(%rip), %rsi      # 0x12561
leaq -0x160(%rbp), %rdi
callq 0x32d0
jmp 0x527e
jmp 0x5280
movl -0xe0(%rbp), %eax
andl $0x40, %eax
cmpl $0x0, %eax
je 0x52a5
leaq 0xd2ce(%rip), %rsi      # 0x12563
leaq -0x160(%rbp), %rdi
callq 0x32d0
jmp 0x52a3
jmp 0x52bc
leaq 0xd2b5(%rip), %rsi      # 0x12561
leaq -0x160(%rbp), %rdi
callq 0x32d0
jmp 0x52ba
jmp 0x52bc
movl -0xe0(%rbp), %eax
andl $0x20, %eax
cmpl $0x0, %eax
je 0x52e1
leaq 0xce84(%rip), %rsi      # 0x12155
leaq -0x160(%rbp), %rdi
callq 0x32d0
jmp 0x52df
jmp 0x52f8
leaq 0xd279(%rip), %rsi      # 0x12561
leaq -0x160(%rbp), %rdi
callq 0x32d0
jmp 0x52f6
jmp 0x52f8
movl -0xe0(%rbp), %eax
andl $0x10, %eax
cmpl $0x0, %eax
je 0x531d
leaq 0xcdcd(%rip), %rsi      # 0x120da
leaq -0x160(%rbp), %rdi
callq 0x32d0
jmp 0x531b
jmp 0x5334
leaq 0xd23d(%rip), %rsi      # 0x12561
leaq -0x160(%rbp), %rdi
callq 0x32d0
jmp 0x5332
jmp 0x5334
movl -0xe0(%rbp), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0x5359
leaq 0xd21a(%rip), %rsi      # 0x12563
leaq -0x160(%rbp), %rdi
callq 0x32d0
jmp 0x5357
jmp 0x5370
leaq 0xd201(%rip), %rsi      # 0x12561
leaq -0x160(%rbp), %rdi
callq 0x32d0
jmp 0x536e
jmp 0x5370
movl -0xe0(%rbp), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x5395
leaq 0xcdd0(%rip), %rsi      # 0x12155
leaq -0x160(%rbp), %rdi
callq 0x32d0
jmp 0x5393
jmp 0x53ac
leaq 0xd1c5(%rip), %rsi      # 0x12561
leaq -0x160(%rbp), %rdi
callq 0x32d0
jmp 0x53aa
jmp 0x53ac
movl -0xe0(%rbp), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x53d1
leaq 0xcd19(%rip), %rsi      # 0x120da
leaq -0x160(%rbp), %rdi
callq 0x32d0
jmp 0x53cf
jmp 0x53e8
leaq 0xd189(%rip), %rsi      # 0x12561
leaq -0x160(%rbp), %rdi
callq 0x32d0
jmp 0x53e6
jmp 0x53e8
movl -0xe0(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x540d
leaq 0xd166(%rip), %rsi      # 0x12563
leaq -0x160(%rbp), %rdi
callq 0x32d0
jmp 0x540b
jmp 0x5424
leaq 0xd14d(%rip), %rsi      # 0x12561
leaq -0x160(%rbp), %rdi
callq 0x32d0
jmp 0x5422
jmp 0x5424
movq 0x11b9d(%rip), %rdi     # 0x16fc8
leaq -0x160(%rbp), %rsi
callq 0x3290
jmp 0x5439
movl -0xdc(%rbp), %edi
callq 0x33b0
movq %rax, -0x1f0(%rbp)
jmp 0x544d
movq -0x1f0(%rbp), %rax
movq %rax, -0x170(%rbp)
movl -0xd8(%rbp), %edi
callq 0x3540
movq %rax, -0x1f8(%rbp)
jmp 0x546f
movq -0x1f8(%rbp), %rax
movq %rax, -0x178(%rbp)
movl -0x10(%rbp), %esi
movl -0x4(%rbp), %eax
subl %eax, %esi
addl $0x3, %esi
leaq 0xcbb9(%rip), %rdi      # 0x12048
xorl %eax, %eax
movl $0x32, %edx
callq 0x3070
jmp 0x549d
movq -0x178(%rbp), %rax
movq (%rax), %rsi
movq -0x170(%rbp), %rax
movq (%rax), %rdx
leaq 0xd0ad(%rip), %rdi      # 0x12565
xorl %eax, %eax
callq 0x3070
jmp 0x54c1
movl -0x10(%rbp), %esi
movl -0x4(%rbp), %eax
subl %eax, %esi
addl $0x3, %esi
leaq 0xcb75(%rip), %rdi      # 0x12048
xorl %eax, %eax
movl $0x41, %edx
callq 0x3070
jmp 0x54e1
leaq -0xa0(%rbp), %rdi
callq 0x3120
movq %rax, -0x208(%rbp)
leaq -0x199(%rbp), %rdi
movq %rdi, -0x200(%rbp)
callq 0x3580
movq -0x208(%rbp), %rsi
movq -0x200(%rbp), %rdx
leaq -0x198(%rbp), %rdi
callq 0xe090
jmp 0x5523
leaq -0x199(%rbp), %rdi
callq 0x3360
movq 0x11a92(%rip), %rdi     # 0x16fc8
leaq 0xcba5(%rip), %rsi      # 0x120e2
callq 0x32e0
movq %rax, -0x210(%rbp)
jmp 0x554b
leaq -0x1c0(%rbp), %rdi
leaq -0x198(%rbp), %rsi
movl $0x4, %edx
movl $0xc, %ecx
callq 0x3320
jmp 0x556a
movq -0x210(%rbp), %rdi
leaq -0x1c0(%rbp), %rsi
callq 0x3290
jmp 0x557f
leaq -0x1c0(%rbp), %rdi
callq 0x3628
movq 0x11a36(%rip), %rdi     # 0x16fc8
leaq 0xcb45(%rip), %rsi      # 0x120de
callq 0x32e0
jmp 0x55a0
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
leaq -0x198(%rbp), %rdi
callq 0x3628
leaq -0x160(%rbp), %rdi
callq 0x3628
movl $0x0, -0x13c(%rbp)
leaq -0x118(%rbp), %rdi
callq 0x3628
leaq -0x30(%rbp), %rdi
callq 0x3628
movl -0x13c(%rbp), %eax
testl %eax, %eax
je 0x55fa
jmp 0x55f5
jmp 0x5688
jmp 0x4da9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x199(%rbp), %rdi
callq 0x3360
jmp 0x564b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x563f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x1c0(%rbp), %rdi
callq 0x3628
leaq -0x198(%rbp), %rdi
callq 0x3628
leaq -0x160(%rbp), %rdi
callq 0x3628
leaq -0x118(%rbp), %rdi
callq 0x3628
leaq -0x30(%rbp), %rdi
callq 0x3628
jmp 0x5691
movl 0x11cb0(%rip), %esi     # 0x17324
movl 0x11cae(%rip), %edx     # 0x17328
leaq 0xc9c7(%rip), %rdi      # 0x12048
movb $0x0, %al
callq 0x3070
addq $0x210, %rsp            # imm = 0x210
popq %rbp
retq
movq -0x40(%rbp), %rdi
callq 0x3570
nopw (%rax,%rax)