#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*/ szBuffer;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
char *fgets(char *, int, int /*<<< orphan*/ *);
int line_length(int /*<<< orphan*/ *);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
int get_number_of_snps(FILE *vcf_file_pointer) {
  rewind(vcf_file_pointer);
  int i = 0;
  int length_of_line = 0;
  char szBuffer[2] = {0};
  char *returnchar;
  do {
    returnchar = fgets(szBuffer, sizeof(szBuffer), vcf_file_pointer);
    if (szBuffer[0] != '#') {
      i++;
    }
    length_of_line = line_length(vcf_file_pointer);
  } while (length_of_line != 0);
  return (i > 0) ? i - 1 : 0;
}


x86 assembly (clang, -O0):
<get_number_of_snps>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <rewind@plt>
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
lea    -0x12(%rbp),%rdi
xor    %esi,%esi
mov    $0x2,%edx
call   1050 <memset@plt>
lea    -0x12(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0x2,%esi
call   1060 <fgets@plt>
mov    %rax,-0x20(%rbp)
movsbl -0x12(%rbp),%eax
cmp    $0x23,%eax
je     119f <get_number_of_snps+0x5f>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <line_length@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jne    1173 <get_number_of_snps+0x33>
cmpl   $0x0,-0xc(%rbp)
jle    11cd <get_number_of_snps+0x8d>
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11d7 <get_number_of_snps+0x97>
xor    %eax,%eax
mov    %eax,-0x24(%rbp)
jmp    11d7 <get_number_of_snps+0x97>
mov    -0x24(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_number_of_snps>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%r14
call   1040 <rewind@plt>
movw   $0x0,0xe(%rsp)
xor    %ebx,%ebx
lea    0xe(%rsp),%r15
nop
mov    %r15,%rdi
mov    $0x2,%esi
mov    %r14,%rdx
call   1050 <fgets@plt>
xor    %eax,%eax
cmpb   $0x23,0xe(%rsp)
setne  %al
add    %eax,%ebx
mov    %r14,%rdi
call   1030 <line_length@plt>
test   %eax,%eax
jne    1150 <get_number_of_snps+0x20>
xor    %eax,%eax
sub    $0x1,%ebx
cmovb  %eax,%ebx
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @get_number_of_snps(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
%5 = alloca [2 x i8]
%6 = alloca i8*
store i32* %0, i32** %2
%7 = load i32*, i32** %2
%8 = call i32 @rewind(i32* %7)
store i32 0, i32* %3
store i32 0, i32* %4
%9 = bitcast [2 x i8]* %5 to i8*
br label %10
10: ; preds = %24, %1
%11 = getelementptr inbounds [2 x i8], [2 x i8]* %5, i64 0, i64 0
%12 = load i32*, i32** %2
%13 = call i8* @fgets(i8* %11, i32 2, i32* %12)
store i8* %13, i8** %6
%14 = getelementptr inbounds [2 x i8], [2 x i8]* %5, i64 0, i64 0
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp ne i32 %16, 35
br i1 %17, label %18, label %21
18: ; preds = %10
%19 = load i32, i32* %3
%20 = add nsw i32 %19, 1
store i32 %20, i32* %3
br label %21
21: ; preds = %18, %10
%22 = load i32*, i32** %2
%23 = call i32 @line_length(i32* %22)
store i32 %23, i32* %4
br label %24
24: ; preds = %21
%25 = load i32, i32* %4
%26 = icmp ne i32 %25, 0
br i1 %26, label %10, label %27
27: ; preds = %24
%28 = load i32, i32* %3
%29 = icmp sgt i32 %28, 0
br i1 %29, label %30, label %33
30: ; preds = %27
%31 = load i32, i32* %3
%32 = sub nsw i32 %31, 1
br label %34
33: ; preds = %27
br label %34
34: ; preds = %33, %30
%35 = phi i32 [ %32, %30 ], [ 0, %33 ]
ret i32 %35
}

LLVM IR (-O2):
define i32 @get_number_of_snps(i32* %0) {
%2 = alloca i16
%3 = tail call i32 @rewind(i32* %0)
%4 = bitcast i16* %2 to i8*
store i16 0, i16* %2
br label %5
5: ; preds = %5, %1
%6 = phi i32 [ 0, %1 ], [ %11, %5 ]
%7 = call i8* @fgets(i8* %4, i32 2, i32* %0)
%8 = load i8, i8* %4
%9 = icmp ne i8 %8, 35
%10 = zext i1 %9 to i32
%11 = add nuw nsw i32 %6, %10
%12 = call i32 @line_length(i32* %0)
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %5
14: ; preds = %5
%15 = icmp eq i32 %11, 0
%16 = add nsw i32 %11, -1
%17 = select i1 %15, i32 0, i32 %16
ret i32 %17
}