// File: /workspace/github_c_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x218, %rsp            # imm = 0x218
movq %rdx, %r14
movq %rsi, %r12
leaq 0xdb3(%rip), %rsi       # 0x2008
movq %rdi, -0x38(%rbp)
callq 0x1080
testq %rax, %rax
je 0x13e2
movq %rax, %rbx
leaq -0x240(%rbp), %rdi
movl $0x200, %esi            # imm = 0x200
movq %rax, %rdx
callq 0x1070
testq %rax, %rax
je 0x13d6
movl $0x1, %r13d
leaq -0x240(%rbp), %r15
movl $0x0, -0x2c(%rbp)
movq %r15, %rdi
movq %r12, %rsi
callq 0x10b0
movzbl (%r14), %ecx
testq %rax, %rax
je 0x12c4
cmpl $0x76, %ecx
jne 0x12dd
cmpb $0x0, 0x1(%r14)
jne 0x1343
jmp 0x138b
cmpl $0x76, %ecx
jne 0x1359
cmpb $0x0, 0x1(%r14)
jne 0x138b
jmp 0x1373
leal -0x6e(%rcx), %eax
negl %eax
movl %eax, %edx
cmpl $0x6e, %ecx
jne 0x12fa
movzbl 0x1(%r14), %edx
subl $0x76, %edx
jne 0x12f8
movzbl 0x2(%r14), %edx
negl %edx
testl %edx, %edx
je 0x138b
movl %eax, %edx
cmpb $0x6e, %cl
jne 0x1310
movzbl 0x1(%r14), %edx
negl %edx
testl %edx, %edx
je 0x132e
cmpb $0x6e, %cl
jne 0x132a
movzbl 0x1(%r14), %eax
subl $0x63, %eax
jne 0x1328
movzbl 0x2(%r14), %eax
negl %eax
testl %eax, %eax
jne 0x1343
leaq 0xce8(%rip), %rdi       # 0x201d
movq -0x38(%rbp), %rsi
movl %r13d, %edx
xorl %eax, %eax
callq 0x1060
leaq 0xcde(%rip), %rdi       # 0x2028
movq %r15, %rsi
xorl %eax, %eax
callq 0x1060
incl -0x2c(%rbp)
jmp 0x138b
subl $0x6e, %ecx
jne 0x136d
movzbl 0x1(%r14), %ecx
subl $0x76, %ecx
jne 0x136d
movzbl 0x2(%r14), %ecx
negl %ecx
testl %ecx, %ecx
jne 0x138b
leaq 0xcb3(%rip), %rdi       # 0x202d
movq -0x38(%rbp), %rsi
movl %r13d, %edx
movq %r15, %rcx
xorl %eax, %eax
callq 0x1060
incl %r13d
movq %r15, %rdi
movl $0x200, %esi            # imm = 0x200
movq %rbx, %rdx
callq 0x1070
testq %rax, %rax
jne 0x129b
movl -0x2c(%rbp), %esi
testl %esi, %esi
je 0x13d6
movzbl (%r14), %eax
cmpl $0x63, %eax
jne 0x13f9
cmpb $0x0, 0x1(%r14)
jne 0x13cc
leaq 0xc79(%rip), %rdi       # 0x203e
xorl %eax, %eax
callq 0x1060
movl $0xa, %edi
callq 0x1030
movq %rbx, %rdi
callq 0x1050
xorl %eax, %eax
jmp 0x13e7
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x218, %rsp            # imm = 0x218
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
subl $0x6e, %eax
jne 0x140d
movzbl 0x1(%r14), %eax
subl $0x63, %eax
jne 0x140d
movzbl 0x2(%r14), %eax
negl %eax
testl %eax, %eax
jne 0x13cc
jmp 0x13be