#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*/ fprintf(int /*<<< orphan*/, char *, char const *);
int is_uniform_array_value(double const *const, size_t const, double const,
                           int *);
int /*<<< orphan*/ print_array_index_error(char const *, int,
                                           double const *const, double const);
int /*<<< orphan*/ stderr;
bool check_uniform_array_value(const double *const arr, const size_t size,
                               const char *arr_name, const double expected) {
  int invalid_entries[size];
  for (size_t i = 0; i < size; ++i)
    invalid_entries[i] = -1;
  bool valid = is_uniform_array_value(arr, size, expected, invalid_entries);
  if (!valid) {
    fprintf(stderr, "Wrong values for %s!\n", arr_name);
    size_t _index = 0;
    while (_index < size && invalid_entries[_index] != -1) {
      print_array_index_error(arr_name, invalid_entries[_index], arr, expected);
      _index++;
    }
  }
  return valid;
}


x86 assembly (clang, -O0):
<check_uniform_array_value>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movsd  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    %rsp,%rcx
mov    %rcx,-0x28(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x50(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    11a7 <check_uniform_array_value+0x77>
mov    -0x50(%rbp),%rax
mov    -0x38(%rbp),%rcx
movl   $0xffffffff,(%rax,%rcx,4)
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    1179 <check_uniform_array_value+0x49>
mov    -0x50(%rbp),%rdx
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
movsd  -0x20(%rbp),%xmm0
call   1050 <is_uniform_array_value@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,-0x3c(%rbp)
jne    1253 <check_uniform_array_value+0x123>
mov    0x2e0f(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xe22(%rip),%rsi
call   1030 <fprintf@plt>
movq   $0x0,-0x48(%rbp)
mov    -0x48(%rbp),%rcx
xor    %eax,%eax
cmp    -0x10(%rbp),%rcx
mov    %al,-0x51(%rbp)
jae    1210 <check_uniform_array_value+0xe0>
mov    -0x50(%rbp),%rax
mov    -0x48(%rbp),%rcx
cmpl   $0xffffffff,(%rax,%rcx,4)
setne  %al
mov    %al,-0x51(%rbp)
mov    -0x51(%rbp),%al
test   $0x1,%al
jne    1220 <check_uniform_array_value+0xf0>
jmp    124e <check_uniform_array_value+0x11e>
mov    -0x50(%rbp),%rax
mov    -0x18(%rbp),%rdi
mov    -0x48(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
mov    -0x8(%rbp),%rdx
movsd  -0x20(%rbp),%xmm0
call   1040 <print_array_index_error@plt>
mov    -0x48(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x48(%rbp)
jmp    11eb <check_uniform_array_value+0xbb>
jmp    1253 <check_uniform_array_value+0x123>
mov    -0x3c(%rbp),%eax
mov    -0x28(%rbp),%rcx
mov    %rcx,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_uniform_array_value>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
movsd  %xmm0,-0x38(%rbp)
mov    %rdx,%r14
mov    %rsi,%r12
mov    %rdi,%r15
mov    %rsp,%rbx
lea    0xf(,%rsi,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
test   %rsi,%rsi
je     118e <check_uniform_array_value+0x4e>
lea    0x0(,%r12,4),%rdx
mov    %rbx,%rdi
mov    $0xff,%esi
call   1030 <memset@plt>
mov    %r15,%rdi
mov    %r12,%rsi
movsd  -0x38(%rbp),%xmm0
mov    %rbx,%rdx
call   1060 <is_uniform_array_value@plt>
mov    %eax,-0x2c(%rbp)
test   %eax,%eax
je     11ba <check_uniform_array_value+0x7a>
mov    -0x2c(%rbp),%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2e1f(%rip),%rax
mov    (%rax),%edi
lea    0xe36(%rip),%rsi
mov    %r14,%rdx
call   1040 <fprintf@plt>
test   %r12,%r12
je     11a8 <check_uniform_array_value+0x68>
xor    %r13d,%r13d
nopw   0x0(%rax,%rax,1)
mov    (%rbx,%r13,4),%esi
cmp    $0xffffffff,%esi
je     11a8 <check_uniform_array_value+0x68>
mov    %r14,%rdi
mov    %r15,%rdx
movsd  -0x38(%rbp),%xmm0
call   1050 <print_array_index_error@plt>
add    $0x1,%r13
cmp    %r13,%r12
jne    11e0 <check_uniform_array_value+0xa0>
jmp    11a8 <check_uniform_array_value+0x68>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [22 x i8] c"Wrong values for %s!\0A\00"
define i32 @check_uniform_array_value(double* %0, i64 %1, i8* %2, double %3) {
%5 = alloca double*
%6 = alloca i64
%7 = alloca i8*
%8 = alloca double
%9 = alloca i8*
%10 = alloca i64
%11 = alloca i64
%12 = alloca i32
%13 = alloca i64
store double* %0, double** %5
store i64 %1, i64* %6
store i8* %2, i8** %7
store double %3, double* %8
%14 = load i64, i64* %6
%15 = call i8* @llvm.stacksave()
store i8* %15, i8** %9
%16 = alloca i32, i64 %14
store i64 %14, i64* %10
store i64 0, i64* %11
br label %17
17: ; preds = %24, %4
%18 = load i64, i64* %11
%19 = load i64, i64* %6
%20 = icmp ult i64 %18, %19
br i1 %20, label %21, label %27
21: ; preds = %17
%22 = load i64, i64* %11
%23 = getelementptr inbounds i32, i32* %16, i64 %22
store i32 -1, i32* %23
br label %24
24: ; preds = %21
%25 = load i64, i64* %11
%26 = add i64 %25, 1
store i64 %26, i64* %11
br label %17
27: ; preds = %17
%28 = load double*, double** %5
%29 = load i64, i64* %6
%30 = load double, double* %8
%31 = call i32 @is_uniform_array_value(double* %28, i64 %29, double %30, i32* %16)
store i32 %31, i32* %12
%32 = load i32, i32* %12
%33 = icmp ne i32 %32, 0
br i1 %33, label %60, label %34
34: ; preds = %27
%35 = load i32, i32* @stderr
%36 = load i8*, i8** %7
%37 = call i32 @fprintf(i32 %35, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %36)
store i64 0, i64* %13
br label %38
38: ; preds = %49, %34
%39 = load i64, i64* %13
%40 = load i64, i64* %6
%41 = icmp ult i64 %39, %40
br i1 %41, label %42, label %47
42: ; preds = %38
%43 = load i64, i64* %13
%44 = getelementptr inbounds i32, i32* %16, i64 %43
%45 = load i32, i32* %44
%46 = icmp ne i32 %45, -1
br label %47
47: ; preds = %42, %38
%48 = phi i1 [ false, %38 ], [ %46, %42 ]
br i1 %48, label %49, label %59
49: ; preds = %47
%50 = load i8*, i8** %7
%51 = load i64, i64* %13
%52 = getelementptr inbounds i32, i32* %16, i64 %51
%53 = load i32, i32* %52
%54 = load double*, double** %5
%55 = load double, double* %8
%56 = call i32 @print_array_index_error(i8* %50, i32 %53, double* %54, double %55)
%57 = load i64, i64* %13
%58 = add i64 %57, 1
store i64 %58, i64* %13
br label %38
59: ; preds = %47
br label %60
60: ; preds = %59, %27
%61 = load i32, i32* %12
%62 = load i8*, i8** %9
ret i32 %61
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [22 x i8] c"Wrong values for %s!\0A\00"
define i32 @check_uniform_array_value(double* %0, i64 %1, i8* %2, double %3) {
%5 = alloca i32, i64 %1
%6 = icmp eq i64 %1, 0
br i1 %6, label %10, label %7
7: ; preds = %4
%8 = bitcast i32* %5 to i8*
%9 = shl nuw i64 %1, 2
br label %10
10: ; preds = %7, %4
%11 = call i32 @is_uniform_array_value(double* %0, i64 %1, double %3, i32* %5)
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %25
13: ; preds = %10
%14 = load i32, i32* @stderr
%15 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %2)
br i1 %6, label %25, label %16
16: ; preds = %13, %21
%17 = phi i64 [ %23, %21 ], [ 0, %13 ]
%18 = getelementptr inbounds i32, i32* %5, i64 %17
%19 = load i32, i32* %18
%20 = icmp eq i32 %19, -1
br i1 %20, label %25, label %21
21: ; preds = %16
%22 = call i32 @print_array_index_error(i8* %2, i32 %19, double* %0, double %3)
%23 = add nuw i64 %17, 1
%24 = icmp eq i64 %23, %1
br i1 %24, label %25, label %16
25: ; preds = %21, %16, %13, %10
ret i32 %11
}