// File: /workspace/github_c_makefile_star2_O1/sushant8421[P]create_your_own_shell/my_shell.c
// Function: main
int main() {
    char **command;
    char *input;
    pid_t child_pid;
    int stat_loc;

    while (1) {
        	input = readline("cheetah@sushant>> ");

        	command = get_input(input);

        	if (!command[0]) {      /* Handle empty commands */
            		free(input);
            		free(command);
            		continue;
       		}
		if(strcmp(command[0], "exit") == 0){
			printf("\tgoodbye!!\n") ;
			exit(0) ;
		}

		if(strcmp(command[0], "SS") == 0){
			int t =  SS(command[3] , command);
		//exit(0) ;
		}

		if(strcmp(command[0], "break") == 0){
			int x ;
			pid_t ch ;
			if((ch = fork()) < 0){
    				printf("child is not created\n") ;
    			}
    			else if(ch > 0){
    				waitpid(ch, &stat_loc, WUNTRACED);
    			}
    			else{
    				if(x=execv("./break", command)<0)
    					printf("execution error in break()\n");
			}
			//exit(0) ;
		}

		if(strcmp(command[0], "cwd") == 0){
			int x ;
			pid_t ch ;
			if((ch = fork()) < 0){
    			printf("child is not created\n") ;
    		}
    		else if(ch > 0){
    			waitpid(ch, &stat_loc, WUNTRACED);
    		}
    		else{
    			if(x=execv("./cwd", command)<0)
    				printf("execution error in cwd()\n");
			}
		//exit(0) ;
		}


		if(strcmp(command[0], "move") == 0){
			int x ;
			pid_t ch ;
			if((ch = fork()) < 0){
    				printf("child is not created\n") ;
    			}
    			else if(ch > 0){
    				waitpid(ch, &stat_loc, WUNTRACED);
    			}
    			else{
    				if(x=execv("./move", command)<0)
    					printf("execution error in move()\n");
			}
			//exit(0) ;
		}
	

		if (strcmp(command[0], "help") == 0){
			child_pid = fork();
        		if (child_pid < 0) {
            			perror("Fork failed");
            			exit(1);
       	 		}

        		else if (child_pid == 0) {
            		/* Never returns if the call is successful */
				printf("\t\t ### help ####\n\n ") ;
        			printf("1.cwd - Display Current Working Directory \n Syntax : cwd (No Arguments Required)") ;
        			printf("\n\n") ;
        			printf("2.move - for moving File/Directory from Source_dir to Destination_dir \n Syntax : move [source_path] [destination_path]\n") ;
        			printf("\n3.SS - Search a given String in whole directory (Always take 4 arguments)\n ");
        			printf("Syntax : SS [options] [search_string] [directory_path]\n") ;
        			printf("options : n - position of line in the text file(line_no)\n");
        			printf("\t c - no_of_lines in which the search_string in present\n") ;
                		printf("\t v - Display those lines in which the search_string is not present\n") ;
        			printf("\t nc - for implementing both n and c options simultaneously\n\n ") ;
        			printf("4.break - Split the given file \n Syntax : break [options] [file_name_path]\n");
        			printf("options : int_value - in how many lines you want to break the file\n");
        			printf("\n5.exit -for getting out of the shell\n\n") ;

                		exit(1);
            		}


    	 		else {
            			waitpid(child_pid, &stat_loc, WUNTRACED);
        		}
		}
		
	}

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
leaq 0xca2(%rip), %rbx       # 0x2044
leaq 0xccb(%rip), %r15       # 0x2074
movq %rbx, %rdi
callq 0x1080
movq %rax, %r14
movq %rax, %rdi
callq 0x121c
movq %rax, %r12
movq (%rax), %r13
testq %r13, %r13
je 0x142f
movq %r13, %rdi
leaq 0xc86(%rip), %rsi       # 0x2057
callq 0x1090
testl %eax, %eax
je 0x1566
movq %r13, %rdi
leaq 0xc74(%rip), %rsi       # 0x205c
callq 0x1090
testl %eax, %eax
jne 0x13fe
movq 0x18(%r12), %rdi
movq %r12, %rsi
callq 0x12af
movq (%r12), %rdi
leaq 0xc58(%rip), %rsi       # 0x2061
callq 0x1090
testl %eax, %eax
jne 0x1469
callq 0x1110
testl %eax, %eax
js 0x1444
je 0x1452
movl %eax, %edi
leaq -0x2c(%rbp), %rsi
movl $0x2, %edx
callq 0x10c0
jmp 0x1469
movq %r14, %rdi
callq 0x1030
movq %r12, %rdi
callq 0x1030
jmp 0x13a9
leaq 0xd87(%rip), %rdi       # 0x21d2
callq 0x1040
jmp 0x1469
leaq 0xc06(%rip), %rdi       # 0x205f
movq %r12, %rsi
callq 0x1100
testl %eax, %eax
js 0x1545
movq (%r12), %rdi
leaq 0xbf5(%rip), %rsi       # 0x2069
callq 0x1090
testl %eax, %eax
jne 0x14bf
callq 0x1110
testl %eax, %eax
js 0x149a
je 0x14a8
movl %eax, %edi
leaq -0x2c(%rbp), %rsi
movl $0x2, %edx
callq 0x10c0
jmp 0x14bf
leaq 0xd31(%rip), %rdi       # 0x21d2
callq 0x1040
jmp 0x14bf
leaq 0xbb8(%rip), %rdi       # 0x2067
movq %r12, %rsi
callq 0x1100
testl %eax, %eax
js 0x1551
movq (%r12), %rdi
leaq 0xba5(%rip), %rsi       # 0x206f
callq 0x1090
testl %eax, %eax
jne 0x1511
callq 0x1110
testl %eax, %eax
js 0x14f0
je 0x14fe
movl %eax, %edi
leaq -0x2c(%rbp), %rsi
movl $0x2, %edx
callq 0x10c0
jmp 0x1511
leaq 0xcdb(%rip), %rdi       # 0x21d2
callq 0x1040
jmp 0x1511
leaq 0xb68(%rip), %rdi       # 0x206d
movq %r12, %rsi
callq 0x1100
testl %eax, %eax
js 0x155d
movq (%r12), %rdi
movq %r15, %rsi
callq 0x1090
testl %eax, %eax
jne 0x13a9
callq 0x1110
testl %eax, %eax
js 0x1579
je 0x158a
movl %eax, %edi
leaq -0x2c(%rbp), %rsi
movl $0x2, %edx
callq 0x10c0
jmp 0x13a9
leaq 0xc38(%rip), %rdi       # 0x2184
jmp 0x144b
leaq 0xc47(%rip), %rdi       # 0x219f
jmp 0x14a1
leaq 0xc54(%rip), %rdi       # 0x21b8
jmp 0x14f7
leaq 0xe92(%rip), %rdi       # 0x23ff
callq 0x1040
xorl %edi, %edi
callq 0x10f0
leaq 0xaf9(%rip), %rdi       # 0x2079
callq 0x10d0
jmp 0x162e
leaq 0xaf4(%rip), %rdi       # 0x2085
xorl %eax, %eax
callq 0x1070
leaq 0xafa(%rip), %rdi       # 0x2099
xorl %eax, %eax
callq 0x1070
leaq 0xe50(%rip), %rdi       # 0x23fd
callq 0x1040
leaq 0xc2e(%rip), %rdi       # 0x21e7
callq 0x1040
leaq 0xb25(%rip), %rdi       # 0x20ea
xorl %eax, %eax
callq 0x1070
leaq 0xc8b(%rip), %rdi       # 0x225e
callq 0x1040
leaq 0xcb6(%rip), %rdi       # 0x2295
callq 0x1040
leaq 0xce3(%rip), %rdi       # 0x22ce
callq 0x1040
leaq 0xd0f(%rip), %rdi       # 0x2306
callq 0x1040
leaq 0xb34(%rip), %rdi       # 0x2137
xorl %eax, %eax
callq 0x1070
leaq 0xd39(%rip), %rdi       # 0x234a
callq 0x1040
leaq 0xd78(%rip), %rdi       # 0x2395
callq 0x1040
leaq 0xdaf(%rip), %rdi       # 0x23d8
callq 0x1040
movl $0x1, %edi
callq 0x10f0