#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*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ error(char *, char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
scalar_t__ keyword(char *, char *);
int /*<<< orphan*/ sscanf(char *, char *, char *, char *, int *, int *, int *,
                          char *, int *, int *, int *, int *);
int count_blockerrs(char *filename, int low_cutoff, int high_cutoff) {
  FILE *fin;
  char line[1024 + 1];
  int nblockerrs;
  char tmp[1024 + 1];
  int g1, f1, l1, g2, f2, l2, score;
  if ((fin = fopen(filename, "r")) == NULL) {
    error("Could not open file %s", filename);
    return 0;
  }
  nblockerrs = 0;
  while (fgets(line, 1024 + 1, fin)) {
    if (keyword(line, "BLOCK_ERROR")) {
      sscanf(line, "%s %s %d %d %d %s %d %d %d %d \n", tmp, tmp, &g1, &f1, &l1,
             tmp, &g2, &f2, &l2, &score);
      if (score > low_cutoff && score < high_cutoff)
        nblockerrs++;
    }
  }
  fclose(fin);
  return nblockerrs;
}


x86 assembly (clang, -O0):
<count_blockerrs>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %rbx
sub    $0x888,%rsp
mov    %rdi,-0x28(%rbp)
mov    %esi,-0x2c(%rbp)
mov    %edx,-0x30(%rbp)
mov    -0x28(%rbp),%rdi
lea    0xe7b(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x38(%rbp)
cmp    $0x0,%rax
jne    11b4 <count_blockerrs+0x54>
mov    -0x28(%rbp),%rsi
lea    0xe5f(%rip),%rdi
call   1070 <error@plt>
movl   $0x0,-0x1c(%rbp)
jmp    12b9 <count_blockerrs+0x159>
movl   $0x0,-0x444(%rbp)
lea    -0x440(%rbp),%rdi
mov    -0x38(%rbp),%rdx
mov    $0x401,%esi
call   1040 <fgets@plt>
cmp    $0x0,%rax
je     12a7 <count_blockerrs+0x147>
lea    -0x440(%rbp),%rdi
lea    0xe2e(%rip),%rsi
call   1050 <keyword@plt>
cmp    $0x0,%rax
je     12a2 <count_blockerrs+0x142>
lea    -0x440(%rbp),%rdi
lea    -0x850(%rbp),%rdx
lea    -0x850(%rbp),%rcx
lea    -0x850(%rbp),%r14
lea    0xe08(%rip),%rsi
lea    -0x854(%rbp),%r8
lea    -0x858(%rbp),%r9
lea    -0x85c(%rbp),%r15
lea    -0x860(%rbp),%rbx
lea    -0x864(%rbp),%r11
lea    -0x868(%rbp),%r10
lea    -0x86c(%rbp),%rax
mov    %r15,(%rsp)
mov    %r14,0x8(%rsp)
mov    %rbx,0x10(%rsp)
mov    %r11,0x18(%rsp)
mov    %r10,0x20(%rsp)
mov    %rax,0x28(%rsp)
call   1060 <sscanf@plt>
mov    -0x86c(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jle    129d <count_blockerrs+0x13d>
mov    -0x86c(%rbp),%eax
cmp    -0x30(%rbp),%eax
jge    129d <count_blockerrs+0x13d>
mov    -0x444(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x444(%rbp)
jmp    12a2 <count_blockerrs+0x142>
jmp    11be <count_blockerrs+0x5e>
mov    -0x38(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x444(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x888,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

x86 assembly (clang, -O2):
<count_blockerrs>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x838,%rsp
mov    %edx,%r14d
mov    %esi,%r15d
mov    %rdi,%rbx
lea    0xe7f(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     1252 <count_blockerrs+0xf2>
mov    %rax,%r13
lea    0x20(%rsp),%rdi
mov    $0x401,%esi
mov    %rax,%rdx
call   1040 <fgets@plt>
xor    %ebp,%ebp
test   %rax,%rax
je     1248 <count_blockerrs+0xe8>
lea    0x20(%rsp),%rbx
lea    0x430(%rsp),%r12
jmp    11d5 <count_blockerrs+0x75>
xchg   %ax,%ax
mov    %rbx,%rdi
mov    $0x401,%esi
mov    %r13,%rdx
call   1040 <fgets@plt>
test   %rax,%rax
je     1248 <count_blockerrs+0xe8>
mov    %rbx,%rdi
lea    0xe3a(%rip),%rsi
call   1050 <keyword@plt>
test   %rax,%rax
je     11c0 <count_blockerrs+0x60>
mov    %rbx,%rdi
lea    0xe32(%rip),%rsi
mov    %r12,%rdx
mov    %r12,%rcx
lea    0x1c(%rsp),%r8
lea    0x18(%rsp),%r9
lea    0x4(%rsp),%rax
push   %rax
lea    0x10(%rsp),%rax
push   %rax
lea    0x1c(%rsp),%rax
push   %rax
lea    0x28(%rsp),%rax
push   %rax
push   %r12
lea    0x3c(%rsp),%rax
push   %rax
call   1060 <sscanf@plt>
add    $0x30,%rsp
mov    0x4(%rsp),%eax
cmp    %r15d,%eax
setg   %cl
cmp    %r14d,%eax
setl   %al
and    %cl,%al
movzbl %al,%eax
add    %eax,%ebp
jmp    11c0 <count_blockerrs+0x60>
mov    %r13,%rdi
call   1030 <fclose@plt>
jmp    1263 <count_blockerrs+0x103>
lea    0xda9(%rip),%rdi
mov    %rbx,%rsi
call   1070 <error@plt>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x838,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [23 x i8] c"Could not open file %s\00"
@.str.2 = [12 x i8] c"BLOCK_ERROR\00"
@.str.3 = [32 x i8] c"%s %s %d %d %d %s %d %d %d %d \0A\00"
define i32 @count_blockerrs(i8* %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32*
%9 = alloca [1025 x i8]
%10 = alloca i32
%11 = alloca [1025 x i8]
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
store i8* %0, i8** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
%19 = load i8*, i8** %5
%20 = call i32* @fopen(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %20, i32** %8
%21 = icmp eq i32* %20, null
br i1 %21, label %22, label %25
22: ; preds = %3
%23 = load i8*, i8** %5
%24 = call i32 @error(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %23)
store i32 0, i32* %4
br label %57
25: ; preds = %3
store i32 0, i32* %10
br label %26
26: ; preds = %52, %25
%27 = getelementptr inbounds [1025 x i8], [1025 x i8]* %9, i64 0, i64 0
%28 = load i32*, i32** %8
%29 = call i64 @fgets(i8* %27, i32 1025, i32* %28)
%30 = icmp ne i64 %29, 0
br i1 %30, label %31, label %53
31: ; preds = %26
%32 = getelementptr inbounds [1025 x i8], [1025 x i8]* %9, i64 0, i64 0
%33 = call i64 @keyword(i8* %32, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%34 = icmp ne i64 %33, 0
br i1 %34, label %35, label %52
35: ; preds = %31
%36 = getelementptr inbounds [1025 x i8], [1025 x i8]* %9, i64 0, i64 0
%37 = getelementptr inbounds [1025 x i8], [1025 x i8]* %11, i64 0, i64 0
%38 = getelementptr inbounds [1025 x i8], [1025 x i8]* %11, i64 0, i64 0
%39 = getelementptr inbounds [1025 x i8], [1025 x i8]* %11, i64 0, i64 0
%40 = call i32 @sscanf(i8* %36, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i8* %37, i8* %38, i32* %12, i32* %13, i32* %14, i8* %39, i32* %15, i32* %16, i32* %17, i32* %18)
%41 = load i32, i32* %18
%42 = load i32, i32* %6
%43 = icmp sgt i32 %41, %42
br i1 %43, label %44, label %51
44: ; preds = %35
%45 = load i32, i32* %18
%46 = load i32, i32* %7
%47 = icmp slt i32 %45, %46
br i1 %47, label %48, label %51
48: ; preds = %44
%49 = load i32, i32* %10
%50 = add nsw i32 %49, 1
store i32 %50, i32* %10
br label %51
51: ; preds = %48, %44, %35
br label %52
52: ; preds = %51, %31
br label %26
53: ; preds = %26
%54 = load i32*, i32** %8
%55 = call i32 @fclose(i32* %54)
%56 = load i32, i32* %10
store i32 %56, i32* %4
br label %57
57: ; preds = %53, %22
%58 = load i32, i32* %4
ret i32 %58
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [23 x i8] c"Could not open file %s\00"
@.str.2 = [12 x i8] c"BLOCK_ERROR\00"
@.str.3 = [32 x i8] c"%s %s %d %d %d %s %d %d %d %d \0A\00"
define i32 @count_blockerrs(i8* %0, i32 %1, i32 %2) {
%4 = alloca [1025 x i8]
%5 = alloca [1025 x i8]
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = getelementptr inbounds [1025 x i8], [1025 x i8]* %4, i64 0, i64 0
%14 = getelementptr inbounds [1025 x i8], [1025 x i8]* %5, i64 0, i64 0
%15 = bitcast i32* %6 to i8*
%16 = bitcast i32* %7 to i8*
%17 = bitcast i32* %8 to i8*
%18 = bitcast i32* %9 to i8*
%19 = bitcast i32* %10 to i8*
%20 = bitcast i32* %11 to i8*
%21 = bitcast i32* %12 to i8*
%22 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%23 = icmp eq i32* %22, null
br i1 %23, label %27, label %24
24: ; preds = %3
%25 = call i64 @fgets(i8* %13, i32 1025, i32* %22)
%26 = icmp eq i64 %25, 0
br i1 %26, label %45, label %29
27: ; preds = %3
%28 = tail call i32 @error(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %48
29: ; preds = %24, %41
%30 = phi i32 [ %42, %41 ], [ 0, %24 ]
%31 = call i64 @keyword(i8* %13, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%32 = icmp eq i64 %31, 0
br i1 %32, label %41, label %33
33: ; preds = %29
%34 = call i32 @sscanf(i8* %13, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i8* %14, i8* %14, i32* %6, i32* %7, i32* %8, i8* %14, i32* %9, i32* %10, i32* %11, i32* %12)
%35 = load i32, i32* %12
%36 = icmp sgt i32 %35, %1
%37 = icmp slt i32 %35, %2
%38 = and i1 %36, %37
%39 = zext i1 %38 to i32
%40 = add nsw i32 %30, %39
br label %41
41: ; preds = %33, %29
%42 = phi i32 [ %30, %29 ], [ %40, %33 ]
%43 = call i64 @fgets(i8* %13, i32 1025, i32* %22)
%44 = icmp eq i64 %43, 0
br i1 %44, label %45, label %29
45: ; preds = %41, %24
%46 = phi i32 [ 0, %24 ], [ %42, %41 ]
%47 = call i32 @fclose(i32* %22)
br label %48
48: ; preds = %45, %27
%49 = phi i32 [ 0, %27 ], [ %46, %45 ]
ret i32 %49
}