; LLVM IR from idmillington/cyclone-physics :: src/contacts.ll (ZN7cyclone15ContactResolver15adjustPositionsEPNS_7ContactEjd)

; 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.cyclone::Vector3" = type { double, double, double, double }
%"class.cyclone::ContactResolver" = type <{ i32, i32, double, double, i32, i32, i8, [7 x i8] }>
%"class.cyclone::Contact" = type { [2 x ptr], double, double, %"class.cyclone::Vector3", %"class.cyclone::Vector3", double, %"class.cyclone::Matrix3", %"class.cyclone::Vector3", double, [2 x %"class.cyclone::Vector3"] }
%"class.cyclone::Matrix3" = type { [9 x double] }

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7cyclone7Contact15matchAwakeStateEv(ptr noundef nonnull align 8 dereferenceable(280)) #0 align 2

; 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: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #3

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN7cyclone7Vector3C2Ev(ptr noundef nonnull align 8 dereferenceable(32)) unnamed_addr #4 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7cyclone7Contact19applyPositionChangeEPNS_7Vector3ES2_d(ptr noundef nonnull align 8 dereferenceable(280), ptr noundef, ptr noundef, double noundef) #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_ZNK7cyclone7Vector313scalarProductERKS0_(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 8 dereferenceable(32)) #4 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK7cyclone7Vector313vectorProductERKS0_(ptr dead_on_unwind noalias writable sret(%"class.cyclone::Vector3") align 8, ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 8 dereferenceable(32)) #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN7cyclone15ContactResolver15adjustPositionsEPNS_7ContactEjd(ptr noundef nonnull align 8 dereferenceable(33) %0, ptr noundef %1, i32 noundef %2, double noundef %3) #0 align 2 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca double, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca [2 x %"class.cyclone::Vector3"], align 16
  %12 = alloca [2 x %"class.cyclone::Vector3"], align 16
  %13 = alloca double, align 8
  %14 = alloca %"class.cyclone::Vector3", align 8
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca %"class.cyclone::Vector3", align 8
  %19 = alloca %"class.cyclone::Vector3", align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i32 %2, ptr %7, align 4, !tbaa !9
  store double %3, ptr %8, align 8, !tbaa !11
  %20 = load ptr, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  call void @llvm.lifetime.start.p0(i64 64, ptr %11) #5
  %21 = getelementptr inbounds [2 x %"class.cyclone::Vector3"], ptr %11, i32 0, i32 0
  %22 = getelementptr inbounds %"class.cyclone::Vector3", ptr %21, i64 2
  br label %23

23:                                               ; preds = %23, %4
  %24 = phi ptr [ %21, %4 ], [ %25, %23 ]
  call void @_ZN7cyclone7Vector3C2Ev(ptr noundef nonnull align 8 dereferenceable(32) %24)
  %25 = getelementptr inbounds %"class.cyclone::Vector3", ptr %24, i64 1
  %26 = icmp eq ptr %25, %22
  br i1 %26, label %27, label %23

27:                                               ; preds = %23
  call void @llvm.lifetime.start.p0(i64 64, ptr %12) #5
  %28 = getelementptr inbounds [2 x %"class.cyclone::Vector3"], ptr %12, i32 0, i32 0
  %29 = getelementptr inbounds %"class.cyclone::Vector3", ptr %28, i64 2
  br label %30

30:                                               ; preds = %30, %27
  %31 = phi ptr [ %28, %27 ], [ %32, %30 ]
  call void @_ZN7cyclone7Vector3C2Ev(ptr noundef nonnull align 8 dereferenceable(32) %31)
  %32 = getelementptr inbounds %"class.cyclone::Vector3", ptr %31, i64 1
  %33 = icmp eq ptr %32, %29
  br i1 %33, label %34, label %30

34:                                               ; preds = %30
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #5
  call void @llvm.lifetime.start.p0(i64 32, ptr %14) #5
  call void @_ZN7cyclone7Vector3C2Ev(ptr noundef nonnull align 8 dereferenceable(32) %14)
  %35 = getelementptr inbounds %"class.cyclone::ContactResolver", ptr %20, i32 0, i32 5
  store i32 0, ptr %35, align 4, !tbaa !13
  br label %36

36:                                               ; preds = %179, %34
  %37 = getelementptr inbounds %"class.cyclone::ContactResolver", ptr %20, i32 0, i32 5
  %38 = load i32, ptr %37, align 4, !tbaa !13
  %39 = getelementptr inbounds %"class.cyclone::ContactResolver", ptr %20, i32 0, i32 1
  %40 = load i32, ptr %39, align 4, !tbaa !16
  %41 = icmp ult i32 %38, %40
  br i1 %41, label %42, label %183

