#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*/ BUFSIZ;
scalar_t__ EOF;
float atof(char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
scalar_t__ fscanf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ printf(char *, char *);
int valid_cells(char maskf[BUFSIZ + 1]) {
  FILE *fpmaskf;
  char str1[BUFSIZ + 1], voidstr[BUFSIZ + 1];
  int i;
  float high, low, valmask;
  if ((fpmaskf = fopen(maskf, "r")) == NULL) {
    printf("Cannot open file %s \n", maskf);
    exit(0);
  }
  for (i = 0; i < 12; i++)
    fscanf(fpmaskf, "%s", voidstr);
  i = 0;
  while (fscanf(fpmaskf, "%s", str1) != EOF) {
    valmask = atof(voidstr);
    high = valmask + 0.001;
    low = valmask - 0.001;
    if (atof(str1) > high || atof(str1) < low)
      i++;
  }
  return i;
  fclose(fpmaskf);
}


x86 assembly (clang, -O0):
<valid_cells>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    0x2e75(%rip),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %rsp,%rdx
mov    %rdx,-0x18(%rbp)
mov    %rcx,%rsi
add    $0xf,%rsi
and    $0xfffffffffffffff0,%rsi
mov    %rsp,%rdx
sub    %rsi,%rdx
mov    %rdx,-0x48(%rbp)
mov    %rdx,%rsp
mov    %rcx,-0x20(%rbp)
mov    (%rax),%eax
add    $0x1,%eax
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x40(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe51(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    11e1 <valid_cells+0x91>
mov    -0x8(%rbp),%rsi
lea    0xe35(%rip),%rdi
call   1040 <printf@plt>
xor    %edi,%edi
call   1070 <exit@plt>
movl   $0x0,-0x2c(%rbp)
cmpl   $0xc,-0x2c(%rbp)
jge    1214 <valid_cells+0xc4>
mov    -0x40(%rbp),%rdx
mov    -0x10(%rbp),%rdi
lea    0xe1f(%rip),%rsi
call   1050 <fscanf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11e8 <valid_cells+0x98>
movl   $0x0,-0x2c(%rbp)
mov    -0x48(%rbp),%rdx
mov    -0x10(%rbp),%rdi
lea    0xdf6(%rip),%rsi
call   1050 <fscanf@plt>
mov    0x2db2(%rip),%rcx
cmp    (%rcx),%rax
je     12c4 <valid_cells+0x174>
mov    -0x40(%rbp),%rdi
call   1030 <atof@plt>
mov    -0x48(%rbp),%rdi
movss  %xmm0,-0x38(%rbp)
movss  -0x38(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xd9e(%rip),%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x30(%rbp)
movss  -0x38(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xd80(%rip),%xmm1
subsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x34(%rbp)
call   1030 <atof@plt>
ucomiss -0x30(%rbp),%xmm0
ja     12b6 <valid_cells+0x166>
mov    -0x48(%rbp),%rdi
call   1030 <atof@plt>
movaps %xmm0,%xmm1
movss  -0x34(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    12bf <valid_cells+0x16f>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    121b <valid_cells+0xcb>
mov    -0x2c(%rbp),%eax
mov    -0x18(%rbp),%rcx
mov    %rcx,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<valid_cells>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%rbx
mov    0x2e6d(%rip),%rax
mov    (%rax),%eax
add    $0x1,%eax
mov    %rsp,%r13
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r13
mov    %r13,%rsp
mov    %rsp,%r14
sub    %rax,%r14
mov    %r14,%rsp
lea    0xe7f(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     12f5 <valid_cells+0x1a5>
mov    %rax,%r15
lea    0xe7f(%rip),%r12
mov    %rax,%rdi
mov    %r12,%rsi
mov    %r14,%rdx
call   1050 <fscanf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %r14,%rdx
call   1050 <fscanf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %r14,%rdx
call   1050 <fscanf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %r14,%rdx
call   1050 <fscanf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %r14,%rdx
call   1050 <fscanf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %r14,%rdx
call   1050 <fscanf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %r14,%rdx
call   1050 <fscanf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %r14,%rdx
call   1050 <fscanf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %r14,%rdx
call   1050 <fscanf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %r14,%rdx
call   1050 <fscanf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %r14,%rdx
call   1050 <fscanf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %r14,%rdx
call   1050 <fscanf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
call   1050 <fscanf@plt>
mov    0x2d82(%rip),%rcx
xor    %ebx,%ebx
cmp    (%rcx),%rax
jne    127e <valid_cells+0x12e>
mov    %ebx,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %ebx,%ebx
lea    0xda1(%rip),%r12
jmp    12ad <valid_cells+0x15d>
nopl   0x0(%rax)
add    $0x1,%ebx
mov    %r15,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
call   1050 <fscanf@plt>
mov    0x2d40(%rip),%rcx
cmp    (%rcx),%rax
je     126d <valid_cells+0x11d>
mov    %r14,%rdi
call   1030 <atof@plt>
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
addsd  0xd3a(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x2c(%rbp)
mov    %r13,%rdi
call   1030 <atof@plt>
ucomiss -0x2c(%rbp),%xmm0
ja     1290 <valid_cells+0x140>
movsd  -0x38(%rbp),%xmm1
addsd  0xd1e(%rip),%xmm1
cvtsd2ss %xmm1,%xmm1
ucomiss %xmm0,%xmm1
ja     1290 <valid_cells+0x140>
jmp    1293 <valid_cells+0x143>
lea    0xd16(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
xor    %edi,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@BUFSIZ = global i32 0
@.str = [2 x i8] c"r\00"
@.str.1 = [22 x i8] c"Cannot open file %s \0A\00"
@.str.2 = [3 x i8] c"%s\00"
@EOF = global i64 0
define i32 @valid_cells(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i64
%7 = alloca i32
%8 = alloca float
%9 = alloca float
%10 = alloca float
store i8* %0, i8** %2
%11 = load i32, i32* @BUFSIZ
%12 = add nsw i32 %11, 1
%13 = zext i32 %12 to i64
%14 = load i32, i32* @BUFSIZ
%15 = add nsw i32 %14, 1
%16 = zext i32 %15 to i64
%17 = call i8* @llvm.stacksave()
store i8* %17, i8** %4
%18 = alloca i8, i64 %16
store i64 %16, i64* %5
%19 = load i32, i32* @BUFSIZ
%20 = add nsw i32 %19, 1
%21 = zext i32 %20 to i64
%22 = alloca i8, i64 %21
store i64 %21, i64* %6
%23 = load i8*, i8** %2
%24 = call i32* @fopen(i8* %23, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %24, i32** %3
%25 = icmp eq i32* %24, null
br i1 %25, label %26, label %30
26: ; preds = %1
%27 = load i8*, i8** %2
%28 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %27)
%29 = call i32 @exit(i32 0)
unreachable
30: ; preds = %1
store i32 0, i32* %7
br label %31
31: ; preds = %37, %30
%32 = load i32, i32* %7
%33 = icmp slt i32 %32, 12
br i1 %33, label %34, label %40
34: ; preds = %31
%35 = load i32*, i32** %3
%36 = call i64 @fscanf(i32* %35, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %22)
br label %37
37: ; preds = %34
%38 = load i32, i32* %7
%39 = add nsw i32 %38, 1
store i32 %39, i32* %7
br label %31
40: ; preds = %31
store i32 0, i32* %7
br label %41
41: ; preds = %66, %40
%42 = load i32*, i32** %3
%43 = call i64 @fscanf(i32* %42, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %18)
%44 = load i64, i64* @EOF
%45 = icmp ne i64 %43, %44
br i1 %45, label %46, label %67
46: ; preds = %41
%47 = call float @atof(i8* %22)
store float %47, float* %10
%48 = load float, float* %10
%49 = fpext float %48 to double
%50 = fadd double %49, 1.000000e-03
%51 = fptrunc double %50 to float
store float %51, float* %8
%52 = load float, float* %10
%53 = fpext float %52 to double
%54 = fsub double %53, 1.000000e-03
%55 = fptrunc double %54 to float
store float %55, float* %9
%56 = call float @atof(i8* %18)
%57 = load float, float* %8
%58 = fcmp ogt float %56, %57
br i1 %58, label %63, label %59
59: ; preds = %46
%60 = call float @atof(i8* %18)
%61 = load float, float* %9
%62 = fcmp olt float %60, %61
br i1 %62, label %63, label %66
63: ; preds = %59, %46
%64 = load i32, i32* %7
%65 = add nsw i32 %64, 1
store i32 %65, i32* %7
br label %66
66: ; preds = %63, %59
br label %41
67: ; preds = %41
%68 = load i32, i32* %7
%69 = load i8*, i8** %4
ret i32 %68
}

LLVM IR (-O2):
@BUFSIZ = global i32 0
@.str = [2 x i8] c"r\00"
@.str.1 = [22 x i8] c"Cannot open file %s \0A\00"
@.str.2 = [3 x i8] c"%s\00"
@EOF = global i64 0
define i32 @valid_cells(i8* %0) {
%2 = load i32, i32* @BUFSIZ
%3 = add nsw i32 %2, 1
%4 = zext i32 %3 to i64
%5 = alloca i8, i64 %4
%6 = alloca i8, i64 %4
%7 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i32* %7, null
br i1 %8, label %25, label %9
9: ; preds = %1
%10 = call i64 @fscanf(i32* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %6)
%11 = call i64 @fscanf(i32* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %6)
%12 = call i64 @fscanf(i32* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %6)
%13 = call i64 @fscanf(i32* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %6)
%14 = call i64 @fscanf(i32* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %6)
%15 = call i64 @fscanf(i32* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %6)
%16 = call i64 @fscanf(i32* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %6)
%17 = call i64 @fscanf(i32* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %6)
%18 = call i64 @fscanf(i32* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %6)
%19 = call i64 @fscanf(i32* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %6)
%20 = call i64 @fscanf(i32* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %6)
%21 = call i64 @fscanf(i32* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %6)
%22 = call i64 @fscanf(i32* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %5)
%23 = load i64, i64* @EOF
%24 = icmp eq i64 %22, %23
br i1 %24, label %47, label %28
25: ; preds = %1
%26 = tail call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%27 = tail call i32 @exit(i32 0)
unreachable
28: ; preds = %9, %42
%29 = phi i32 [ %43, %42 ], [ 0, %9 ]
%30 = call float @atof(i8* %6)
%31 = fpext float %30 to double
%32 = fadd double %31, 1.000000e-03
%33 = fptrunc double %32 to float
%34 = call float @atof(i8* %5)
%35 = fcmp ogt float %34, %33
br i1 %35, label %40, label %36
36: ; preds = %28
%37 = fadd double %31, -1.000000e-03
%38 = fptrunc double %37 to float
%39 = fcmp olt float %34, %38
br i1 %39, label %40, label %42
40: ; preds = %36, %28
%41 = add nsw i32 %29, 1
br label %42
42: ; preds = %40, %36
%43 = phi i32 [ %41, %40 ], [ %29, %36 ]
%44 = call i64 @fscanf(i32* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %5)
%45 = load i64, i64* @EOF
%46 = icmp eq i64 %44, %45
br i1 %46, label %47, label %28
47: ; preds = %42, %9
%48 = phi i32 [ 0, %9 ], [ %43, %42 ]
ret i32 %48
}