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

; 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::Vec3" = type { %union.anon }
%union.anon = type { <4 x float> }
%"struct.JPH::AssertLastParam" = type { i8 }

@.str.8 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [106 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [6 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: mustprogress uwtable
define dso_local noundef ptr @_ZNK3JPH20TaperedCylinderShape18GetSupportFunctionENS_11ConvexShape12ESupportModeERNS1_13SupportBufferENS_4Vec3E(ptr noundef nonnull align 8 dereferenceable(64) %0, i32 noundef %1, ptr noundef nonnull align 16 dereferenceable(4160) %2, double %3, double %4) unnamed_addr #1 align 2 {
  %6 = alloca ptr, align 8
  %7 = alloca %"class.JPH::Vec3", align 16
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca %"class.JPH::Vec3", align 16
  %12 = alloca %"struct.JPH::AssertLastParam", align 1
  %13 = alloca float, align 4
  %14 = alloca float, align 4
  %15 = alloca float, align 4
  %16 = alloca float, align 4
  %17 = alloca float, align 4
  %18 = alloca %"class.JPH::Vec3", align 16
  %19 = alloca i32, align 4
  %20 = alloca %"struct.JPH::AssertLastParam", align 1
  %21 = getelementptr inbounds { double, double }, ptr %7, i32 0, i32 0
  store double %3, ptr %21, align 16
  %22 = getelementptr inbounds { double, double }, ptr %7, i32 0, i32 1
  store double %4, ptr %22, align 8
  store ptr %0, ptr %8, align 8, !tbaa !5
  store i32 %1, ptr %9, align 4, !tbaa !9
  store ptr %2, ptr %10, align 8, !tbaa !5
  %23 = load ptr, ptr %8, align 8
  br label %24

24:                                               ; preds = %5
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %11, ptr align 16 %7, i64 16, i1 false), !tbaa.struct !11
  %25 = getelementptr inbounds { double, double }, ptr %11, i32 0, i32 0
  %26 = load double, ptr %25, align 16
  %27 = getelementptr inbounds { double, double }, ptr %11, i32 0, i32 1
  %28 = load double, ptr %27, align 8
  %29 = call noundef zeroext i1 @_ZNK3JPH20TaperedCylinderShape12IsValidScaleENS_4Vec3E(ptr noundef nonnull align 8 dereferenceable(64) %23, double %26, double %28)
  br i1 %29, label %33, label %30

30:                                               ; preds = %24
  %31 = call noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef @.str.8, ptr noundef @.str.9, i32 noundef 215)
  br i1 %31, label %32, label %33

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

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

34:                                               ; preds = %33
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %18, ptr align 16 %7, i64 16, i1 false), !tbaa.struct !11
  %35 = getelementptr inbounds { double, double }, ptr %18, i32 0, i32 0
  %36 = load double, ptr %35, align 16
  %37 = getelementptr inbounds { double, double }, ptr %18, i32 0, i32 1
  %38 = load double, ptr %37, align 8
  call void @_ZNK3JPH20TaperedCylinderShape9GetScaledENS_4Vec3ERfS2_S2_S2_S2_(ptr noundef nonnull align 8 dereferenceable(64) %23, double %36, double %38, ptr noundef nonnull align 4 dereferenceable(4) %13, ptr noundef nonnull align 4 dereferenceable(4) %14, ptr noundef nonnull align 4 dereferenceable(4) %15, ptr noundef nonnull align 4 dereferenceable(4) %16, ptr noundef nonnull align 4 dereferenceable(4) %17)
  %39 = load i32, ptr %9, align 4, !tbaa !9
  switch i32 %39, label %61 [
    i32 1, label %40
    i32 2, label %40
    i32 0, label %46
  ]

40:                                               ; preds = %34, %34
  %41 = load ptr, ptr %10, align 8, !tbaa !5
  %42 = load float, ptr %13, align 4, !tbaa !14
  %43 = load float, ptr %14, align 4, !tbaa !14
  %44 = load float, ptr %15, align 4, !tbaa !14
  %45 = load float, ptr %16, align 4, !tbaa !14
  call void @_ZN3JPH20TaperedCylinderShape15TaperedCylinderC2Efffff(ptr noundef nonnull align 8 dereferenceable(32) %41, float noundef %42, float noundef %43, float noundef %44, float noundef %45, float noundef 0.000000e+00)
  store ptr %41, ptr %6, align 8
  store i32 1, ptr %19, align 4
  br label %68

46:                                               ; preds = %34
  %47 = load ptr, ptr %10, align 8, !tbaa !5
  %48 = load float, ptr %13, align 4, !tbaa !14
  %49 = load float, ptr %17, align 4, !tbaa !14
  %50 = fsub float %48, %49
  %51 = load float, ptr %14, align 4, !tbaa !14
  %52 = load float, ptr %17, align 4, !tbaa !14
  %53 = fadd float %51, %52
  %54 = load float, ptr %15, align 4, !tbaa !14
  %55 = load float, ptr %17, align 4, !tbaa !14
  %56 = fsub float %54, %55
  %57 = load float, ptr %16, align 4, !tbaa !14
  %58 = load float, ptr %17, align 4, !tbaa !14
  %59 = fsub float %57, %58
  %60 = load float, ptr %17, align 4, !tbaa !14
  call void @_ZN3JPH20TaperedCylinderShape15TaperedCylinderC2Efffff(ptr noundef nonnull align 8 dereferenceable(32) %47, float noundef %50, float noundef %53, float noundef %56, float noundef %59, float noundef %60)
  store ptr %47, ptr %6, align 8
  store i32 1, ptr %19, align 4
  br label %68

61:                                               ; preds = %34
  br label %62

62:                                               ; preds = %61
  %63 = call noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef @.str.10, ptr noundef @.str.9, i32 noundef 231)
  br i1 %63, label %64, label %65

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

65:                                               ; preds = %64, %62
  br label %66

66:                                               ; preds = %65
  br label %67

67:                                               ; preds = %66
  store ptr null, ptr %6, align 8
  store i32 1, ptr %19, align 4
  br label %68

68:                                               ; preds = %67, %46, %40
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  %69 = load ptr, ptr %6, align 8
  ret ptr %69
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZNK3JPH20TaperedCylinderShape12IsValidScaleENS_4Vec3E(ptr noundef nonnull align 8 dereferenceable(64), double, double) unnamed_addr #1 align 2

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

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

; Function Attrs: alwaysinline mustprogress uwtable
declare dso_local void @_ZNK3JPH20TaperedCylinderShape9GetScaledENS_4Vec3ERfS2_S2_S2_S2_(ptr noundef nonnull align 8 dereferenceable(64), double, double, ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #4 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3JPH20TaperedCylinderShape15TaperedCylinderC2Efffff(ptr noundef nonnull align 8 dereferenceable(32), float noundef, float noundef, float noundef, float noundef, float noundef) unnamed_addr #1 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #4 = { alwaysinline 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 = !{!"_ZTSN3JPH11ConvexShape12ESupportModeE", !7, i64 0}
!11 = !{i64 0, i64 16, !12}
!12 = !{!7, !7, i64 0}
!13 = !{i64 2157859391}
!14 = !{!15, !15, i64 0}
!15 = !{!"float", !7, i64 0}
!16 = !{i64 2157859715}


; 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"

@.str.8 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [106 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [6 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

; 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 uwtable
define dso_local noundef ptr @_ZNK3JPH20TaperedCylinderShape18GetSupportFunctionENS_11ConvexShape12ESupportModeERNS1_13SupportBufferENS_4Vec3E(ptr noundef nonnull align 8 dereferenceable(64) %0, i32 noundef %1, ptr noundef nonnull align 16 dereferenceable(4160) %2, double %3, double %4) unnamed_addr #1 align 2 {
  %6 = alloca float, align 4
  %7 = alloca float, align 4
  %8 = alloca float, align 4
  %9 = alloca float, align 4
  %10 = alloca float, align 4
  %11 = tail call noundef zeroext i1 @_ZNK3JPH20TaperedCylinderShape12IsValidScaleENS_4Vec3E(ptr noundef nonnull align 8 dereferenceable(64) %0, double %3, double %4)
  br i1 %11, label %15, label %12

12:                                               ; preds = %5
  %13 = tail call noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef nonnull @.str.8, ptr noundef nonnull @.str.9, i32 noundef 215)
  br i1 %13, label %14, label %15

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

15:                                               ; preds = %5, %12, %14
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %8) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %9) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %10) #4
  call void @_ZNK3JPH20TaperedCylinderShape9GetScaledENS_4Vec3ERfS2_S2_S2_S2_(ptr noundef nonnull align 8 dereferenceable(64) %0, double %3, double %4, ptr noundef nonnull align 4 dereferenceable(4) %6, ptr noundef nonnull align 4 dereferenceable(4) %7, ptr noundef nonnull align 4 dereferenceable(4) %8, ptr noundef nonnull align 4 dereferenceable(4) %9, ptr noundef nonnull align 4 dereferenceable(4) %10)
  switch i32 %1, label %31 [
    i32 1, label %16
    i32 2, label %16
    i32 0, label %21
  ]

16:                                               ; preds = %15, %15
  %17 = load float, ptr %6, align 4, !tbaa !6
  %18 = load float, ptr %7, align 4, !tbaa !6
  %19 = load float, ptr %8, align 4, !tbaa !6
  %20 = load float, ptr %9, align 4, !tbaa !6
  call void @_ZN3JPH20TaperedCylinderShape15TaperedCylinderC2Efffff(ptr noundef nonnull align 8 dereferenceable(32) %2, float noundef %17, float noundef %18, float noundef %19, float noundef %20, float noundef 0.000000e+00)
  br label %34

21:                                               ; preds = %15
  %22 = load float, ptr %6, align 4, !tbaa !6
  %23 = load float, ptr %10, align 4, !tbaa !6
  %24 = fsub float %22, %23
  %25 = load float, ptr %7, align 4, !tbaa !6
  %26 = fadd float %23, %25
  %27 = load float, ptr %8, align 4, !tbaa !6
  %28 = fsub float %27, %23
  %29 = load float, ptr %9, align 4, !tbaa !6
  %30 = fsub float %29, %23
  call void @_ZN3JPH20TaperedCylinderShape15TaperedCylinderC2Efffff(ptr noundef nonnull align 8 dereferenceable(32) %2, float noundef %24, float noundef %26, float noundef %28, float noundef %30, float noundef %23)
  br label %34

31:                                               ; preds = %15
  %32 = call noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef nonnull @.str.10, ptr noundef nonnull @.str.9, i32 noundef 231)
  br i1 %32, label %33, label %34

33:                                               ; preds = %31
  call void asm sideeffect "int $$0x3", "~{dirflag},~{fpsr},~{flags}"() #4, !srcloc !10
  br label %34

34:                                               ; preds = %31, %33, %21, %16
  %.0 = phi ptr [ %2, %21 ], [ %2, %16 ], [ null, %33 ], [ null, %31 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #4
  ret ptr %.0
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZNK3JPH20TaperedCylinderShape12IsValidScaleENS_4Vec3E(ptr noundef nonnull align 8 dereferenceable(64), double, double) unnamed_addr #1 align 2

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

; Function Attrs: alwaysinline mustprogress uwtable
declare dso_local void @_ZNK3JPH20TaperedCylinderShape9GetScaledENS_4Vec3ERfS2_S2_S2_S2_(ptr noundef nonnull align 8 dereferenceable(64), double, double, ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3JPH20TaperedCylinderShape15TaperedCylinderC2Efffff(ptr noundef nonnull align 8 dereferenceable(32), float noundef, float noundef, float noundef, float noundef, float noundef) unnamed_addr #1 align 2

attributes #0 = { mustprogress 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 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 = { alwaysinline 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 = { 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 = !{i64 2157859391}
!6 = !{!7, !7, i64 0}
!7 = !{!"float", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{i64 2157859715}


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