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

; 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: 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) #2

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZNK8R4Matrix8HasScaleEv(ptr noundef nonnull align 8 dereferenceable(128) %0) #3 align 2 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca double, align 8
  %5 = alloca i32, align 4
  %6 = alloca double, align 8
  %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
  %36 = load double, ptr %4, align 8, !tbaa !9
  %37 = load double, ptr @RN_EPSILON, align 8, !tbaa !9
  %38 = call noundef i32 @_Z12RNIsNotEqualddd(double noundef %36, double noundef 1.000000e+00, double noundef %37)
  %39 = icmp ne i32 %38, 0
  br i1 %39, label %40, label %41

40:                                               ; preds = %1
  store i32 1, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %110

41:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %42 = getelementptr inbounds %class.R4Matrix, ptr %8, i32 0, i32 0
  %43 = getelementptr inbounds [4 x [4 x double]], ptr %42, i64 0, i64 0
  %44 = getelementptr inbounds [4 x double], ptr %43, i64 0, i64 1
  %45 = load double, ptr %44, align 8, !tbaa !9
  %46 = getelementptr inbounds %class.R4Matrix, ptr %8, i32 0, i32 0
  %47 = getelementptr inbounds [4 x [4 x double]], ptr %46, i64 0, i64 0
  %48 = getelementptr inbounds [4 x double], ptr %47, i64 0, i64 1
  %49 = load double, ptr %48, align 8, !tbaa !9
  %50 = getelementptr inbounds %class.R4Matrix, ptr %8, i32 0, i32 0
  %51 = getelementptr inbounds [4 x [4 x double]], ptr %50, i64 0, i64 1
  %52 = getelementptr inbounds [4 x double], ptr %51, i64 0, i64 1
  %53 = load double, ptr %52, align 8, !tbaa !9
  %54 = getelementptr inbounds %class.R4Matrix, ptr %8, i32 0, i32 0
  %55 = getelementptr inbounds [4 x [4 x double]], ptr %54, i64 0, i64 1
  %56 = getelementptr inbounds [4 x double], ptr %55, i64 0, i64 1
  %57 = load double, ptr %56, align 8, !tbaa !9
  %58 = fmul double %53, %57
  %59 = call double @llvm.fmuladd.f64(double %45, double %49, double %58)
  %60 = getelementptr inbounds %class.R4Matrix, ptr %8, i32 0, i32 0
  %61 = getelementptr inbounds [4 x [4 x double]], ptr %60, i64 0, i64 2
  %62 = getelementptr inbounds [4 x double], ptr %61, i64 0, i64 1
  %63 = load double, ptr %62, align 8, !tbaa !9
  %64 = getelementptr inbounds %class.R4Matrix, ptr %8, i32 0, i32 0
  %65 = getelementptr inbounds [4 x [4 x double]], ptr %64, i64 0, i64 2
  %66 = getelementptr inbounds [4 x double], ptr %65, i64 0, i64 1
  %67 = load double, ptr %66, align 8, !tbaa !9
  %68 = call double @llvm.fmuladd.f64(double %63, double %67, double %59)
  store double %68, ptr %6, align 8, !tbaa !9
  %69 = load double, ptr %6, align 8, !tbaa !9
  %70 = load double, ptr @RN_EPSILON, align 8, !tbaa !9
  %71 = call noundef i32 @_Z12RNIsNotEqualddd(double noundef %69, double noundef 1.000000e+00, double noundef %70)
  %72 = icmp ne i32 %71, 0
  br i1 %72, label %73, label %74

73:                                               ; preds = %41
  store i32 1, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %109

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

106:                                              ; preds = %74
  store i32 1, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %108

107:                                              ; preds = %74
  store i32 0, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %108

108:                                              ; preds = %107, %106
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  br label %109

109:                                              ; preds = %108, %73
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  br label %110

110:                                              ; preds = %109, %40
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  %111 = load i32, ptr %2, align 4
  ret i32 %111
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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" }
attributes #3 = { 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 nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #0

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

; Function Attrs: mustprogress uwtable
define dso_local noundef range(i32 0, 2) i32 @_ZNK8R4Matrix8HasScaleEv(ptr nocapture noundef nonnull readonly align 8 dereferenceable(128) %0) local_unnamed_addr #2 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 = load double, ptr @RN_EPSILON, align 8, !tbaa !5
  %11 = tail call noundef i32 @_Z12RNIsNotEqualddd(double noundef %9, double noundef 1.000000e+00, double noundef %10)
  %.not = icmp eq i32 %11, 0
  br i1 %.not, label %12, label %36

12:                                               ; preds = %1
  %13 = getelementptr inbounds i8, ptr %0, i64 8
  %14 = load double, ptr %13, align 8, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %0, i64 40
  %16 = load double, ptr %15, align 8, !tbaa !5
  %17 = fmul double %16, %16
  %18 = tail call double @llvm.fmuladd.f64(double %14, double %14, double %17)
  %19 = getelementptr inbounds i8, ptr %0, i64 72
  %20 = load double, ptr %19, align 8, !tbaa !5
  %21 = tail call double @llvm.fmuladd.f64(double %20, double %20, double %18)
  %22 = load double, ptr @RN_EPSILON, align 8, !tbaa !5
  %23 = tail call noundef i32 @_Z12RNIsNotEqualddd(double noundef %21, double noundef 1.000000e+00, double noundef %22)
  %.not4 = icmp eq i32 %23, 0
  br i1 %.not4, label %24, label %36

24:                                               ; preds = %12
  %25 = getelementptr inbounds i8, ptr %0, i64 16
  %26 = load double, ptr %25, align 8, !tbaa !5
  %27 = getelementptr inbounds i8, ptr %0, i64 48
  %28 = load double, ptr %27, align 8, !tbaa !5
  %29 = fmul double %28, %28
  %30 = tail call double @llvm.fmuladd.f64(double %26, double %26, double %29)
  %31 = getelementptr inbounds i8, ptr %0, i64 80
  %32 = load double, ptr %31, align 8, !tbaa !5
  %33 = tail call double @llvm.fmuladd.f64(double %32, double %32, double %30)
  %34 = load double, ptr @RN_EPSILON, align 8, !tbaa !5
  %35 = tail call noundef i32 @_Z12RNIsNotEqualddd(double noundef %33, double noundef 1.000000e+00, double noundef %34)
  %.not5 = icmp ne i32 %35, 0
  %. = zext i1 %.not5 to i32
  br label %36

36:                                               ; preds = %24, %12, %1
  %.2 = phi i32 [ 1, %1 ], [ %., %24 ], [ 1, %12 ]
  ret i32 %.2
}

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