#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(double);
int mat3_cmpV(double A[3][3], double B[3][3], double precision) {
  int c, r, ret;
  ret = 0;
  for (c = 0; c < 3; c++) {
    for (r = 0; r < 3; r++) {
      if (fabs(A[r][c] - B[r][c]) > precision) {
        ret = ret + 1;
      }
    }
  }
  return ret;
}


x86 assembly (clang, -O0):
<mat3_cmpV>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x3,-0x1c(%rbp)
jge    11af <mat3_cmpV+0xaf>
movl   $0x0,-0x20(%rbp)
cmpl   $0x3,-0x20(%rbp)
jge    119c <mat3_cmpV+0x9c>
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movslq -0x1c(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
movaps 0xe8f(%rip),%xmm1
pand   %xmm1,%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    1189 <mat3_cmpV+0x89>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    118e <mat3_cmpV+0x8e>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1130 <mat3_cmpV+0x30>
jmp    11a1 <mat3_cmpV+0xa1>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    111f <mat3_cmpV+0x1f>
mov    -0x24(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<mat3_cmpV>:
movupd (%rdi),%xmm1
movupd 0x10(%rdi),%xmm2
movupd 0x20(%rdi),%xmm3
movupd 0x30(%rdi),%xmm4
movupd (%rsi),%xmm5
subpd  %xmm5,%xmm1
movupd 0x10(%rsi),%xmm5
subpd  %xmm5,%xmm2
movupd 0x20(%rsi),%xmm5
subpd  %xmm5,%xmm3
movupd 0x30(%rsi),%xmm5
subpd  %xmm5,%xmm4
movapd 0xec2(%rip),%xmm5
andpd  %xmm5,%xmm1
andpd  %xmm5,%xmm2
andpd  %xmm5,%xmm3
andpd  %xmm5,%xmm4
movsd  0x40(%rdi),%xmm6
subsd  0x40(%rsi),%xmm6
andpd  %xmm5,%xmm6
xor    %ecx,%ecx
ucomisd %xmm0,%xmm6
unpcklpd %xmm0,%xmm0
seta   %cl
movapd %xmm0,%xmm5
cmpltpd %xmm4,%xmm5
movapd %xmm0,%xmm4
cmpltpd %xmm3,%xmm4
packssdw %xmm5,%xmm4
movapd %xmm0,%xmm3
cmpltpd %xmm2,%xmm3
cmpltpd %xmm1,%xmm0
packssdw %xmm3,%xmm0
packssdw %xmm4,%xmm0
packsswb %xmm0,%xmm0
pmovmskb %xmm0,%eax
mov    %eax,%edx
shr    %dl
and    $0x55,%dl
sub    %dl,%al
mov    %eax,%edx
and    $0x33,%dl
shr    $0x2,%al
and    $0x33,%al
add    %dl,%al
mov    %eax,%edx
shr    $0x4,%dl
add    %al,%dl
and    $0xf,%dl
movzbl %dl,%eax
add    %ecx,%eax
ret

LLVM IR (-O0):
define i32 @mat3_cmpV([3 x double]* %0, [3 x double]* %1, double %2) {
%4 = alloca [3 x double]*
%5 = alloca [3 x double]*
%6 = alloca double
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store [3 x double]* %0, [3 x double]** %4
store [3 x double]* %1, [3 x double]** %5
store double %2, double* %6
store i32 0, i32* %9
store i32 0, i32* %7
br label %10
10: ; preds = %46, %3
%11 = load i32, i32* %7
%12 = icmp slt i32 %11, 3
br i1 %12, label %13, label %49
13: ; preds = %10
store i32 0, i32* %8
br label %14
14: ; preds = %42, %13
%15 = load i32, i32* %8
%16 = icmp slt i32 %15, 3
br i1 %16, label %17, label %45
17: ; preds = %14
%18 = load [3 x double]*, [3 x double]** %4
%19 = load i32, i32* %8
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [3 x double], [3 x double]* %18, i64 %20
%22 = load i32, i32* %7
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [3 x double], [3 x double]* %21, i64 0, i64 %23
%25 = load double, double* %24
%26 = load [3 x double]*, [3 x double]** %5
%27 = load i32, i32* %8
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [3 x double], [3 x double]* %26, i64 %28
%30 = load i32, i32* %7
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [3 x double], [3 x double]* %29, i64 0, i64 %31
%33 = load double, double* %32
%34 = fsub double %25, %33
%35 = call double @llvm.fabs.f64(double %34)
%36 = load double, double* %6
%37 = fcmp ogt double %35, %36
br i1 %37, label %38, label %41
38: ; preds = %17
%39 = load i32, i32* %9
%40 = add nsw i32 %39, 1
store i32 %40, i32* %9
br label %41
41: ; preds = %38, %17
br label %42
42: ; preds = %41
%43 = load i32, i32* %8
%44 = add nsw i32 %43, 1
store i32 %44, i32* %8
br label %14
45: ; preds = %14
br label %46
46: ; preds = %45
%47 = load i32, i32* %7
%48 = add nsw i32 %47, 1
store i32 %48, i32* %7
br label %10
49: ; preds = %10
%50 = load i32, i32* %9
ret i32 %50
}

LLVM IR (-O2):
define i32 @mat3_cmpV([3 x double]* nocapture %0, [3 x double]* nocapture %1, double %2) {
%4 = bitcast [3 x double]* %0 to <8 x double>*
%5 = load <8 x double>, <8 x double>* %4
%6 = bitcast [3 x double]* %1 to <8 x double>*
%7 = load <8 x double>, <8 x double>* %6
%8 = fsub <8 x double> %5, %7
%9 = call <8 x double> @llvm.fabs.v8f64(<8 x double> %8)
%10 = insertelement <8 x double> poison, double %2, i64 0
%11 = shufflevector <8 x double> %10, <8 x double> poison, <8 x i32> zeroinitializer
%12 = fcmp ogt <8 x double> %9, %11
%13 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 2, i64 2
%14 = load double, double* %13
%15 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 2, i64 2
%16 = load double, double* %15
%17 = fsub double %14, %16
%18 = tail call double @llvm.fabs.f64(double %17)
%19 = fcmp ogt double %18, %2
%20 = zext i1 %19 to i32
%21 = bitcast <8 x i1> %12 to i8
%22 = call i8 @llvm.ctpop.i8(i8 %21)
%23 = zext i8 %22 to i32
%24 = add nuw nsw i32 %23, %20
ret i32 %24
}