42:                                               ; preds = %36
  %43 = getelementptr inbounds %"class.cyclone::ContactResolver", ptr %20, i32 0, i32 3
  %44 = load double, ptr %43, align 8, !tbaa !17
  store double %44, ptr %13, align 8, !tbaa !11
  %45 = load i32, ptr %7, align 4, !tbaa !9
  store i32 %45, ptr %10, align 4, !tbaa !9
  store i32 0, ptr %9, align 4, !tbaa !9
  br label %46

46:                                               ; preds = %68, %42
  %47 = load i32, ptr %9, align 4, !tbaa !9
  %48 = load i32, ptr %7, align 4, !tbaa !9
  %49 = icmp ult i32 %47, %48
  br i1 %49, label %50, label %71

50:                                               ; preds = %46
  %51 = load ptr, ptr %6, align 8, !tbaa !5
  %52 = load i32, ptr %9, align 4, !tbaa !9
  %53 = zext i32 %52 to i64
  %54 = getelementptr inbounds %"class.cyclone::Contact", ptr %51, i64 %53
  %55 = getelementptr inbounds %"class.cyclone::Contact", ptr %54, i32 0, i32 5
  %56 = load double, ptr %55, align 8, !tbaa !18
  %57 = load double, ptr %13, align 8, !tbaa !11
  %58 = fcmp ogt double %56, %57
  br i1 %58, label %59, label %67

59:                                               ; preds = %50
  %60 = load ptr, ptr %6, align 8, !tbaa !5
  %61 = load i32, ptr %9, align 4, !tbaa !9
  %62 = zext i32 %61 to i64
  %63 = getelementptr inbounds %"class.cyclone::Contact", ptr %60, i64 %62
  %64 = getelementptr inbounds %"class.cyclone::Contact", ptr %63, i32 0, i32 5
  %65 = load double, ptr %64, align 8, !tbaa !18
  store double %65, ptr %13, align 8, !tbaa !11
  %66 = load i32, ptr %9, align 4, !tbaa !9
  store i32 %66, ptr %10, align 4, !tbaa !9
  br label %67

67:                                               ; preds = %59, %50
  br label %68

68:                                               ; preds = %67
  %69 = load i32, ptr %9, align 4, !tbaa !9
  %70 = add i32 %69, 1
  store i32 %70, ptr %9, align 4, !tbaa !9
  br label %46, !llvm.loop !22

71:                                               ; preds = %46
  %72 = load i32, ptr %10, align 4, !tbaa !9
  %73 = load i32, ptr %7, align 4, !tbaa !9
  %74 = icmp eq i32 %72, %73
  br i1 %74, label %75, label %76

75:                                               ; preds = %71
  br label %183

76:                                               ; preds = %71
  %77 = load ptr, ptr %6, align 8, !tbaa !5
  %78 = load i32, ptr %10, align 4, !tbaa !9
  %79 = zext i32 %78 to i64
  %80 = getelementptr inbounds %"class.cyclone::Contact", ptr %77, i64 %79
  call void @_ZN7cyclone7Contact15matchAwakeStateEv(ptr noundef nonnull align 8 dereferenceable(280) %80)
  %81 = load ptr, ptr %6, align 8, !tbaa !5
  %82 = load i32, ptr %10, align 4, !tbaa !9
  %83 = zext i32 %82 to i64
  %84 = getelementptr inbounds %"class.cyclone::Contact", ptr %81, i64 %83
  %85 = getelementptr inbounds [2 x %"class.cyclone::Vector3"], ptr %11, i64 0, i64 0
  %86 = getelementptr inbounds [2 x %"class.cyclone::Vector3"], ptr %12, i64 0, i64 0
  %87 = load double, ptr %13, align 8, !tbaa !11
  call void @_ZN7cyclone7Contact19applyPositionChangeEPNS_7Vector3ES2_d(ptr noundef nonnull align 8 dereferenceable(280) %84, ptr noundef %85, ptr noundef %86, double noundef %87)
  store i32 0, ptr %9, align 4, !tbaa !9
  br label %88

88:                                               ; preds = %176, %76
  %89 = load i32, ptr %9, align 4, !tbaa !9
  %90 = load i32, ptr %7, align 4, !tbaa !9
  %91 = icmp ult i32 %89, %90
  br i1 %91, label %92, label %179

92:                                               ; preds = %88
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #5
  store i32 0, ptr %15, align 4, !tbaa !9
  br label %93

93:                                               ; preds = %172, %92
  %94 = load i32, ptr %15, align 4, !tbaa !9
  %95 = icmp ult i32 %94, 2
  br i1 %95, label %97, label %96

96:                                               ; preds = %93
  store i32 10, ptr %16, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #5
  br label %175

97:                                               ; preds = %93
  %98 = load ptr, ptr %6, align 8, !tbaa !5
  %99 = load i32, ptr %9, align 4, !tbaa !9
  %100 = zext i32 %99 to i64
  %101 = getelementptr inbounds %"class.cyclone::Contact", ptr %98, i64 %100
  %102 = getelementptr inbounds %"class.cyclone::Contact", ptr %101, i32 0, i32 0
  %103 = load i32, ptr %15, align 4, !tbaa !9
  %104 = zext i32 %103 to i64
  %105 = getelementptr inbounds [2 x ptr], ptr %102, i64 0, i64 %104
  %106 = load ptr, ptr %105, align 8, !tbaa !5
  %107 = icmp ne ptr %106, null
  br i1 %107, label %108, label %171

108:                                              ; preds = %97
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #5
  store i32 0, ptr %17, align 4, !tbaa !9
  br label %109

109:                                              ; preds = %167, %108
  %110 = load i32, ptr %17, align 4, !tbaa !9
  %111 = icmp ult i32 %110, 2
  br i1 %111, label %113, label %112

112:                                              ; preds = %109
  store i32 13, ptr %16, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #5
  br label %170

113:                                              ; preds = %109
  %114 = load ptr, ptr %6, align 8, !tbaa !5
  %115 = load i32, ptr %9, align 4, !tbaa !9
  %116 = zext i32 %115 to i64
  %117 = getelementptr inbounds %"class.cyclone::Contact", ptr %114, i64 %116
  %118 = getelementptr inbounds %"class.cyclone::Contact", ptr %117, i32 0, i32 0
  %119 = load i32, ptr %15, align 4, !tbaa !9
  %120 = zext i32 %119 to i64
  %121 = getelementptr inbounds [2 x ptr], ptr %118, i64 0, i64 %120
  %122 = load ptr, ptr %121, align 8, !tbaa !5
  %123 = load ptr, ptr %6, align 8, !tbaa !5
  %124 = load i32, ptr %10, align 4, !tbaa !9
  %125 = zext i32 %124 to i64
  %126 = getelementptr inbounds %"class.cyclone::Contact", ptr %123, i64 %125
  %127 = getelementptr inbounds %"class.cyclone::Contact", ptr %126, i32 0, i32 0
  %128 = load i32, ptr %17, align 4, !tbaa !9
  %129 = zext i32 %128 to i64
  %130 = getelementptr inbounds [2 x ptr], ptr %127, i64 0, i64 %129
  %131 = load ptr, ptr %130, align 8, !tbaa !5
  %132 = icmp eq ptr %122, %131
  br i1 %132, label %133, label %166

133:                                              ; preds = %113
  call void @llvm.lifetime.start.p0(i64 32, ptr %18) #5
  %134 = load i32, ptr %17, align 4, !tbaa !9
  %135 = zext i32 %134 to i64
  %136 = getelementptr inbounds [2 x %"class.cyclone::Vector3"], ptr %11, i64 0, i64 %135
  call void @llvm.lifetime.start.p0(i64 32, ptr %19) #5
  %137 = load i32, ptr %17, align 4, !tbaa !9
  %138 = zext i32 %137 to i64
  %139 = getelementptr inbounds [2 x %"class.cyclone::Vector3"], ptr %12, i64 0, i64 %138
  %140 = load ptr, ptr %6, align 8, !tbaa !5
  %141 = load i32, ptr %9, align 4, !tbaa !9
  %142 = zext i32 %141 to i64
  %143 = getelementptr inbounds %"class.cyclone::Contact", ptr %140, i64 %142
  %144 = getelementptr inbounds %"class.cyclone::Contact", ptr %143, i32 0, i32 9
  %145 = load i32, ptr %15, align 4, !tbaa !9
  %146 = zext i32 %145 to i64
  %147 = getelementptr inbounds [2 x %"class.cyclone::Vector3"], ptr %144, i64 0, i64 %146
  call void @_ZNK7cyclone7Vector313vectorProductERKS0_(ptr dead_on_unwind writable sret(%"class.cyclone::Vector3") align 8 %19, ptr noundef nonnull align 8 dereferenceable(32) %139, ptr noundef nonnull align 8 dereferenceable(32) %147)
  call void @_ZNK7cyclone7Vector3plERKS0_(ptr dead_on_unwind writable sret(%"class.cyclone::Vector3") align 8 %18, ptr noundef nonnull align 8 dereferenceable(32) %136, ptr noundef nonnull align 8 dereferenceable(32) %19)
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %14, ptr align 8 %18, i64 32, i1 false), !tbaa.struct !24
  call void @llvm.lifetime.end.p0(i64 32, ptr %19) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr %18) #5
  %148 = load ptr, ptr %6, align 8, !tbaa !5
  %149 = load i32, ptr %9, align 4, !tbaa !9
  %150 = zext i32 %149 to i64
  %151 = getelementptr inbounds %"class.cyclone::Contact", ptr %148, i64 %150
  %152 = getelementptr inbounds %"class.cyclone::Contact", ptr %151, i32 0, i32 4
  %153 = call noundef double @_ZNK7cyclone7Vector313scalarProductERKS0_(ptr noundef nonnull align 8 dereferenceable(32) %14, ptr noundef nonnull align 8 dereferenceable(32) %152)
  %154 = load i32, ptr %15, align 4, !tbaa !9
  %155 = icmp ne i32 %154, 0
  %156 = zext i1 %155 to i64
  %157 = select i1 %155, i32 1, i32 -1
  %158 = sitofp i32 %157 to double
  %159 = load ptr, ptr %6, align 8, !tbaa !5
  %160 = load i32, ptr %9, align 4, !tbaa !9
  %161 = zext i32 %160 to i64
  %162 = getelementptr inbounds %"class.cyclone::Contact", ptr %159, i64 %161
  %163 = getelementptr inbounds %"class.cyclone::Contact", ptr %162, i32 0, i32 5
  %164 = load double, ptr %163, align 8, !tbaa !18
  %165 = call double @llvm.fmuladd.f64(double %153, double %158, double %164)
  store double %165, ptr %163, align 8, !tbaa !18
  br label %166

