; LLVM IR from SOHNE/Dura2D :: src/collision/d2Constraint.ll (ZNK12d2Constraint7GetInvMEv)

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

%struct.d2MatMN = type { i32, i32, ptr }
%class.d2Constraint = type { ptr, ptr, ptr, %struct.d2Vec2, %struct.d2Vec2, ptr, ptr }
%struct.d2Vec2 = type { float, float }
%struct.d2VecN = type { i32, ptr }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK12d2Constraint7GetInvMEv(ptr dead_on_unwind noalias writable sret(%struct.d2MatMN) align 8 %0, ptr noundef nonnull align 8 dereferenceable(56) %1) #0 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i1, align 1
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  store ptr %0, ptr %3, align 8
  store ptr %1, ptr %4, align 8, !tbaa !5
  %8 = load ptr, ptr %4, align 8
  store i1 false, ptr %5, align 1
  call void @_ZN7d2MatMNC1Eii(ptr noundef nonnull align 8 dereferenceable(16) %0, i32 noundef 6, i32 noundef 6)
  invoke void @_ZN7d2MatMN4ZeroEv(ptr noundef nonnull align 8 dereferenceable(16) %0)
          to label %9 unwind label %65

9:                                                ; preds = %2
  %10 = getelementptr inbounds %class.d2Constraint, ptr %8, i32 0, i32 1
  %11 = load ptr, ptr %10, align 8, !tbaa !9
  %12 = invoke noundef float @_ZNK6d2Body10GetInvMassEv(ptr noundef nonnull align 8 dereferenceable(132) %11)
          to label %13 unwind label %65

13:                                               ; preds = %9
  %14 = getelementptr inbounds %struct.d2MatMN, ptr %0, i32 0, i32 2
  %15 = load ptr, ptr %14, align 8, !tbaa !13
  %16 = getelementptr inbounds %struct.d2VecN, ptr %15, i64 0
  %17 = invoke noundef nonnull align 4 dereferenceable(4) ptr @_ZN6d2VecNixEi(ptr noundef nonnull align 8 dereferenceable(16) %16, i32 noundef 0)
          to label %18 unwind label %65

18:                                               ; preds = %13
  store float %12, ptr %17, align 4, !tbaa !16
  %19 = getelementptr inbounds %class.d2Constraint, ptr %8, i32 0, i32 1
  %20 = load ptr, ptr %19, align 8, !tbaa !9
  %21 = invoke noundef float @_ZNK6d2Body10GetInvMassEv(ptr noundef nonnull align 8 dereferenceable(132) %20)
          to label %22 unwind label %65

22:                                               ; preds = %18
  %23 = getelementptr inbounds %struct.d2MatMN, ptr %0, i32 0, i32 2
  %24 = load ptr, ptr %23, align 8, !tbaa !13
  %25 = getelementptr inbounds %struct.d2VecN, ptr %24, i64 1
  %26 = invoke noundef nonnull align 4 dereferenceable(4) ptr @_ZN6d2VecNixEi(ptr noundef nonnull align 8 dereferenceable(16) %25, i32 noundef 1)
          to label %27 unwind label %65

27:                                               ; preds = %22
  store float %21, ptr %26, align 4, !tbaa !16
  %28 = getelementptr inbounds %class.d2Constraint, ptr %8, i32 0, i32 1
  %29 = load ptr, ptr %28, align 8, !tbaa !9
  %30 = invoke noundef float @_ZNK6d2Body7GetInvIEv(ptr noundef nonnull align 8 dereferenceable(132) %29)
          to label %31 unwind label %65

31:                                               ; preds = %27
  %32 = getelementptr inbounds %struct.d2MatMN, ptr %0, i32 0, i32 2
  %33 = load ptr, ptr %32, align 8, !tbaa !13
  %34 = getelementptr inbounds %struct.d2VecN, ptr %33, i64 2
  %35 = invoke noundef nonnull align 4 dereferenceable(4) ptr @_ZN6d2VecNixEi(ptr noundef nonnull align 8 dereferenceable(16) %34, i32 noundef 2)
          to label %36 unwind label %65

36:                                               ; preds = %31
  store float %30, ptr %35, align 4, !tbaa !16
  %37 = getelementptr inbounds %class.d2Constraint, ptr %8, i32 0, i32 2
  %38 = load ptr, ptr %37, align 8, !tbaa !17
  %39 = invoke noundef float @_ZNK6d2Body10GetInvMassEv(ptr noundef nonnull align 8 dereferenceable(132) %38)
          to label %40 unwind label %65

40:                                               ; preds = %36
  %41 = getelementptr inbounds %struct.d2MatMN, ptr %0, i32 0, i32 2
  %42 = load ptr, ptr %41, align 8, !tbaa !13
  %43 = getelementptr inbounds %struct.d2VecN, ptr %42, i64 3
  %44 = invoke noundef nonnull align 4 dereferenceable(4) ptr @_ZN6d2VecNixEi(ptr noundef nonnull align 8 dereferenceable(16) %43, i32 noundef 3)
          to label %45 unwind label %65

45:                                               ; preds = %40
  store float %39, ptr %44, align 4, !tbaa !16
  %46 = getelementptr inbounds %class.d2Constraint, ptr %8, i32 0, i32 2
  %47 = load ptr, ptr %46, align 8, !tbaa !17
  %48 = invoke noundef float @_ZNK6d2Body10GetInvMassEv(ptr noundef nonnull align 8 dereferenceable(132) %47)
          to label %49 unwind label %65

49:                                               ; preds = %45
  %50 = getelementptr inbounds %struct.d2MatMN, ptr %0, i32 0, i32 2
  %51 = load ptr, ptr %50, align 8, !tbaa !13
  %52 = getelementptr inbounds %struct.d2VecN, ptr %51, i64 4
  %53 = invoke noundef nonnull align 4 dereferenceable(4) ptr @_ZN6d2VecNixEi(ptr noundef nonnull align 8 dereferenceable(16) %52, i32 noundef 4)
          to label %54 unwind label %65

54:                                               ; preds = %49
  store float %48, ptr %53, align 4, !tbaa !16
  %55 = getelementptr inbounds %class.d2Constraint, ptr %8, i32 0, i32 2
  %56 = load ptr, ptr %55, align 8, !tbaa !17
  %57 = invoke noundef float @_ZNK6d2Body7GetInvIEv(ptr noundef nonnull align 8 dereferenceable(132) %56)
          to label %58 unwind label %65

58:                                               ; preds = %54
  %59 = getelementptr inbounds %struct.d2MatMN, ptr %0, i32 0, i32 2
  %60 = load ptr, ptr %59, align 8, !tbaa !13
  %61 = getelementptr inbounds %struct.d2VecN, ptr %60, i64 5
  %62 = invoke noundef nonnull align 4 dereferenceable(4) ptr @_ZN6d2VecNixEi(ptr noundef nonnull align 8 dereferenceable(16) %61, i32 noundef 5)
          to label %63 unwind label %65

63:                                               ; preds = %58
  store float %57, ptr %62, align 4, !tbaa !16
  store i1 true, ptr %5, align 1
  %64 = load i1, ptr %5, align 1
  br i1 %64, label %70, label %69

65:                                               ; preds = %58, %54, %49, %45, %40, %36, %31, %27, %22, %18, %13, %9, %2
  %66 = landingpad { ptr, i32 }
          cleanup
  %67 = extractvalue { ptr, i32 } %66, 0
  store ptr %67, ptr %6, align 8
  %68 = extractvalue { ptr, i32 } %66, 1
  store i32 %68, ptr %7, align 4
  call void @_ZN7d2MatMND1Ev(ptr noundef nonnull align 8 dereferenceable(16) %0) #4
  br label %71

69:                                               ; preds = %63
  call void @_ZN7d2MatMND1Ev(ptr noundef nonnull align 8 dereferenceable(16) %0) #4
  br label %70

70:                                               ; preds = %69, %63
  ret void

71:                                               ; preds = %65
  %72 = load ptr, ptr %6, align 8
  %73 = load i32, ptr %7, align 4
  %74 = insertvalue { ptr, i32 } poison, ptr %72, 0
  %75 = insertvalue { ptr, i32 } %74, i32 %73, 1
  resume { ptr, i32 } %75
}

declare void @_ZN7d2MatMNC1Eii(ptr noundef nonnull align 8 dereferenceable(16), i32 noundef, i32 noundef) unnamed_addr #1

declare void @_ZN7d2MatMN4ZeroEv(ptr noundef nonnull align 8 dereferenceable(16)) #1

declare i32 @__gxx_personality_v0(...)

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_ZNK6d2Body10GetInvMassEv(ptr noundef nonnull align 8 dereferenceable(132)) #2 align 2

declare noundef nonnull align 4 dereferenceable(4) ptr @_ZN6d2VecNixEi(ptr noundef nonnull align 8 dereferenceable(16), i32 noundef) #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_ZNK6d2Body7GetInvIEv(ptr noundef nonnull align 8 dereferenceable(132)) #2 align 2

; Function Attrs: nounwind
declare void @_ZN7d2MatMND1Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #3

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 = { "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 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 "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, !6, i64 8}
!10 = !{!"_ZTS12d2Constraint", !6, i64 8, !6, i64 16, !11, i64 24, !11, i64 32, !6, i64 40, !6, i64 48}
!11 = !{!"_ZTS6d2Vec2", !12, i64 0, !12, i64 4}
!12 = !{!"float", !7, i64 0}
!13 = !{!14, !6, i64 8}
!14 = !{!"_ZTS7d2MatMN", !15, i64 0, !15, i64 4, !6, i64 8}
!15 = !{!"int", !7, i64 0}
!16 = !{!12, !12, i64 0}
!17 = !{!10, !6, i64 16}


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

%struct.d2MatMN = type { i32, i32, ptr }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK12d2Constraint7GetInvMEv(ptr dead_on_unwind noalias nonnull writable sret(%struct.d2MatMN) align 8 %0, ptr nocapture noundef nonnull readonly align 8 dereferenceable(56) %1) local_unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  tail call void @_ZN7d2MatMNC1Eii(ptr noundef nonnull align 8 dereferenceable(16) %0, i32 noundef 6, i32 noundef 6)
  invoke void @_ZN7d2MatMN4ZeroEv(ptr noundef nonnull align 8 dereferenceable(16) %0)
          to label %3 unwind label %42

3:                                                ; preds = %2
  %4 = getelementptr inbounds i8, ptr %1, i64 8
  %5 = load ptr, ptr %4, align 8, !tbaa !5
  %6 = tail call noundef float @_ZNK6d2Body10GetInvMassEv(ptr noundef nonnull align 8 dereferenceable(132) %5)
  %7 = getelementptr inbounds i8, ptr %0, i64 8
  %8 = load ptr, ptr %7, align 8, !tbaa !12
  %9 = invoke noundef nonnull align 4 dereferenceable(4) ptr @_ZN6d2VecNixEi(ptr noundef nonnull align 8 dereferenceable(16) %8, i32 noundef 0)
          to label %10 unwind label %42

10:                                               ; preds = %3
  store float %6, ptr %9, align 4, !tbaa !15
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = tail call noundef float @_ZNK6d2Body10GetInvMassEv(ptr noundef nonnull align 8 dereferenceable(132) %11)
  %13 = load ptr, ptr %7, align 8, !tbaa !12
  %14 = getelementptr inbounds i8, ptr %13, i64 16
  %15 = invoke noundef nonnull align 4 dereferenceable(4) ptr @_ZN6d2VecNixEi(ptr noundef nonnull align 8 dereferenceable(16) %14, i32 noundef 1)
          to label %16 unwind label %42

16:                                               ; preds = %10
  store float %12, ptr %15, align 4, !tbaa !15
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = tail call noundef float @_ZNK6d2Body7GetInvIEv(ptr noundef nonnull align 8 dereferenceable(132) %17)
  %19 = load ptr, ptr %7, align 8, !tbaa !12
  %20 = getelementptr inbounds i8, ptr %19, i64 32
  %21 = invoke noundef nonnull align 4 dereferenceable(4) ptr @_ZN6d2VecNixEi(ptr noundef nonnull align 8 dereferenceable(16) %20, i32 noundef 2)
          to label %22 unwind label %42

22:                                               ; preds = %16
  store float %18, ptr %21, align 4, !tbaa !15
  %23 = getelementptr inbounds i8, ptr %1, i64 16
  %24 = load ptr, ptr %23, align 8, !tbaa !16
  %25 = tail call noundef float @_ZNK6d2Body10GetInvMassEv(ptr noundef nonnull align 8 dereferenceable(132) %24)
  %26 = load ptr, ptr %7, align 8, !tbaa !12
  %27 = getelementptr inbounds i8, ptr %26, i64 48
  %28 = invoke noundef nonnull align 4 dereferenceable(4) ptr @_ZN6d2VecNixEi(ptr noundef nonnull align 8 dereferenceable(16) %27, i32 noundef 3)
          to label %29 unwind label %42

29:                                               ; preds = %22
  store float %25, ptr %28, align 4, !tbaa !15
  %30 = load ptr, ptr %23, align 8, !tbaa !16
  %31 = tail call noundef float @_ZNK6d2Body10GetInvMassEv(ptr noundef nonnull align 8 dereferenceable(132) %30)
  %32 = load ptr, ptr %7, align 8, !tbaa !12
  %33 = getelementptr inbounds i8, ptr %32, i64 64
  %34 = invoke noundef nonnull align 4 dereferenceable(4) ptr @_ZN6d2VecNixEi(ptr noundef nonnull align 8 dereferenceable(16) %33, i32 noundef 4)
          to label %35 unwind label %42

35:                                               ; preds = %29
  store float %31, ptr %34, align 4, !tbaa !15
  %36 = load ptr, ptr %23, align 8, !tbaa !16
  %37 = tail call noundef float @_ZNK6d2Body7GetInvIEv(ptr noundef nonnull align 8 dereferenceable(132) %36)
  %38 = load ptr, ptr %7, align 8, !tbaa !12
  %39 = getelementptr inbounds i8, ptr %38, i64 80
  %40 = invoke noundef nonnull align 4 dereferenceable(4) ptr @_ZN6d2VecNixEi(ptr noundef nonnull align 8 dereferenceable(16) %39, i32 noundef 5)
          to label %41 unwind label %42

41:                                               ; preds = %35
  store float %37, ptr %40, align 4, !tbaa !15
  ret void

42:                                               ; preds = %35, %29, %22, %16, %10, %3, %2
  %43 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZN7d2MatMND1Ev(ptr noundef nonnull align 8 dereferenceable(16) %0) #4
  resume { ptr, i32 } %43
}

declare void @_ZN7d2MatMNC1Eii(ptr noundef nonnull align 8 dereferenceable(16), i32 noundef, i32 noundef) unnamed_addr #1

declare void @_ZN7d2MatMN4ZeroEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #1

declare i32 @__gxx_personality_v0(...)

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_ZNK6d2Body10GetInvMassEv(ptr noundef nonnull align 8 dereferenceable(132)) local_unnamed_addr #2 align 2

declare noundef nonnull align 4 dereferenceable(4) ptr @_ZN6d2VecNixEi(ptr noundef nonnull align 8 dereferenceable(16), i32 noundef) local_unnamed_addr #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_ZNK6d2Body7GetInvIEv(ptr noundef nonnull align 8 dereferenceable(132)) local_unnamed_addr #2 align 2

; Function Attrs: nounwind
declare void @_ZN7d2MatMND1Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #3

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 = { "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 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 "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, !7, i64 8}
!6 = !{!"_ZTS12d2Constraint", !7, i64 8, !7, i64 16, !10, i64 24, !10, i64 32, !7, i64 40, !7, i64 48}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTS6d2Vec2", !11, i64 0, !11, i64 4}
!11 = !{!"float", !8, i64 0}
!12 = !{!13, !7, i64 8}
!13 = !{!"_ZTS7d2MatMN", !14, i64 0, !14, i64 4, !7, i64 8}
!14 = !{!"int", !8, i64 0}
!15 = !{!11, !11, i64 0}
!16 = !{!6, !7, i64 16}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass