; LLVM IR from atlantis13579/Riemann :: Src/CollisionPrimitive (Cylinder3)

; 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.Maths::TVector3" = type { float, float, float }

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN7Riemann9Cylinder326IntersectRayInfinityLengthERKN5Maths8TVector3IfEES5_fPf(ptr noundef nonnull align 4 dereferenceable(12) %0, ptr noundef nonnull align 4 dereferenceable(12) %1, float noundef %2, ptr noundef %3) #0 align 2 {
  %5 = alloca i1, align 1
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca float, align 4
  %9 = alloca ptr, align 8
  %10 = alloca %"class.Maths::TVector3", align 4
  %11 = alloca float, align 4
  %12 = alloca %"class.Maths::TVector3", align 4
  %13 = alloca float, align 4
  %14 = alloca float, align 4
  %15 = alloca float, align 4
  %16 = alloca [2 x float], align 4
  %17 = alloca i32, align 4
  %18 = alloca float, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store float %2, ptr %8, align 4, !tbaa !9
  store ptr %3, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 12, ptr %10) #5
  %19 = load ptr, ptr %6, align 8, !tbaa !5
  %20 = getelementptr inbounds %"class.Maths::TVector3", ptr %19, i32 0, i32 0
  %21 = load float, ptr %20, align 4, !tbaa !11
  %22 = load ptr, ptr %6, align 8, !tbaa !5
  %23 = getelementptr inbounds %"class.Maths::TVector3", ptr %22, i32 0, i32 2
  %24 = load float, ptr %23, align 4, !tbaa !13
  call void @_ZN5Maths8TVector3IfEC2Efff(ptr noundef nonnull align 4 dereferenceable(12) %10, float noundef %21, float noundef 0.000000e+00, float noundef %24)
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  %25 = call noundef float @_ZNK5Maths8TVector3IfE12SquareLengthEv(ptr noundef nonnull align 4 dereferenceable(12) %10)
  store float %25, ptr %11, align 4, !tbaa !9
  %26 = load float, ptr %11, align 4, !tbaa !9
  %27 = load float, ptr %8, align 4, !tbaa !9
  %28 = load float, ptr %8, align 4, !tbaa !9
  %29 = fmul float %27, %28
  %30 = fcmp ogt float %26, %29
  br i1 %30, label %31, label %67

31:                                               ; preds = %4
  call void @llvm.lifetime.start.p0(i64 12, ptr %12) #5
  %32 = load ptr, ptr %7, align 8, !tbaa !5
  %33 = getelementptr inbounds %"class.Maths::TVector3", ptr %32, i32 0, i32 0
  %34 = load float, ptr %33, align 4, !tbaa !11
  %35 = load ptr, ptr %7, align 8, !tbaa !5
  %36 = getelementptr inbounds %"class.Maths::TVector3", ptr %35, i32 0, i32 2
  %37 = load float, ptr %36, align 4, !tbaa !13
  call void @_ZN5Maths8TVector3IfEC2Efff(ptr noundef nonnull align 4 dereferenceable(12) %12, float noundef %34, float noundef 0.000000e+00, float noundef %37)
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  %38 = call noundef float @_ZNK5Maths8TVector3IfE12SquareLengthEv(ptr noundef nonnull align 4 dereferenceable(12) %12)
  store float %38, ptr %13, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #5
  %39 = call noundef float @_ZNK5Maths8TVector3IfE3DotERKS1_(ptr noundef nonnull align 4 dereferenceable(12) %10, ptr noundef nonnull align 4 dereferenceable(12) %12)
  %40 = fmul float 2.000000e+00, %39
  store float %40, ptr %14, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #5
  %41 = load float, ptr %11, align 4, !tbaa !9
  %42 = load float, ptr %8, align 4, !tbaa !9
  %43 = load float, ptr %8, align 4, !tbaa !9
  %44 = fneg float %42
  %45 = call float @llvm.fmuladd.f32(float %44, float %43, float %41)
  store float %45, ptr %15, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #5
  %46 = load float, ptr %13, align 4, !tbaa !9
  %47 = load float, ptr %14, align 4, !tbaa !9
  %48 = load float, ptr %15, align 4, !tbaa !9
  %49 = call noundef float @_ZN5Maths14SolveQuadraticIfEET_S1_S1_S1_(float noundef %46, float noundef %47, float noundef %48)
  %50 = fcmp oeq float %49, 0.000000e+00
  br i1 %50, label %51, label %52

51:                                               ; preds = %31
  store i1 false, ptr %5, align 1
  store i32 1, ptr %17, align 4
  br label %64

52:                                               ; preds = %31
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #5
  %53 = getelementptr inbounds [2 x float], ptr %16, i64 0, i64 0
  %54 = getelementptr inbounds [2 x float], ptr %16, i64 0, i64 1
  %55 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIfERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %53, ptr noundef nonnull align 4 dereferenceable(4) %54)
  %56 = load float, ptr %55, align 4, !tbaa !9
  store float %56, ptr %18, align 4, !tbaa !9
  %57 = load float, ptr %18, align 4, !tbaa !9
  %58 = fcmp oge float %57, 0.000000e+00
  br i1 %58, label %59, label %62

59:                                               ; preds = %52
  %60 = load float, ptr %18, align 4, !tbaa !9
  %61 = load ptr, ptr %9, align 8, !tbaa !5
  store float %60, ptr %61, align 4, !tbaa !9
  store i1 true, ptr %5, align 1
  store i32 1, ptr %17, align 4
  br label %63

62:                                               ; preds = %52
  store i32 0, ptr %17, align 4
  br label %63

63:                                               ; preds = %62, %59
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #5
  br label %64

64:                                               ; preds = %63, %51
  call void @llvm.lifetime.end.p0(i64 8, 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
  call void @llvm.lifetime.end.p0(i64 12, ptr %12) #5
  %65 = load i32, ptr %17, align 4
  switch i32 %65, label %69 [
    i32 0, label %66
  ]

66:                                               ; preds = %64
  br label %67

67:                                               ; preds = %66, %4
  %68 = load ptr, ptr %9, align 8, !tbaa !5
  store float 0.000000e+00, ptr %68, align 4, !tbaa !9
  store i1 true, ptr %5, align 1
  store i32 1, ptr %17, align 4
  br label %69

69:                                               ; preds = %67, %64
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 12, ptr %10) #5
  %70 = load i1, ptr %5, align 1
  ret i1 %70
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #1

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN5Maths8TVector3IfEC2Efff(ptr noundef nonnull align 4 dereferenceable(12), float noundef, float noundef, float noundef) unnamed_addr #3 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_ZNK5Maths8TVector3IfE12SquareLengthEv(ptr noundef nonnull align 4 dereferenceable(12)) #3 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_ZNK5Maths8TVector3IfE3DotERKS1_(ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12)) #3 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef float @_ZN5Maths14SolveQuadraticIfEET_S1_S1_S1_(float noundef, float noundef, float noundef) #4

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIfERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #3

attributes #0 = { 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #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 = !{!"float", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"_ZTSN5Maths8TVector3IfEE", !10, i64 0, !10, i64 4, !10, i64 8}
!13 = !{!12, !10, i64 8}


; 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.Maths::TVector3" = type { float, float, float }

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN7Riemann9Cylinder326IntersectRayInfinityLengthERKN5Maths8TVector3IfEES5_fPf(ptr nocapture noundef nonnull readonly align 4 dereferenceable(12) %0, ptr nocapture noundef nonnull readonly align 4 dereferenceable(12) %1, float noundef %2, ptr nocapture noundef writeonly %3) local_unnamed_addr #0 align 2 {
  %5 = alloca %"class.Maths::TVector3", align 4
  %6 = alloca %"class.Maths::TVector3", align 4
  %7 = alloca [2 x float], align 4
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %5) #5
  %8 = load float, ptr %0, align 4, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %0, i64 8
  %10 = load float, ptr %9, align 4, !tbaa !10
  call void @_ZN5Maths8TVector3IfEC2Efff(ptr noundef nonnull align 4 dereferenceable(12) %5, float noundef %8, float noundef 0.000000e+00, float noundef %10)
  %11 = call noundef float @_ZNK5Maths8TVector3IfE12SquareLengthEv(ptr noundef nonnull align 4 dereferenceable(12) %5)
  %12 = fmul float %2, %2
  %13 = fcmp ogt float %11, %12
  br i1 %13, label %14, label %31

14:                                               ; preds = %4
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %6) #5
  %15 = load float, ptr %1, align 4, !tbaa !5
  %16 = getelementptr inbounds i8, ptr %1, i64 8
  %17 = load float, ptr %16, align 4, !tbaa !10
  call void @_ZN5Maths8TVector3IfEC2Efff(ptr noundef nonnull align 4 dereferenceable(12) %6, float noundef %15, float noundef 0.000000e+00, float noundef %17)
  %18 = call noundef float @_ZNK5Maths8TVector3IfE12SquareLengthEv(ptr noundef nonnull align 4 dereferenceable(12) %6)
  %19 = call noundef float @_ZNK5Maths8TVector3IfE3DotERKS1_(ptr noundef nonnull align 4 dereferenceable(12) %5, ptr noundef nonnull align 4 dereferenceable(12) %6)
  %20 = fmul float %19, 2.000000e+00
  %21 = fneg float %2
  %22 = call float @llvm.fmuladd.f32(float %21, float %2, float %11)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #5
  %23 = call noundef float @_ZN5Maths14SolveQuadraticIfEET_S1_S1_S1_(float noundef %18, float noundef %20, float noundef %22)
  %24 = fcmp une float %23, 0.000000e+00
  br i1 %24, label %25, label %.critedge

25:                                               ; preds = %14
  %26 = getelementptr inbounds i8, ptr %7, i64 4
  %27 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIfERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %7, ptr noundef nonnull align 4 dereferenceable(4) %26)
  %28 = load float, ptr %27, align 4, !tbaa !11
  %29 = fcmp ult float %28, 0.000000e+00
  br i1 %29, label %.critedge22, label %30

30:                                               ; preds = %25
  store float %28, ptr %3, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #5
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %6) #5
  br label %32

.critedge22:                                      ; preds = %25
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #5
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %6) #5
  br label %31

31:                                               ; preds = %.critedge22, %4
  store float 0.000000e+00, ptr %3, align 4, !tbaa !11
  br label %32

.critedge:                                        ; preds = %14
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #5
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %6) #5
  br label %32

32:                                               ; preds = %30, %.critedge, %31
  %.2 = phi i1 [ true, %31 ], [ true, %30 ], [ false, %.critedge ]
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %5) #5
  ret i1 %.2
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #1

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN5Maths8TVector3IfEC2Efff(ptr noundef nonnull align 4 dereferenceable(12), float noundef, float noundef, float noundef) unnamed_addr #3 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_ZNK5Maths8TVector3IfE12SquareLengthEv(ptr noundef nonnull align 4 dereferenceable(12)) local_unnamed_addr #3 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_ZNK5Maths8TVector3IfE3DotERKS1_(ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12)) local_unnamed_addr #3 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef float @_ZN5Maths14SolveQuadraticIfEET_S1_S1_S1_(float noundef, float noundef, float noundef) local_unnamed_addr #4

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIfERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #3

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


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