#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*/ value;
typedef scalar_t__ uint32_t;
typedef int uint16_t;
typedef int /*<<< orphan*/ count;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ fread(int *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, scalar_t__, int /*<<< orphan*/);
int test_list_16(FILE *file, uint32_t start, uint16_t v_begin, uint16_t v_end) {
  int result = 0;
  uint16_t count = 0;
  fseek(file, start, SEEK_SET);
  fread(&count, sizeof(count), 1, file);
  uint16_t i;
  for (i = 0; i < count; i++) {
    uint16_t value;
    fseek(file, start + 2 + i * sizeof(value), SEEK_SET);
    fread(&value, sizeof(value), 1, file);
    if ((value < v_begin) || (value > v_end)) {
      result++;
    }
  }
  if (count == 0)
    result = -1;
  return result;
}


x86 assembly (clang, -O0):
<test_list_16>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    0x2e8d(%rip),%rax
mov    (%rax),%edx
call   1040 <fseek@plt>
mov    -0x8(%rbp),%rcx
lea    -0x20(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    11f4 <test_list_16+0xd4>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
add    $0x2,%rsi
movslq -0x24(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
mov    0x2e3e(%rip),%rax
mov    (%rax),%edx
call   1040 <fseek@plt>
mov    -0x8(%rbp),%rcx
lea    -0x28(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
mov    -0x28(%rbp),%eax
cmp    -0x14(%rbp),%eax
jl     11d8 <test_list_16+0xb8>
mov    -0x28(%rbp),%eax
cmp    -0x18(%rbp),%eax
jle    11e1 <test_list_16+0xc1>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11e6 <test_list_16+0xc6>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1178 <test_list_16+0x58>
cmpl   $0x0,-0x20(%rbp)
jne    1205 <test_list_16+0xe5>
movl   $0xffffffff,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_list_16>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %ecx,%r14d
mov    %edx,%r15d
mov    %rsi,%rbx
mov    %rdi,%rbp
movl   $0x0,0x8(%rsp)
mov    0x2e97(%rip),%rax
mov    (%rax),%edx
call   1040 <fseek@plt>
lea    0x8(%rsp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %rbp,%rcx
call   1030 <fread@plt>
mov    0x8(%rsp),%r12d
test   %r12d,%r12d
mov    %r12,0x10(%rsp)
jle    11cf <test_list_16+0xaf>
add    $0x2,%rbx
xor    %r13d,%r13d
nopl   (%rax)
mov    0x2e59(%rip),%rax
mov    (%rax),%edx
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1040 <fseek@plt>
lea    0xc(%rsp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %rbp,%rcx
call   1030 <fread@plt>
mov    0xc(%rsp),%eax
cmp    %r15d,%eax
setl   %cl
cmp    %r14d,%eax
setg   %al
or     %cl,%al
movzbl %al,%eax
add    %eax,%r13d
add    $0x4,%rbx
add    $0xffffffffffffffff,%r12
jne    1180 <test_list_16+0x60>
jmp    11d2 <test_list_16+0xb2>
xor    %r13d,%r13d
cmpq   $0x1,0x10(%rsp)
sbb    %eax,%eax
or     %r13d,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@SEEK_SET = global i32 0
define i32 @test_list_16(i32* %0, i64 %1, i32 %2, i32 %3) {
%5 = alloca i32*
%6 = alloca i64
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32* %0, i32** %5
store i64 %1, i64* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
store i32 0, i32* %9
store i32 0, i32* %10
%13 = load i32*, i32** %5
%14 = load i64, i64* %6
%15 = load i32, i32* @SEEK_SET
%16 = call i32 @fseek(i32* %13, i64 %14, i32 %15)
%17 = load i32*, i32** %5
%18 = call i32 @fread(i32* %10, i32 4, i32 1, i32* %17)
store i32 0, i32* %11
br label %19
19: ; preds = %46, %4
%20 = load i32, i32* %11
%21 = load i32, i32* %10
%22 = icmp slt i32 %20, %21
br i1 %22, label %23, label %49
23: ; preds = %19
%24 = load i32*, i32** %5
%25 = load i64, i64* %6
%26 = add nsw i64 %25, 2
%27 = load i32, i32* %11
%28 = sext i32 %27 to i64
%29 = mul i64 %28, 4
%30 = add i64 %26, %29
%31 = load i32, i32* @SEEK_SET
%32 = call i32 @fseek(i32* %24, i64 %30, i32 %31)
%33 = load i32*, i32** %5
%34 = call i32 @fread(i32* %12, i32 4, i32 1, i32* %33)
%35 = load i32, i32* %12
%36 = load i32, i32* %7
%37 = icmp slt i32 %35, %36
br i1 %37, label %42, label %38
38: ; preds = %23
%39 = load i32, i32* %12
%40 = load i32, i32* %8
%41 = icmp sgt i32 %39, %40
br i1 %41, label %42, label %45
42: ; preds = %38, %23
%43 = load i32, i32* %9
%44 = add nsw i32 %43, 1
store i32 %44, i32* %9
br label %45
45: ; preds = %42, %38
br label %46
46: ; preds = %45
%47 = load i32, i32* %11
%48 = add nsw i32 %47, 1
store i32 %48, i32* %11
br label %19
49: ; preds = %19
%50 = load i32, i32* %10
%51 = icmp eq i32 %50, 0
br i1 %51, label %52, label %53
52: ; preds = %49
store i32 -1, i32* %9
br label %53
53: ; preds = %52, %49
%54 = load i32, i32* %9
ret i32 %54
}

LLVM IR (-O2):
@SEEK_SET = global i32 0
define i32 @test_list_16(i32* nocapture %0, i64 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = bitcast i32* %5 to i8*
store i32 0, i32* %5
%8 = load i32, i32* @SEEK_SET
%9 = tail call i32 @fseek(i32* %0, i64 %1, i32 %8)
%10 = call i32 @fread(i32* %5, i32 4, i32 1, i32* %0)
%11 = load i32, i32* %5
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %33
13: ; preds = %4
%14 = bitcast i32* %6 to i8*
%15 = add nsw i64 %1, 2
%16 = zext i32 %11 to i64
br label %17
17: ; preds = %13, %17
%18 = phi i64 [ 0, %13 ], [ %31, %17 ]
%19 = phi i32 [ 0, %13 ], [ %30, %17 ]
%20 = shl nuw nsw i64 %18, 2
%21 = add i64 %15, %20
%22 = load i32, i32* @SEEK_SET
%23 = tail call i32 @fseek(i32* %0, i64 %21, i32 %22)
%24 = call i32 @fread(i32* %6, i32 4, i32 1, i32* %0)
%25 = load i32, i32* %6
%26 = icmp slt i32 %25, %2
%27 = icmp sgt i32 %25, %3
%28 = or i1 %26, %27
%29 = zext i1 %28 to i32
%30 = add nuw nsw i32 %19, %29
%31 = add nuw nsw i64 %18, 1
%32 = icmp eq i64 %31, %16
br i1 %32, label %33, label %17
33: ; preds = %17, %4
%34 = phi i32 [ 0, %4 ], [ %30, %17 ]
%35 = icmp eq i32 %11, 0
%36 = select i1 %35, i32 -1, i32 %34
ret i32 %36
}