166:                                              ; preds = %133, %113
  br label %167

167:                                              ; preds = %166
  %168 = load i32, ptr %17, align 4, !tbaa !9
  %169 = add i32 %168, 1
  store i32 %169, ptr %17, align 4, !tbaa !9
  br label %109, !llvm.loop !25

170:                                              ; preds = %112
  br label %171

171:                                              ; preds = %170, %97
  br label %172

172:                                              ; preds = %171
  %173 = load i32, ptr %15, align 4, !tbaa !9
  %174 = add i32 %173, 1
  store i32 %174, ptr %15, align 4, !tbaa !9
  br label %93, !llvm.loop !26

175:                                              ; preds = %96
  br label %176

176:                                              ; preds = %175
  %177 = load i32, ptr %9, align 4, !tbaa !9
  %178 = add i32 %177, 1
  store i32 %178, ptr %9, align 4, !tbaa !9
  br label %88, !llvm.loop !27

179:                                              ; preds = %88
  %180 = getelementptr inbounds %"class.cyclone::ContactResolver", ptr %20, i32 0, i32 5
  %181 = load i32, ptr %180, align 4, !tbaa !13
  %182 = add i32 %181, 1
  store i32 %182, ptr %180, align 4, !tbaa !13
  br label %36, !llvm.loop !28

