; LLVM IR from jrouwe/JoltPhysics :: Jolt/Physics/Collision/Shape (CapsuleShape)

; 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.JPH::Ref" = type { ptr }
%"class.JPH::CapsuleShape" = type { %"class.JPH::ConvexShape.base", float, float, [4 x i8] }
%"class.JPH::ConvexShape.base" = type <{ %"class.JPH::Shape.base", [6 x i8], %"class.JPH::RefConst", float }>
%"class.JPH::Shape.base" = type <{ ptr, %"class.JPH::RefTarget.11", [4 x i8], i64, i8, i8 }>
%"class.JPH::RefTarget.11" = type { %"struct.std::atomic" }
%"struct.std::atomic" = type { %"struct.std::__atomic_base" }
%"struct.std::__atomic_base" = type { i32 }
%"class.JPH::RefConst" = type { ptr }
%"class.JPH::CapsuleShapeSettings" = type { %"class.JPH::ConvexShapeSettings.base", float, float, [4 x i8] }
%"class.JPH::ConvexShapeSettings.base" = type <{ %"class.JPH::ShapeSettings", %"class.JPH::RefConst", float }>
%"class.JPH::ShapeSettings" = type { %"class.JPH::SerializableObject", %"class.JPH::RefTarget", i64, %"class.JPH::Result" }
%"class.JPH::SerializableObject" = type { ptr }
%"class.JPH::RefTarget" = type { %"struct.std::atomic" }
%"class.JPH::Result" = type <{ %union.anon, i8, [7 x i8] }>
%union.anon = type { %"class.std::__cxx11::basic_string" }
%"class.std::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char, std::char_traits<char>, JPH::STLAllocator<char>>::_Alloc_hider", i64, %union.anon.2 }
%"struct.std::__cxx11::basic_string<char, std::char_traits<char>, JPH::STLAllocator<char>>::_Alloc_hider" = type { ptr }
%union.anon.2 = type { i64, [8 x i8] }

@_ZTVN3JPH12CapsuleShapeE = external dso_local unnamed_addr constant { [38 x ptr] }, align 8
@.str.4 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [15 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

declare i32 @__gxx_personality_v0(...)

; 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 nounwind uwtable
declare dso_local void @_ZN3JPH3RefINS_5ShapeEED2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3JPH12CapsuleShapeC2ERKNS_20CapsuleShapeSettingsERNS_6ResultINS_3RefINS_5ShapeEEEEE(ptr noundef nonnull align 8 dereferenceable(56) %0, ptr noundef nonnull align 8 dereferenceable(88) %1, ptr noundef nonnull align 8 dereferenceable(33) %2) unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca %"class.JPH::Ref", align 8
  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
  %10 = load ptr, ptr %4, align 8
  %11 = load ptr, ptr %5, align 8, !tbaa !5
  %12 = load ptr, ptr %6, align 8, !tbaa !5
  call void @_ZN3JPH11ConvexShapeC2ENS_13EShapeSubTypeERKNS_19ConvexShapeSettingsERNS_6ResultINS_3RefINS_5ShapeEEEEE(ptr noundef nonnull align 8 dereferenceable(44) %10, i8 noundef zeroext 3, ptr noundef nonnull align 8 dereferenceable(76) %11, ptr noundef nonnull align 8 dereferenceable(33) %12)
  store ptr getelementptr inbounds inrange(-16, 288) ({ [38 x ptr] }, ptr @_ZTVN3JPH12CapsuleShapeE, i32 0, i32 0, i32 2), ptr %10, align 8, !tbaa !9
  %13 = getelementptr inbounds %"class.JPH::CapsuleShape", ptr %10, i32 0, i32 1
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  %15 = getelementptr inbounds %"class.JPH::CapsuleShapeSettings", ptr %14, i32 0, i32 1
  %16 = load float, ptr %15, align 4, !tbaa !11
  store float %16, ptr %13, align 4, !tbaa !25
  %17 = getelementptr inbounds %"class.JPH::CapsuleShape", ptr %10, i32 0, i32 2
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = getelementptr inbounds %"class.JPH::CapsuleShapeSettings", ptr %18, i32 0, i32 2
  %20 = load float, ptr %19, align 8, !tbaa !32
  store float %20, ptr %17, align 8, !tbaa !33
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = getelementptr inbounds %"class.JPH::CapsuleShapeSettings", ptr %21, i32 0, i32 2
  %23 = load float, ptr %22, align 8, !tbaa !32
  %24 = fcmp ole float %23, 0.000000e+00
  br i1 %24, label %25, label %32

25:                                               ; preds = %3
  %26 = load ptr, ptr %6, align 8, !tbaa !5
  invoke void @_ZN3JPH6ResultINS_3RefINS_5ShapeEEEE8SetErrorEPKc(ptr noundef nonnull align 8 dereferenceable(33) %26, ptr noundef @.str.4)
          to label %27 unwind label %28

27:                                               ; preds = %25
  br label %44

28:                                               ; preds = %37, %25
  %29 = landingpad { ptr, i32 }
          cleanup
  %30 = extractvalue { ptr, i32 } %29, 0
  store ptr %30, ptr %7, align 8
  %31 = extractvalue { ptr, i32 } %29, 1
  store i32 %31, ptr %8, align 4
  br label %54

32:                                               ; preds = %3
  %33 = load ptr, ptr %5, align 8, !tbaa !5
  %34 = getelementptr inbounds %"class.JPH::CapsuleShapeSettings", ptr %33, i32 0, i32 1
  %35 = load float, ptr %34, align 4, !tbaa !11
  %36 = fcmp ole float %35, 0.000000e+00
  br i1 %36, label %37, label %40

37:                                               ; preds = %32
  %38 = load ptr, ptr %6, align 8, !tbaa !5
  invoke void @_ZN3JPH6ResultINS_3RefINS_5ShapeEEEE8SetErrorEPKc(ptr noundef nonnull align 8 dereferenceable(33) %38, ptr noundef @.str.5)
          to label %39 unwind label %28

39:                                               ; preds = %37
  br label %44

40:                                               ; preds = %32
  %41 = load ptr, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  invoke void @_ZN3JPH3RefINS_5ShapeEEC2EPS1_(ptr noundef nonnull align 8 dereferenceable(8) %9, ptr noundef %10)
          to label %42 unwind label %45

42:                                               ; preds = %40
  invoke void @_ZN3JPH6ResultINS_3RefINS_5ShapeEEEE3SetEOS3_(ptr noundef nonnull align 8 dereferenceable(33) %41, ptr noundef nonnull align 8 dereferenceable(8) %9)
          to label %43 unwind label %49

43:                                               ; preds = %42
  call void @_ZN3JPH3RefINS_5ShapeEED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  br label %44

44:                                               ; preds = %43, %39, %27
  ret void

45:                                               ; preds = %40
  %46 = landingpad { ptr, i32 }
          cleanup
  %47 = extractvalue { ptr, i32 } %46, 0
  store ptr %47, ptr %7, align 8
  %48 = extractvalue { ptr, i32 } %46, 1
  store i32 %48, ptr %8, align 4
  br label %53

49:                                               ; preds = %42
  %50 = landingpad { ptr, i32 }
          cleanup
  %51 = extractvalue { ptr, i32 } %50, 0
  store ptr %51, ptr %7, align 8
  %52 = extractvalue { ptr, i32 } %50, 1
  store i32 %52, ptr %8, align 4
  call void @_ZN3JPH3RefINS_5ShapeEED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %9) #5
  br label %53

53:                                               ; preds = %49, %45
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  br label %54

54:                                               ; preds = %53, %28
  call void @_ZN3JPH11ConvexShapeD2Ev(ptr noundef nonnull align 8 dereferenceable(44) %10) #5
  br label %55

55:                                               ; preds = %54
  %56 = load ptr, ptr %7, align 8
  %57 = load i32, ptr %8, align 4
  %58 = insertvalue { ptr, i32 } poison, ptr %56, 0
  %59 = insertvalue { ptr, i32 } %58, i32 %57, 1
  resume { ptr, i32 } %59
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3JPH11ConvexShapeC2ENS_13EShapeSubTypeERKNS_19ConvexShapeSettingsERNS_6ResultINS_3RefINS_5ShapeEEEEE(ptr noundef nonnull align 8 dereferenceable(44), i8 noundef zeroext, ptr noundef nonnull align 8 dereferenceable(76), ptr noundef nonnull align 8 dereferenceable(33)) unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3JPH6ResultINS_3RefINS_5ShapeEEEE8SetErrorEPKc(ptr noundef nonnull align 8 dereferenceable(33), ptr noundef) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3JPH6ResultINS_3RefINS_5ShapeEEEE3SetEOS3_(ptr noundef nonnull align 8 dereferenceable(33), ptr noundef nonnull align 8 dereferenceable(8)) #3 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN3JPH3RefINS_5ShapeEEC2EPS1_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) unnamed_addr #4 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN3JPH11ConvexShapeD2Ev(ptr noundef nonnull align 8 dereferenceable(44)) unnamed_addr #1 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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" }
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 = { 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 = { 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 #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 = !{!"vtable pointer", !8, i64 0}
!11 = !{!12, !24, i64 76}
!12 = !{!"_ZTSN3JPH20CapsuleShapeSettingsE", !13, i64 0, !24, i64 76, !24, i64 80}
!13 = !{!"_ZTSN3JPH19ConvexShapeSettingsE", !14, i64 0, !23, i64 64, !24, i64 72}
!14 = !{!"_ZTSN3JPH13ShapeSettingsE", !15, i64 0, !16, i64 8, !20, i64 16, !21, i64 24}
!15 = !{!"_ZTSN3JPH18SerializableObjectE"}
!16 = !{!"_ZTSN3JPH9RefTargetINS_13ShapeSettingsEEE", !17, i64 0}
!17 = !{!"_ZTSSt6atomicIjE", !18, i64 0}
!18 = !{!"_ZTSSt13__atomic_baseIjE", !19, i64 0}
!19 = !{!"int", !7, i64 0}
!20 = !{!"long", !7, i64 0}
!21 = !{!"_ZTSN3JPH6ResultINS_3RefINS_5ShapeEEEEE", !7, i64 0, !22, i64 32}
!22 = !{!"_ZTSN3JPH6ResultINS_3RefINS_5ShapeEEEE6EStateE", !7, i64 0}
!23 = !{!"_ZTSN3JPH8RefConstINS_15PhysicsMaterialEEE", !6, i64 0}
!24 = !{!"float", !7, i64 0}
!25 = !{!26, !24, i64 44}
!26 = !{!"_ZTSN3JPH12CapsuleShapeE", !27, i64 0, !24, i64 44, !24, i64 48}
!27 = !{!"_ZTSN3JPH11ConvexShapeE", !28, i64 0, !23, i64 32, !24, i64 40}
!28 = !{!"_ZTSN3JPH5ShapeE", !29, i64 8, !20, i64 16, !30, i64 24, !31, i64 25}
!29 = !{!"_ZTSN3JPH9RefTargetINS_5ShapeEEE", !17, i64 0}
!30 = !{!"_ZTSN3JPH10EShapeTypeE", !7, i64 0}
!31 = !{!"_ZTSN3JPH13EShapeSubTypeE", !7, i64 0}
!32 = !{!12, !24, i64 80}
!33 = !{!26, !24, i64 48}


; 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.JPH::Ref" = type { ptr }

@_ZTVN3JPH12CapsuleShapeE = external dso_local unnamed_addr constant { [38 x ptr] }, align 8
@.str.4 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [15 x i8], align 1

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

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN3JPH3RefINS_5ShapeEED2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3JPH12CapsuleShapeC2ERKNS_20CapsuleShapeSettingsERNS_6ResultINS_3RefINS_5ShapeEEEEE(ptr noundef nonnull align 8 dereferenceable(56) %0, ptr noundef nonnull align 8 dereferenceable(88) %1, ptr noundef nonnull align 8 dereferenceable(33) %2) unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca %"class.JPH::Ref", align 8
  tail call void @_ZN3JPH11ConvexShapeC2ENS_13EShapeSubTypeERKNS_19ConvexShapeSettingsERNS_6ResultINS_3RefINS_5ShapeEEEEE(ptr noundef nonnull align 8 dereferenceable(44) %0, i8 noundef zeroext 3, ptr noundef nonnull align 8 dereferenceable(76) %1, ptr noundef nonnull align 8 dereferenceable(33) %2)
  store ptr getelementptr inbounds inrange(-16, 288) (i8, ptr @_ZTVN3JPH12CapsuleShapeE, i64 16), ptr %0, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 44
  %6 = getelementptr inbounds i8, ptr %1, i64 76
  %7 = load <2 x float>, ptr %6, align 4, !tbaa !8
  store <2 x float> %7, ptr %5, align 4, !tbaa !8
  %8 = extractelement <2 x float> %7, i64 1
  %9 = fcmp ugt float %8, 0.000000e+00
  br i1 %9, label %12, label %.invoke

10:                                               ; preds = %.invoke
  %11 = landingpad { ptr, i32 }
          cleanup
  br label %21

12:                                               ; preds = %3
  %13 = extractelement <2 x float> %7, i64 0
  %14 = fcmp ugt float %13, 0.000000e+00
  br i1 %14, label %16, label %.invoke

.invoke:                                          ; preds = %3, %12
  %15 = phi ptr [ @.str.5, %12 ], [ @.str.4, %3 ]
  invoke void @_ZN3JPH6ResultINS_3RefINS_5ShapeEEEE8SetErrorEPKc(ptr noundef nonnull align 8 dereferenceable(33) %2, ptr noundef nonnull %15)
          to label %18 unwind label %10

16:                                               ; preds = %12
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #5
  invoke void @_ZN3JPH3RefINS_5ShapeEEC2EPS1_(ptr noundef nonnull align 8 dereferenceable(8) %4, ptr noundef nonnull %0)
          to label %17 unwind label %19

17:                                               ; preds = %16
  call void @_ZN3JPH6ResultINS_3RefINS_5ShapeEEEE3SetEOS3_(ptr noundef nonnull align 8 dereferenceable(33) %2, ptr noundef nonnull align 8 dereferenceable(8) %4)
  call void @_ZN3JPH3RefINS_5ShapeEED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %4) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #5
  br label %18

18:                                               ; preds = %.invoke, %17
  ret void

19:                                               ; preds = %16
  %20 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #5
  br label %21

21:                                               ; preds = %19, %10
  %.pn = phi { ptr, i32 } [ %11, %10 ], [ %20, %19 ]
  call void @_ZN3JPH11ConvexShapeD2Ev(ptr noundef nonnull align 8 dereferenceable(44) %0) #5
  resume { ptr, i32 } %.pn
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3JPH11ConvexShapeC2ENS_13EShapeSubTypeERKNS_19ConvexShapeSettingsERNS_6ResultINS_3RefINS_5ShapeEEEEE(ptr noundef nonnull align 8 dereferenceable(44), i8 noundef zeroext, ptr noundef nonnull align 8 dereferenceable(76), ptr noundef nonnull align 8 dereferenceable(33)) unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3JPH6ResultINS_3RefINS_5ShapeEEEE8SetErrorEPKc(ptr noundef nonnull align 8 dereferenceable(33), ptr noundef) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3JPH6ResultINS_3RefINS_5ShapeEEEE3SetEOS3_(ptr noundef nonnull align 8 dereferenceable(33), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #3 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN3JPH3RefINS_5ShapeEEC2EPS1_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) unnamed_addr #4 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN3JPH11ConvexShapeD2Ev(ptr noundef nonnull align 8 dereferenceable(44)) unnamed_addr #1 align 2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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" }
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 = { 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 = { 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 #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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"float", !10, i64 0}
!10 = !{!"omnipotent char", !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass