#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef int /*<<< orphan*/ gzFile;

/* Variables and functions */
char EOF;
char gzgetc(int /*<<< orphan*/);
scalar_t__ gzrewind(int /*<<< orphan*/);
int /*<<< orphan*/ my_err(char *, char *, int);
long util_gzcount_lines(gzFile gzf) {
  char c;
  long line_count;
  if (gzrewind(gzf) != 0) {
    my_err("%s:%d: could not rewind filehandle",
           "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
           "2022-01-22/02-19-57/repos/bmvdgeijn/WASP/refs/heads/master/snp2h5/"
           "util.c",
           196);
  }
  line_count = 0;
  while ((c = gzgetc(gzf)) != EOF) {
    if (c == '\n') {
      line_count += 1;
    }
  }
  if (gzrewind(gzf) != 0) {
    my_err("%s:%d: could not rewind filehandle",
           "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
           "2022-01-22/02-19-57/repos/bmvdgeijn/WASP/refs/heads/master/snp2h5/"
           "util.c",
           209);
  }
  return line_count;
}


x86 assembly (clang, -O0):
<util_gzcount_lines>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
call   1040 <gzrewind@plt>
cmp    $0x0,%rax
je     1165 <util_gzcount_lines+0x35>
lea    0xeac(%rip),%rdi
lea    0xec8(%rip),%rsi
mov    $0xc4,%edx
call   1050 <my_err@plt>
movq   $0x0,-0x10(%rbp)
mov    -0x4(%rbp),%edi
call   1030 <gzgetc@plt>
mov    %al,-0x5(%rbp)
movsbl %al,%eax
mov    0x2e66(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     11ab <util_gzcount_lines+0x7b>
movsbl -0x5(%rbp),%eax
cmp    $0xa,%eax
jne    11a6 <util_gzcount_lines+0x76>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    116d <util_gzcount_lines+0x3d>
mov    -0x4(%rbp),%edi
call   1040 <gzrewind@plt>
cmp    $0x0,%rax
je     11d5 <util_gzcount_lines+0xa5>
lea    0xe3c(%rip),%rdi
lea    0xe58(%rip),%rsi
mov    $0xd1,%edx
call   1050 <my_err@plt>
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<util_gzcount_lines>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%ebp
call   1040 <gzrewind@plt>
test   %rax,%rax
je     1158 <util_gzcount_lines+0x28>
lea    0xeb9(%rip),%rdi
lea    0xed5(%rip),%rsi
mov    $0xc4,%edx
call   1050 <my_err@plt>
mov    %ebp,%edi
call   1030 <gzgetc@plt>
mov    0x2e82(%rip),%r14
cmp    (%r14),%al
jne    116f <util_gzcount_lines+0x3f>
xor    %ebx,%ebx
jmp    1196 <util_gzcount_lines+0x66>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %ecx,%ecx
cmp    $0xa,%al
sete   %cl
add    %rcx,%rbx
mov    %ebp,%edi
call   1030 <gzgetc@plt>
cmp    (%r14),%al
jne    1180 <util_gzcount_lines+0x50>
mov    %ebp,%edi
call   1040 <gzrewind@plt>
test   %rax,%rax
je     11ba <util_gzcount_lines+0x8a>
lea    0xe57(%rip),%rdi
lea    0xe73(%rip),%rsi
mov    $0xd1,%edx
call   1050 <my_err@plt>
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [35 x i8] c"%s:%d: could not rewind filehandle\00"
@.str.1 = [137 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/bmvdgeijn/WASP/refs/heads/master/snp2h5/util.c\00"
@EOF = global i8 0
define i64 @util_gzcount_lines(i32 %0) {
%2 = alloca i32
%3 = alloca i8
%4 = alloca i64
store i32 %0, i32* %2
%5 = load i32, i32* %2
%6 = call i64 @gzrewind(i32 %5)
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %1
%9 = call i32 @my_err(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([137 x i8], [137 x i8]* @.str.1, i64 0, i64 0), i32 196)
br label %10
10: ; preds = %8, %1
store i64 0, i64* %4
br label %11
11: ; preds = %25, %10
%12 = load i32, i32* %2
%13 = call signext i8 @gzgetc(i32 %12)
store i8 %13, i8* %3
%14 = sext i8 %13 to i32
%15 = load i8, i8* @EOF
%16 = sext i8 %15 to i32
%17 = icmp ne i32 %14, %16
br i1 %17, label %18, label %26
18: ; preds = %11
%19 = load i8, i8* %3
%20 = sext i8 %19 to i32
%21 = icmp eq i32 %20, 10
br i1 %21, label %22, label %25
22: ; preds = %18
%23 = load i64, i64* %4
%24 = add nsw i64 %23, 1
store i64 %24, i64* %4
br label %25
25: ; preds = %22, %18
br label %11
26: ; preds = %11
%27 = load i32, i32* %2
%28 = call i64 @gzrewind(i32 %27)
%29 = icmp ne i64 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %26
%31 = call i32 @my_err(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([137 x i8], [137 x i8]* @.str.1, i64 0, i64 0), i32 209)
br label %32
32: ; preds = %30, %26
%33 = load i64, i64* %4
ret i64 %33
}

LLVM IR (-O2):
@.str = [35 x i8] c"%s:%d: could not rewind filehandle\00"
@.str.1 = [137 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/bmvdgeijn/WASP/refs/heads/master/snp2h5/util.c\00"
@EOF = global i8 0
define i64 @util_gzcount_lines(i32 %0) {
%2 = tail call i64 @gzrewind(i32 %0)
%3 = icmp eq i64 %2, 0
br i1 %3, label %6, label %4
4: ; preds = %1
%5 = tail call i32 @my_err(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([137 x i8], [137 x i8]* @.str.1, i64 0, i64 0), i32 196)
br label %6
6: ; preds = %4, %1
%7 = tail call signext i8 @gzgetc(i32 %0)
%8 = load i8, i8* @EOF
%9 = icmp eq i8 %7, %8
br i1 %9, label %19, label %10
10: ; preds = %6, %10
%11 = phi i8 [ %16, %10 ], [ %7, %6 ]
%12 = phi i64 [ %15, %10 ], [ 0, %6 ]
%13 = icmp eq i8 %11, 10
%14 = zext i1 %13 to i64
%15 = add nuw nsw i64 %12, %14
%16 = tail call signext i8 @gzgetc(i32 %0)
%17 = load i8, i8* @EOF
%18 = icmp eq i8 %16, %17
br i1 %18, label %19, label %10
19: ; preds = %10, %6
%20 = phi i64 [ 0, %6 ], [ %15, %10 ]
%21 = tail call i64 @gzrewind(i32 %0)
%22 = icmp eq i64 %21, 0
br i1 %22, label %25, label %23
23: ; preds = %19
%24 = tail call i32 @my_err(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([137 x i8], [137 x i8]* @.str.1, i64 0, i64 0), i32 209)
br label %25
25: ; preds = %23, %19
ret i64 %20
}