; LLVM IR from mtsamis/box2d-optimized :: src/particle (b2_particle_system)

; 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.b2ParticleSystem = type { i8, i32, i32, i8, i32, i8, i8, i32, float, float, float, float, i32, i32, %class.b2SlabAllocator, %"struct.b2ParticleSystem::UserOverridableBuffer", %"struct.b2ParticleSystem::UserOverridableBuffer.0", %"struct.b2ParticleSystem::UserOverridableBuffer.2", %"struct.b2ParticleSystem::UserOverridableBuffer.2", ptr, ptr, ptr, ptr, ptr, ptr, %"struct.b2ParticleSystem::UserOverridableBuffer.4", ptr, %"struct.b2ParticleSystem::UserOverridableBuffer.6", i32, [4 x i8], %"struct.b2ParticleSystem::UserOverridableBuffer.8", %"struct.b2ParticleSystem::UserOverridableBuffer.8", %"struct.b2ParticleSystem::UserOverridableBuffer.8", %class.b2GrowableBuffer, %class.b2GrowableBuffer.10, %class.b2GrowableBuffer.11, %class.b2GrowableBuffer.12, %class.b2GrowableBuffer.13, %class.b2GrowableBuffer.14, %"struct.b2ParticleSystem::UserOverridableBuffer.8", %"struct.b2ParticleSystem::UserOverridableBuffer.8", i64, i8, i32, ptr, %struct.b2ParticleSystemDef, ptr, ptr, ptr }
%class.b2SlabAllocator = type { %class.b2TrackedBlockAllocator, i32, %class.b2TypedFreeList }
%class.b2TrackedBlockAllocator = type { %class.b2TypedIntrusiveListNode }
%class.b2TypedIntrusiveListNode = type { %class.b2IntrusiveListNode }
%class.b2IntrusiveListNode = type { ptr, ptr }
%class.b2TypedFreeList = type { %class.b2FreeList }
%class.b2FreeList = type { %class.b2IntrusiveListNode, %class.b2IntrusiveListNode }
%"struct.b2ParticleSystem::UserOverridableBuffer" = type <{ ptr, i32, [4 x i8] }>
%"struct.b2ParticleSystem::UserOverridableBuffer.0" = type <{ ptr, i32, [4 x i8] }>
%"struct.b2ParticleSystem::UserOverridableBuffer.2" = type <{ ptr, i32, [4 x i8] }>
%"struct.b2ParticleSystem::UserOverridableBuffer.4" = type <{ ptr, i32, [4 x i8] }>
%"struct.b2ParticleSystem::UserOverridableBuffer.6" = type <{ ptr, i32, [4 x i8] }>
%class.b2GrowableBuffer = type { ptr, i32, i32, ptr }
%class.b2GrowableBuffer.10 = type { ptr, i32, i32, ptr }
%class.b2GrowableBuffer.11 = type { ptr, i32, i32, ptr }
%class.b2GrowableBuffer.12 = type { ptr, i32, i32, ptr }
%class.b2GrowableBuffer.13 = type { ptr, i32, i32, ptr }
%class.b2GrowableBuffer.14 = type { ptr, i32, i32, ptr }
%"struct.b2ParticleSystem::UserOverridableBuffer.8" = type <{ ptr, i32, [4 x i8] }>
%struct.b2ParticleSystemDef = type { i8, float, float, float, i32, float, float, float, float, float, float, float, float, float, float, float, float, i32, float, i8, float }
%struct.b2ParticlePair = type { i32, i32, i32, float, float }
%"struct.b2ParticleSystem::ParticleListNode" = type { ptr, ptr, i32, i32 }
%struct.b2ParticleTriad = type { i32, i32, i32, i32, float, %struct.b2Vec2, %struct.b2Vec2, %struct.b2Vec2, float, float, float, float }
%struct.b2Vec2 = type { float, float }

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN16b2ParticleSystem36UpdatePairsAndTriadsWithParticleListEPK15b2ParticleGroupPKNS_16ParticleListNodeE(ptr noundef nonnull align 8 dereferenceable(632) %0, ptr noundef %1, ptr noundef %2) #1 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  %17 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = call noundef i32 @_ZNK15b2ParticleGroup14GetBufferIndexEv(ptr noundef nonnull align 8 dereferenceable(96) %18)
  store i32 %19, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  store i32 0, ptr %8, align 4, !tbaa !9
  br label %20

20:                                               ; preds = %66, %3
  %21 = load i32, ptr %8, align 4, !tbaa !9
  %22 = getelementptr inbounds %class.b2ParticleSystem, ptr %17, i32 0, i32 37
  %23 = call noundef i32 @_ZNK16b2GrowableBufferI14b2ParticlePairE8GetCountEv(ptr noundef nonnull align 8 dereferenceable(24) %22)
  %24 = icmp slt i32 %21, %23
  br i1 %24, label %26, label %25

25:                                               ; preds = %20
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  br label %69

26:                                               ; preds = %20
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %27 = getelementptr inbounds %class.b2ParticleSystem, ptr %17, i32 0, i32 37
  %28 = load i32, ptr %8, align 4, !tbaa !9
  %29 = call noundef nonnull align 4 dereferenceable(20) ptr @_ZN16b2GrowableBufferI14b2ParticlePairEixEi(ptr noundef nonnull align 8 dereferenceable(24) %27, i32 noundef %28)
  store ptr %29, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  %30 = load ptr, ptr %9, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.b2ParticlePair, ptr %30, i32 0, i32 0
  %32 = load i32, ptr %31, align 4, !tbaa !11
  store i32 %32, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  %33 = load ptr, ptr %9, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.b2ParticlePair, ptr %33, i32 0, i32 1
  %35 = load i32, ptr %34, align 4, !tbaa !14
  store i32 %35, ptr %11, align 4, !tbaa !9
  %36 = load ptr, ptr %5, align 8, !tbaa !5
  %37 = load i32, ptr %10, align 4, !tbaa !9
  %38 = call noundef zeroext i1 @_ZNK15b2ParticleGroup16ContainsParticleEi(ptr noundef nonnull align 8 dereferenceable(96) %36, i32 noundef %37)
  br i1 %38, label %39, label %50

39:                                               ; preds = %26
  %40 = load ptr, ptr %6, align 8, !tbaa !5
  %41 = load i32, ptr %10, align 4, !tbaa !9
  %42 = load i32, ptr %7, align 4, !tbaa !9
  %43 = sub nsw i32 %41, %42
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds %"struct.b2ParticleSystem::ParticleListNode", ptr %40, i64 %44
  %46 = getelementptr inbounds %"struct.b2ParticleSystem::ParticleListNode", ptr %45, i32 0, i32 3
  %47 = load i32, ptr %46, align 4, !tbaa !15
  %48 = load ptr, ptr %9, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.b2ParticlePair, ptr %48, i32 0, i32 0
  store i32 %47, ptr %49, align 4, !tbaa !11
  br label %50

50:                                               ; preds = %39, %26
  %51 = load ptr, ptr %5, align 8, !tbaa !5
  %52 = load i32, ptr %11, align 4, !tbaa !9
  %53 = call noundef zeroext i1 @_ZNK15b2ParticleGroup16ContainsParticleEi(ptr noundef nonnull align 8 dereferenceable(96) %51, i32 noundef %52)
  br i1 %53, label %54, label %65

54:                                               ; preds = %50
  %55 = load ptr, ptr %6, align 8, !tbaa !5
  %56 = load i32, ptr %11, align 4, !tbaa !9
  %57 = load i32, ptr %7, align 4, !tbaa !9
  %58 = sub nsw i32 %56, %57
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds %"struct.b2ParticleSystem::ParticleListNode", ptr %55, i64 %59
  %61 = getelementptr inbounds %"struct.b2ParticleSystem::ParticleListNode", ptr %60, i32 0, i32 3
  %62 = load i32, ptr %61, align 4, !tbaa !15
  %63 = load ptr, ptr %9, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.b2ParticlePair, ptr %63, i32 0, i32 1
  store i32 %62, ptr %64, align 4, !tbaa !14
  br label %65

65:                                               ; preds = %54, %50
  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 8, ptr %9) #4
  br label %66

