; LLVM IR from niessner/Matterport :: code/gaps/pkgs/R3Shapes/R4Matrix.ll (ZNK8R4Matrix11IsIsotropicEv)

; 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.R4Matrix = type { [4 x [4 x double]] }

@RN_EPSILON = external global double, align 8

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

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

69:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %70 = getelementptr inbounds %class.R4Matrix, ptr %8, i32 0, i32 0
  %71 = getelementptr inbounds [4 x [4 x double]], ptr %70, i64 0, i64 0
  %72 = getelementptr inbounds [4 x double], ptr %71, i64 0, i64 2
  %73 = load double, ptr %72, align 8, !tbaa !9
  %74 = getelementptr inbounds %class.R4Matrix, ptr %8, i32 0, i32 0
  %75 = getelementptr inbounds [4 x [4 x double]], ptr %74, i64 0, i64 0
  %76 = getelementptr inbounds [4 x double], ptr %75, i64 0, i64 2
  %77 = load double, ptr %76, align 8, !tbaa !9
  %78 = getelementptr inbounds %class.R4Matrix, ptr %8, i32 0, i32 0
  %79 = getelementptr inbounds [4 x [4 x double]], ptr %78, i64 0, i64 1
  %80 = getelementptr inbounds [4 x double], ptr %79, i64 0, i64 2
  %81 = load double, ptr %80, align 8, !tbaa !9
  %82 = getelementptr inbounds %class.R4Matrix, ptr %8, i32 0, i32 0
  %83 = getelementptr inbounds [4 x [4 x double]], ptr %82, i64 0, i64 1
  %84 = getelementptr inbounds [4 x double], ptr %83, i64 0, i64 2
  %85 = load double, ptr %84, align 8, !tbaa !9
  %86 = fmul double %81, %85
  %87 = call double @llvm.fmuladd.f64(double %73, double %77, double %86)
  %88 = getelementptr inbounds %class.R4Matrix, ptr %8, i32 0, i32 0
  %89 = getelementptr inbounds [4 x [4 x double]], ptr %88, i64 0, i64 2
  %90 = getelementptr inbounds [4 x double], ptr %89, i64 0, i64 2
  %91 = load double, ptr %90, align 8, !tbaa !9
  %92 = getelementptr inbounds %class.R4Matrix, ptr %8, i32 0, i32 0
  %93 = getelementptr inbounds [4 x [4 x double]], ptr %92, i64 0, i64 2
  %94 = getelementptr inbounds [4 x double], ptr %93, i64 0, i64 2
  %95 = load double, ptr %94, align 8, !tbaa !9
  %96 = call double @llvm.fmuladd.f64(double %91, double %95, double %87)
  store double %96, ptr %7, align 8, !tbaa !9
  %97 = load double, ptr %4, align 8, !tbaa !9
  %98 = load double, ptr %7, align 8, !tbaa !9
  %99 = load double, ptr @RN_EPSILON, align 8, !tbaa !9
  %100 = call noundef i32 @_Z12RNIsNotEqualddd(double noundef %97, double noundef %98, double noundef %99)
  %101 = icmp ne i32 %100, 0
  br i1 %101, label %102, label %103

102:                                              ; preds = %69
  store i32 0, ptr %2, align 4
  store i32 1, ptr %6, align 4
  br label %104

103:                                              ; preds = %69
  store i32 1, ptr %2, align 4
  store i32 1, ptr %6, align 4
  br label %104

104:                                              ; preds = %103, %102
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  br label %105

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

; 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: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_Z12RNIsNotEqualddd(double noundef, double noundef, double noundef) #3

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

attributes #0 = { mustprogress 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 = { inlinehint mustprogress 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 #4 = { 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"

@RN_EPSILON = external local_unnamed_addr global double, align 8

; Function Attrs: mustprogress uwtable
define dso_local noundef range(i32 0, 2) i32 @_ZNK8R4Matrix11IsIsotropicEv(ptr nocapture noundef nonnull readonly align 8 dereferenceable(128) %0) local_unnamed_addr #0 align 2 {
  %2 = load double, ptr %0, align 8, !tbaa !5
  %3 = getelementptr inbounds i8, ptr %0, i64 32
  %4 = load double, ptr %3, align 8, !tbaa !5
  %5 = fmul double %4, %4
  %6 = tail call double @llvm.fmuladd.f64(double %2, double %2, double %5)
  %7 = getelementptr inbounds i8, ptr %0, i64 64
  %8 = load double, ptr %7, align 8, !tbaa !5
  %9 = tail call double @llvm.fmuladd.f64(double %8, double %8, double %6)
  %10 = getelementptr inbounds i8, ptr %0, i64 8
  %11 = load double, ptr %10, align 8, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %0, i64 40
  %13 = load double, ptr %12, align 8, !tbaa !5
  %14 = fmul double %13, %13
  %15 = tail call double @llvm.fmuladd.f64(double %11, double %11, double %14)
  %16 = getelementptr inbounds i8, ptr %0, i64 72
  %17 = load double, ptr %16, align 8, !tbaa !5
  %18 = tail call double @llvm.fmuladd.f64(double %17, double %17, double %15)
  %19 = load double, ptr @RN_EPSILON, align 8, !tbaa !5
  %20 = tail call noundef i32 @_Z12RNIsNotEqualddd(double noundef %9, double noundef %18, double noundef %19)
  %.not = icmp eq i32 %20, 0
  br i1 %.not, label %21, label %33

21:                                               ; preds = %1
  %22 = getelementptr inbounds i8, ptr %0, i64 16
  %23 = load double, ptr %22, align 8, !tbaa !5
  %24 = getelementptr inbounds i8, ptr %0, i64 48
  %25 = load double, ptr %24, align 8, !tbaa !5
  %26 = fmul double %25, %25
  %27 = tail call double @llvm.fmuladd.f64(double %23, double %23, double %26)
  %28 = getelementptr inbounds i8, ptr %0, i64 80
  %29 = load double, ptr %28, align 8, !tbaa !5
  %30 = tail call double @llvm.fmuladd.f64(double %29, double %29, double %27)
  %31 = load double, ptr @RN_EPSILON, align 8, !tbaa !5
  %32 = tail call noundef i32 @_Z12RNIsNotEqualddd(double noundef %9, double noundef %30, double noundef %31)
  %.not5 = icmp eq i32 %32, 0
  %. = zext i1 %.not5 to i32
  br label %33

33:                                               ; preds = %1, %21
  %.1 = phi i32 [ %., %21 ], [ 0, %1 ]
  ret i32 %.1
}

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_Z12RNIsNotEqualddd(double noundef, double noundef, double noundef) local_unnamed_addr #2

attributes #0 = { mustprogress 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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { inlinehint mustprogress 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" }

!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,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass