// File: /workspace/github_cpp_makefile_star2_O3/danish241194[P]Linux-Terminal-Based-File-Explorer/start_page.cpp
// Function: searchConsole(int, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void searchConsole(int j,int limit_y,string name){

	tcgetattr(0,&initial_settings);
	new_settings = initial_settings;

	new_settings.c_lflag &= ~ECHO;

	new_settings.c_lflag &= ~ICANON;

	tcsetattr(0, TCSANOW, &new_settings); 
	init_Search_Screen();
	print_search(j,limit_y,name);
	char ch;
	gotoxy(start_x,start_y);
	int flag=0;
	y=1;
	scroll_k = 0;
	init_Search_Screen();

	while(1){
		ch = getchar();
		int s = (int)ch;
	
	
		switch(s){
		case 58:{
			flag=1;
				break;		
			}
			case 65:
			{
					
				if(y>=2){
					y--;
					gotoxy(y+start_x-1,1);//y+2,1....new change

						break;
				}
				
				if(scroll_k!=0)
				{
	
				gotoxy(start_x,start_y);
				scroll_k=scroll_k-1;

				print_search(scroll_k,height+scroll_k,name);
				gotoxy(start_x,start_y);
				
				}
				else
				{
								
				}
				break;			
			}
			//down
			case 66:{	

				if(nn>height){
				if(height-(height-y)+scroll_k<nn){
				if(y<height){
					y++;
					gotoxy(y+start_x-1,1); //y,1....y+2
					break;
				}		
				gotoxy(start_x,start_y);
				scroll_k++;
				print_search(scroll_k,height+scroll_k,name);
				gotoxy(height+start_x-1,1);//height,1
				}
				}else{
				if(y<nn)
				{
					y++;
					gotoxy(y+start_x-1,1);//shayad y,1 ///............y+2
				}	

				}
				break;			
			}
			case 68:case 127:
				{
				fflush(stdout);		
				

				y=1;
				scroll_k=0;
								
				flag=1;
				print_dirs(0,height);break;
				
			}
			case 10:{	
				
				fflush(stdout);		
				cout<<path;
				string pathre = search_path[y+scroll_k-1]+"/"+name;
				for(int k=0;k<pathre.size();k++){
					if(pathre[k]==' '){

						pathre.insert(k,1,'\\');
						k+=1;
					}
				}
				
				pid_t pid = fork();
				string path1 = pathre;

				if (pid == 0) {		
  					
					int out = open("err.log", O_RDWR|O_CREAT|O_APPEND, 0600);
    					
  					 if (-1 == out) { perror("opening cout.log"); return ; }
    					int save_out = dup(fileno(stderr));
   					if (-1 == dup2(out, fileno(stderr))) { perror("cannot redirect stdout"); return ; }
      					
  	  			  	execl("/usr/bin/xdg-open", "xdg-open", path1.c_str(), (char *)0);
						
  	  				fflush(stderr); close(out);
  			
  	  				dup2(save_out, fileno(stderr));
   

  	  				close(save_out);
  				
  					exit(1);
				}
				y=1;
				scroll_k=0;

								
				flag=1;
				print_dirs(0,height);

			break;
			}
		}
		if(flag){
			break;
		}

	}




}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %rdx, %rbx
movl %esi, %ebp
movl %edi, %r14d
leaq 0x11182(%rip), %rsi     # 0x1549c
xorl %edi, %edi
callq 0x32a0
movups 0x11174(%rip), %xmm0    # 0x1549c
movups %xmm0, 0x111a9(%rip)    # 0x154d8
movups 0x11176(%rip), %xmm0    # 0x154ac
movups %xmm0, 0x111ab(%rip)    # 0x154e8
movups 0x11178(%rip), %xmm0    # 0x154bc
movups %xmm0, 0x111ad(%rip)    # 0x154f8
movups 0x11176(%rip), %xmm0    # 0x154c8
movups %xmm0, 0x111ab(%rip)    # 0x15504
leaq 0x11178(%rip), %rdx     # 0x154d8
andb $-0xb, 0x1117d(%rip)    # 0x154e4
xorl %edi, %edi
xorl %esi, %esi
callq 0x3350
callq 0x3e11
leaq 0x98(%rsp), %r12
movq %r12, -0x10(%r12)
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
addq %rsi, %rdx
leaq 0x88(%rsp), %r15
movq %r15, %rdi
callq 0xfc98
movl %r14d, %edi
movl %ebp, %esi
movq %r15, %rdx
callq 0x3fc6
movq 0x88(%rsp), %rdi
cmpq %r12, %rdi
je 0x43c6
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x3260
movl 0x10ea8(%rip), %esi     # 0x15274
movl 0x10ea6(%rip), %edx     # 0x15278
leaq 0xccaf(%rip), %rdi      # 0x11088
xorl %eax, %eax
callq 0x3060
movl $0x1, 0x10e92(%rip)     # 0x1527c
movl $0x0, 0x110a4(%rip)     # 0x15498
callq 0x3e11
leaq 0x28(%rsp), %r15
callq 0x3370
movsbl %al, %eax
cmpl $0x41, %eax
jg 0x4450
cmpl $0xa, %eax
je 0x452c
cmpl $0x41, %eax
jne 0x45ff
movl 0x10e59(%rip), %eax     # 0x1527c
cmpl $0x2, %eax
jl 0x4613
leal -0x1(%rax), %ecx
movl %ecx, 0x10e47(%rip)     # 0x1527c
movl 0x10e39(%rip), %ecx     # 0x15274
leal (%rax,%rcx), %esi
addl $-0x2, %esi
xorl %r14d, %r14d
leaq 0xcc3d(%rip), %rdi      # 0x11088
jmp 0x46ef
cmpl $0x42, %eax
jne 0x45e2
movl 0x110f1(%rip), %eax     # 0x15550
movl 0x10e0b(%rip), %ecx     # 0x15270
movl 0x10e11(%rip), %esi     # 0x1527c
cmpl %ecx, %eax
jle 0x46c8
movl 0x1101f(%rip), %edx     # 0x15498
addl %esi, %edx
movl $0x0, %r14d
cmpl %eax, %edx
jge 0x487b
cmpl %ecx, %esi
jl 0x46d6
movl 0x10ddd(%rip), %esi     # 0x15274
movl 0x10ddb(%rip), %edx     # 0x15278
leaq 0xcbe4(%rip), %rdi      # 0x11088
xorl %eax, %eax
callq 0x3060
movl 0x10fe6(%rip), %r14d    # 0x15498
incl %r14d
movl %r14d, 0x10fdc(%rip)    # 0x15498
movl 0x10dad(%rip), %r15d    # 0x15270
addl %r14d, %r15d
leaq 0x58(%rsp), %rax
movq %rax, 0x48(%rsp)
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
addq %rsi, %rdx
leaq 0x48(%rsp), %r12
movq %r12, %rdi
callq 0xfc98
movl %r14d, %edi
movl %r15d, %esi
movq %r12, %rdx
callq 0x3fc6
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
leaq 0x28(%rsp), %r15
je 0x4516
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x3260
movl 0x10d54(%rip), %eax     # 0x15270
movl 0x10d52(%rip), %ecx     # 0x15274
leal (%rax,%rcx), %esi
decl %esi
jmp 0x4441
movq 0x10a6d(%rip), %rax     # 0x14fa0
movq (%rax), %rdi
callq 0x32e0
movq 0x10ee6(%rip), %rsi     # 0x15428
movq 0x10ee7(%rip), %rdx     # 0x15430
movq 0x10a78(%rip), %rdi     # 0x14fc8
callq 0x32c0
movslq 0x10d20(%rip), %rax     # 0x1527c
movslq 0x10f35(%rip), %rcx     # 0x15498
addq %rax, %rcx
movq 0x112c3(%rip), %rax     # 0x15830
shlq $0x5, %rcx
leaq 0x18(%rsp), %rdx
movq %rdx, 0x8(%rsp)
movq -0x20(%rax,%rcx), %rsi
movq -0x18(%rax,%rcx), %rdx
addq %rsi, %rdx
leaq 0x8(%rsp), %r14
movq %r14, %rdi
callq 0xfc98
movq %r14, %rdi
leaq 0xcafa(%rip), %rsi      # 0x11099
callq 0x3480
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
movq %r14, %rdi
callq 0x30d0
leaq 0x38(%rsp), %rsi
movq %rsi, 0x28(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x4700
movq %rdx, 0x28(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x38(%rsp)
jmp 0x4706
cmpl $0x44, %eax
je 0x4886
movl $0x0, %r14d
cmpl $0x7f, %eax
jne 0x487b
jmp 0x4886
movl $0x0, %r14d
cmpl $0x3a, %eax
jne 0x487b
jmp 0x48b6
cmpl $0x0, 0x10e7e(%rip)     # 0x15498
movl $0x0, %r14d
je 0x487b
movl 0x10c48(%rip), %esi     # 0x15274
movl 0x10c46(%rip), %edx     # 0x15278
leaq 0xca4f(%rip), %rdi      # 0x11088
xorl %eax, %eax
callq 0x3060
movl 0x10e51(%rip), %r14d    # 0x15498
decl %r14d
movl %r14d, 0x10e47(%rip)    # 0x15498
movl 0x10c18(%rip), %r15d    # 0x15270
addl %r14d, %r15d
leaq 0x78(%rsp), %r13
movq %r13, 0x68(%rsp)
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
addq %rsi, %rdx
leaq 0x68(%rsp), %r12
movq %r12, %rdi
callq 0xfc98
movl %r14d, %edi
movl %r15d, %esi
movq %r12, %rdx
callq 0x3fc6
movq 0x68(%rsp), %rdi
cmpq %r13, %rdi
je 0x46a1
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x3260
movl 0x10bcd(%rip), %esi     # 0x15274
movl 0x10bcb(%rip), %edx     # 0x15278
xorl %r14d, %r14d
leaq 0xc9d1(%rip), %rdi      # 0x11088
xorl %eax, %eax
callq 0x3060
leaq 0x28(%rsp), %r15
jmp 0x487b
movl $0x0, %r14d
cmpl %eax, %esi
jge 0x487b
leal 0x1(%rsi), %eax
movl %eax, 0x10b9d(%rip)     # 0x1527c
addl 0x10b8f(%rip), %esi     # 0x15274
xorl %r14d, %r14d
leaq 0xc999(%rip), %rdi      # 0x11088
movl $0x1, %edx
xorl %eax, %eax
callq 0x3060
jmp 0x487b
movups (%rcx), %xmm0
movups %xmm0, (%rsi)
movq 0x8(%rax), %rdx
movq %rdx, 0x30(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x473a
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3260
movq 0x30(%rsp), %rax
testq %rax, %rax
je 0x4779
xorl %esi, %esi
xorl %r14d, %r14d
movq 0x28(%rsp), %rcx
cmpb $0x20, (%rcx,%rsi)
jne 0x476e
movl $0x1, %edx
movq %r15, %rdi
movl $0x5c, %ecx
callq 0x34b0
incl %r14d
movq 0x30(%rsp), %rax
incl %r14d
movslq %r14d, %rsi
cmpq %rsi, %rax
ja 0x4749
callq 0x30a0
movl %eax, %r15d
leaq 0x18(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rdx
addq %rsi, %rdx
leaq 0x8(%rsp), %rdi
callq 0xfc98
testl %r15d, %r15d
je 0x47d0
movl $0x1, 0x10acb(%rip)     # 0x1527c
movl $0x0, 0x10cdd(%rip)     # 0x15498
movl $0x1, %r14d
movl 0x10aa9(%rip), %esi     # 0x15270
xorl %edi, %edi
callq 0x49db
jmp 0x4839
leaq 0xc901(%rip), %rdi      # 0x110d8
movl $0x442, %esi            # imm = 0x442
movl $0x180, %edx            # imm = 0x180
xorl %eax, %eax
callq 0x31b0
movl %eax, %r13d
leaq 0xc8ee(%rip), %rdi      # 0x110e0
cmpl $-0x1, %eax
je 0x4831
movq 0x107d2(%rip), %r14     # 0x14fd0
movq (%r14), %rdi
callq 0x3280
movl %eax, %edi
callq 0x33b0
movl %eax, %ebp
movq (%r14), %rdi
callq 0x3280
movl %r13d, %edi
movl %eax, %esi
callq 0x3220
leaq 0xc8c9(%rip), %rdi      # 0x110f1
cmpl $-0x1, %eax
jne 0x48c8
callq 0x31e0
xorl %r14d, %r14d
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x4855
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3260
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x4871
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x3260
testl %r15d, %r15d
leaq 0x28(%rsp), %r15
je 0x48b6
testl %r14d, %r14d
je 0x43fe
jmp 0x48b6
movq 0x10713(%rip), %rax     # 0x14fa0
movq (%rax), %rdi
callq 0x32e0
movl $0x1, 0x109dd(%rip)     # 0x1527c
movl $0x0, 0x10bef(%rip)     # 0x15498
movl 0x109c1(%rip), %esi     # 0x15270
xorl %edi, %edi
callq 0x49db
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x8(%rsp), %rdx
leaq 0xc834(%rip), %rdi      # 0x11108
leaq 0xc836(%rip), %rsi      # 0x11111
xorl %ecx, %ecx
xorl %eax, %eax
callq 0x3330
movq 0x106e5(%rip), %rax     # 0x14fd0
movq (%rax), %rdi
callq 0x32e0
movl %r13d, %edi
callq 0x34a0
movq 0x106ce(%rip), %rax     # 0x14fd0
movq (%rax), %rdi
callq 0x3280
movl %ebp, %edi
movl %eax, %esi
callq 0x3220
movl %ebp, %edi
callq 0x34a0
movl $0x1, %edi
callq 0x3310
movq %rax, %rbx
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x49d3
movq 0x58(%rsp), %rsi
jmp 0x49cb
movq %rax, %rbx
movq 0x88(%rsp), %rdi
cmpq %r12, %rdi
je 0x49d3
movq 0x98(%rsp), %rsi
jmp 0x49cb
movq %rax, %rbx
movq 0x68(%rsp), %rdi
cmpq %r13, %rdi
je 0x49d3
movq 0x78(%rsp), %rsi
jmp 0x49cb
jmp 0x4993
jmp 0x4993
jmp 0x4978
movq %rax, %rbx
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x49d3
movq 0x18(%rsp), %rsi
jmp 0x49cb
jmp 0x49b4
movq %rax, %rbx
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x49b7
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3260
jmp 0x49b7
movq %rax, %rbx
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x49d3
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x3260
movq %rbx, %rdi
callq 0x3450