66:                                               ; preds = %65
  %67 = load i32, ptr %8, align 4, !tbaa !9
  %68 = add nsw i32 %67, 1
  store i32 %68, ptr %8, align 4, !tbaa !9
  br label %20, !llvm.loop !17

69:                                               ; preds = %25
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  store i32 0, ptr %12, align 4, !tbaa !9
  br label %70

70:                                               ; preds = %134, %69
  %71 = load i32, ptr %12, align 4, !tbaa !9
  %72 = getelementptr inbounds %class.b2ParticleSystem, ptr %17, i32 0, i32 38
  %73 = call noundef i32 @_ZNK16b2GrowableBufferI15b2ParticleTriadE8GetCountEv(ptr noundef nonnull align 8 dereferenceable(24) %72)
  %74 = icmp slt i32 %71, %73
  br i1 %74, label %76, label %75

75:                                               ; preds = %70
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  br label %137

76:                                               ; preds = %70
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  %77 = getelementptr inbounds %class.b2ParticleSystem, ptr %17, i32 0, i32 38
  %78 = load i32, ptr %12, align 4, !tbaa !9
  %79 = call noundef nonnull align 4 dereferenceable(60) ptr @_ZN16b2GrowableBufferI15b2ParticleTriadEixEi(ptr noundef nonnull align 8 dereferenceable(24) %77, i32 noundef %78)
  store ptr %79, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  %80 = load ptr, ptr %13, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.b2ParticleTriad, ptr %80, i32 0, i32 0
  %82 = load i32, ptr %81, align 4, !tbaa !19
  store i32 %82, ptr %14, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #4
  %83 = load ptr, ptr %13, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.b2ParticleTriad, ptr %83, i32 0, i32 1
  %85 = load i32, ptr %84, align 4, !tbaa !22
  store i32 %85, ptr %15, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #4
  %86 = load ptr, ptr %13, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.b2ParticleTriad, ptr %86, i32 0, i32 2
  %88 = load i32, ptr %87, align 4, !tbaa !23
  store i32 %88, ptr %16, align 4, !tbaa !9
  %89 = load ptr, ptr %5, align 8, !tbaa !5
  %90 = load i32, ptr %14, align 4, !tbaa !9
  %91 = call noundef zeroext i1 @_ZNK15b2ParticleGroup16ContainsParticleEi(ptr noundef nonnull align 8 dereferenceable(96) %89, i32 noundef %90)
  br i1 %91, label %92, label %103

92:                                               ; preds = %76
  %93 = load ptr, ptr %6, align 8, !tbaa !5
  %94 = load i32, ptr %14, align 4, !tbaa !9
  %95 = load i32, ptr %7, align 4, !tbaa !9
  %96 = sub nsw i32 %94, %95
  %97 = sext i32 %96 to i64
  %98 = getelementptr inbounds %"struct.b2ParticleSystem::ParticleListNode", ptr %93, i64 %97
  %99 = getelementptr inbounds %"struct.b2ParticleSystem::ParticleListNode", ptr %98, i32 0, i32 3
  %100 = load i32, ptr %99, align 4, !tbaa !15
  %101 = load ptr, ptr %13, align 8, !tbaa !5
  %102 = getelementptr inbounds %struct.b2ParticleTriad, ptr %101, i32 0, i32 0
  store i32 %100, ptr %102, align 4, !tbaa !19
  br label %103

103:                                              ; preds = %92, %76
  %104 = load ptr, ptr %5, align 8, !tbaa !5
  %105 = load i32, ptr %15, align 4, !tbaa !9
  %106 = call noundef zeroext i1 @_ZNK15b2ParticleGroup16ContainsParticleEi(ptr noundef nonnull align 8 dereferenceable(96) %104, i32 noundef %105)
  br i1 %106, label %107, label %118

107:                                              ; preds = %103
  %108 = load ptr, ptr %6, align 8, !tbaa !5
  %109 = load i32, ptr %15, align 4, !tbaa !9
  %110 = load i32, ptr %7, align 4, !tbaa !9
  %111 = sub nsw i32 %109, %110
  %112 = sext i32 %111 to i64
  %113 = getelementptr inbounds %"struct.b2ParticleSystem::ParticleListNode", ptr %108, i64 %112
  %114 = getelementptr inbounds %"struct.b2ParticleSystem::ParticleListNode", ptr %113, i32 0, i32 3
  %115 = load i32, ptr %114, align 4, !tbaa !15
  %116 = load ptr, ptr %13, align 8, !tbaa !5
  %117 = getelementptr inbounds %struct.b2ParticleTriad, ptr %116, i32 0, i32 1
  store i32 %115, ptr %117, align 4, !tbaa !22
  br label %118

118:                                              ; preds = %107, %103
  %119 = load ptr, ptr %5, align 8, !tbaa !5
  %120 = load i32, ptr %16, align 4, !tbaa !9
  %121 = call noundef zeroext i1 @_ZNK15b2ParticleGroup16ContainsParticleEi(ptr noundef nonnull align 8 dereferenceable(96) %119, i32 noundef %120)
  br i1 %121, label %122, label %133

122:                                              ; preds = %118
  %123 = load ptr, ptr %6, align 8, !tbaa !5
  %124 = load i32, ptr %16, align 4, !tbaa !9
  %125 = load i32, ptr %7, align 4, !tbaa !9
  %126 = sub nsw i32 %124, %125
  %127 = sext i32 %126 to i64
  %128 = getelementptr inbounds %"struct.b2ParticleSystem::ParticleListNode", ptr %123, i64 %127
  %129 = getelementptr inbounds %"struct.b2ParticleSystem::ParticleListNode", ptr %128, i32 0, i32 3
  %130 = load i32, ptr %129, align 4, !tbaa !15
  %131 = load ptr, ptr %13, align 8, !tbaa !5
  %132 = getelementptr inbounds %struct.b2ParticleTriad, ptr %131, i32 0, i32 2
  store i32 %130, ptr %132, align 4, !tbaa !23
  br label %133

133:                                              ; preds = %122, %118
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  br label %134

134:                                              ; preds = %133
  %135 = load i32, ptr %12, align 4, !tbaa !9
  %136 = add nsw i32 %135, 1
  store i32 %136, ptr %12, align 4, !tbaa !9
  br label %70, !llvm.loop !24

137:                                              ; preds = %75
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK15b2ParticleGroup14GetBufferIndexEv(ptr noundef nonnull align 8 dereferenceable(96)) #2 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK15b2ParticleGroup16ContainsParticleEi(ptr noundef nonnull align 8 dereferenceable(96), i32 noundef) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK16b2GrowableBufferI14b2ParticlePairE8GetCountEv(ptr noundef nonnull align 8 dereferenceable(24)) #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(20) ptr @_ZN16b2GrowableBufferI14b2ParticlePairEixEi(ptr noundef nonnull align 8 dereferenceable(24), i32 noundef) #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK16b2GrowableBufferI15b2ParticleTriadE8GetCountEv(ptr noundef nonnull align 8 dereferenceable(24)) #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(60) ptr @_ZN16b2GrowableBufferI15b2ParticleTriadEixEi(ptr noundef nonnull align 8 dereferenceable(24), i32 noundef) #3 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"_ZTS14b2ParticlePair", !10, i64 0, !10, i64 4, !10, i64 8, !13, i64 12, !13, i64 16}
!13 = !{!"float", !7, i64 0}
!14 = !{!12, !10, i64 4}
!15 = !{!16, !10, i64 20}
!16 = !{!"_ZTSN16b2ParticleSystem16ParticleListNodeE", !6, i64 0, !6, i64 8, !10, i64 16, !10, i64 20}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = !{!20, !10, i64 0}
!20 = !{!"_ZTS15b2ParticleTriad", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !13, i64 16, !21, i64 20, !21, i64 28, !21, i64 36, !13, i64 44, !13, i64 48, !13, i64 52, !13, i64 56}
!21 = !{!"_ZTS6b2Vec2", !13, i64 0, !13, i64 4}
!22 = !{!20, !10, i64 4}
!23 = !{!20, !10, i64 8}
!24 = distinct !{!24, !18}


; 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.b2ParticleSystem::ParticleListNode" = type { ptr, ptr, i32, i32 }

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN16b2ParticleSystem36UpdatePairsAndTriadsWithParticleListEPK15b2ParticleGroupPKNS_16ParticleListNodeE(ptr noundef nonnull align 8 dereferenceable(632) %0, ptr noundef nonnull %1, ptr nocapture noundef readonly %2) local_unnamed_addr #0 align 2 {
  %4 = tail call noundef i32 @_ZNK15b2ParticleGroup14GetBufferIndexEv(ptr noundef nonnull align 8 dereferenceable(96) %1)
  %5 = getelementptr inbounds i8, ptr %0, i64 416
  %6 = tail call noundef i32 @_ZNK16b2GrowableBufferI14b2ParticlePairE8GetCountEv(ptr noundef nonnull align 8 dereferenceable(24) %5)
  %7 = icmp sgt i32 %6, 0
  br i1 %7, label %.lr.ph, label %.preheader

.preheader:                                       ; preds = %28, %3
  %8 = getelementptr inbounds i8, ptr %0, i64 440
  %9 = tail call noundef i32 @_ZNK16b2GrowableBufferI15b2ParticleTriadE8GetCountEv(ptr noundef nonnull align 8 dereferenceable(24) %8)
  %10 = icmp sgt i32 %9, 0
  br i1 %10, label %.lr.ph45, label %._crit_edge

.lr.ph:                                           ; preds = %3, %28
  %.043 = phi i32 [ %29, %28 ], [ 0, %3 ]
  %11 = tail call noundef nonnull align 4 dereferenceable(20) ptr @_ZN16b2GrowableBufferI14b2ParticlePairEixEi(ptr noundef nonnull align 8 dereferenceable(24) %5, i32 noundef %.043)
  %12 = load i32, ptr %11, align 4, !tbaa !5
  %13 = getelementptr inbounds i8, ptr %11, i64 4
  %14 = load i32, ptr %13, align 4, !tbaa !11
  %15 = tail call noundef zeroext i1 @_ZNK15b2ParticleGroup16ContainsParticleEi(ptr noundef nonnull align 8 dereferenceable(96) %1, i32 noundef %12)
  br i1 %15, label %16, label %21

16:                                               ; preds = %.lr.ph
  %17 = sub nsw i32 %12, %4
  %18 = sext i32 %17 to i64
  %19 = getelementptr inbounds %"struct.b2ParticleSystem::ParticleListNode", ptr %2, i64 %18, i32 3
  %20 = load i32, ptr %19, align 4, !tbaa !12
  store i32 %20, ptr %11, align 4, !tbaa !5
  br label %21

21:                                               ; preds = %16, %.lr.ph
  %22 = tail call noundef zeroext i1 @_ZNK15b2ParticleGroup16ContainsParticleEi(ptr noundef nonnull align 8 dereferenceable(96) %1, i32 noundef %14)
  br i1 %22, label %23, label %28

23:                                               ; preds = %21
  %24 = sub nsw i32 %14, %4
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds %"struct.b2ParticleSystem::ParticleListNode", ptr %2, i64 %25, i32 3
  %27 = load i32, ptr %26, align 4, !tbaa !12
  store i32 %27, ptr %13, align 4, !tbaa !11
  br label %28

28:                                               ; preds = %23, %21
  %29 = add nuw nsw i32 %.043, 1
  %30 = tail call noundef i32 @_ZNK16b2GrowableBufferI14b2ParticlePairE8GetCountEv(ptr noundef nonnull align 8 dereferenceable(24) %5)
  %31 = icmp slt i32 %29, %30
  br i1 %31, label %.lr.ph, label %.preheader, !llvm.loop !15

._crit_edge:                                      ; preds = %58, %.preheader
  ret void

.lr.ph45:                                         ; preds = %.preheader, %58
  %.04244 = phi i32 [ %59, %58 ], [ 0, %.preheader ]
  %32 = tail call noundef nonnull align 4 dereferenceable(60) ptr @_ZN16b2GrowableBufferI15b2ParticleTriadEixEi(ptr noundef nonnull align 8 dereferenceable(24) %8, i32 noundef %.04244)
  %33 = load i32, ptr %32, align 4, !tbaa !17
  %34 = getelementptr inbounds i8, ptr %32, i64 4
  %35 = load i32, ptr %34, align 4, !tbaa !20
  %36 = getelementptr inbounds i8, ptr %32, i64 8
  %37 = load i32, ptr %36, align 4, !tbaa !21
  %38 = tail call noundef zeroext i1 @_ZNK15b2ParticleGroup16ContainsParticleEi(ptr noundef nonnull align 8 dereferenceable(96) %1, i32 noundef %33)
  br i1 %38, label %39, label %44

39:                                               ; preds = %.lr.ph45
  %40 = sub nsw i32 %33, %4
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds %"struct.b2ParticleSystem::ParticleListNode", ptr %2, i64 %41, i32 3
  %43 = load i32, ptr %42, align 4, !tbaa !12
  store i32 %43, ptr %32, align 4, !tbaa !17
  br label %44

44:                                               ; preds = %39, %.lr.ph45
  %45 = tail call noundef zeroext i1 @_ZNK15b2ParticleGroup16ContainsParticleEi(ptr noundef nonnull align 8 dereferenceable(96) %1, i32 noundef %35)
  br i1 %45, label %46, label %51

46:                                               ; preds = %44
  %47 = sub nsw i32 %35, %4
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds %"struct.b2ParticleSystem::ParticleListNode", ptr %2, i64 %48, i32 3
  %50 = load i32, ptr %49, align 4, !tbaa !12
  store i32 %50, ptr %34, align 4, !tbaa !20
  br label %51

51:                                               ; preds = %46, %44
  %52 = tail call noundef zeroext i1 @_ZNK15b2ParticleGroup16ContainsParticleEi(ptr noundef nonnull align 8 dereferenceable(96) %1, i32 noundef %37)
  br i1 %52, label %53, label %58

53:                                               ; preds = %51
  %54 = sub nsw i32 %37, %4
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds %"struct.b2ParticleSystem::ParticleListNode", ptr %2, i64 %55, i32 3
  %57 = load i32, ptr %56, align 4, !tbaa !12
  store i32 %57, ptr %36, align 4, !tbaa !21
  br label %58

58:                                               ; preds = %53, %51
  %59 = add nuw nsw i32 %.04244, 1
  %60 = tail call noundef i32 @_ZNK16b2GrowableBufferI15b2ParticleTriadE8GetCountEv(ptr noundef nonnull align 8 dereferenceable(24) %8)
  %61 = icmp slt i32 %59, %60
  br i1 %61, label %.lr.ph45, label %._crit_edge, !llvm.loop !22
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK15b2ParticleGroup14GetBufferIndexEv(ptr noundef nonnull align 8 dereferenceable(96)) local_unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK15b2ParticleGroup16ContainsParticleEi(ptr noundef nonnull align 8 dereferenceable(96), i32 noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK16b2GrowableBufferI14b2ParticlePairE8GetCountEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(20) ptr @_ZN16b2GrowableBufferI14b2ParticlePairEixEi(ptr noundef nonnull align 8 dereferenceable(24), i32 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK16b2GrowableBufferI15b2ParticleTriadE8GetCountEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(60) ptr @_ZN16b2GrowableBufferI15b2ParticleTriadEixEi(ptr noundef nonnull align 8 dereferenceable(24), i32 noundef) local_unnamed_addr #0 align 2

attributes #0 = { 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 #1 = { 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" }

!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 0}
!6 = !{!"_ZTS14b2ParticlePair", !7, i64 0, !7, i64 4, !7, i64 8, !10, i64 12, !10, i64 16}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"float", !8, i64 0}
!11 = !{!6, !7, i64 4}
!12 = !{!13, !7, i64 20}
!13 = !{!"_ZTSN16b2ParticleSystem16ParticleListNodeE", !14, i64 0, !14, i64 8, !7, i64 16, !7, i64 20}
!14 = !{!"any pointer", !8, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{!18, !7, i64 0}
!18 = !{!"_ZTS15b2ParticleTriad", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !10, i64 16, !19, i64 20, !19, i64 28, !19, i64 36, !10, i64 44, !10, i64 48, !10, i64 52, !10, i64 56}
!19 = !{!"_ZTS6b2Vec2", !10, i64 0, !10, i64 4}
!20 = !{!18, !7, i64 4}
!21 = !{!18, !7, i64 8}
!22 = distinct !{!22, !16}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass