; LLVM IR from jrouwe/JoltPhysics :: Samples/Tests/General (SimShapeFilterTest)

; 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.SimShapeFilterTest::Filter" = type { %"class.JPH::SimShapeFilter", %"class.JPH::BodyID", %"class.JPH::BodyID", [2 x %"class.JPH::BodyID"] }
%"class.JPH::SimShapeFilter" = type { ptr }
%"class.JPH::BodyID" = type { i32 }

; 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 noundef zeroext i1 @_ZNK18SimShapeFilterTest6Filter13ShouldCollideERKN3JPH4BodyEPKNS1_5ShapeERKNS1_10SubShapeIDES4_S7_SA_(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull align 16 dereferenceable(122) %1, ptr noundef %2, ptr noundef nonnull align 4 dereferenceable(4) %3, ptr noundef nonnull align 16 dereferenceable(122) %4, ptr noundef %5, ptr noundef nonnull align 4 dereferenceable(4) %6) unnamed_addr #1 align 2 {
  %8 = alloca i1, align 1
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  store ptr %0, ptr %9, align 8, !tbaa !5
  store ptr %1, ptr %10, align 8, !tbaa !5
  store ptr %2, ptr %11, align 8, !tbaa !5
  store ptr %3, ptr %12, align 8, !tbaa !5
  store ptr %4, ptr %13, align 8, !tbaa !5
  store ptr %5, ptr %14, align 8, !tbaa !5
  store ptr %6, ptr %15, align 8, !tbaa !5
  %19 = load ptr, ptr %9, align 8
  %20 = load ptr, ptr %10, align 8, !tbaa !5
  %21 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK3JPH4Body5GetIDEv(ptr noundef nonnull align 16 dereferenceable(122) %20)
  %22 = getelementptr inbounds %"class.SimShapeFilterTest::Filter", ptr %19, i32 0, i32 1
  %23 = call noundef zeroext i1 @_ZNK3JPH6BodyIDeqERKS0_(ptr noundef nonnull align 4 dereferenceable(4) %21, ptr noundef nonnull align 4 dereferenceable(4) %22)
  br i1 %23, label %29, label %24

24:                                               ; preds = %7
  %25 = load ptr, ptr %10, align 8, !tbaa !5
  %26 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK3JPH4Body5GetIDEv(ptr noundef nonnull align 16 dereferenceable(122) %25)
  %27 = getelementptr inbounds %"class.SimShapeFilterTest::Filter", ptr %19, i32 0, i32 2
  %28 = call noundef zeroext i1 @_ZNK3JPH6BodyIDeqERKS0_(ptr noundef nonnull align 4 dereferenceable(4) %26, ptr noundef nonnull align 4 dereferenceable(4) %27)
  br i1 %28, label %29, label %53

29:                                               ; preds = %24, %7
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #4
  store i32 0, ptr %16, align 4, !tbaa !9
  br label %30

30:                                               ; preds = %47, %29
  %31 = load i32, ptr %16, align 4, !tbaa !9
  %32 = icmp slt i32 %31, 2
  br i1 %32, label %34, label %33

33:                                               ; preds = %30
  store i32 2, ptr %17, align 4
  br label %50

34:                                               ; preds = %30
  %35 = load ptr, ptr %13, align 8, !tbaa !5
  %36 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK3JPH4Body5GetIDEv(ptr noundef nonnull align 16 dereferenceable(122) %35)
  %37 = getelementptr inbounds %"class.SimShapeFilterTest::Filter", ptr %19, i32 0, i32 3
  %38 = load i32, ptr %16, align 4, !tbaa !9
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds [2 x %"class.JPH::BodyID"], ptr %37, i64 0, i64 %39
  %41 = call noundef zeroext i1 @_ZNK3JPH6BodyIDeqERKS0_(ptr noundef nonnull align 4 dereferenceable(4) %36, ptr noundef nonnull align 4 dereferenceable(4) %40)
  br i1 %41, label %42, label %46

42:                                               ; preds = %34
  %43 = load ptr, ptr %14, align 8, !tbaa !5
  %44 = call noundef i64 @_ZNK3JPH5Shape11GetUserDataEv(ptr noundef nonnull align 8 dereferenceable(26) %43)
  %45 = icmp ne i64 %44, 1
  store i1 %45, ptr %8, align 1
  store i32 1, ptr %17, align 4
  br label %50

46:                                               ; preds = %34
  br label %47

47:                                               ; preds = %46
  %48 = load i32, ptr %16, align 4, !tbaa !9
  %49 = add nsw i32 %48, 1
  store i32 %49, ptr %16, align 4, !tbaa !9
  br label %30, !llvm.loop !11

50:                                               ; preds = %42, %33
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #4
  %51 = load i32, ptr %17, align 4
  switch i32 %51, label %91 [
    i32 2, label %52
    i32 1, label %89
  ]

52:                                               ; preds = %50
  br label %88

53:                                               ; preds = %24
  %54 = load ptr, ptr %13, align 8, !tbaa !5
  %55 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK3JPH4Body5GetIDEv(ptr noundef nonnull align 16 dereferenceable(122) %54)
  %56 = getelementptr inbounds %"class.SimShapeFilterTest::Filter", ptr %19, i32 0, i32 1
  %57 = call noundef zeroext i1 @_ZNK3JPH6BodyIDeqERKS0_(ptr noundef nonnull align 4 dereferenceable(4) %55, ptr noundef nonnull align 4 dereferenceable(4) %56)
  br i1 %57, label %63, label %58

58:                                               ; preds = %53
  %59 = load ptr, ptr %13, align 8, !tbaa !5
  %60 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK3JPH4Body5GetIDEv(ptr noundef nonnull align 16 dereferenceable(122) %59)
  %61 = getelementptr inbounds %"class.SimShapeFilterTest::Filter", ptr %19, i32 0, i32 2
  %62 = call noundef zeroext i1 @_ZNK3JPH6BodyIDeqERKS0_(ptr noundef nonnull align 4 dereferenceable(4) %60, ptr noundef nonnull align 4 dereferenceable(4) %61)
  br i1 %62, label %63, label %87

63:                                               ; preds = %58, %53
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #4
  store i32 0, ptr %18, align 4, !tbaa !9
  br label %64

64:                                               ; preds = %81, %63
  %65 = load i32, ptr %18, align 4, !tbaa !9
  %66 = icmp slt i32 %65, 2
  br i1 %66, label %68, label %67

67:                                               ; preds = %64
  store i32 5, ptr %17, align 4
  br label %84

68:                                               ; preds = %64
  %69 = load ptr, ptr %10, align 8, !tbaa !5
  %70 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK3JPH4Body5GetIDEv(ptr noundef nonnull align 16 dereferenceable(122) %69)
  %71 = getelementptr inbounds %"class.SimShapeFilterTest::Filter", ptr %19, i32 0, i32 3
  %72 = load i32, ptr %18, align 4, !tbaa !9
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds [2 x %"class.JPH::BodyID"], ptr %71, i64 0, i64 %73
  %75 = call noundef zeroext i1 @_ZNK3JPH6BodyIDeqERKS0_(ptr noundef nonnull align 4 dereferenceable(4) %70, ptr noundef nonnull align 4 dereferenceable(4) %74)
  br i1 %75, label %76, label %80

76:                                               ; preds = %68
  %77 = load ptr, ptr %11, align 8, !tbaa !5
  %78 = call noundef i64 @_ZNK3JPH5Shape11GetUserDataEv(ptr noundef nonnull align 8 dereferenceable(26) %77)
  %79 = icmp ne i64 %78, 1
  store i1 %79, ptr %8, align 1
  store i32 1, ptr %17, align 4
  br label %84

80:                                               ; preds = %68
  br label %81

81:                                               ; preds = %80
  %82 = load i32, ptr %18, align 4, !tbaa !9
  %83 = add nsw i32 %82, 1
  store i32 %83, ptr %18, align 4, !tbaa !9
  br label %64, !llvm.loop !13

84:                                               ; preds = %76, %67
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #4
  %85 = load i32, ptr %17, align 4
  switch i32 %85, label %91 [
    i32 5, label %86
    i32 1, label %89
  ]

86:                                               ; preds = %84
  br label %87

87:                                               ; preds = %86, %58
  br label %88

88:                                               ; preds = %87, %52
  store i1 true, ptr %8, align 1
  br label %89

89:                                               ; preds = %88, %84, %50
  %90 = load i1, ptr %8, align 1
  ret i1 %90

91:                                               ; preds = %84, %50
  unreachable
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNK3JPH4Body5GetIDEv(ptr noundef nonnull align 16 dereferenceable(122)) #2 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK3JPH6BodyIDeqERKS0_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNK3JPH5Shape11GetUserDataEv(ptr noundef nonnull align 8 dereferenceable(26)) #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 = 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"

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_ZNK18SimShapeFilterTest6Filter13ShouldCollideERKN3JPH4BodyEPKNS1_5ShapeERKNS1_10SubShapeIDES4_S7_SA_(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull align 16 dereferenceable(122) %1, ptr noundef %2, ptr nocapture noundef nonnull readnone align 4 dereferenceable(4) %3, ptr noundef nonnull align 16 dereferenceable(122) %4, ptr noundef %5, ptr nocapture noundef nonnull readnone align 4 dereferenceable(4) %6) unnamed_addr #0 align 2 {
  %8 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK3JPH4Body5GetIDEv(ptr noundef nonnull align 16 dereferenceable(122) %1)
  %9 = getelementptr inbounds i8, ptr %0, i64 8
  %10 = tail call noundef zeroext i1 @_ZNK3JPH6BodyIDeqERKS0_(ptr noundef nonnull align 4 dereferenceable(4) %8, ptr noundef nonnull align 4 dereferenceable(4) %9)
  br i1 %10, label %15, label %11

11:                                               ; preds = %7
  %12 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK3JPH4Body5GetIDEv(ptr noundef nonnull align 16 dereferenceable(122) %1)
  %13 = getelementptr inbounds i8, ptr %0, i64 12
  %14 = tail call noundef zeroext i1 @_ZNK3JPH6BodyIDeqERKS0_(ptr noundef nonnull align 4 dereferenceable(4) %12, ptr noundef nonnull align 4 dereferenceable(4) %13)
  br i1 %14, label %15, label %23

15:                                               ; preds = %11, %7
  %16 = getelementptr inbounds i8, ptr %0, i64 16
  %17 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK3JPH4Body5GetIDEv(ptr noundef nonnull align 16 dereferenceable(122) %4)
  %18 = tail call noundef zeroext i1 @_ZNK3JPH6BodyIDeqERKS0_(ptr noundef nonnull align 4 dereferenceable(4) %17, ptr noundef nonnull align 4 dereferenceable(4) %16)
  br i1 %18, label %.thread.sink.split, label %19

19:                                               ; preds = %15
  %20 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK3JPH4Body5GetIDEv(ptr noundef nonnull align 16 dereferenceable(122) %4)
  %21 = getelementptr inbounds i8, ptr %0, i64 20
  %22 = tail call noundef zeroext i1 @_ZNK3JPH6BodyIDeqERKS0_(ptr noundef nonnull align 4 dereferenceable(4) %20, ptr noundef nonnull align 4 dereferenceable(4) %21)
  br i1 %22, label %.thread.sink.split, label %.thread

23:                                               ; preds = %11
  %24 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK3JPH4Body5GetIDEv(ptr noundef nonnull align 16 dereferenceable(122) %4)
  %25 = tail call noundef zeroext i1 @_ZNK3JPH6BodyIDeqERKS0_(ptr noundef nonnull align 4 dereferenceable(4) %24, ptr noundef nonnull align 4 dereferenceable(4) %9)
  br i1 %25, label %29, label %26

26:                                               ; preds = %23
  %27 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK3JPH4Body5GetIDEv(ptr noundef nonnull align 16 dereferenceable(122) %4)
  %28 = tail call noundef zeroext i1 @_ZNK3JPH6BodyIDeqERKS0_(ptr noundef nonnull align 4 dereferenceable(4) %27, ptr noundef nonnull align 4 dereferenceable(4) %13)
  br i1 %28, label %29, label %.thread

29:                                               ; preds = %26, %23
  %30 = getelementptr inbounds i8, ptr %0, i64 16
  %31 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK3JPH4Body5GetIDEv(ptr noundef nonnull align 16 dereferenceable(122) %1)
  %32 = tail call noundef zeroext i1 @_ZNK3JPH6BodyIDeqERKS0_(ptr noundef nonnull align 4 dereferenceable(4) %31, ptr noundef nonnull align 4 dereferenceable(4) %30)
  br i1 %32, label %.thread.sink.split, label %33

33:                                               ; preds = %29
  %34 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK3JPH4Body5GetIDEv(ptr noundef nonnull align 16 dereferenceable(122) %1)
  %35 = getelementptr inbounds i8, ptr %0, i64 20
  %36 = tail call noundef zeroext i1 @_ZNK3JPH6BodyIDeqERKS0_(ptr noundef nonnull align 4 dereferenceable(4) %34, ptr noundef nonnull align 4 dereferenceable(4) %35)
  br i1 %36, label %.thread.sink.split, label %.thread

.thread.sink.split:                               ; preds = %29, %33, %15, %19
  %.sink38 = phi ptr [ %5, %19 ], [ %5, %15 ], [ %2, %33 ], [ %2, %29 ]
  %37 = tail call noundef i64 @_ZNK3JPH5Shape11GetUserDataEv(ptr noundef nonnull align 8 dereferenceable(26) %.sink38)
  %38 = icmp ne i64 %37, 1
  br label %.thread

.thread:                                          ; preds = %.thread.sink.split, %33, %19, %26
  %.2 = phi i1 [ true, %26 ], [ true, %19 ], [ true, %33 ], [ %38, %.thread.sink.split ]
  ret i1 %.2
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNK3JPH4Body5GetIDEv(ptr noundef nonnull align 16 dereferenceable(122)) local_unnamed_addr #1 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNK3JPH5Shape11GetUserDataEv(ptr noundef nonnull align 8 dereferenceable(26)) 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)"}


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