#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 */
double fabs(float);
scalar_t__ isnan(float);
int /*<<< orphan*/ printf(char *, float, float, ...);
bool _assertFloatArrayEquals(float *expected, float *actual, int length,
                             double epsilon, int line) {
  int i;
  if (length <= 0) {
    printf("assertFloatArrayEquals FAILED, line: %i, negative or zero array "
           "length: %i",
           line, length);
    return false;
  }
  for (i = 0; i < length; i++) {
    if (isnan(expected[i]) || isnan(actual[i]) ||
        fabs(expected[i] - actual[i]) > epsilon) {
      printf("assertFloatArrayEquals FAILED, line: %i, on index %i with array "
             "length %i\n",
             line, i, length);
      printf("expected: %e, actual: %e, difference: %e\n", expected[i],
             actual[i], expected[i] - actual[i]);
      return false;
    }
  }
  return true;
}


x86 assembly (clang, -O0):
<_assertFloatArrayEquals>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
movsd  %xmm0,-0x28(%rbp)
mov    %ecx,-0x2c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jg     1179 <_assertFloatArrayEquals+0x49>
cvtsi2ssl -0x2c(%rbp),%xmm0
cvtsi2ssl -0x1c(%rbp),%xmm1
lea    0xe9a(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1275 <_assertFloatArrayEquals+0x145>
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    126e <_assertFloatArrayEquals+0x13e>
mov    -0x10(%rbp),%rax
movslq -0x30(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
call   1050 <isnan@plt>
cmp    $0x0,%rax
jne    11ee <_assertFloatArrayEquals+0xbe>
mov    -0x18(%rbp),%rax
movslq -0x30(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
call   1050 <isnan@plt>
cmp    $0x0,%rax
jne    11ee <_assertFloatArrayEquals+0xbe>
mov    -0x10(%rbp),%rax
movslq -0x30(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x30(%rbp),%rcx
subss  (%rax,%rcx,4),%xmm0
call   1040 <fabs@plt>
ucomisd -0x28(%rbp),%xmm0
jbe    125b <_assertFloatArrayEquals+0x12b>
cvtsi2ssl -0x2c(%rbp),%xmm0
cvtsi2ssl -0x30(%rbp),%xmm1
mov    -0x1c(%rbp),%esi
lea    0xe49(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
movslq -0x30(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x30(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm1
mov    -0x10(%rbp),%rax
movslq -0x30(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm2
mov    -0x18(%rbp),%rax
movslq -0x30(%rbp),%rcx
subss  (%rax,%rcx,4),%xmm2
cvtss2sd %xmm2,%xmm2
lea    0xe4e(%rip),%rdi
mov    $0x3,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1275 <_assertFloatArrayEquals+0x145>
jmp    1260 <_assertFloatArrayEquals+0x130>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1180 <_assertFloatArrayEquals+0x50>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_assertFloatArrayEquals>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %ecx,%r15d
movsd  %xmm0,0x8(%rsp)
test   %edx,%edx
jle    11ea <_assertFloatArrayEquals+0xba>
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %edx,%r12d
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
movss  (%rbx,%rbp,4),%xmm0
call   1050 <isnan@plt>
test   %rax,%rax
jne    11a7 <_assertFloatArrayEquals+0x77>
movss  (%r14,%rbp,4),%xmm0
call   1050 <isnan@plt>
test   %rax,%rax
jne    11a7 <_assertFloatArrayEquals+0x77>
movss  (%rbx,%rbp,4),%xmm0
subss  (%r14,%rbp,4),%xmm0
call   1040 <fabs@plt>
ucomisd 0x8(%rsp),%xmm0
ja     11a7 <_assertFloatArrayEquals+0x77>
add    $0x1,%rbp
cmp    %rbp,%r12
jne    1160 <_assertFloatArrayEquals+0x30>
mov    $0x1,%eax
jmp    1206 <_assertFloatArrayEquals+0xd6>
xorps  %xmm0,%xmm0
cvtsi2ss %r15d,%xmm0
cvtsi2ss %ebp,%xmm1
lea    0xe91(%rip),%rdi
mov    %r12d,%esi
mov    $0x2,%al
call   1030 <printf@plt>
movss  (%rbx,%rbp,4),%xmm0
movss  (%r14,%rbp,4),%xmm1
movaps %xmm0,%xmm2
subss  %xmm1,%xmm2
cvtss2sd %xmm2,%xmm2
lea    0xeb5(%rip),%rdi
mov    $0x3,%al
call   1030 <printf@plt>
jmp    1204 <_assertFloatArrayEquals+0xd4>
xorps  %xmm0,%xmm0
cvtsi2ss %r15d,%xmm0
cvtsi2ss %edx,%xmm1
lea    0xe03(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [75 x i8] c"assertFloatArrayEquals FAILED, line: %i, negative or zero array length: %i\00"
@.str.1 = [75 x i8] c"assertFloatArrayEquals FAILED, line: %i, on index %i with array length %i\0A\00"
@.str.2 = [42 x i8] c"expected: %e, actual: %e, difference: %e\0A\00"
define i32 @_assertFloatArrayEquals(float* %0, float* %1, i32 %2, double %3, i32 %4) {
%6 = alloca i32
%7 = alloca float*
%8 = alloca float*
%9 = alloca i32
%10 = alloca double
%11 = alloca i32
%12 = alloca i32
store float* %0, float** %7
store float* %1, float** %8
store i32 %2, i32* %9
store double %3, double* %10
store i32 %4, i32* %11
%13 = load i32, i32* %9
%14 = icmp sle i32 %13, 0
br i1 %14, label %15, label %21
15: ; preds = %5
%16 = load i32, i32* %11
%17 = sitofp i32 %16 to float
%18 = load i32, i32* %9
%19 = sitofp i32 %18 to float
%20 = call i32 (i8*, float, float, ...) @printf(i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str, i64 0, i64 0), float %17, float %19)
store i32 0, i32* %6
br label %92
21: ; preds = %5
store i32 0, i32* %12
br label %22
22: ; preds = %88, %21
%23 = load i32, i32* %12
%24 = load i32, i32* %9
%25 = icmp slt i32 %23, %24
br i1 %25, label %26, label %91
26: ; preds = %22
%27 = load float*, float** %7
%28 = load i32, i32* %12
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds float, float* %27, i64 %29
%31 = load float, float* %30
%32 = call i64 @isnan(float %31)
%33 = icmp ne i64 %32, 0
br i1 %33, label %57, label %34
34: ; preds = %26
%35 = load float*, float** %8
%36 = load i32, i32* %12
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds float, float* %35, i64 %37
%39 = load float, float* %38
%40 = call i64 @isnan(float %39)
%41 = icmp ne i64 %40, 0
br i1 %41, label %57, label %42
42: ; preds = %34
%43 = load float*, float** %7
%44 = load i32, i32* %12
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds float, float* %43, i64 %45
%47 = load float, float* %46
%48 = load float*, float** %8
%49 = load i32, i32* %12
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds float, float* %48, i64 %50
%52 = load float, float* %51
%53 = fsub float %47, %52
%54 = call double @fabs(float %53)
%55 = load double, double* %10
%56 = fcmp ogt double %54, %55
br i1 %56, label %57, label %87
57: ; preds = %42, %34, %26
%58 = load i32, i32* %11
%59 = sitofp i32 %58 to float
%60 = load i32, i32* %12
%61 = sitofp i32 %60 to float
%62 = load i32, i32* %9
%63 = call i32 (i8*, float, float, ...) @printf(i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str.1, i64 0, i64 0), float %59, float %61, i32 %62)
%64 = load float*, float** %7
%65 = load i32, i32* %12
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds float, float* %64, i64 %66
%68 = load float, float* %67
%69 = load float*, float** %8
%70 = load i32, i32* %12
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds float, float* %69, i64 %71
%73 = load float, float* %72
%74 = load float*, float** %7
%75 = load i32, i32* %12
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds float, float* %74, i64 %76
%78 = load float, float* %77
%79 = load float*, float** %8
%80 = load i32, i32* %12
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds float, float* %79, i64 %81
%83 = load float, float* %82
%84 = fsub float %78, %83
%85 = fpext float %84 to double
%86 = call i32 (i8*, float, float, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0), float %68, float %73, double %85)
store i32 0, i32* %6
br label %92
87: ; preds = %42
br label %88
88: ; preds = %87
%89 = load i32, i32* %12
%90 = add nsw i32 %89, 1
store i32 %90, i32* %12
br label %22
91: ; preds = %22
store i32 1, i32* %6
br label %92
92: ; preds = %91, %57, %15
%93 = load i32, i32* %6
ret i32 %93
}

LLVM IR (-O2):
@.str = [75 x i8] c"assertFloatArrayEquals FAILED, line: %i, negative or zero array length: %i\00"
@.str.1 = [75 x i8] c"assertFloatArrayEquals FAILED, line: %i, on index %i with array length %i\0A\00"
@.str.2 = [42 x i8] c"expected: %e, actual: %e, difference: %e\0A\00"
define i32 @_assertFloatArrayEquals(float* nocapture %0, float* nocapture %1, i32 %2, double %3, i32 %4) {
%6 = icmp slt i32 %2, 1
br i1 %6, label %9, label %7
7: ; preds = %5
%8 = zext i32 %2 to i64
br label %13
9: ; preds = %5
%10 = sitofp i32 %4 to float
%11 = sitofp i32 %2 to float
%12 = tail call i32 (i8*, float, float, ...) @printf(i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str, i64 0, i64 0), float %10, float %11)
br label %45
13: ; preds = %7, %42
%14 = phi i64 [ 0, %7 ], [ %43, %42 ]
%15 = getelementptr inbounds float, float* %0, i64 %14
%16 = load float, float* %15
%17 = tail call i64 @isnan(float %16)
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %30
19: ; preds = %13
%20 = getelementptr inbounds float, float* %1, i64 %14
%21 = load float, float* %20
%22 = tail call i64 @isnan(float %21)
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %30
24: ; preds = %19
%25 = load float, float* %15
%26 = load float, float* %20
%27 = fsub float %25, %26
%28 = tail call double @fabs(float %27)
%29 = fcmp ogt double %28, %3
br i1 %29, label %30, label %42
30: ; preds = %24, %19, %13
%31 = trunc i64 %14 to i32
%32 = and i64 %14, 4294967295
%33 = sitofp i32 %4 to float
%34 = sitofp i32 %31 to float
%35 = tail call i32 (i8*, float, float, ...) @printf(i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str.1, i64 0, i64 0), float %33, float %34, i32 %2)
%36 = load float, float* %15
%37 = getelementptr inbounds float, float* %1, i64 %32
%38 = load float, float* %37
%39 = fsub float %36, %38
%40 = fpext float %39 to double
%41 = tail call i32 (i8*, float, float, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0), float %36, float %38, double %40)
br label %45
42: ; preds = %24
%43 = add nuw nsw i64 %14, 1
%44 = icmp eq i64 %43, %8
br i1 %44, label %45, label %13
45: ; preds = %42, %30, %9
%46 = phi i32 [ 0, %9 ], [ 0, %30 ], [ 1, %42 ]
ret i32 %46
}