; LLVM IR from jrouwe/JoltPhysics :: Jolt/Physics (IslandBuilder)

; 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.JPH::AssertLastParam" = type { i8 }
%"class.JPH::IslandBuilder" = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i32, i32, i32, i32, i32, i32 }
%"struct.JPH::IslandBuilder::BodyLink" = type { %"struct.std::atomic", i32 }
%"struct.std::atomic" = type { %"struct.std::__atomic_base" }
%"struct.std::__atomic_base" = type { i32 }
%"class.JPH::BodyID" = type { i32 }

@.str.1 = external hidden unnamed_addr constant [83 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [77 x i8], align 1

; 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: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef, ptr noundef, i32 noundef) #1

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local void @_ZNSt13__atomic_baseIjE5storeEjSt12memory_order(ptr noundef nonnull align 4 dereferenceable(4), i32 noundef, i32 noundef) #2 align 2

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNKSt13__atomic_baseIjE4loadESt12memory_order(ptr noundef nonnull align 4 dereferenceable(4), i32 noundef) #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3JPH13IslandBuilder16BuildBodyIslandsEPKNS_6BodyIDEjPNS_13TempAllocatorE(ptr noundef nonnull align 8 dereferenceable(112) %0, ptr noundef %1, i32 noundef %2, ptr noundef %3) #3 align 2 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca %"struct.JPH::AssertLastParam", align 1
  %10 = alloca ptr, align 8
  %11 = alloca %"struct.JPH::AssertLastParam", align 1
  %12 = alloca i32, align 4
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  %15 = alloca %"struct.JPH::AssertLastParam", align 1
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  %19 = alloca ptr, align 8
  %20 = alloca ptr, align 8
  %21 = alloca %"struct.JPH::AssertLastParam", align 1
  %22 = alloca %"struct.JPH::AssertLastParam", align 1
  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 ptr %3, ptr %8, align 8, !tbaa !5
  %23 = load ptr, ptr %5, align 8
  %24 = load i32, ptr %7, align 4, !tbaa !9
  %25 = getelementptr inbounds %"class.JPH::IslandBuilder", ptr %23, i32 0, i32 12
  store i32 %24, ptr %25, align 4, !tbaa !11
  br label %26

26:                                               ; preds = %4
  %27 = getelementptr inbounds %"class.JPH::IslandBuilder", ptr %23, i32 0, i32 3
  %28 = load ptr, ptr %27, align 8, !tbaa !13
  %29 = icmp eq ptr %28, null
  br i1 %29, label %33, label %30

30:                                               ; preds = %26
  %31 = call noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef @.str.3, ptr noundef @.str.1, i32 noundef 218)
  br i1 %31, label %32, label %33

32:                                               ; preds = %30
  call void asm sideeffect "int $$0x3", "~{dirflag},~{fpsr},~{flags}"() #5, !srcloc !14
  br label %33

33:                                               ; preds = %32, %30, %26
  br label %34

34:                                               ; preds = %33
  %35 = load ptr, ptr %8, align 8, !tbaa !5
  %36 = load i32, ptr %7, align 4, !tbaa !9
  %37 = zext i32 %36 to i64
  %38 = mul i64 %37, 4
  %39 = trunc i64 %38 to i32
  %40 = load ptr, ptr %35, align 8, !tbaa !15
  %41 = getelementptr inbounds ptr, ptr %40, i64 2
  %42 = load ptr, ptr %41, align 8
  %43 = call noundef ptr %42(ptr noundef nonnull align 8 dereferenceable(8) %35, i32 noundef %39)
  %44 = getelementptr inbounds %"class.JPH::IslandBuilder", ptr %23, i32 0, i32 3
  store ptr %43, ptr %44, align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  %45 = load ptr, ptr %8, align 8, !tbaa !5
  %46 = load i32, ptr %7, align 4, !tbaa !9
  %47 = add i32 %46, 1
  %48 = zext i32 %47 to i64
  %49 = mul i64 %48, 4
  %50 = trunc i64 %49 to i32
  %51 = load ptr, ptr %45, align 8, !tbaa !15
  %52 = getelementptr inbounds ptr, ptr %51, i64 2
  %53 = load ptr, ptr %52, align 8
  %54 = call noundef ptr %53(ptr noundef nonnull align 8 dereferenceable(8) %45, i32 noundef %50)
  store ptr %54, ptr %10, align 8, !tbaa !5
  %55 = load ptr, ptr %10, align 8, !tbaa !5
  %56 = getelementptr inbounds i32, ptr %55, i64 0
  store i32 0, ptr %56, align 4, !tbaa !9
  br label %57

57:                                               ; preds = %34
  %58 = getelementptr inbounds %"class.JPH::IslandBuilder", ptr %23, i32 0, i32 16
  %59 = load i32, ptr %58, align 4, !tbaa !17
  %60 = icmp eq i32 %59, 0
  br i1 %60, label %64, label %61

61:                                               ; preds = %57
  %62 = call noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef @.str.13, ptr noundef @.str.1, i32 noundef 229)
  br i1 %62, label %63, label %64

63:                                               ; preds = %61
  call void asm sideeffect "int $$0x3", "~{dirflag},~{fpsr},~{flags}"() #5, !srcloc !18
  br label %64

64:                                               ; preds = %63, %61, %57
  br label %65

65:                                               ; preds = %64
  br label %66

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

67:                                               ; preds = %126, %66
  %68 = load i32, ptr %12, align 4, !tbaa !9
  %69 = load i32, ptr %7, align 4, !tbaa !9
  %70 = icmp ult i32 %68, %69
  br i1 %70, label %72, label %71

71:                                               ; preds = %67
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  br label %129

72:                                               ; preds = %67
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #5
  %73 = getelementptr inbounds %"class.JPH::IslandBuilder", ptr %23, i32 0, i32 0
  %74 = load ptr, ptr %73, align 8, !tbaa !19
  %75 = load i32, ptr %12, align 4, !tbaa !9
  %76 = zext i32 %75 to i64
  %77 = getelementptr inbounds %"struct.JPH::IslandBuilder::BodyLink", ptr %74, i64 %76
  store ptr %77, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #5
  %78 = load ptr, ptr %13, align 8, !tbaa !5
  %79 = getelementptr inbounds %"struct.JPH::IslandBuilder::BodyLink", ptr %78, i32 0, i32 0
  %80 = call noundef i32 @_ZNKSt13__atomic_baseIjE4loadESt12memory_order(ptr noundef nonnull align 4 dereferenceable(4) %79, i32 noundef 0) #5
  store i32 %80, ptr %14, align 4, !tbaa !9
  %81 = load i32, ptr %14, align 4, !tbaa !9
  %82 = load i32, ptr %12, align 4, !tbaa !9
  %83 = icmp ne i32 %81, %82
  br i1 %83, label %84, label %112

84:                                               ; preds = %72
  br label %85

85:                                               ; preds = %84
  %86 = load i32, ptr %14, align 4, !tbaa !9
  %87 = load i32, ptr %12, align 4, !tbaa !9
  %88 = icmp ult i32 %86, %87
  br i1 %88, label %92, label %89

89:                                               ; preds = %85
  %90 = call noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef @.str.17, ptr noundef @.str.1, i32 noundef 237)
  br i1 %90, label %91, label %92

91:                                               ; preds = %89
  call void asm sideeffect "int $$0x3", "~{dirflag},~{fpsr},~{flags}"() #5, !srcloc !20
  br label %92

92:                                               ; preds = %91, %89, %85
  br label %93

93:                                               ; preds = %92
  br label %94

94:                                               ; preds = %93
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #5
  %95 = getelementptr inbounds %"class.JPH::IslandBuilder", ptr %23, i32 0, i32 0
  %96 = load ptr, ptr %95, align 8, !tbaa !19
  %97 = load i32, ptr %14, align 4, !tbaa !9
  %98 = zext i32 %97 to i64
  %99 = getelementptr inbounds %"struct.JPH::IslandBuilder::BodyLink", ptr %96, i64 %98
  %100 = getelementptr inbounds %"struct.JPH::IslandBuilder::BodyLink", ptr %99, i32 0, i32 1
  %101 = load i32, ptr %100, align 4, !tbaa !21
  store i32 %101, ptr %16, align 4, !tbaa !9
  %102 = load i32, ptr %16, align 4, !tbaa !9
  %103 = load ptr, ptr %13, align 8, !tbaa !5
  %104 = getelementptr inbounds %"struct.JPH::IslandBuilder::BodyLink", ptr %103, i32 0, i32 1
  store i32 %102, ptr %104, align 4, !tbaa !21
  %105 = load ptr, ptr %10, align 8, !tbaa !5
  %106 = load i32, ptr %16, align 4, !tbaa !9
  %107 = add i32 %106, 1
  %108 = zext i32 %107 to i64
  %109 = getelementptr inbounds i32, ptr %105, i64 %108
  %110 = load i32, ptr %109, align 4, !tbaa !9
  %111 = add i32 %110, 1
  store i32 %111, ptr %109, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #5
  br label %125

112:                                              ; preds = %72
  %113 = getelementptr inbounds %"class.JPH::IslandBuilder", ptr %23, i32 0, i32 16
  %114 = load i32, ptr %113, align 4, !tbaa !17
  %115 = load ptr, ptr %13, align 8, !tbaa !5
  %116 = getelementptr inbounds %"struct.JPH::IslandBuilder::BodyLink", ptr %115, i32 0, i32 1
  store i32 %114, ptr %116, align 4, !tbaa !21
  %117 = getelementptr inbounds %"class.JPH::IslandBuilder", ptr %23, i32 0, i32 16
  %118 = load i32, ptr %117, align 4, !tbaa !17
  %119 = add i32 %118, 1
  store i32 %119, ptr %117, align 4, !tbaa !17
  %120 = load ptr, ptr %10, align 8, !tbaa !5
  %121 = getelementptr inbounds %"class.JPH::IslandBuilder", ptr %23, i32 0, i32 16
  %122 = load i32, ptr %121, align 4, !tbaa !17
  %123 = zext i32 %122 to i64
  %124 = getelementptr inbounds i32, ptr %120, i64 %123
  store i32 1, ptr %124, align 4, !tbaa !9
  br label %125

125:                                              ; preds = %112, %94
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #5
  br label %126

126:                                              ; preds = %125
  %127 = load i32, ptr %12, align 4, !tbaa !9
  %128 = add i32 %127, 1
  store i32 %128, ptr %12, align 4, !tbaa !9
  br label %67, !llvm.loop !25

129:                                              ; preds = %71
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #5
  store i32 1, ptr %17, align 4, !tbaa !9
  br label %130

130:                                              ; preds = %149, %129
  %131 = load i32, ptr %17, align 4, !tbaa !9
  %132 = getelementptr inbounds %"class.JPH::IslandBuilder", ptr %23, i32 0, i32 16
  %133 = load i32, ptr %132, align 4, !tbaa !17
  %134 = icmp ult i32 %131, %133
  br i1 %134, label %136, label %135

135:                                              ; preds = %130
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #5
  br label %152

136:                                              ; preds = %130
  %137 = load ptr, ptr %10, align 8, !tbaa !5
  %138 = load i32, ptr %17, align 4, !tbaa !9
  %139 = sub i32 %138, 1
  %140 = zext i32 %139 to i64
  %141 = getelementptr inbounds i32, ptr %137, i64 %140
  %142 = load i32, ptr %141, align 4, !tbaa !9
  %143 = load ptr, ptr %10, align 8, !tbaa !5
  %144 = load i32, ptr %17, align 4, !tbaa !9
  %145 = zext i32 %144 to i64
  %146 = getelementptr inbounds i32, ptr %143, i64 %145
  %147 = load i32, ptr %146, align 4, !tbaa !9
  %148 = add i32 %147, %142
  store i32 %148, ptr %146, align 4, !tbaa !9
  br label %149

149:                                              ; preds = %136
  %150 = load i32, ptr %17, align 4, !tbaa !9
  %151 = add i32 %150, 1
  store i32 %151, ptr %17, align 4, !tbaa !9
  br label %130, !llvm.loop !27

152:                                              ; preds = %135
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #5
  store i32 0, ptr %18, align 4, !tbaa !9
  br label %153

153:                                              ; preds = %186, %152
  %154 = load i32, ptr %18, align 4, !tbaa !9
  %155 = load i32, ptr %7, align 4, !tbaa !9
  %156 = icmp ult i32 %154, %155
  br i1 %156, label %158, label %157

157:                                              ; preds = %153
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #5
  br label %189

158:                                              ; preds = %153
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #5
  %159 = getelementptr inbounds %"class.JPH::IslandBuilder", ptr %23, i32 0, i32 0
  %160 = load ptr, ptr %159, align 8, !tbaa !19
  %161 = load i32, ptr %18, align 4, !tbaa !9
  %162 = zext i32 %161 to i64
  %163 = getelementptr inbounds %"struct.JPH::IslandBuilder::BodyLink", ptr %160, i64 %162
  store ptr %163, ptr %19, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #5
  %164 = load ptr, ptr %10, align 8, !tbaa !5
  %165 = load ptr, ptr %19, align 8, !tbaa !5
  %166 = getelementptr inbounds %"struct.JPH::IslandBuilder::BodyLink", ptr %165, i32 0, i32 1
  %167 = load i32, ptr %166, align 4, !tbaa !21
  %168 = zext i32 %167 to i64
  %169 = getelementptr inbounds i32, ptr %164, i64 %168
  store ptr %169, ptr %20, align 8, !tbaa !5
  %170 = load ptr, ptr %6, align 8, !tbaa !5
  %171 = load i32, ptr %18, align 4, !tbaa !9
  %172 = zext i32 %171 to i64
  %173 = getelementptr inbounds %"class.JPH::BodyID", ptr %170, i64 %172
  %174 = getelementptr inbounds %"class.JPH::IslandBuilder", ptr %23, i32 0, i32 3
  %175 = load ptr, ptr %174, align 8, !tbaa !13
  %176 = load ptr, ptr %20, align 8, !tbaa !5
  %177 = load i32, ptr %176, align 4, !tbaa !9
  %178 = zext i32 %177 to i64
  %179 = getelementptr inbounds %"class.JPH::BodyID", ptr %175, i64 %178
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %179, ptr align 4 %173, i64 4, i1 false), !tbaa.struct !28
  %180 = load ptr, ptr %20, align 8, !tbaa !5
  %181 = load i32, ptr %180, align 4, !tbaa !9
  %182 = add i32 %181, 1
  store i32 %182, ptr %180, align 4, !tbaa !9
  %183 = load ptr, ptr %19, align 8, !tbaa !5
  %184 = getelementptr inbounds %"struct.JPH::IslandBuilder::BodyLink", ptr %183, i32 0, i32 0
  %185 = load i32, ptr %18, align 4, !tbaa !9
  call void @_ZNSt13__atomic_baseIjE5storeEjSt12memory_order(ptr noundef nonnull align 4 dereferenceable(4) %184, i32 noundef %185, i32 noundef 0) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #5
  br label %186

186:                                              ; preds = %158
  %187 = load i32, ptr %18, align 4, !tbaa !9
  %188 = add i32 %187, 1
  store i32 %188, ptr %18, align 4, !tbaa !9
  br label %153, !llvm.loop !29

189:                                              ; preds = %157
  br label %190

190:                                              ; preds = %189
  %191 = getelementptr inbounds %"class.JPH::IslandBuilder", ptr %23, i32 0, i32 16
  %192 = load i32, ptr %191, align 4, !tbaa !17
  %193 = icmp eq i32 %192, 0
  br i1 %193, label %207, label %194

194:                                              ; preds = %190
  %195 = load ptr, ptr %10, align 8, !tbaa !5
  %196 = getelementptr inbounds %"class.JPH::IslandBuilder", ptr %23, i32 0, i32 16
  %197 = load i32, ptr %196, align 4, !tbaa !17
  %198 = sub i32 %197, 1
  %199 = zext i32 %198 to i64
  %200 = getelementptr inbounds i32, ptr %195, i64 %199
  %201 = load i32, ptr %200, align 4, !tbaa !9
  %202 = load i32, ptr %7, align 4, !tbaa !9
  %203 = icmp eq i32 %201, %202
  br i1 %203, label %207, label %204

204:                                              ; preds = %194
  %205 = call noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef @.str.18, ptr noundef @.str.1, i32 noundef 278)
  br i1 %205, label %206, label %207

206:                                              ; preds = %204
  call void asm sideeffect "int $$0x3", "~{dirflag},~{fpsr},~{flags}"() #5, !srcloc !30
  br label %207

207:                                              ; preds = %206, %204, %194, %190
  br label %208

208:                                              ; preds = %207
  br label %209

209:                                              ; preds = %208
  br label %210

210:                                              ; preds = %209
  %211 = getelementptr inbounds %"class.JPH::IslandBuilder", ptr %23, i32 0, i32 4
  %212 = load ptr, ptr %211, align 8, !tbaa !31
  %213 = icmp eq ptr %212, null
  br i1 %213, label %217, label %214

214:                                              ; preds = %210
  %215 = call noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef @.str.4, ptr noundef @.str.1, i32 noundef 281)
  br i1 %215, label %216, label %217

216:                                              ; preds = %214
  call void asm sideeffect "int $$0x3", "~{dirflag},~{fpsr},~{flags}"() #5, !srcloc !32
  br label %217

217:                                              ; preds = %216, %214, %210
  br label %218

218:                                              ; preds = %217
  br label %219

219:                                              ; preds = %218
  %220 = load ptr, ptr %10, align 8, !tbaa !5
  %221 = getelementptr inbounds %"class.JPH::IslandBuilder", ptr %23, i32 0, i32 4
  store ptr %220, ptr %221, align 8, !tbaa !31
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  ret void
}

; 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) #4

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { inlinehint 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 = { alwaysinline 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 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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, !10, i64 92}
!12 = !{!"_ZTSN3JPH13IslandBuilderE", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !10, i64 88, !10, i64 92, !10, i64 96, !10, i64 100, !10, i64 104, !10, i64 108}
!13 = !{!12, !6, i64 24}
!14 = !{i64 2158301621}
!15 = !{!16, !16, i64 0}
!16 = !{!"vtable pointer", !8, i64 0}
!17 = !{!12, !10, i64 108}
!18 = !{i64 2158301944}
!19 = !{!12, !6, i64 0}
!20 = !{i64 2158302261}
!21 = !{!22, !10, i64 4}
!22 = !{!"_ZTSN3JPH13IslandBuilder8BodyLinkE", !23, i64 0, !10, i64 4}
!23 = !{!"_ZTSSt6atomicIjE", !24, i64 0}
!24 = !{!"_ZTSSt13__atomic_baseIjE", !10, i64 0}
!25 = distinct !{!25, !26}
!26 = !{!"llvm.loop.mustprogress"}
!27 = distinct !{!27, !26}
!28 = !{i64 0, i64 4, !9}
!29 = distinct !{!29, !26}
!30 = !{i64 2158302704}
!31 = !{!12, !6, i64 32}
!32 = !{i64 2158303047}


; 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.JPH::IslandBuilder::BodyLink" = type { %"struct.std::atomic", i32 }
%"struct.std::atomic" = type { %"struct.std::__atomic_base" }
%"struct.std::__atomic_base" = type { i32 }
%"class.JPH::BodyID" = type { i32 }

@.str.1 = external hidden unnamed_addr constant [83 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [77 x i8], align 1

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local void @_ZNSt13__atomic_baseIjE5storeEjSt12memory_order(ptr noundef nonnull align 4 dereferenceable(4), i32 noundef, i32 noundef) local_unnamed_addr #1 align 2

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNKSt13__atomic_baseIjE4loadESt12memory_order(ptr noundef nonnull align 4 dereferenceable(4), i32 noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3JPH13IslandBuilder16BuildBodyIslandsEPKNS_6BodyIDEjPNS_13TempAllocatorE(ptr nocapture noundef nonnull align 8 dereferenceable(112) %0, ptr nocapture noundef readonly %1, i32 noundef %2, ptr noundef %3) local_unnamed_addr #2 align 2 {
  %5 = getelementptr inbounds i8, ptr %0, i64 92
  store i32 %2, ptr %5, align 4, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %0, i64 24
  %7 = load ptr, ptr %6, align 8, !tbaa !11
  %8 = icmp eq ptr %7, null
  br i1 %8, label %12, label %9

9:                                                ; preds = %4
  %10 = tail call noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.1, i32 noundef 218)
  br i1 %10, label %11, label %12

11:                                               ; preds = %9
  tail call void asm sideeffect "int $$0x3", "~{dirflag},~{fpsr},~{flags}"() #3, !srcloc !12
  br label %12

12:                                               ; preds = %4, %9, %11
  %13 = shl i32 %2, 2
  %14 = load ptr, ptr %3, align 8, !tbaa !13
  %15 = getelementptr inbounds i8, ptr %14, i64 16
  %16 = load ptr, ptr %15, align 8
  %17 = tail call noundef ptr %16(ptr noundef nonnull align 8 dereferenceable(8) %3, i32 noundef %13)
  store ptr %17, ptr %6, align 8, !tbaa !11
  %18 = add i32 %13, 4
  %19 = load ptr, ptr %3, align 8, !tbaa !13
  %20 = getelementptr inbounds i8, ptr %19, i64 16
  %21 = load ptr, ptr %20, align 8
  %22 = tail call noundef ptr %21(ptr noundef nonnull align 8 dereferenceable(8) %3, i32 noundef %18)
  store i32 0, ptr %22, align 4, !tbaa !15
  %23 = getelementptr inbounds i8, ptr %0, i64 108
  %24 = load i32, ptr %23, align 4, !tbaa !16
  %25 = icmp eq i32 %24, 0
  br i1 %25, label %29, label %26

26:                                               ; preds = %12
  %27 = tail call noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef nonnull @.str.13, ptr noundef nonnull @.str.1, i32 noundef 229)
  br i1 %27, label %28, label %29

28:                                               ; preds = %26
  tail call void asm sideeffect "int $$0x3", "~{dirflag},~{fpsr},~{flags}"() #3, !srcloc !17
  br label %29

29:                                               ; preds = %28, %26, %12
  %.not54 = icmp eq i32 %2, 0
  br i1 %.not54, label %.preheader48, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %29
  %wide.trip.count = zext i32 %2 to i64
  br label %.lr.ph

.preheader48:                                     ; preds = %57, %29
  %30 = load i32, ptr %23, align 4, !tbaa !16
  %31 = icmp ugt i32 %30, 1
  br i1 %31, label %.lr.ph51.preheader, label %.preheader

.lr.ph51.preheader:                               ; preds = %.preheader48
  %.pre = load i32, ptr %22, align 4, !tbaa !15
  br label %.lr.ph51

.lr.ph:                                           ; preds = %.lr.ph.preheader, %57
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next, %57 ]
  %32 = load ptr, ptr %0, align 8, !tbaa !18
  %33 = getelementptr inbounds %"struct.JPH::IslandBuilder::BodyLink", ptr %32, i64 %indvars.iv
  %34 = tail call noundef i32 @_ZNKSt13__atomic_baseIjE4loadESt12memory_order(ptr noundef nonnull align 4 dereferenceable(4) %33, i32 noundef 0) #3
  %35 = zext i32 %34 to i64
  %.not = icmp eq i64 %indvars.iv, %35
  br i1 %.not, label %51, label %36

36:                                               ; preds = %.lr.ph
  %37 = icmp ugt i64 %indvars.iv, %35
  br i1 %37, label %41, label %38

38:                                               ; preds = %36
  %39 = tail call noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef nonnull @.str.17, ptr noundef nonnull @.str.1, i32 noundef 237)
  br i1 %39, label %40, label %41

40:                                               ; preds = %38
  tail call void asm sideeffect "int $$0x3", "~{dirflag},~{fpsr},~{flags}"() #3, !srcloc !19
  br label %41

41:                                               ; preds = %40, %38, %36
  %42 = load ptr, ptr %0, align 8, !tbaa !18
  %43 = getelementptr inbounds %"struct.JPH::IslandBuilder::BodyLink", ptr %42, i64 %35, i32 1
  %44 = load i32, ptr %43, align 4, !tbaa !20
  %45 = getelementptr inbounds i8, ptr %33, i64 4
  store i32 %44, ptr %45, align 4, !tbaa !20
  %46 = add i32 %44, 1
  %47 = zext i32 %46 to i64
  %48 = getelementptr inbounds i32, ptr %22, i64 %47
  %49 = load i32, ptr %48, align 4, !tbaa !15
  %50 = add i32 %49, 1
  store i32 %50, ptr %48, align 4, !tbaa !15
  br label %57

51:                                               ; preds = %.lr.ph
  %52 = load i32, ptr %23, align 4, !tbaa !16
  %53 = getelementptr inbounds i8, ptr %33, i64 4
  store i32 %52, ptr %53, align 4, !tbaa !20
  %54 = add i32 %52, 1
  store i32 %54, ptr %23, align 4, !tbaa !16
  %55 = zext i32 %54 to i64
  %56 = getelementptr inbounds i32, ptr %22, i64 %55
  store i32 1, ptr %56, align 4, !tbaa !15
  br label %57

57:                                               ; preds = %51, %41
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %.preheader48, label %.lr.ph, !llvm.loop !24

.preheader:                                       ; preds = %.lr.ph51, %.preheader48
  %58 = phi i32 [ %30, %.preheader48 ], [ %63, %.lr.ph51 ]
  br i1 %.not54, label %._crit_edge, label %.lr.ph53.preheader

.lr.ph53.preheader:                               ; preds = %.preheader
  %wide.trip.count63 = zext i32 %2 to i64
  br label %.lr.ph53

.lr.ph51:                                         ; preds = %.lr.ph51.preheader, %.lr.ph51
  %59 = phi i32 [ %.pre, %.lr.ph51.preheader ], [ %62, %.lr.ph51 ]
  %indvars.iv57 = phi i64 [ 1, %.lr.ph51.preheader ], [ %indvars.iv.next58, %.lr.ph51 ]
  %60 = getelementptr inbounds i32, ptr %22, i64 %indvars.iv57
  %61 = load i32, ptr %60, align 4, !tbaa !15
  %62 = add i32 %61, %59
  store i32 %62, ptr %60, align 4, !tbaa !15
  %indvars.iv.next58 = add nuw nsw i64 %indvars.iv57, 1
  %63 = load i32, ptr %23, align 4, !tbaa !16
  %64 = zext i32 %63 to i64
  %65 = icmp ult i64 %indvars.iv.next58, %64
  br i1 %65, label %.lr.ph51, label %.preheader, !llvm.loop !26

._crit_edge.loopexit:                             ; preds = %.lr.ph53
  %.pre65 = load i32, ptr %23, align 4, !tbaa !16
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %.preheader
  %66 = phi i32 [ %.pre65, %._crit_edge.loopexit ], [ %58, %.preheader ]
  %67 = icmp eq i32 %66, 0
  br i1 %67, label %92, label %83

.lr.ph53:                                         ; preds = %.lr.ph53.preheader, %.lr.ph53
  %indvars.iv60 = phi i64 [ 0, %.lr.ph53.preheader ], [ %indvars.iv.next61, %.lr.ph53 ]
  %68 = load ptr, ptr %0, align 8, !tbaa !18
  %69 = getelementptr inbounds %"struct.JPH::IslandBuilder::BodyLink", ptr %68, i64 %indvars.iv60
  %70 = getelementptr inbounds i8, ptr %69, i64 4
  %71 = load i32, ptr %70, align 4, !tbaa !20
  %72 = zext i32 %71 to i64
  %73 = getelementptr inbounds i32, ptr %22, i64 %72
  %74 = getelementptr inbounds %"class.JPH::BodyID", ptr %1, i64 %indvars.iv60
  %75 = load ptr, ptr %6, align 8, !tbaa !11
  %76 = load i32, ptr %73, align 4, !tbaa !15
  %77 = zext i32 %76 to i64
  %78 = getelementptr inbounds %"class.JPH::BodyID", ptr %75, i64 %77
  %79 = load i32, ptr %74, align 4, !tbaa !15
  store i32 %79, ptr %78, align 4, !tbaa !15
  %80 = load i32, ptr %73, align 4, !tbaa !15
  %81 = add i32 %80, 1
  store i32 %81, ptr %73, align 4, !tbaa !15
  %82 = trunc nuw i64 %indvars.iv60 to i32
  tail call void @_ZNSt13__atomic_baseIjE5storeEjSt12memory_order(ptr noundef nonnull align 4 dereferenceable(4) %69, i32 noundef %82, i32 noundef 0) #3
  %indvars.iv.next61 = add nuw nsw i64 %indvars.iv60, 1
  %exitcond64.not = icmp eq i64 %indvars.iv.next61, %wide.trip.count63
  br i1 %exitcond64.not, label %._crit_edge.loopexit, label %.lr.ph53, !llvm.loop !27

83:                                               ; preds = %._crit_edge
  %84 = add i32 %66, -1
  %85 = zext i32 %84 to i64
  %86 = getelementptr inbounds i32, ptr %22, i64 %85
  %87 = load i32, ptr %86, align 4, !tbaa !15
  %88 = icmp eq i32 %87, %2
  br i1 %88, label %92, label %89

89:                                               ; preds = %83
  %90 = tail call noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef nonnull @.str.18, ptr noundef nonnull @.str.1, i32 noundef 278)
  br i1 %90, label %91, label %92

91:                                               ; preds = %89
  tail call void asm sideeffect "int $$0x3", "~{dirflag},~{fpsr},~{flags}"() #3, !srcloc !28
  br label %92

92:                                               ; preds = %._crit_edge, %83, %89, %91
  %93 = getelementptr inbounds i8, ptr %0, i64 32
  %94 = load ptr, ptr %93, align 8, !tbaa !29
  %95 = icmp eq ptr %94, null
  br i1 %95, label %99, label %96

96:                                               ; preds = %92
  %97 = tail call noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef nonnull @.str.4, ptr noundef nonnull @.str.1, i32 noundef 281)
  br i1 %97, label %98, label %99

98:                                               ; preds = %96
  tail call void asm sideeffect "int $$0x3", "~{dirflag},~{fpsr},~{flags}"() #3, !srcloc !30
  br label %99

99:                                               ; preds = %98, %96, %92
  store ptr %22, ptr %93, align 8, !tbaa !29
  ret void
}

attributes #0 = { inlinehint 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 = { alwaysinline 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 #2 = { 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 #3 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !10, i64 92}
!6 = !{!"_ZTSN3JPH13IslandBuilderE", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !7, i64 56, !7, i64 64, !7, i64 72, !7, i64 80, !10, i64 88, !10, i64 92, !10, i64 96, !10, i64 100, !10, i64 104, !10, i64 108}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!6, !7, i64 24}
!12 = !{i64 2158301621}
!13 = !{!14, !14, i64 0}
!14 = !{!"vtable pointer", !9, i64 0}
!15 = !{!10, !10, i64 0}
!16 = !{!6, !10, i64 108}
!17 = !{i64 2158301944}
!18 = !{!6, !7, i64 0}
!19 = !{i64 2158302261}
!20 = !{!21, !10, i64 4}
!21 = !{!"_ZTSN3JPH13IslandBuilder8BodyLinkE", !22, i64 0, !10, i64 4}
!22 = !{!"_ZTSSt6atomicIjE", !23, i64 0}
!23 = !{!"_ZTSSt13__atomic_baseIjE", !10, i64 0}
!24 = distinct !{!24, !25}
!25 = !{!"llvm.loop.mustprogress"}
!26 = distinct !{!26, !25}
!27 = distinct !{!27, !25}
!28 = !{i64 2158302704}
!29 = !{!6, !7, i64 32}
!30 = !{i64 2158303047}


; Effective O3 passes: BDCEPass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass