// File: /workspace/github_c_makefile_star2_O0/gmcvicker[P]check_fastq/util.c
// Function: util_gzcount_lines_match
long util_gzcount_lines_match(gzFile gzf, const char *starts_with) {
  char buf[UTIL_FGETS_BUF_SZ];
  long line_count;
  int started_with, at_line_start;
  int match_len, len;

  if(gzseek(gzf, 0L, SEEK_SET) != 0) {
    my_err("%s:%d: could not rewind filehandle", __FILE__, __LINE__);
  }

  match_len = strlen(starts_with);
  if(match_len == 0) {
    return 0;
  }

  if(match_len > UTIL_FGETS_BUF_SZ) {
    my_err("%s:%d: length of string to match must be"
	    "<= %d bytes", __FILE__, __LINE__, UTIL_FGETS_BUF_SZ);
  }

  line_count = 0;
  started_with  = FALSE;
  at_line_start = TRUE;

  while(gzgets(gzf, buf, UTIL_FGETS_BUF_SZ) != NULL) {
    if(at_line_start) {
      /* we are at the beginning of a line, does it match the string? */
      if(strncmp(starts_with, buf, match_len) == 0) {
	started_with = TRUE;
      }
    }

    len = strlen(buf);
    if(buf[len-1] == '\n') {
      /* we are at the end of the line, did the beginning match? */
      if(started_with) {
	line_count++;
	started_with = FALSE;
      }
      at_line_start = TRUE;
    } else {
      at_line_start = FALSE;
    }
  }

  if(gzseek(gzf, 0L, SEEK_SET) != 0) {
    my_err("%s:%d: could not rewind filehandle", __FILE__, __LINE__);
  }

  return line_count;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x4020, %rsp           # imm = 0x4020
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
xorl %edx, %edx
callq 0x2120
cmpq $0x0, %rax
je 0x2b02
leaq 0x25c3(%rip), %rdi      # 0x50b2
leaq 0x2856(%rip), %rsi      # 0x534c
movl $0xcc, %edx
movb $0x0, %al
callq 0x4010
movq -0x18(%rbp), %rdi
callq 0x2150
movl %eax, -0x4014(%rbp)
cmpl $0x0, -0x4014(%rbp)
jne 0x2b27
movq $0x0, -0x8(%rbp)
jmp 0x2c65
cmpl $0x3fdc, -0x4014(%rbp)  # imm = 0x3FDC
jle 0x2b52
leaq 0x259b(%rip), %rdi      # 0x50d5
leaq 0x280b(%rip), %rsi      # 0x534c
movl $0xd6, %edx
movl $0x3fdc, %ecx           # imm = 0x3FDC
movb $0x0, %al
callq 0x4010
movq $0x0, -0x4008(%rbp)
movl $0x0, -0x400c(%rbp)
movl $0x1, -0x4010(%rbp)
movq -0x10(%rbp), %rdi
leaq -0x4000(%rbp), %rsi
movl $0x3fdc, %edx           # imm = 0x3FDC
callq 0x2230
cmpq $0x0, %rax
je 0x2c2b
cmpl $0x0, -0x4010(%rbp)
je 0x2bc1
movq -0x18(%rbp), %rdi
leaq -0x4000(%rbp), %rsi
movslq -0x4014(%rbp), %rdx
callq 0x20f0
cmpl $0x0, %eax
jne 0x2bbf
movl $0x1, -0x400c(%rbp)
jmp 0x2bc1
leaq -0x4000(%rbp), %rdi
callq 0x2150
movl %eax, -0x4018(%rbp)
movl -0x4018(%rbp), %eax
subl $0x1, %eax
cltq
movsbl -0x4000(%rbp,%rax), %eax
cmpl $0xa, %eax
jne 0x2c1c
cmpl $0x0, -0x400c(%rbp)
je 0x2c10
movq -0x4008(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x4008(%rbp)
movl $0x0, -0x400c(%rbp)
movl $0x1, -0x4010(%rbp)
jmp 0x2c26
movl $0x0, -0x4010(%rbp)
jmp 0x2b71
movq -0x10(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
xorl %edx, %edx
callq 0x2120
cmpq $0x0, %rax
je 0x2c5a
leaq 0x246b(%rip), %rdi      # 0x50b2
leaq 0x26fe(%rip), %rsi      # 0x534c
movl $0xf3, %edx
movb $0x0, %al
callq 0x4010
movq -0x4008(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x4020, %rsp           # imm = 0x4020
popq %rbp
retq
nopw %cs:(%rax,%rax)