; LLVM IR from jrouwe/JoltPhysics :: Jolt/Physics/Collision/CollisionDispatch.ll (ZN3JPH17CollisionDispatch5sInitEv)

; 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.anon = type { i8 }
%class.anon.0 = type { i8 }

@_ZN3JPH17CollisionDispatch13sCollideShapeE = external dso_local global [34 x [34 x ptr]], align 16
@_ZN3JPH17CollisionDispatch10sCastShapeE = external dso_local global [34 x [34 x ptr]], align 16

; 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 nounwind uwtable
define dso_local void @_ZN3JPH17CollisionDispatch5sInitEv() #1 align 2 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca %class.anon, align 1
  %5 = alloca %class.anon.0, align 1
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #3
  store i32 0, ptr %1, align 4, !tbaa !5
  br label %6

6:                                                ; preds = %54, %0
  %7 = load i32, ptr %1, align 4, !tbaa !5
  %8 = icmp ult i32 %7, 34
  br i1 %8, label %10, label %9

9:                                                ; preds = %6
  store i32 2, ptr %2, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #3
  br label %57

10:                                               ; preds = %6
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %11

11:                                               ; preds = %50, %10
  %12 = load i32, ptr %3, align 4, !tbaa !5
  %13 = icmp ult i32 %12, 34
  br i1 %13, label %15, label %14

14:                                               ; preds = %11
  store i32 5, ptr %2, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  br label %53

15:                                               ; preds = %11
  %16 = load i32, ptr %1, align 4, !tbaa !5
  %17 = zext i32 %16 to i64
  %18 = getelementptr inbounds [34 x [34 x ptr]], ptr @_ZN3JPH17CollisionDispatch13sCollideShapeE, i64 0, i64 %17
  %19 = load i32, ptr %3, align 4, !tbaa !5
  %20 = zext i32 %19 to i64
  %21 = getelementptr inbounds [34 x ptr], ptr %18, i64 0, i64 %20
  %22 = load ptr, ptr %21, align 8, !tbaa !9
  %23 = icmp eq ptr %22, null
  br i1 %23, label %24, label %32

24:                                               ; preds = %15
  call void @llvm.lifetime.start.p0(i64 1, ptr %4) #3
  %25 = call noundef ptr @"_ZZN3JPH17CollisionDispatch5sInitEvENK3$_0cvPFvPKNS_5ShapeES4_NS_4Vec3ES5_RKNS_5Mat44ES8_RKNS_17SubShapeIDCreatorESB_RKNS_20CollideShapeSettingsERNS_18CollisionCollectorINS_18CollideShapeResultENS_36CollisionCollectorTraitsCollideShapeEEERKNS_11ShapeFilterEEEv"(ptr noundef nonnull align 1 dereferenceable(1) %4) #3
  %26 = load i32, ptr %1, align 4, !tbaa !5
  %27 = zext i32 %26 to i64
  %28 = getelementptr inbounds [34 x [34 x ptr]], ptr @_ZN3JPH17CollisionDispatch13sCollideShapeE, i64 0, i64 %27
  %29 = load i32, ptr %3, align 4, !tbaa !5
  %30 = zext i32 %29 to i64
  %31 = getelementptr inbounds [34 x ptr], ptr %28, i64 0, i64 %30
  store ptr %25, ptr %31, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 1, ptr %4) #3
  br label %32

32:                                               ; preds = %24, %15
  %33 = load i32, ptr %1, align 4, !tbaa !5
  %34 = zext i32 %33 to i64
  %35 = getelementptr inbounds [34 x [34 x ptr]], ptr @_ZN3JPH17CollisionDispatch10sCastShapeE, i64 0, i64 %34
  %36 = load i32, ptr %3, align 4, !tbaa !5
  %37 = zext i32 %36 to i64
  %38 = getelementptr inbounds [34 x ptr], ptr %35, i64 0, i64 %37
  %39 = load ptr, ptr %38, align 8, !tbaa !9
  %40 = icmp eq ptr %39, null
  br i1 %40, label %41, label %49

41:                                               ; preds = %32
  call void @llvm.lifetime.start.p0(i64 1, ptr %5) #3
  %42 = call noundef ptr @"_ZZN3JPH17CollisionDispatch5sInitEvENK3$_1cvPFvRKNS_9ShapeCastERKNS_17ShapeCastSettingsEPKNS_5ShapeENS_4Vec3ERKNS_11ShapeFilterERKNS_5Mat44ERKNS_17SubShapeIDCreatorESK_RNS_18CollisionCollectorINS_15ShapeCastResultENS_33CollisionCollectorTraitsCastShapeEEEEEv"(ptr noundef nonnull align 1 dereferenceable(1) %5) #3
  %43 = load i32, ptr %1, align 4, !tbaa !5
  %44 = zext i32 %43 to i64
  %45 = getelementptr inbounds [34 x [34 x ptr]], ptr @_ZN3JPH17CollisionDispatch10sCastShapeE, i64 0, i64 %44
  %46 = load i32, ptr %3, align 4, !tbaa !5
  %47 = zext i32 %46 to i64
  %48 = getelementptr inbounds [34 x ptr], ptr %45, i64 0, i64 %47
  store ptr %42, ptr %48, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 1, ptr %5) #3
  br label %49

49:                                               ; preds = %41, %32
  br label %50

50:                                               ; preds = %49
  %51 = load i32, ptr %3, align 4, !tbaa !5
  %52 = add i32 %51, 1
  store i32 %52, ptr %3, align 4, !tbaa !5
  br label %11, !llvm.loop !11

53:                                               ; preds = %14
  br label %54

54:                                               ; preds = %53
  %55 = load i32, ptr %1, align 4, !tbaa !5
  %56 = add i32 %55, 1
  store i32 %56, ptr %1, align 4, !tbaa !5
  br label %6, !llvm.loop !13

57:                                               ; preds = %9
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden noundef ptr @"_ZZN3JPH17CollisionDispatch5sInitEvENK3$_0cvPFvPKNS_5ShapeES4_NS_4Vec3ES5_RKNS_5Mat44ES8_RKNS_17SubShapeIDCreatorESB_RKNS_20CollideShapeSettingsERNS_18CollisionCollectorINS_18CollideShapeResultENS_36CollisionCollectorTraitsCollideShapeEEERKNS_11ShapeFilterEEEv"(ptr noundef nonnull align 1 dereferenceable(1)) #2 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden noundef ptr @"_ZZN3JPH17CollisionDispatch5sInitEvENK3$_1cvPFvRKNS_9ShapeCastERKNS_17ShapeCastSettingsEPKNS_5ShapeENS_4Vec3ERKNS_11ShapeFilterERKNS_5Mat44ERKNS_17SubShapeIDCreatorESK_RNS_18CollisionCollectorINS_15ShapeCastResultENS_33CollisionCollectorTraitsCastShapeEEEEEv"(ptr noundef nonnull align 1 dereferenceable(1)) #2 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { inlinehint mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nounwind }

!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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


; 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.anon = type { i8 }
%class.anon.0 = type { i8 }

@_ZN3JPH17CollisionDispatch13sCollideShapeE = external dso_local local_unnamed_addr global [34 x [34 x ptr]], align 16
@_ZN3JPH17CollisionDispatch10sCastShapeE = external dso_local local_unnamed_addr global [34 x [34 x ptr]], align 16

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

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN3JPH17CollisionDispatch5sInitEv() local_unnamed_addr #1 align 2 {
  %1 = alloca %class.anon, align 1
  %2 = alloca %class.anon.0, align 1
  br label %.preheader

.preheader:                                       ; preds = %0, %4
  %indvars.iv16 = phi i64 [ 0, %0 ], [ %indvars.iv.next17, %4 ]
  br label %5

3:                                                ; preds = %4
  ret void

4:                                                ; preds = %17
  %indvars.iv.next17 = add nuw nsw i64 %indvars.iv16, 1
  %exitcond19.not = icmp eq i64 %indvars.iv.next17, 34
  br i1 %exitcond19.not, label %3, label %.preheader, !llvm.loop !5

5:                                                ; preds = %.preheader, %17
  %indvars.iv = phi i64 [ 0, %.preheader ], [ %indvars.iv.next, %17 ]
  %6 = getelementptr inbounds [34 x [34 x ptr]], ptr @_ZN3JPH17CollisionDispatch13sCollideShapeE, i64 0, i64 %indvars.iv16, i64 %indvars.iv
  %7 = load ptr, ptr %6, align 8, !tbaa !7
  %8 = icmp eq ptr %7, null
  br i1 %8, label %9, label %11

9:                                                ; preds = %5
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %1) #3
  %10 = call noundef ptr @"_ZZN3JPH17CollisionDispatch5sInitEvENK3$_0cvPFvPKNS_5ShapeES4_NS_4Vec3ES5_RKNS_5Mat44ES8_RKNS_17SubShapeIDCreatorESB_RKNS_20CollideShapeSettingsERNS_18CollisionCollectorINS_18CollideShapeResultENS_36CollisionCollectorTraitsCollideShapeEEERKNS_11ShapeFilterEEEv"(ptr noundef nonnull align 1 dereferenceable(1) %1) #3
  store ptr %10, ptr %6, align 8, !tbaa !7
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %1) #3
  br label %11

11:                                               ; preds = %9, %5
  %12 = getelementptr inbounds [34 x [34 x ptr]], ptr @_ZN3JPH17CollisionDispatch10sCastShapeE, i64 0, i64 %indvars.iv16, i64 %indvars.iv
  %13 = load ptr, ptr %12, align 8, !tbaa !7
  %14 = icmp eq ptr %13, null
  br i1 %14, label %15, label %17

15:                                               ; preds = %11
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %2) #3
  %16 = call noundef ptr @"_ZZN3JPH17CollisionDispatch5sInitEvENK3$_1cvPFvRKNS_9ShapeCastERKNS_17ShapeCastSettingsEPKNS_5ShapeENS_4Vec3ERKNS_11ShapeFilterERKNS_5Mat44ERKNS_17SubShapeIDCreatorESK_RNS_18CollisionCollectorINS_15ShapeCastResultENS_33CollisionCollectorTraitsCastShapeEEEEEv"(ptr noundef nonnull align 1 dereferenceable(1) %2) #3
  store ptr %16, ptr %12, align 8, !tbaa !7
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %2) #3
  br label %17

17:                                               ; preds = %11, %15
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 34
  br i1 %exitcond.not, label %4, label %5, !llvm.loop !11
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden noundef ptr @"_ZZN3JPH17CollisionDispatch5sInitEvENK3$_0cvPFvPKNS_5ShapeES4_NS_4Vec3ES5_RKNS_5Mat44ES8_RKNS_17SubShapeIDCreatorESB_RKNS_20CollideShapeSettingsERNS_18CollisionCollectorINS_18CollideShapeResultENS_36CollisionCollectorTraitsCollideShapeEEERKNS_11ShapeFilterEEEv"(ptr noundef nonnull align 1 dereferenceable(1)) local_unnamed_addr #2 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden noundef ptr @"_ZZN3JPH17CollisionDispatch5sInitEvENK3$_1cvPFvRKNS_9ShapeCastERKNS_17ShapeCastSettingsEPKNS_5ShapeENS_4Vec3ERKNS_11ShapeFilterERKNS_5Mat44ERKNS_17SubShapeIDCreatorESK_RNS_18CollisionCollectorINS_15ShapeCastResultENS_33CollisionCollectorTraitsCastShapeEEEEEv"(ptr noundef nonnull align 1 dereferenceable(1)) local_unnamed_addr #2 align 2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { inlinehint mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nounwind }

!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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = !{!8, !8, i64 0}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = distinct !{!11, !6}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,LoopSimplifyPass,SROAPass,SimplifyCFGPass