; LLVM IR from ashishzero/karma :: src/modules/core/lin_maths.ll (Z12mat2_inverseRK4Mat2)

; 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"

%union.Mat2 = type { [2 x %union.Vec2] }
%union.Vec2 = type { %struct.anon.1 }
%struct.anon.1 = type { float, 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 nounwind uwtable
define dso_local { <2 x float>, <2 x float> } @_Z12mat2_inverseRK4Mat2(ptr noundef nonnull align 4 dereferenceable(16) %0) #2 {
  %2 = alloca %union.Mat2, align 4
  %3 = alloca ptr, align 8
  %4 = alloca float, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  %5 = load ptr, ptr %3, align 8, !tbaa !5
  %6 = getelementptr inbounds [2 x [2 x float]], ptr %5, i64 0, i64 0
  %7 = getelementptr inbounds [2 x float], ptr %6, i64 0, i64 0
  %8 = load float, ptr %7, align 4, !tbaa !9
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = getelementptr inbounds [2 x [2 x float]], ptr %9, i64 0, i64 1
  %11 = getelementptr inbounds [2 x float], ptr %10, i64 0, i64 1
  %12 = load float, ptr %11, align 4, !tbaa !9
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = getelementptr inbounds [2 x [2 x float]], ptr %13, i64 0, i64 0
  %15 = getelementptr inbounds [2 x float], ptr %14, i64 0, i64 1
  %16 = load float, ptr %15, align 4, !tbaa !9
  %17 = load ptr, ptr %3, align 8, !tbaa !5
  %18 = getelementptr inbounds [2 x [2 x float]], ptr %17, i64 0, i64 1
  %19 = getelementptr inbounds [2 x float], ptr %18, i64 0, i64 0
  %20 = load float, ptr %19, align 4, !tbaa !9
  %21 = fmul float %16, %20
  %22 = fneg float %21
  %23 = call float @llvm.fmuladd.f32(float %8, float %12, float %22)
  store float %23, ptr %4, align 4, !tbaa !10
  %24 = load float, ptr %4, align 4, !tbaa !10
  %25 = load float, ptr %4, align 4, !tbaa !10
  %26 = fdiv float %25, %24
  store float %26, ptr %4, align 4, !tbaa !10
  %27 = load ptr, ptr %3, align 8, !tbaa !5
  %28 = getelementptr inbounds [2 x [2 x float]], ptr %27, i64 0, i64 1
  %29 = getelementptr inbounds [2 x float], ptr %28, i64 0, i64 1
  %30 = load float, ptr %29, align 4, !tbaa !9
  %31 = getelementptr inbounds [2 x [2 x float]], ptr %2, i64 0, i64 0
  %32 = getelementptr inbounds [2 x float], ptr %31, i64 0, i64 0
  store float %30, ptr %32, align 4, !tbaa !9
  %33 = load ptr, ptr %3, align 8, !tbaa !5
  %34 = getelementptr inbounds [2 x [2 x float]], ptr %33, i64 0, i64 0
  %35 = getelementptr inbounds [2 x float], ptr %34, i64 0, i64 1
  %36 = load float, ptr %35, align 4, !tbaa !9
  %37 = fneg float %36
  %38 = getelementptr inbounds [2 x [2 x float]], ptr %2, i64 0, i64 0
  %39 = getelementptr inbounds [2 x float], ptr %38, i64 0, i64 1
  store float %37, ptr %39, align 4, !tbaa !9
  %40 = load ptr, ptr %3, align 8, !tbaa !5
  %41 = getelementptr inbounds [2 x [2 x float]], ptr %40, i64 0, i64 1
  %42 = getelementptr inbounds [2 x float], ptr %41, i64 0, i64 0
  %43 = load float, ptr %42, align 4, !tbaa !9
  %44 = fneg float %43
  %45 = getelementptr inbounds [2 x [2 x float]], ptr %2, i64 0, i64 1
  %46 = getelementptr inbounds [2 x float], ptr %45, i64 0, i64 0
  store float %44, ptr %46, align 4, !tbaa !9
  %47 = load ptr, ptr %3, align 8, !tbaa !5
  %48 = getelementptr inbounds [2 x [2 x float]], ptr %47, i64 0, i64 0
  %49 = getelementptr inbounds [2 x float], ptr %48, i64 0, i64 0
  %50 = load float, ptr %49, align 4, !tbaa !9
  %51 = getelementptr inbounds [2 x [2 x float]], ptr %2, i64 0, i64 1
  %52 = getelementptr inbounds [2 x float], ptr %51, i64 0, i64 1
  store float %50, ptr %52, align 4, !tbaa !9
  %53 = load float, ptr %4, align 4, !tbaa !10
  %54 = getelementptr inbounds [4 x float], ptr %2, i64 0, i64 0
  %55 = load float, ptr %54, align 4, !tbaa !9
  %56 = fmul float %55, %53
  store float %56, ptr %54, align 4, !tbaa !9
  %57 = load float, ptr %4, align 4, !tbaa !10
  %58 = getelementptr inbounds [4 x float], ptr %2, i64 0, i64 1
  %59 = load float, ptr %58, align 4, !tbaa !9
  %60 = fmul float %59, %57
  store float %60, ptr %58, align 4, !tbaa !9
  %61 = load float, ptr %4, align 4, !tbaa !10
  %62 = getelementptr inbounds [4 x float], ptr %2, i64 0, i64 2
  %63 = load float, ptr %62, align 4, !tbaa !9
  %64 = fmul float %63, %61
  store float %64, ptr %62, align 4, !tbaa !9
  %65 = load float, ptr %4, align 4, !tbaa !10
  %66 = getelementptr inbounds [4 x float], ptr %2, i64 0, i64 3
  %67 = load float, ptr %66, align 4, !tbaa !9
  %68 = fmul float %67, %65
  store float %68, ptr %66, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  %69 = getelementptr inbounds %union.Mat2, ptr %2, i32 0, i32 0
  %70 = load { <2 x float>, <2 x float> }, ptr %69, align 4
  ret { <2 x float>, <2 x float> } %70
}

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

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

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) uwtable
define dso_local { <2 x float>, <2 x float> } @_Z12mat2_inverseRK4Mat2(ptr nocapture noundef nonnull readonly align 4 dereferenceable(16) %0) local_unnamed_addr #1 {
  %2 = load float, ptr %0, align 4, !tbaa !5
  %3 = getelementptr inbounds i8, ptr %0, i64 12
  %4 = load float, ptr %3, align 4, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 4
  %6 = load <2 x float>, ptr %5, align 4, !tbaa !5
  %7 = fneg <2 x float> %6
  %shift = shufflevector <2 x float> %6, <2 x float> poison, <2 x i32> <i32 1, i32 poison>
  %8 = fmul <2 x float> %shift, %7
  %9 = extractelement <2 x float> %8, i64 0
  %10 = tail call float @llvm.fmuladd.f32(float %2, float %4, float %9)
  %11 = fdiv float %10, %10
  %12 = insertelement <4 x float> poison, float %11, i64 0
  %13 = shufflevector <4 x float> %12, <4 x float> poison, <4 x i32> zeroinitializer
  %14 = insertelement <4 x float> poison, float %4, i64 0
  %15 = shufflevector <2 x float> %7, <2 x float> poison, <4 x i32> <i32 0, i32 1, i32 poison, i32 poison>
  %16 = shufflevector <4 x float> %14, <4 x float> %15, <4 x i32> <i32 0, i32 4, i32 5, i32 poison>
  %17 = insertelement <4 x float> %16, float %2, i64 3
  %18 = fmul <4 x float> %13, %17
  %19 = shufflevector <4 x float> %18, <4 x float> poison, <2 x i32> <i32 0, i32 1>
  %20 = shufflevector <4 x float> %18, <4 x float> poison, <2 x i32> <i32 2, i32 3>
  %.fca.0.insert = insertvalue { <2 x float>, <2 x float> } poison, <2 x float> %19, 0
  %.fca.1.insert = insertvalue { <2 x float>, <2 x float> } %.fca.0.insert, <2 x float> %20, 1
  ret { <2 x float>, <2 x float> } %.fca.1.insert
}

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

!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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}


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