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

; 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.d2VecN = type { i32, ptr }
%class.d2Constraint = type { ptr, ptr, ptr, %struct.d2Vec2, %struct.d2Vec2, ptr, ptr }
%struct.d2Vec2 = type { float, float }

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK12d2Constraint13GetVelocitiesEv(ptr dead_on_unwind noalias writable sret(%struct.d2VecN) align 8 %0, ptr noundef nonnull align 8 dereferenceable(56) %1) #1 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 @_ZN6d2VecNC1Ei(ptr noundef nonnull align 8 dereferenceable(16) %0, i32 noundef 6)
  invoke void @_ZN6d2VecN4ZeroEv(ptr noundef nonnull align 8 dereferenceable(16) %0)
          to label %9 unwind label %55

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 nonnull align 4 dereferenceable(8) ptr @_ZNK6d2Body11GetVelocityEv(ptr noundef nonnull align 8 dereferenceable(132) %11)
          to label %13 unwind label %55

13:                                               ; preds = %9
  %14 = getelementptr inbounds %struct.d2Vec2, ptr %12, i32 0, i32 0
  %15 = load float, ptr %14, align 4, !tbaa !13
  %16 = invoke noundef nonnull align 4 dereferenceable(4) ptr @_ZN6d2VecNixEi(ptr noundef nonnull align 8 dereferenceable(16) %0, i32 noundef 0)
          to label %17 unwind label %55

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

21:                                               ; preds = %17
  %22 = getelementptr inbounds %struct.d2Vec2, ptr %20, i32 0, i32 1
  %23 = load float, ptr %22, align 4, !tbaa !15
  %24 = invoke noundef nonnull align 4 dereferenceable(4) ptr @_ZN6d2VecNixEi(ptr noundef nonnull align 8 dereferenceable(16) %0, i32 noundef 1)
          to label %25 unwind label %55

25:                                               ; preds = %21
  store float %23, ptr %24, align 4, !tbaa !14
  %26 = getelementptr inbounds %class.d2Constraint, ptr %8, i32 0, i32 1
  %27 = load ptr, ptr %26, align 8, !tbaa !9
  %28 = invoke noundef float @_ZNK6d2Body18GetAngularVelocityEv(ptr noundef nonnull align 8 dereferenceable(132) %27)
          to label %29 unwind label %55

29:                                               ; preds = %25
  %30 = invoke noundef nonnull align 4 dereferenceable(4) ptr @_ZN6d2VecNixEi(ptr noundef nonnull align 8 dereferenceable(16) %0, i32 noundef 2)
          to label %31 unwind label %55

31:                                               ; preds = %29
  store float %28, ptr %30, align 4, !tbaa !14
  %32 = getelementptr inbounds %class.d2Constraint, ptr %8, i32 0, i32 2
  %33 = load ptr, ptr %32, align 8, !tbaa !16
  %34 = invoke noundef nonnull align 4 dereferenceable(8) ptr @_ZNK6d2Body11GetVelocityEv(ptr noundef nonnull align 8 dereferenceable(132) %33)
          to label %35 unwind label %55

35:                                               ; preds = %31
  %36 = getelementptr inbounds %struct.d2Vec2, ptr %34, i32 0, i32 0
  %37 = load float, ptr %36, align 4, !tbaa !13
  %38 = invoke noundef nonnull align 4 dereferenceable(4) ptr @_ZN6d2VecNixEi(ptr noundef nonnull align 8 dereferenceable(16) %0, i32 noundef 3)
          to label %39 unwind label %55

39:                                               ; preds = %35
  store float %37, ptr %38, align 4, !tbaa !14
  %40 = getelementptr inbounds %class.d2Constraint, ptr %8, i32 0, i32 2
  %41 = load ptr, ptr %40, align 8, !tbaa !16
  %42 = invoke noundef nonnull align 4 dereferenceable(8) ptr @_ZNK6d2Body11GetVelocityEv(ptr noundef nonnull align 8 dereferenceable(132) %41)
          to label %43 unwind label %55

43:                                               ; preds = %39
  %44 = getelementptr inbounds %struct.d2Vec2, ptr %42, i32 0, i32 1
  %45 = load float, ptr %44, align 4, !tbaa !15
  %46 = invoke noundef nonnull align 4 dereferenceable(4) ptr @_ZN6d2VecNixEi(ptr noundef nonnull align 8 dereferenceable(16) %0, i32 noundef 4)
          to label %47 unwind label %55

47:                                               ; preds = %43
  store float %45, ptr %46, align 4, !tbaa !14
  %48 = getelementptr inbounds %class.d2Constraint, ptr %8, i32 0, i32 2
  %49 = load ptr, ptr %48, align 8, !tbaa !16
  %50 = invoke noundef float @_ZNK6d2Body18GetAngularVelocityEv(ptr noundef nonnull align 8 dereferenceable(132) %49)
          to label %51 unwind label %55

51:                                               ; preds = %47
  %52 = invoke noundef nonnull align 4 dereferenceable(4) ptr @_ZN6d2VecNixEi(ptr noundef nonnull align 8 dereferenceable(16) %0, i32 noundef 5)
          to label %53 unwind label %55

53:                                               ; preds = %51
  store float %50, ptr %52, align 4, !tbaa !14
  store i1 true, ptr %5, align 1
  %54 = load i1, ptr %5, align 1
  br i1 %54, label %60, label %59

55:                                               ; preds = %51, %47, %43, %39, %35, %31, %29, %25, %21, %17, %13, %9, %2
  %56 = landingpad { ptr, i32 }
          cleanup
  %57 = extractvalue { ptr, i32 } %56, 0
  store ptr %57, ptr %6, align 8
  %58 = extractvalue { ptr, i32 } %56, 1
  store i32 %58, ptr %7, align 4
  call void @_ZN6d2VecND1Ev(ptr noundef nonnull align 8 dereferenceable(16) %0) #4
  br label %61

59:                                               ; preds = %53
  call void @_ZN6d2VecND1Ev(ptr noundef nonnull align 8 dereferenceable(16) %0) #4
  br label %60

60:                                               ; preds = %59, %53
  ret void

61:                                               ; preds = %55
  %62 = load ptr, ptr %6, align 8
  %63 = load i32, ptr %7, align 4
  %64 = insertvalue { ptr, i32 } poison, ptr %62, 0
  %65 = insertvalue { ptr, i32 } %64, i32 %63, 1
  resume { ptr, i32 } %65
}

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

declare void @_ZN6d2VecN4ZeroEv(ptr noundef nonnull align 8 dereferenceable(16)) #0

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

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

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

attributes #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 = { 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 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 = !{!11, !12, i64 0}
!14 = !{!12, !12, i64 0}
!15 = !{!11, !12, i64 4}
!16 = !{!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.d2VecN = type { i32, ptr }

declare i32 @__gxx_personality_v0(...)

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

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

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

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

15:                                               ; preds = %9
  store float %13, ptr %14, align 4, !tbaa !13
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = tail call noundef float @_ZNK6d2Body18GetAngularVelocityEv(ptr noundef nonnull align 8 dereferenceable(132) %16)
  %18 = invoke noundef nonnull align 4 dereferenceable(4) ptr @_ZN6d2VecNixEi(ptr noundef nonnull align 8 dereferenceable(16) %0, i32 noundef 2)
          to label %19 unwind label %36

19:                                               ; preds = %15
  store float %17, ptr %18, align 4, !tbaa !13
  %20 = getelementptr inbounds i8, ptr %1, i64 16
  %21 = load ptr, ptr %20, align 8, !tbaa !15
  %22 = tail call noundef nonnull align 4 dereferenceable(8) ptr @_ZNK6d2Body11GetVelocityEv(ptr noundef nonnull align 8 dereferenceable(132) %21)
  %23 = load float, ptr %22, align 4, !tbaa !12
  %24 = invoke noundef nonnull align 4 dereferenceable(4) ptr @_ZN6d2VecNixEi(ptr noundef nonnull align 8 dereferenceable(16) %0, i32 noundef 3)
          to label %25 unwind label %36

25:                                               ; preds = %19
  store float %23, ptr %24, align 4, !tbaa !13
  %26 = load ptr, ptr %20, align 8, !tbaa !15
  %27 = tail call noundef nonnull align 4 dereferenceable(8) ptr @_ZNK6d2Body11GetVelocityEv(ptr noundef nonnull align 8 dereferenceable(132) %26)
  %28 = getelementptr inbounds i8, ptr %27, i64 4
  %29 = load float, ptr %28, align 4, !tbaa !14
  %30 = invoke noundef nonnull align 4 dereferenceable(4) ptr @_ZN6d2VecNixEi(ptr noundef nonnull align 8 dereferenceable(16) %0, i32 noundef 4)
          to label %31 unwind label %36

31:                                               ; preds = %25
  store float %29, ptr %30, align 4, !tbaa !13
  %32 = load ptr, ptr %20, align 8, !tbaa !15
  %33 = tail call noundef float @_ZNK6d2Body18GetAngularVelocityEv(ptr noundef nonnull align 8 dereferenceable(132) %32)
  %34 = invoke noundef nonnull align 4 dereferenceable(4) ptr @_ZN6d2VecNixEi(ptr noundef nonnull align 8 dereferenceable(16) %0, i32 noundef 5)
          to label %35 unwind label %36

35:                                               ; preds = %31
  store float %33, ptr %34, align 4, !tbaa !13
  ret void

36:                                               ; preds = %31, %25, %19, %15, %9, %3, %2
  %37 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZN6d2VecND1Ev(ptr noundef nonnull align 8 dereferenceable(16) %0) #4
  resume { ptr, i32 } %37
}

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

declare void @_ZN6d2VecN4ZeroEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #0

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

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

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

attributes #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 = { 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 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 = !{!10, !11, i64 0}
!13 = !{!11, !11, i64 0}
!14 = !{!10, !11, i64 4}
!15 = !{!6, !7, i64 16}


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