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

; 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]] }

@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: 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 @_ZNK8R3Matrix8HasScaleEv(ptr noundef nonnull align 8 dereferenceable(72) %0) #2 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
  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) #4
  %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)
  store double %25, ptr %4, align 8, !tbaa !9
  %26 = load double, ptr %4, align 8, !tbaa !9
  %27 = load double, ptr @RN_EPSILON, align 8, !tbaa !9
  %28 = call noundef i32 @_Z12RNIsNotEqualddd(double noundef %26, double noundef 1.000000e+00, double noundef %27)
  %29 = icmp ne i32 %28, 0
  br i1 %29, label %30, label %31

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

31:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %32 = getelementptr inbounds %class.R3Matrix, ptr %7, i32 0, i32 0
  %33 = getelementptr inbounds [3 x [3 x double]], ptr %32, i64 0, i64 0
  %34 = getelementptr inbounds [3 x double], ptr %33, i64 0, i64 1
  %35 = load double, ptr %34, align 8, !tbaa !9
  %36 = getelementptr inbounds %class.R3Matrix, ptr %7, i32 0, i32 0
  %37 = getelementptr inbounds [3 x [3 x double]], ptr %36, i64 0, i64 0
  %38 = getelementptr inbounds [3 x double], ptr %37, i64 0, i64 1
  %39 = load double, ptr %38, align 8, !tbaa !9
  %40 = getelementptr inbounds %class.R3Matrix, ptr %7, i32 0, i32 0
  %41 = getelementptr inbounds [3 x [3 x double]], ptr %40, i64 0, i64 1
  %42 = getelementptr inbounds [3 x double], ptr %41, i64 0, i64 1
  %43 = load double, ptr %42, align 8, !tbaa !9
  %44 = getelementptr inbounds %class.R3Matrix, ptr %7, i32 0, i32 0
  %45 = getelementptr inbounds [3 x [3 x double]], ptr %44, i64 0, i64 1
  %46 = getelementptr inbounds [3 x double], ptr %45, i64 0, i64 1
  %47 = load double, ptr %46, align 8, !tbaa !9
  %48 = fmul double %43, %47
  %49 = call double @llvm.fmuladd.f64(double %35, double %39, double %48)
  store double %49, ptr %6, align 8, !tbaa !9
  %50 = load double, ptr %6, align 8, !tbaa !9
  %51 = load double, ptr @RN_EPSILON, align 8, !tbaa !9
  %52 = call noundef i32 @_Z12RNIsNotEqualddd(double noundef %50, double noundef 1.000000e+00, double noundef %51)
  %53 = icmp ne i32 %52, 0
  br i1 %53, label %54, label %55

54:                                               ; preds = %31
  store i32 1, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %56

55:                                               ; preds = %31
  store i32 0, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %56

56:                                               ; preds = %55, %54
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  br label %57

57:                                               ; preds = %56, %30
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  %58 = load i32, ptr %2, align 4
  ret i32 %58
}

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef range(i32 0, 2) i32 @_ZNK8R3Matrix8HasScaleEv(ptr nocapture noundef nonnull readonly align 8 dereferenceable(72) %0) local_unnamed_addr #1 align 2 {
  %2 = load double, ptr %0, align 8, !tbaa !5
  %3 = getelementptr inbounds i8, ptr %0, i64 24
  %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 = load double, ptr @RN_EPSILON, align 8, !tbaa !5
  %8 = tail call noundef i32 @_Z12RNIsNotEqualddd(double noundef %6, double noundef 1.000000e+00, double noundef %7)
  %.not = icmp eq i32 %8, 0
  br i1 %.not, label %9, label %18

9:                                                ; preds = %1
  %10 = getelementptr inbounds i8, ptr %0, i64 8
  %11 = load double, ptr %10, align 8, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %0, i64 32
  %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 = load double, ptr @RN_EPSILON, align 8, !tbaa !5
  %17 = tail call noundef i32 @_Z12RNIsNotEqualddd(double noundef %15, double noundef 1.000000e+00, double noundef %16)
  %.not3 = icmp ne i32 %17, 0
  %. = zext i1 %.not3 to i32
  br label %18

18:                                               ; preds = %1, %9
  %.1 = phi i32 [ %., %9 ], [ 1, %1 ]
  ret i32 %.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 nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { 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 = { 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