; LLVM IR from DreamingInfraviolet/EstimateImageMatting :: Primatte/matrixd.ll (ZNK4math3tmp5_mat310getInverseEv)

; 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.math::tmp::_mat3" = type { [3 x [3 x float]] }

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #0

; 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 willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK4math3tmp5_mat3mlEf(ptr dead_on_unwind noalias writable sret(%"class.math::tmp::_mat3") align 4, ptr noundef nonnull align 4 dereferenceable(36), float noundef) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef float @_ZNK4math3tmp5_mat33detEv(ptr noundef nonnull align 4 dereferenceable(36)) #3 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK4math3tmp5_mat310getInverseEv(ptr dead_on_unwind noalias writable sret(%"class.math::tmp::_mat3") align 4 %0, ptr noundef nonnull align 4 dereferenceable(36) %1) #2 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca float, align 4
  %5 = alloca i32, align 4
  %6 = alloca float, align 4
  %7 = alloca float, align 4
  %8 = alloca float, align 4
  %9 = alloca float, align 4
  %10 = alloca float, align 4
  %11 = alloca float, align 4
  %12 = alloca float, align 4
  %13 = alloca float, align 4
  %14 = alloca float, align 4
  %15 = alloca %"class.math::tmp::_mat3", align 4
  store ptr %1, ptr %3, align 8, !tbaa !5
  %16 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  %17 = call noundef float @_ZNK4math3tmp5_mat33detEv(ptr noundef nonnull align 4 dereferenceable(36) %16)
  store float %17, ptr %4, align 4, !tbaa !9
  %18 = load float, ptr %4, align 4, !tbaa !9
  %19 = fcmp oeq float %18, 0.000000e+00
  br i1 %19, label %20, label %21

20:                                               ; preds = %2
  call void @_ZN4math3tmp5_mat3C1Ev(ptr noundef nonnull align 4 dereferenceable(36) %0)
  store i32 1, ptr %5, align 4
  br label %123

21:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  %22 = getelementptr inbounds %"class.math::tmp::_mat3", ptr %16, i32 0, i32 0
  %23 = getelementptr inbounds [3 x [3 x float]], ptr %22, i64 0, i64 0
  %24 = getelementptr inbounds [3 x float], ptr %23, i64 0, i64 0
  %25 = load float, ptr %24, align 4, !tbaa !9
  store float %25, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  %26 = getelementptr inbounds %"class.math::tmp::_mat3", ptr %16, i32 0, i32 0
  %27 = getelementptr inbounds [3 x [3 x float]], ptr %26, i64 0, i64 1
  %28 = getelementptr inbounds [3 x float], ptr %27, i64 0, i64 0
  %29 = load float, ptr %28, align 4, !tbaa !9
  store float %29, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  %30 = getelementptr inbounds %"class.math::tmp::_mat3", ptr %16, i32 0, i32 0
  %31 = getelementptr inbounds [3 x [3 x float]], ptr %30, i64 0, i64 2
  %32 = getelementptr inbounds [3 x float], ptr %31, i64 0, i64 0
  %33 = load float, ptr %32, align 4, !tbaa !9
  store float %33, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  %34 = getelementptr inbounds %"class.math::tmp::_mat3", ptr %16, i32 0, i32 0
  %35 = getelementptr inbounds [3 x [3 x float]], ptr %34, i64 0, i64 0
  %36 = getelementptr inbounds [3 x float], ptr %35, i64 0, i64 1
  %37 = load float, ptr %36, align 4, !tbaa !9
  store float %37, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  %38 = getelementptr inbounds %"class.math::tmp::_mat3", ptr %16, i32 0, i32 0
  %39 = getelementptr inbounds [3 x [3 x float]], ptr %38, i64 0, i64 1
  %40 = getelementptr inbounds [3 x float], ptr %39, i64 0, i64 1
  %41 = load float, ptr %40, align 4, !tbaa !9
  store float %41, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  %42 = getelementptr inbounds %"class.math::tmp::_mat3", ptr %16, i32 0, i32 0
  %43 = getelementptr inbounds [3 x [3 x float]], ptr %42, i64 0, i64 2
  %44 = getelementptr inbounds [3 x float], ptr %43, i64 0, i64 1
  %45 = load float, ptr %44, align 4, !tbaa !9
  store float %45, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  %46 = getelementptr inbounds %"class.math::tmp::_mat3", ptr %16, i32 0, i32 0
  %47 = getelementptr inbounds [3 x [3 x float]], ptr %46, i64 0, i64 0
  %48 = getelementptr inbounds [3 x float], ptr %47, i64 0, i64 2
  %49 = load float, ptr %48, align 4, !tbaa !9
  store float %49, ptr %12, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  %50 = getelementptr inbounds %"class.math::tmp::_mat3", ptr %16, i32 0, i32 0
  %51 = getelementptr inbounds [3 x [3 x float]], ptr %50, i64 0, i64 1
  %52 = getelementptr inbounds [3 x float], ptr %51, i64 0, i64 2
  %53 = load float, ptr %52, align 4, !tbaa !9
  store float %53, ptr %13, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  %54 = getelementptr inbounds %"class.math::tmp::_mat3", ptr %16, i32 0, i32 0
  %55 = getelementptr inbounds [3 x [3 x float]], ptr %54, i64 0, i64 2
  %56 = getelementptr inbounds [3 x float], ptr %55, i64 0, i64 2
  %57 = load float, ptr %56, align 4, !tbaa !9
  store float %57, ptr %14, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 36, ptr %15) #4
  %58 = load float, ptr %10, align 4, !tbaa !9
  %59 = load float, ptr %14, align 4, !tbaa !9
  %60 = load float, ptr %11, align 4, !tbaa !9
  %61 = load float, ptr %13, align 4, !tbaa !9
  %62 = fmul float %60, %61
  %63 = fneg float %62
  %64 = call float @llvm.fmuladd.f32(float %58, float %59, float %63)
  %65 = load float, ptr %11, align 4, !tbaa !9
  %66 = load float, ptr %12, align 4, !tbaa !9
  %67 = load float, ptr %9, align 4, !tbaa !9
  %68 = load float, ptr %14, align 4, !tbaa !9
  %69 = fmul float %67, %68
  %70 = fneg float %69
  %71 = call float @llvm.fmuladd.f32(float %65, float %66, float %70)
  %72 = load float, ptr %9, align 4, !tbaa !9
  %73 = load float, ptr %13, align 4, !tbaa !9
  %74 = load float, ptr %10, align 4, !tbaa !9
  %75 = load float, ptr %12, align 4, !tbaa !9
  %76 = fmul float %74, %75
  %77 = fneg float %76
  %78 = call float @llvm.fmuladd.f32(float %72, float %73, float %77)
  %79 = load float, ptr %8, align 4, !tbaa !9
  %80 = load float, ptr %13, align 4, !tbaa !9
  %81 = load float, ptr %7, align 4, !tbaa !9
  %82 = load float, ptr %14, align 4, !tbaa !9
  %83 = fmul float %81, %82
  %84 = fneg float %83
  %85 = call float @llvm.fmuladd.f32(float %79, float %80, float %84)
  %86 = load float, ptr %6, align 4, !tbaa !9
  %87 = load float, ptr %14, align 4, !tbaa !9
  %88 = load float, ptr %8, align 4, !tbaa !9
  %89 = load float, ptr %12, align 4, !tbaa !9
  %90 = fmul float %88, %89
  %91 = fneg float %90
  %92 = call float @llvm.fmuladd.f32(float %86, float %87, float %91)
  %93 = load float, ptr %7, align 4, !tbaa !9
  %94 = load float, ptr %12, align 4, !tbaa !9
  %95 = load float, ptr %6, align 4, !tbaa !9
  %96 = load float, ptr %13, align 4, !tbaa !9
  %97 = fmul float %95, %96
  %98 = fneg float %97
  %99 = call float @llvm.fmuladd.f32(float %93, float %94, float %98)
  %100 = load float, ptr %7, align 4, !tbaa !9
  %101 = load float, ptr %11, align 4, !tbaa !9
  %102 = load float, ptr %8, align 4, !tbaa !9
  %103 = load float, ptr %10, align 4, !tbaa !9
  %104 = fmul float %102, %103
  %105 = fneg float %104
  %106 = call float @llvm.fmuladd.f32(float %100, float %101, float %105)
  %107 = load float, ptr %8, align 4, !tbaa !9
  %108 = load float, ptr %9, align 4, !tbaa !9
  %109 = load float, ptr %6, align 4, !tbaa !9
  %110 = load float, ptr %11, align 4, !tbaa !9
  %111 = fmul float %109, %110
  %112 = fneg float %111
  %113 = call float @llvm.fmuladd.f32(float %107, float %108, float %112)
  %114 = load float, ptr %6, align 4, !tbaa !9
  %115 = load float, ptr %10, align 4, !tbaa !9
  %116 = load float, ptr %7, align 4, !tbaa !9
  %117 = load float, ptr %9, align 4, !tbaa !9
  %118 = fmul float %116, %117
  %119 = fneg float %118
  %120 = call float @llvm.fmuladd.f32(float %114, float %115, float %119)
  call void @_ZN4math3tmp5_mat3C1Efffffffff(ptr noundef nonnull align 4 dereferenceable(36) %15, float noundef %64, float noundef %71, float noundef %78, float noundef %85, float noundef %92, float noundef %99, float noundef %106, float noundef %113, float noundef %120)
  %121 = load float, ptr %4, align 4, !tbaa !9
  %122 = fdiv float 1.000000e+00, %121
  call void @_ZNK4math3tmp5_mat3mlEf(ptr dead_on_unwind writable sret(%"class.math::tmp::_mat3") align 4 %0, ptr noundef nonnull align 4 dereferenceable(36) %15, float noundef %122)
  call void @llvm.lifetime.end.p0(i64 36, ptr %15) #4
  store i32 1, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  br label %123

123:                                              ; preds = %21, %20
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  ret void
}

declare void @_ZN4math3tmp5_mat3C1Ev(ptr)

declare void @_ZN4math3tmp5_mat3C1Efffffffff(ptr, float, float, float, float, float, float, float, float, float)

attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #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 = !{!"float", !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"

%"class.math::tmp::_mat3" = type { [3 x [3 x float]] }

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #0

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK4math3tmp5_mat3mlEf(ptr dead_on_unwind noalias writable sret(%"class.math::tmp::_mat3") align 4, ptr noundef nonnull align 4 dereferenceable(36), float noundef) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef float @_ZNK4math3tmp5_mat33detEv(ptr noundef nonnull align 4 dereferenceable(36)) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK4math3tmp5_mat310getInverseEv(ptr dead_on_unwind noalias writable sret(%"class.math::tmp::_mat3") align 4 %0, ptr noundef nonnull align 4 dereferenceable(36) %1) local_unnamed_addr #2 align 2 {
  %3 = alloca %"class.math::tmp::_mat3", align 4
  %4 = tail call noundef float @_ZNK4math3tmp5_mat33detEv(ptr noundef nonnull align 4 dereferenceable(36) %1)
  %5 = fcmp oeq float %4, 0.000000e+00
  br i1 %5, label %6, label %7

6:                                                ; preds = %2
  tail call void @_ZN4math3tmp5_mat3C1Ev(ptr noundef nonnull align 4 dereferenceable(36) %0)
  br label %50

7:                                                ; preds = %2
  %8 = load float, ptr %1, align 4, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %1, i64 12
  %10 = load float, ptr %9, align 4, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %1, i64 24
  %12 = load float, ptr %11, align 4, !tbaa !5
  %13 = getelementptr inbounds i8, ptr %1, i64 4
  %14 = load float, ptr %13, align 4, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %1, i64 16
  %16 = load float, ptr %15, align 4, !tbaa !5
  %17 = getelementptr inbounds i8, ptr %1, i64 28
  %18 = load float, ptr %17, align 4, !tbaa !5
  %19 = getelementptr inbounds i8, ptr %1, i64 8
  %20 = load float, ptr %19, align 4, !tbaa !5
  %21 = getelementptr inbounds i8, ptr %1, i64 20
  %22 = load float, ptr %21, align 4, !tbaa !5
  %23 = getelementptr inbounds i8, ptr %1, i64 32
  %24 = load float, ptr %23, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 36, ptr nonnull %3) #4
  %25 = fneg float %18
  %26 = fmul float %22, %25
  %27 = tail call float @llvm.fmuladd.f32(float %16, float %24, float %26)
  %28 = fneg float %14
  %29 = fmul float %24, %28
  %30 = tail call float @llvm.fmuladd.f32(float %18, float %20, float %29)
  %31 = fneg float %16
  %32 = fmul float %20, %31
  %33 = tail call float @llvm.fmuladd.f32(float %14, float %22, float %32)
  %34 = fneg float %10
  %35 = fmul float %24, %34
  %36 = tail call float @llvm.fmuladd.f32(float %12, float %22, float %35)
  %37 = fneg float %12
  %38 = fmul float %20, %37
  %39 = tail call float @llvm.fmuladd.f32(float %8, float %24, float %38)
  %40 = fneg float %8
  %41 = fmul float %22, %40
  %42 = tail call float @llvm.fmuladd.f32(float %10, float %20, float %41)
  %43 = fmul float %16, %37
  %44 = tail call float @llvm.fmuladd.f32(float %10, float %18, float %43)
  %45 = fmul float %18, %40
  %46 = tail call float @llvm.fmuladd.f32(float %12, float %14, float %45)
  %47 = fmul float %14, %34
  %48 = tail call float @llvm.fmuladd.f32(float %8, float %16, float %47)
  call void @_ZN4math3tmp5_mat3C1Efffffffff(ptr noundef nonnull align 4 dereferenceable(36) %3, float noundef %27, float noundef %30, float noundef %33, float noundef %36, float noundef %39, float noundef %42, float noundef %44, float noundef %46, float noundef %48)
  %49 = fdiv float 1.000000e+00, %4
  call void @_ZNK4math3tmp5_mat3mlEf(ptr dead_on_unwind writable sret(%"class.math::tmp::_mat3") align 4 %0, ptr noundef nonnull align 4 dereferenceable(36) %3, float noundef %49)
  call void @llvm.lifetime.end.p0(i64 36, ptr nonnull %3) #4
  br label %50

50:                                               ; preds = %7, %6
  ret void
}

declare void @_ZN4math3tmp5_mat3C1Ev(ptr) local_unnamed_addr

declare void @_ZN4math3tmp5_mat3C1Efffffffff(ptr, float, float, float, float, float, float, float, float, float) local_unnamed_addr

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,ReassociatePass,SROAPass,TailCallElimPass