183:                                              ; preds = %75, %36
  call void @llvm.lifetime.end.p0(i64 32, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 64, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 64, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK7cyclone7Vector3plERKS0_(ptr dead_on_unwind noalias writable sret(%"class.cyclone::Vector3") align 8, ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 8 dereferenceable(32)) #0 align 2

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { 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 #5 = { 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 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = !{!14, !10, i64 28}
!14 = !{!"_ZTSN7cyclone15ContactResolverE", !10, i64 0, !10, i64 4, !12, i64 8, !12, i64 16, !10, i64 24, !10, i64 28, !15, i64 32}
!15 = !{!"bool", !7, i64 0}
!16 = !{!14, !10, i64 4}
!17 = !{!14, !12, i64 16}
!18 = !{!19, !12, i64 96}
!19 = !{!"_ZTSN7cyclone7ContactE", !7, i64 0, !12, i64 16, !12, i64 24, !20, i64 32, !20, i64 64, !12, i64 96, !21, i64 104, !20, i64 176, !12, i64 208, !7, i64 216}
!20 = !{!"_ZTSN7cyclone7Vector3E", !12, i64 0, !12, i64 8, !12, i64 16, !12, i64 24}
!21 = !{!"_ZTSN7cyclone7Matrix3E", !7, i64 0}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}
!24 = !{i64 0, i64 8, !11, i64 8, i64 8, !11, i64 16, i64 8, !11, i64 24, i64 8, !11}
!25 = distinct !{!25, !23}
!26 = distinct !{!26, !23}
!27 = distinct !{!27, !23}
!28 = distinct !{!28, !23}


; 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.cyclone::Vector3" = type { double, double, double, double }
%"class.cyclone::Contact" = type { [2 x ptr], double, double, %"class.cyclone::Vector3", %"class.cyclone::Vector3", double, %"class.cyclone::Matrix3", %"class.cyclone::Vector3", double, [2 x %"class.cyclone::Vector3"] }
%"class.cyclone::Matrix3" = type { [9 x double] }

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7cyclone7Contact15matchAwakeStateEv(ptr noundef nonnull align 8 dereferenceable(280)) local_unnamed_addr #0 align 2

; 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 nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #3

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN7cyclone7Vector3C2Ev(ptr noundef nonnull align 8 dereferenceable(32)) unnamed_addr #4 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7cyclone7Contact19applyPositionChangeEPNS_7Vector3ES2_d(ptr noundef nonnull align 8 dereferenceable(280), ptr noundef, ptr noundef, double noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_ZNK7cyclone7Vector313scalarProductERKS0_(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #4 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK7cyclone7Vector313vectorProductERKS0_(ptr dead_on_unwind noalias writable sret(%"class.cyclone::Vector3") align 8, ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN7cyclone15ContactResolver15adjustPositionsEPNS_7ContactEjd(ptr nocapture noundef nonnull align 8 dereferenceable(33) %0, ptr noundef %1, i32 noundef %2, double noundef %3) local_unnamed_addr #0 align 2 {
  %5 = alloca [2 x %"class.cyclone::Vector3"], align 16
  %6 = alloca [2 x %"class.cyclone::Vector3"], align 16
  %7 = alloca %"class.cyclone::Vector3", align 8
  %8 = alloca %"class.cyclone::Vector3", align 8
  %9 = alloca %"class.cyclone::Vector3", align 8
  call void @llvm.lifetime.start.p0(i64 64, ptr nonnull %5) #5
  call void @_ZN7cyclone7Vector3C2Ev(ptr noundef nonnull align 8 dereferenceable(32) %5)
  %.ptr.1 = getelementptr inbounds i8, ptr %5, i64 32
  call void @_ZN7cyclone7Vector3C2Ev(ptr noundef nonnull align 8 dereferenceable(32) %.ptr.1)
  call void @llvm.lifetime.start.p0(i64 64, ptr nonnull %6) #5
  call void @_ZN7cyclone7Vector3C2Ev(ptr noundef nonnull align 8 dereferenceable(32) %6)
  %.ptr54.1 = getelementptr inbounds i8, ptr %6, i64 32
  call void @_ZN7cyclone7Vector3C2Ev(ptr noundef nonnull align 8 dereferenceable(32) %.ptr54.1)
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %7) #5
  call void @_ZN7cyclone7Vector3C2Ev(ptr noundef nonnull align 8 dereferenceable(32) %7)
  %10 = getelementptr inbounds i8, ptr %0, i64 28
  %11 = getelementptr inbounds i8, ptr %0, i64 4
  store i32 0, ptr %10, align 4, !tbaa !5
  %12 = load i32, ptr %11, align 4, !tbaa !12
  %.not = icmp eq i32 %12, 0
  br i1 %.not, label %._crit_edge68, label %.lr.ph67

.lr.ph67:                                         ; preds = %4
  %13 = getelementptr inbounds i8, ptr %0, i64 16
  %.not81 = icmp eq i32 %2, 0
  br i1 %.not81, label %._crit_edge68, label %.lr.ph67.split.us.preheader

.lr.ph67.split.us.preheader:                      ; preds = %.lr.ph67
  %wide.trip.count = zext i32 %2 to i64
  %wide.trip.count93 = zext i32 %2 to i64
  %xtraiter = and i64 %wide.trip.count, 1
  %14 = icmp eq i32 %2, 1
  %unroll_iter = and i64 %wide.trip.count, 4294967294
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br label %.lr.ph.us.preheader

.lr.ph.us.preheader:                              ; preds = %._crit_edge65.us, %.lr.ph67.split.us.preheader
  %15 = load double, ptr %13, align 8, !tbaa !13
  br i1 %14, label %._crit_edge.us.unr-lcssa, label %.lr.ph.us

._crit_edge.us.unr-lcssa:                         ; preds = %.lr.ph.us, %.lr.ph.us.preheader
  %.146.us.lcssa.ph = phi i32 [ poison, %.lr.ph.us.preheader ], [ %.146.us.1, %.lr.ph.us ]
  %.1.us.lcssa.ph = phi double [ poison, %.lr.ph.us.preheader ], [ %.1.us.1, %.lr.ph.us ]
  %indvars.iv.unr = phi i64 [ 0, %.lr.ph.us.preheader ], [ %indvars.iv.next.1, %.lr.ph.us ]
  %.04460.us.unr = phi double [ %15, %.lr.ph.us.preheader ], [ %.1.us.1, %.lr.ph.us ]
  %.04559.us.unr = phi i32 [ %2, %.lr.ph.us.preheader ], [ %.146.us.1, %.lr.ph.us ]
  br i1 %lcmp.mod.not, label %._crit_edge.us, label %.lr.ph.us.epil

.lr.ph.us.epil:                                   ; preds = %._crit_edge.us.unr-lcssa
  %16 = getelementptr inbounds %"class.cyclone::Contact", ptr %1, i64 %indvars.iv.unr, i32 5
  %17 = load double, ptr %16, align 8, !tbaa !14
  %18 = fcmp ogt double %17, %.04460.us.unr
  %19 = trunc nuw i64 %indvars.iv.unr to i32
  %.146.us.epil = select i1 %18, i32 %19, i32 %.04559.us.unr
  %.1.us.epil = select i1 %18, double %17, double %.04460.us.unr
  br label %._crit_edge.us

._crit_edge.us:                                   ; preds = %._crit_edge.us.unr-lcssa, %.lr.ph.us.epil
  %.146.us.lcssa = phi i32 [ %.146.us.lcssa.ph, %._crit_edge.us.unr-lcssa ], [ %.146.us.epil, %.lr.ph.us.epil ]
  %.1.us.lcssa = phi double [ %.1.us.lcssa.ph, %._crit_edge.us.unr-lcssa ], [ %.1.us.epil, %.lr.ph.us.epil ]
  %20 = icmp eq i32 %.146.us.lcssa, %2
  br i1 %20, label %._crit_edge68, label %.preheader57.lr.ph.us

.preheader57.lr.ph.us:                            ; preds = %._crit_edge.us
  %21 = zext i32 %.146.us.lcssa to i64
  %22 = getelementptr inbounds %"class.cyclone::Contact", ptr %1, i64 %21
  call void @_ZN7cyclone7Contact15matchAwakeStateEv(ptr noundef nonnull align 8 dereferenceable(280) %22)
  call void @_ZN7cyclone7Contact19applyPositionChangeEPNS_7Vector3ES2_d(ptr noundef nonnull align 8 dereferenceable(280) %22, ptr noundef nonnull %5, ptr noundef nonnull %6, double noundef %.1.us.lcssa)
  %23 = getelementptr inbounds i8, ptr %22, i64 8
  %24 = getelementptr inbounds i8, ptr %22, i64 8
  br label %.preheader57.us

25:                                               ; preds = %.preheader.us
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %8) #5
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %9) #5
  call void @_ZNK7cyclone7Vector313vectorProductERKS0_(ptr dead_on_unwind nonnull writable sret(%"class.cyclone::Vector3") align 8 %9, ptr noundef nonnull align 8 dereferenceable(32) %6, ptr noundef nonnull align 8 dereferenceable(32) %65)
  call void @_ZNK7cyclone7Vector3plERKS0_(ptr dead_on_unwind nonnull writable sret(%"class.cyclone::Vector3") align 8 %8, ptr noundef nonnull align 8 dereferenceable(32) %5, ptr noundef nonnull align 8 dereferenceable(32) %9)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(32) %7, ptr noundef nonnull align 8 dereferenceable(32) %8, i64 32, i1 false), !tbaa.struct !18
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %9) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %8) #5
  %26 = call noundef double @_ZNK7cyclone7Vector313scalarProductERKS0_(ptr noundef nonnull align 8 dereferenceable(32) %7, ptr noundef nonnull align 8 dereferenceable(32) %66)
  %27 = load double, ptr %67, align 8, !tbaa !14
  %28 = call double @llvm.fmuladd.f64(double %26, double -1.000000e+00, double %27)
  store double %28, ptr %67, align 8, !tbaa !14
  %.pre = load ptr, ptr %64, align 8, !tbaa !20
  br label %29

29:                                               ; preds = %25, %.preheader.us
  %30 = phi ptr [ %.pre, %25 ], [ %68, %.preheader.us ]
  %31 = load ptr, ptr %23, align 8, !tbaa !20
  %32 = icmp eq ptr %30, %31
  br i1 %32, label %33, label %.loopexit.us

33:                                               ; preds = %29
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %8) #5
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %9) #5
  call void @_ZNK7cyclone7Vector313vectorProductERKS0_(ptr dead_on_unwind nonnull writable sret(%"class.cyclone::Vector3") align 8 %9, ptr noundef nonnull align 8 dereferenceable(32) %.ptr54.1, ptr noundef nonnull align 8 dereferenceable(32) %65)
  call void @_ZNK7cyclone7Vector3plERKS0_(ptr dead_on_unwind nonnull writable sret(%"class.cyclone::Vector3") align 8 %8, ptr noundef nonnull align 8 dereferenceable(32) %.ptr.1, ptr noundef nonnull align 8 dereferenceable(32) %9)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(32) %7, ptr noundef nonnull align 8 dereferenceable(32) %8, i64 32, i1 false), !tbaa.struct !18
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %9) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %8) #5
  %34 = call noundef double @_ZNK7cyclone7Vector313scalarProductERKS0_(ptr noundef nonnull align 8 dereferenceable(32) %7, ptr noundef nonnull align 8 dereferenceable(32) %66)
  %35 = load double, ptr %67, align 8, !tbaa !14
  %36 = call double @llvm.fmuladd.f64(double %34, double -1.000000e+00, double %35)
  store double %36, ptr %67, align 8, !tbaa !14
  br label %.loopexit.us

.loopexit.us:                                     ; preds = %29, %33, %.preheader57.us
  %37 = getelementptr inbounds i8, ptr %64, i64 8
  %38 = load ptr, ptr %37, align 8, !tbaa !20
  %.not.us.1 = icmp eq ptr %38, null
  br i1 %.not.us.1, label %.loopexit.us.1, label %.preheader.us.1

.preheader.us.1:                                  ; preds = %.loopexit.us
  %39 = getelementptr inbounds i8, ptr %64, i64 248
  %40 = load ptr, ptr %22, align 8, !tbaa !20
  %41 = icmp eq ptr %38, %40
  br i1 %41, label %42, label %46

42:                                               ; preds = %.preheader.us.1
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %8) #5
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %9) #5
  call void @_ZNK7cyclone7Vector313vectorProductERKS0_(ptr dead_on_unwind nonnull writable sret(%"class.cyclone::Vector3") align 8 %9, ptr noundef nonnull align 8 dereferenceable(32) %6, ptr noundef nonnull align 8 dereferenceable(32) %39)
  call void @_ZNK7cyclone7Vector3plERKS0_(ptr dead_on_unwind nonnull writable sret(%"class.cyclone::Vector3") align 8 %8, ptr noundef nonnull align 8 dereferenceable(32) %5, ptr noundef nonnull align 8 dereferenceable(32) %9)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(32) %7, ptr noundef nonnull align 8 dereferenceable(32) %8, i64 32, i1 false), !tbaa.struct !18
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %9) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %8) #5
  %43 = call noundef double @_ZNK7cyclone7Vector313scalarProductERKS0_(ptr noundef nonnull align 8 dereferenceable(32) %7, ptr noundef nonnull align 8 dereferenceable(32) %66)
  %44 = load double, ptr %67, align 8, !tbaa !14
  %45 = fadd double %43, %44
  store double %45, ptr %67, align 8, !tbaa !14
  %.pre95 = load ptr, ptr %37, align 8, !tbaa !20
  br label %46

46:                                               ; preds = %42, %.preheader.us.1
  %47 = phi ptr [ %.pre95, %42 ], [ %38, %.preheader.us.1 ]
  %48 = load ptr, ptr %24, align 8, !tbaa !20
  %49 = icmp eq ptr %47, %48
  br i1 %49, label %50, label %.loopexit.us.1

50:                                               ; preds = %46
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %8) #5
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %9) #5
  call void @_ZNK7cyclone7Vector313vectorProductERKS0_(ptr dead_on_unwind nonnull writable sret(%"class.cyclone::Vector3") align 8 %9, ptr noundef nonnull align 8 dereferenceable(32) %.ptr54.1, ptr noundef nonnull align 8 dereferenceable(32) %39)
  call void @_ZNK7cyclone7Vector3plERKS0_(ptr dead_on_unwind nonnull writable sret(%"class.cyclone::Vector3") align 8 %8, ptr noundef nonnull align 8 dereferenceable(32) %.ptr.1, ptr noundef nonnull align 8 dereferenceable(32) %9)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(32) %7, ptr noundef nonnull align 8 dereferenceable(32) %8, i64 32, i1 false), !tbaa.struct !18
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %9) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %8) #5
  %51 = call noundef double @_ZNK7cyclone7Vector313scalarProductERKS0_(ptr noundef nonnull align 8 dereferenceable(32) %7, ptr noundef nonnull align 8 dereferenceable(32) %66)
  %52 = load double, ptr %67, align 8, !tbaa !14
  %53 = fadd double %51, %52
  store double %53, ptr %67, align 8, !tbaa !14
  br label %.loopexit.us.1

.loopexit.us.1:                                   ; preds = %46, %50, %.loopexit.us
  %indvars.iv.next91 = add nuw nsw i64 %indvars.iv90, 1
  %exitcond94.not = icmp eq i64 %indvars.iv.next91, %wide.trip.count93
  br i1 %exitcond94.not, label %._crit_edge65.us, label %.preheader57.us, !llvm.loop !22

.lr.ph.us:                                        ; preds = %.lr.ph.us.preheader, %.lr.ph.us
  %indvars.iv = phi i64 [ %indvars.iv.next.1, %.lr.ph.us ], [ 0, %.lr.ph.us.preheader ]
  %.04460.us = phi double [ %.1.us.1, %.lr.ph.us ], [ %15, %.lr.ph.us.preheader ]
  %.04559.us = phi i32 [ %.146.us.1, %.lr.ph.us ], [ %2, %.lr.ph.us.preheader ]
  %niter = phi i64 [ %niter.next.1, %.lr.ph.us ], [ 0, %.lr.ph.us.preheader ]
  %54 = getelementptr inbounds %"class.cyclone::Contact", ptr %1, i64 %indvars.iv, i32 5
  %55 = load double, ptr %54, align 8, !tbaa !14
  %56 = fcmp ogt double %55, %.04460.us
  %57 = trunc nuw i64 %indvars.iv to i32
  %.146.us = select i1 %56, i32 %57, i32 %.04559.us
  %.1.us = select i1 %56, double %55, double %.04460.us
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %58 = getelementptr inbounds %"class.cyclone::Contact", ptr %1, i64 %indvars.iv.next, i32 5
  %59 = load double, ptr %58, align 8, !tbaa !14
  %60 = fcmp ogt double %59, %.1.us
  %61 = trunc nuw i64 %indvars.iv.next to i32
  %.146.us.1 = select i1 %60, i32 %61, i32 %.146.us
  %.1.us.1 = select i1 %60, double %59, double %.1.us
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %._crit_edge.us.unr-lcssa, label %.lr.ph.us, !llvm.loop !24

.preheader.us:                                    ; preds = %.preheader57.us
  %62 = load ptr, ptr %22, align 8, !tbaa !20
  %63 = icmp eq ptr %68, %62
  br i1 %63, label %25, label %29

.preheader57.us:                                  ; preds = %.preheader57.lr.ph.us, %.loopexit.us.1
  %indvars.iv90 = phi i64 [ 0, %.preheader57.lr.ph.us ], [ %indvars.iv.next91, %.loopexit.us.1 ]
  %64 = getelementptr inbounds %"class.cyclone::Contact", ptr %1, i64 %indvars.iv90
  %65 = getelementptr inbounds i8, ptr %64, i64 216
  %66 = getelementptr inbounds i8, ptr %64, i64 64
  %67 = getelementptr inbounds i8, ptr %64, i64 96
  %68 = load ptr, ptr %64, align 8, !tbaa !20
  %.not.us = icmp eq ptr %68, null
  br i1 %.not.us, label %.loopexit.us, label %.preheader.us

._crit_edge65.us:                                 ; preds = %.loopexit.us.1
  %69 = load i32, ptr %10, align 4, !tbaa !5
  %70 = add i32 %69, 1
  store i32 %70, ptr %10, align 4, !tbaa !5
  %71 = load i32, ptr %11, align 4, !tbaa !12
  %72 = icmp ult i32 %70, %71
  br i1 %72, label %.lr.ph.us.preheader, label %._crit_edge68, !llvm.loop !25

._crit_edge68:                                    ; preds = %._crit_edge65.us, %._crit_edge.us, %.lr.ph67, %4
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %7) #5
  call void @llvm.lifetime.end.p0(i64 64, ptr nonnull %6) #5
  call void @llvm.lifetime.end.p0(i64 64, ptr nonnull %5) #5
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK7cyclone7Vector3plERKS0_(ptr dead_on_unwind noalias writable sret(%"class.cyclone::Vector3") align 8, ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #0 align 2

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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { 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 #5 = { 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 28}
!6 = !{!"_ZTSN7cyclone15ContactResolverE", !7, i64 0, !7, i64 4, !10, i64 8, !10, i64 16, !7, i64 24, !7, i64 28, !11, i64 32}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"double", !8, i64 0}
!11 = !{!"bool", !8, i64 0}
!12 = !{!6, !7, i64 4}
!13 = !{!6, !10, i64 16}
!14 = !{!15, !10, i64 96}
!15 = !{!"_ZTSN7cyclone7ContactE", !8, i64 0, !10, i64 16, !10, i64 24, !16, i64 32, !16, i64 64, !10, i64 96, !17, i64 104, !16, i64 176, !10, i64 208, !8, i64 216}
!16 = !{!"_ZTSN7cyclone7Vector3E", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24}
!17 = !{!"_ZTSN7cyclone7Matrix3E", !8, i64 0}
!18 = !{i64 0, i64 8, !19, i64 8, i64 8, !19, i64 16, i64 8, !19, i64 24, i64 8, !19}
!19 = !{!10, !10, i64 0}
!20 = !{!21, !21, i64 0}
!21 = !{!"any pointer", !8, i64 0}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}
!24 = distinct !{!24, !23}
!25 = distinct !{!25, !23}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SCCPPass,SROAPass,SimplifyCFGPass