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

; 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZNK5Maths8TVector3IfEmiERKS1_(ptr dead_on_unwind noalias writable sret(%"class.Maths::TVector3") align 4, ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12)) #1 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZNK5Maths8TVector3IfE5CrossERKS1_(ptr dead_on_unwind noalias writable sret(%"class.Maths::TVector3") align 4, ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12)) #1 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)) #2 align 2

; 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 i32 @_ZN7Riemann9Triangle321RayIntersectTriangle2ERKN5Maths8TVector3IfEES5_S5_S5_S5_PfS6_S6_(ptr noundef nonnull align 4 dereferenceable(12) %0, ptr noundef nonnull align 4 dereferenceable(12) %1, ptr noundef nonnull align 4 dereferenceable(12) %2, ptr noundef nonnull align 4 dereferenceable(12) %3, ptr noundef nonnull align 4 dereferenceable(12) %4, ptr noundef %5, ptr noundef %6, ptr noundef %7) #3 align 2 {
  %9 = alloca i32, align 4
  %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 ptr, align 8
  %17 = alloca ptr, align 8
  %18 = alloca %"class.Maths::TVector3", align 4
  %19 = alloca float, align 4
  %20 = alloca float, align 4
  %21 = alloca i32, align 4
  %22 = alloca float, align 4
  %23 = alloca %"class.Maths::TVector3", align 4
  %24 = alloca %"class.Maths::TVector3", align 4
  store ptr %0, ptr %10, align 8, !tbaa !5
  store ptr %1, ptr %11, align 8, !tbaa !5
  store ptr %2, ptr %12, align 8, !tbaa !5
  store ptr %3, ptr %13, align 8, !tbaa !5
  store ptr %4, ptr %14, align 8, !tbaa !5
  store ptr %5, ptr %15, align 8, !tbaa !5
  store ptr %6, ptr %16, align 8, !tbaa !5
  store ptr %7, ptr %17, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 12, ptr %18) #4
  %25 = load ptr, ptr %11, align 8, !tbaa !5
  %26 = load ptr, ptr %14, align 8, !tbaa !5
  call void @_ZNK5Maths8TVector3IfE5CrossERKS1_(ptr dead_on_unwind writable sret(%"class.Maths::TVector3") align 4 %18, ptr noundef nonnull align 4 dereferenceable(12) %25, ptr noundef nonnull align 4 dereferenceable(12) %26)
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #4
  %27 = load ptr, ptr %13, align 8, !tbaa !5
  %28 = call noundef float @_ZNK5Maths8TVector3IfE3DotERKS1_(ptr noundef nonnull align 4 dereferenceable(12) %27, ptr noundef nonnull align 4 dereferenceable(12) %18)
  store float %28, ptr %19, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #4
  store float 0x3EE4F8B580000000, ptr %20, align 4, !tbaa !9
  %29 = load float, ptr %19, align 4, !tbaa !9
  %30 = fcmp ogt float %29, 0xBEE4F8B580000000
  br i1 %30, label %31, label %35

31:                                               ; preds = %8
  %32 = load float, ptr %19, align 4, !tbaa !9
  %33 = fcmp olt float %32, 0x3EE4F8B580000000
  br i1 %33, label %34, label %35

34:                                               ; preds = %31
  store i32 0, ptr %9, align 4
  store i32 1, ptr %21, align 4
  br label %77

35:                                               ; preds = %31, %8
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #4
  %36 = load float, ptr %19, align 4, !tbaa !9
  %37 = fdiv float 1.000000e+00, %36
  store float %37, ptr %22, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 12, ptr %23) #4
  %38 = load ptr, ptr %10, align 8, !tbaa !5
  %39 = load ptr, ptr %12, align 8, !tbaa !5
  call void @_ZNK5Maths8TVector3IfEmiERKS1_(ptr dead_on_unwind writable sret(%"class.Maths::TVector3") align 4 %23, ptr noundef nonnull align 4 dereferenceable(12) %38, ptr noundef nonnull align 4 dereferenceable(12) %39)
  %40 = call noundef float @_ZNK5Maths8TVector3IfE3DotERKS1_(ptr noundef nonnull align 4 dereferenceable(12) %23, ptr noundef nonnull align 4 dereferenceable(12) %18)
  %41 = load float, ptr %22, align 4, !tbaa !9
  %42 = fmul float %40, %41
  %43 = load ptr, ptr %16, align 8, !tbaa !5
  store float %42, ptr %43, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 12, ptr %24) #4
  %44 = load ptr, ptr %13, align 8, !tbaa !5
  call void @_ZNK5Maths8TVector3IfE5CrossERKS1_(ptr dead_on_unwind writable sret(%"class.Maths::TVector3") align 4 %24, ptr noundef nonnull align 4 dereferenceable(12) %23, ptr noundef nonnull align 4 dereferenceable(12) %44)
  %45 = load ptr, ptr %11, align 8, !tbaa !5
  %46 = call noundef float @_ZNK5Maths8TVector3IfE3DotERKS1_(ptr noundef nonnull align 4 dereferenceable(12) %45, ptr noundef nonnull align 4 dereferenceable(12) %24)
  %47 = load float, ptr %22, align 4, !tbaa !9
  %48 = fmul float %46, %47
  %49 = load ptr, ptr %17, align 8, !tbaa !5
  store float %48, ptr %49, align 4, !tbaa !9
  %50 = load ptr, ptr %16, align 8, !tbaa !5
  %51 = load float, ptr %50, align 4, !tbaa !9
  %52 = fcmp olt float %51, 0.000000e+00
  br i1 %52, label %57, label %53

53:                                               ; preds = %35
  %54 = load ptr, ptr %16, align 8, !tbaa !5
  %55 = load float, ptr %54, align 4, !tbaa !9
  %56 = fcmp ogt float %55, 1.000000e+00
  br i1 %56, label %57, label %58

57:                                               ; preds = %53, %35
  store i32 1, ptr %9, align 4
  store i32 1, ptr %21, align 4
  br label %76

58:                                               ; preds = %53
  %59 = load ptr, ptr %17, align 8, !tbaa !5
  %60 = load float, ptr %59, align 4, !tbaa !9
  %61 = fcmp olt float %60, 0.000000e+00
  br i1 %61, label %69, label %62

62:                                               ; preds = %58
  %63 = load ptr, ptr %16, align 8, !tbaa !5
  %64 = load float, ptr %63, align 4, !tbaa !9
  %65 = load ptr, ptr %17, align 8, !tbaa !5
  %66 = load float, ptr %65, align 4, !tbaa !9
  %67 = fadd float %64, %66
  %68 = fcmp ogt float %67, 1.000000e+00
  br i1 %68, label %69, label %70

69:                                               ; preds = %62, %58
  store i32 1, ptr %9, align 4
  store i32 1, ptr %21, align 4
  br label %76

70:                                               ; preds = %62
  %71 = load ptr, ptr %14, align 8, !tbaa !5
  %72 = call noundef float @_ZNK5Maths8TVector3IfE3DotERKS1_(ptr noundef nonnull align 4 dereferenceable(12) %71, ptr noundef nonnull align 4 dereferenceable(12) %24)
  %73 = load float, ptr %22, align 4, !tbaa !9
  %74 = fmul float %72, %73
  %75 = load ptr, ptr %15, align 8, !tbaa !5
  store float %74, ptr %75, align 4, !tbaa !9
  store i32 2, ptr %9, align 4
  store i32 1, ptr %21, align 4
  br label %76

76:                                               ; preds = %70, %69, %57
  call void @llvm.lifetime.end.p0(i64 12, ptr %24) #4
  call void @llvm.lifetime.end.p0(i64 12, ptr %23) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #4
  br label %77

77:                                               ; preds = %76, %34
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #4
  call void @llvm.lifetime.end.p0(i64 12, ptr %18) #4
  %78 = load i32, ptr %9, align 4
  ret i32 %78
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 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 = !{!"float", !7, i64 0}


; 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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZNK5Maths8TVector3IfEmiERKS1_(ptr dead_on_unwind noalias writable sret(%"class.Maths::TVector3") align 4, ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12)) local_unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZNK5Maths8TVector3IfE5CrossERKS1_(ptr dead_on_unwind noalias writable sret(%"class.Maths::TVector3") align 4, ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12)) local_unnamed_addr #1 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 #2 align 2

; 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 range(i32 0, 3) i32 @_ZN7Riemann9Triangle321RayIntersectTriangle2ERKN5Maths8TVector3IfEES5_S5_S5_S5_PfS6_S6_(ptr noundef nonnull align 4 dereferenceable(12) %0, ptr noundef nonnull align 4 dereferenceable(12) %1, ptr noundef nonnull align 4 dereferenceable(12) %2, ptr noundef nonnull align 4 dereferenceable(12) %3, ptr noundef nonnull align 4 dereferenceable(12) %4, ptr nocapture noundef writeonly %5, ptr nocapture noundef %6, ptr nocapture noundef writeonly %7) local_unnamed_addr #3 align 2 {
  %9 = alloca %"class.Maths::TVector3", align 4
  %10 = alloca %"class.Maths::TVector3", align 4
  %11 = alloca %"class.Maths::TVector3", align 4
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %9) #5
  call void @_ZNK5Maths8TVector3IfE5CrossERKS1_(ptr dead_on_unwind nonnull writable sret(%"class.Maths::TVector3") align 4 %9, ptr noundef nonnull align 4 dereferenceable(12) %1, ptr noundef nonnull align 4 dereferenceable(12) %4)
  %12 = call noundef float @_ZNK5Maths8TVector3IfE3DotERKS1_(ptr noundef nonnull align 4 dereferenceable(12) %3, ptr noundef nonnull align 4 dereferenceable(12) %9)
  %13 = call float @llvm.fabs.f32(float %12)
  %or.cond = fcmp olt float %13, 0x3EE4F8B580000000
  br i1 %or.cond, label %31, label %14

14:                                               ; preds = %8
  %15 = fdiv float 1.000000e+00, %12
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %10) #5
  call void @_ZNK5Maths8TVector3IfEmiERKS1_(ptr dead_on_unwind nonnull writable sret(%"class.Maths::TVector3") align 4 %10, ptr noundef nonnull align 4 dereferenceable(12) %0, ptr noundef nonnull align 4 dereferenceable(12) %2)
  %16 = call noundef float @_ZNK5Maths8TVector3IfE3DotERKS1_(ptr noundef nonnull align 4 dereferenceable(12) %10, ptr noundef nonnull align 4 dereferenceable(12) %9)
  %17 = fmul float %15, %16
  store float %17, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %11) #5
  call void @_ZNK5Maths8TVector3IfE5CrossERKS1_(ptr dead_on_unwind nonnull writable sret(%"class.Maths::TVector3") align 4 %11, ptr noundef nonnull align 4 dereferenceable(12) %10, ptr noundef nonnull align 4 dereferenceable(12) %3)
  %18 = call noundef float @_ZNK5Maths8TVector3IfE3DotERKS1_(ptr noundef nonnull align 4 dereferenceable(12) %1, ptr noundef nonnull align 4 dereferenceable(12) %11)
  %19 = fmul float %15, %18
  store float %19, ptr %7, align 4, !tbaa !5
  %20 = load float, ptr %6, align 4, !tbaa !5
  %21 = fcmp olt float %20, 0.000000e+00
  %22 = fcmp ogt float %20, 1.000000e+00
  %or.cond25 = or i1 %21, %22
  br i1 %or.cond25, label %30, label %23

23:                                               ; preds = %14
  %24 = fcmp olt float %19, 0.000000e+00
  %25 = fadd float %19, %20
  %26 = fcmp ogt float %25, 1.000000e+00
  %or.cond27 = or i1 %24, %26
  br i1 %or.cond27, label %30, label %27

27:                                               ; preds = %23
  %28 = call noundef float @_ZNK5Maths8TVector3IfE3DotERKS1_(ptr noundef nonnull align 4 dereferenceable(12) %4, ptr noundef nonnull align 4 dereferenceable(12) %11)
  %29 = fmul float %15, %28
  store float %29, ptr %5, align 4, !tbaa !5
  br label %30

30:                                               ; preds = %23, %14, %27
  %.0 = phi i32 [ 2, %27 ], [ 1, %14 ], [ 1, %23 ]
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %11) #5
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %10) #5
  br label %31

31:                                               ; preds = %8, %30
  %.1 = phi i32 [ %.0, %30 ], [ 0, %8 ]
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %9) #5
  ret i32 %.1
}

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

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


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