// File: /workspace/github_c_makefile_star2_O0/sushant8421[P]create_your_own_shell/searchstring.c
// Function: Search_in_File
int Search_in_File(char *fname, char *str , char *argv) {
	FILE *fp;
	int line_num = 1;
	int find_result = 0;
	char temp[512];
	
	if((fp = fopen(fname, "r")) == NULL) {
		return(-1);
	}

	while(fgets(temp, 512, fp) != NULL) {
		if(((strstr(temp, str)) != NULL) && !(strcmp("v" , argv) == 0 || strcmp("nv" , argv) == 0)) {
			if(strcmp("n" , argv) == 0 || strcmp("nc" , argv) == 0){
				printf("%s : %d : ", fname , line_num);
			}
			printf(" %s\n", temp);
			find_result++;
		}
		else if((strstr(temp, str)) == NULL){
			if(strcmp("v" , argv) == 0 || strcmp("nv" , argv) == 0){
				printf("%s : %d : %s : \n", fname , line_num , temp);
			}
		}
		line_num++;
	}

	if(find_result == 0) {

		//printf("\nSorry, couldn't find a match.\n");
	}
	else {
		//printf("file name is : %s : " , fname) ;

		if(strcmp(argv , "c") == 0 || strcmp("nc" , argv) == 0)
			printf(" Number Of Lines Matched Are : %d \n" , find_result ) ;
		printf("\n") ;
	}

	
	//Close the file if still open.
	if(fp) {
		fclose(fp);
	}
   	return(0);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x230, %rsp            # imm = 0x230
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movl $0x1, -0x2c(%rbp)
movl $0x0, -0x30(%rbp)
movq -0x10(%rbp), %rdi
leaq 0xd78(%rip), %rsi       # 0x2008
callq 0x1070
movq %rax, -0x28(%rbp)
cmpq $0x0, %rax
jne 0x12ab
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1445
jmp 0x12ad
leaq -0x230(%rbp), %rdi
movq -0x28(%rbp), %rdx
movl $0x200, %esi            # imm = 0x200
callq 0x1050
cmpq $0x0, %rax
je 0x13dd
leaq -0x230(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x10a0
cmpq $0x0, %rax
je 0x136f
movq -0x20(%rbp), %rsi
leaq 0xd64(%rip), %rdi       # 0x2055
callq 0x1060
cmpl $0x0, %eax
je 0x136f
movq -0x20(%rbp), %rsi
leaq 0xd4e(%rip), %rdi       # 0x2054
callq 0x1060
cmpl $0x0, %eax
je 0x136f
movq -0x20(%rbp), %rsi
leaq 0xd3c(%rip), %rdi       # 0x2057
callq 0x1060
cmpl $0x0, %eax
je 0x133a
movq -0x20(%rbp), %rsi
leaq 0xd29(%rip), %rdi       # 0x2059
callq 0x1060
cmpl $0x0, %eax
jne 0x134f
movq -0x10(%rbp), %rsi
movl -0x2c(%rbp), %edx
leaq 0xd14(%rip), %rdi       # 0x205c
movb $0x0, %al
callq 0x1040
leaq -0x230(%rbp), %rsi
leaq 0xd0a(%rip), %rdi       # 0x2067
movb $0x0, %al
callq 0x1040
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x13cf
leaq -0x230(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x10a0
cmpq $0x0, %rax
jne 0x13cd
movq -0x20(%rbp), %rsi
leaq 0xcc5(%rip), %rdi       # 0x2055
callq 0x1060
cmpl $0x0, %eax
je 0x13af
movq -0x20(%rbp), %rsi
leaq 0xcaf(%rip), %rdi       # 0x2054
callq 0x1060
cmpl $0x0, %eax
jne 0x13cb
movq -0x10(%rbp), %rsi
movl -0x2c(%rbp), %edx
leaq -0x230(%rbp), %rcx
leaq 0xca8(%rip), %rdi       # 0x206c
movb $0x0, %al
callq 0x1040
jmp 0x13cd
jmp 0x13cf
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x12ad
cmpl $0x0, -0x30(%rbp)
jne 0x13e5
jmp 0x142e
movq -0x20(%rbp), %rdi
leaq 0xc6a(%rip), %rsi       # 0x205a
callq 0x1060
cmpl $0x0, %eax
je 0x140f
movq -0x20(%rbp), %rsi
leaq 0xc54(%rip), %rdi       # 0x2059
callq 0x1060
cmpl $0x0, %eax
jne 0x1420
movl -0x30(%rbp), %esi
leaq 0xc64(%rip), %rdi       # 0x207d
movb $0x0, %al
callq 0x1040
leaq 0xc54(%rip), %rdi       # 0x207b
movb $0x0, %al
callq 0x1040
cmpq $0x0, -0x28(%rbp)
je 0x143e
movq -0x28(%rbp), %rdi
callq 0x1030
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x230, %rsp            # imm = 0x230
popq %rbp
retq