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

/* Variables and functions */
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
void check_range(double *v, int n, int dim) {
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < dim; j++) {
      if (!(v[dim * i + j] < 1000.0 && v[dim * i + j] > -1000.0)) {
        printf("Error: The array contains out of range values: %f\n",
               v[dim * i + j]);
        exit(0);
      }
    }
  }
  printf("PASS\n");
}


x86 assembly (clang, -O0):
<check_range>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11f5 <check_range+0xd5>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11e2 <check_range+0xc2>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
imul   -0x14(%rbp),%ecx
add    -0x18(%rbp),%ecx
movslq %ecx,%rcx
movsd  0xe8f(%rip),%xmm0
ucomisd (%rax,%rcx,8),%xmm0
jbe    11a4 <check_range+0x84>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
imul   -0x14(%rbp),%ecx
add    -0x18(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  0xe6e(%rip),%xmm1
ucomisd %xmm1,%xmm0
ja     11cf <check_range+0xaf>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
imul   -0x14(%rbp),%ecx
add    -0x18(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xe4f(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %edi,%edi
call   1040 <exit@plt>
jmp    11d4 <check_range+0xb4>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    114c <check_range+0x2c>
jmp    11e7 <check_range+0xc7>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1139 <check_range+0x19>
lea    0xe47(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_range>:
push   %rax
test   %esi,%esi
jle    119c <check_range+0x6c>
movslq %edx,%r9
mov    %esi,%r8d
mov    %r9d,%esi
shl    $0x3,%r9
xor    %ecx,%ecx
movsd  0xeb4(%rip),%xmm1
movsd  0xeb4(%rip),%xmm2
jmp    116c <check_range+0x3c>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%rcx
add    %r9,%rdi
cmp    %r8,%rcx
je     119c <check_range+0x6c>
test   %edx,%edx
jle    1160 <check_range+0x30>
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsd  (%rdi,%rax,8),%xmm0
ucomisd %xmm0,%xmm1
jbe    11a9 <check_range+0x79>
ucomisd %xmm2,%xmm0
jbe    11a9 <check_range+0x79>
add    $0x1,%rax
cmp    %rax,%rsi
jne    1180 <check_range+0x50>
jmp    1160 <check_range+0x30>
lea    0xea0(%rip),%rdi
pop    %rax
jmp    1030 <puts@plt>
lea    0xe60(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %edi,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [51 x i8] c"Error: The array contains out of range values: %f\0A\00"
@.str.1 = [6 x i8] c"PASS\0A\00"
define void @check_range(double* %0, i32 %1, i32 %2) {
%4 = alloca double*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store double* %0, double** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
store i32 0, i32* %7
br label %9
9: ; preds = %57, %3
%10 = load i32, i32* %7
%11 = load i32, i32* %5
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %60
13: ; preds = %9
store i32 0, i32* %8
br label %14
14: ; preds = %53, %13
%15 = load i32, i32* %8
%16 = load i32, i32* %6
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %56
18: ; preds = %14
%19 = load double*, double** %4
%20 = load i32, i32* %6
%21 = load i32, i32* %7
%22 = mul nsw i32 %20, %21
%23 = load i32, i32* %8
%24 = add nsw i32 %22, %23
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds double, double* %19, i64 %25
%27 = load double, double* %26
%28 = fcmp olt double %27, 1.000000e+03
br i1 %28, label %29, label %40
29: ; preds = %18
%30 = load double*, double** %4
%31 = load i32, i32* %6
%32 = load i32, i32* %7
%33 = mul nsw i32 %31, %32
%34 = load i32, i32* %8
%35 = add nsw i32 %33, %34
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds double, double* %30, i64 %36
%38 = load double, double* %37
%39 = fcmp ogt double %38, -1.000000e+03
br i1 %39, label %52, label %40
40: ; preds = %29, %18
%41 = load double*, double** %4
%42 = load i32, i32* %6
%43 = load i32, i32* %7
%44 = mul nsw i32 %42, %43
%45 = load i32, i32* %8
%46 = add nsw i32 %44, %45
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds double, double* %41, i64 %47
%49 = load double, double* %48
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0), double %49)
%51 = call i32 @exit(i32 0)
unreachable
52: ; preds = %29
br label %53
53: ; preds = %52
%54 = load i32, i32* %8
%55 = add nsw i32 %54, 1
store i32 %55, i32* %8
br label %14
56: ; preds = %14
br label %57
57: ; preds = %56
%58 = load i32, i32* %7
%59 = add nsw i32 %58, 1
store i32 %59, i32* %7
br label %9
60: ; preds = %9
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [51 x i8] c"Error: The array contains out of range values: %f\0A\00"
@str = [5 x i8] c"PASS\00"
define void @check_range(double* nocapture %0, i32 %1, i32 %2) {
%4 = icmp sgt i32 %1, 0
br i1 %4, label %5, label %14
5: ; preds = %3
%6 = icmp sgt i32 %2, 0
%7 = sext i32 %2 to i64
%8 = zext i32 %1 to i64
%9 = zext i32 %2 to i64
br label %10
10: ; preds = %5, %18
%11 = phi i64 [ 0, %5 ], [ %19, %18 ]
br i1 %6, label %12, label %18
12: ; preds = %10
%13 = mul nsw i64 %11, %7
br label %21
14: ; preds = %18, %3
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str, i64 0, i64 0))
ret void
16: ; preds = %21
%17 = icmp eq i64 %29, %9
br i1 %17, label %18, label %21
18: ; preds = %16, %10
%19 = add nuw nsw i64 %11, 1
%20 = icmp eq i64 %19, %8
br i1 %20, label %14, label %10
21: ; preds = %12, %16
%22 = phi i64 [ 0, %12 ], [ %29, %16 ]
%23 = add nsw i64 %22, %13
%24 = getelementptr inbounds double, double* %0, i64 %23
%25 = load double, double* %24
%26 = fcmp olt double %25, 1.000000e+03
%27 = fcmp ogt double %25, -1.000000e+03
%28 = and i1 %26, %27
%29 = add nuw nsw i64 %22, 1
br i1 %28, label %16, label %30
30: ; preds = %21
%31 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0), double %25)
%32 = tail call i32 @exit(i32 0)
unreachable
}