; LLVM IR from niessner/Matterport :: code/gaps/pkgs/R2Shapes/R3Matrix.ll (ZNK8R3Matrix11IsIsotropicEv)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%class.R3Matrix = type { [3 x [3 x double]] }

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i32 @_ZNK8R3Matrix11IsIsotropicEv(ptr noundef nonnull align 8 dereferenceable(72) %0) #0 align 2 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca double, align 8
  %5 = alloca double, align 8
  %6 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  %7 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  %8 = getelementptr inbounds %class.R3Matrix, ptr %7, i32 0, i32 0
  %9 = getelementptr inbounds [3 x [3 x double]], ptr %8, i64 0, i64 0
  %10 = getelementptr inbounds [3 x double], ptr %9, i64 0, i64 0
  %11 = load double, ptr %10, align 8, !tbaa !9
  %12 = getelementptr inbounds %class.R3Matrix, ptr %7, i32 0, i32 0
  %13 = getelementptr inbounds [3 x [3 x double]], ptr %12, i64 0, i64 0
  %14 = getelementptr inbounds [3 x double], ptr %13, i64 0, i64 0
  %15 = load double, ptr %14, align 8, !tbaa !9
  %16 = getelementptr inbounds %class.R3Matrix, ptr %7, i32 0, i32 0
  %17 = getelementptr inbounds [3 x [3 x double]], ptr %16, i64 0, i64 1
  %18 = getelementptr inbounds [3 x double], ptr %17, i64 0, i64 0
  %19 = load double, ptr %18, align 8, !tbaa !9
  %20 = getelementptr inbounds %class.R3Matrix, ptr %7, i32 0, i32 0
  %21 = getelementptr inbounds [3 x [3 x double]], ptr %20, i64 0, i64 1
  %22 = getelementptr inbounds [3 x double], ptr %21, i64 0, i64 0
  %23 = load double, ptr %22, align 8, !tbaa !9
  %24 = fmul double %19, %23
  %25 = call double @llvm.fmuladd.f64(double %11, double %15, double %24)
  %26 = getelementptr inbounds %class.R3Matrix, ptr %7, i32 0, i32 0
  %27 = getelementptr inbounds [3 x [3 x double]], ptr %26, i64 0, i64 2
  %28 = getelementptr inbounds [3 x double], ptr %27, i64 0, i64 0
  %29 = load double, ptr %28, align 8, !tbaa !9
  %30 = getelementptr inbounds %class.R3Matrix, ptr %7, i32 0, i32 0
  %31 = getelementptr inbounds [3 x [3 x double]], ptr %30, i64 0, i64 2
  %32 = getelementptr inbounds [3 x double], ptr %31, i64 0, i64 0
  %33 = load double, ptr %32, align 8, !tbaa !9
  %34 = call double @llvm.fmuladd.f64(double %29, double %33, double %25)
  store double %34, ptr %4, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %35 = getelementptr inbounds %class.R3Matrix, ptr %7, i32 0, i32 0
  %36 = getelementptr inbounds [3 x [3 x double]], ptr %35, i64 0, i64 0
  %37 = getelementptr inbounds [3 x double], ptr %36, i64 0, i64 1
  %38 = load double, ptr %37, align 8, !tbaa !9
  %39 = getelementptr inbounds %class.R3Matrix, ptr %7, i32 0, i32 0
  %40 = getelementptr inbounds [3 x [3 x double]], ptr %39, i64 0, i64 0
  %41 = getelementptr inbounds [3 x double], ptr %40, i64 0, i64 1
  %42 = load double, ptr %41, align 8, !tbaa !9
  %43 = getelementptr inbounds %class.R3Matrix, ptr %7, i32 0, i32 0
  %44 = getelementptr inbounds [3 x [3 x double]], ptr %43, i64 0, i64 1
  %45 = getelementptr inbounds [3 x double], ptr %44, i64 0, i64 1
  %46 = load double, ptr %45, align 8, !tbaa !9
  %47 = getelementptr inbounds %class.R3Matrix, ptr %7, i32 0, i32 0
  %48 = getelementptr inbounds [3 x [3 x double]], ptr %47, i64 0, i64 1
  %49 = getelementptr inbounds [3 x double], ptr %48, i64 0, i64 1
  %50 = load double, ptr %49, align 8, !tbaa !9
  %51 = fmul double %46, %50
  %52 = call double @llvm.fmuladd.f64(double %38, double %42, double %51)
  %53 = getelementptr inbounds %class.R3Matrix, ptr %7, i32 0, i32 0
  %54 = getelementptr inbounds [3 x [3 x double]], ptr %53, i64 0, i64 2
  %55 = getelementptr inbounds [3 x double], ptr %54, i64 0, i64 1
  %56 = load double, ptr %55, align 8, !tbaa !9
  %57 = getelementptr inbounds %class.R3Matrix, ptr %7, i32 0, i32 0
  %58 = getelementptr inbounds [3 x [3 x double]], ptr %57, i64 0, i64 2
  %59 = getelementptr inbounds [3 x double], ptr %58, i64 0, i64 1
  %60 = load double, ptr %59, align 8, !tbaa !9
  %61 = call double @llvm.fmuladd.f64(double %56, double %60, double %52)
  store double %61, ptr %5, align 8, !tbaa !9
  %62 = load double, ptr %4, align 8, !tbaa !9
  %63 = load double, ptr %5, align 8, !tbaa !9
  %64 = fcmp une double %62, %63
  br i1 %64, label %65, label %66

65:                                               ; preds = %1
  store i32 0, ptr %2, align 4
  store i32 1, ptr %6, align 4
  br label %67

66:                                               ; preds = %1
  store i32 1, ptr %2, align 4
  store i32 1, ptr %6, align 4
  br label %67

67:                                               ; preds = %66, %65
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  %68 = load i32, ptr %2, align 4
  ret i32 %68
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #2

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

attributes #0 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) uwtable
define dso_local noundef range(i32 0, 2) i32 @_ZNK8R3Matrix11IsIsotropicEv(ptr nocapture noundef nonnull readonly align 8 dereferenceable(72) %0) local_unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 24
  %3 = getelementptr inbounds i8, ptr %0, i64 48
  %4 = load <2 x double>, ptr %0, align 8, !tbaa !5
  %5 = load <2 x double>, ptr %2, align 8, !tbaa !5
  %6 = fmul <2 x double> %5, %5
  %7 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %4, <2 x double> %4, <2 x double> %6)
  %8 = load <2 x double>, ptr %3, align 8, !tbaa !5
  %9 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %8, <2 x double> %8, <2 x double> %7)
  %10 = extractelement <2 x double> %9, i64 0
  %11 = extractelement <2 x double> %9, i64 1
  %12 = fcmp oeq double %10, %11
  %. = zext i1 %12 to i32
  ret i32 %.
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <2 x double> @llvm.fmuladd.v2f64(<2 x double>, <2 x double>, <2 x double>) #1

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GlobalDCEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass