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

; 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.Riemann::Sphere3" = type { %"class.Maths::TVector3", float }
%"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: 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 @_ZNK7Riemann7Sphere313IntersectAABBERKN5Maths8TVector3IfEES5_(ptr noundef nonnull align 4 dereferenceable(16) %0, ptr noundef nonnull align 4 dereferenceable(12) %1, ptr noundef nonnull align 4 dereferenceable(12) %2) #1 align 2 {
  %4 = alloca i1, align 1
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca float, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  %11 = load ptr, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  store float 0.000000e+00, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  store i32 0, ptr %9, align 4, !tbaa !11
  br label %12

12:                                               ; preds = %80, %3
  %13 = load i32, ptr %9, align 4, !tbaa !11
  %14 = icmp slt i32 %13, 3
  br i1 %14, label %16, label %15

15:                                               ; preds = %12
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  br label %83

16:                                               ; preds = %12
  %17 = getelementptr inbounds %"class.Riemann::Sphere3", ptr %11, i32 0, i32 0
  %18 = load i32, ptr %9, align 4, !tbaa !11
  %19 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK5Maths8TVector3IfEixEi(ptr noundef nonnull align 4 dereferenceable(12) %17, i32 noundef %18)
  %20 = load float, ptr %19, align 4, !tbaa !9
  %21 = load ptr, ptr %6, align 8, !tbaa !5
  %22 = load i32, ptr %9, align 4, !tbaa !11
  %23 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK5Maths8TVector3IfEixEi(ptr noundef nonnull align 4 dereferenceable(12) %21, i32 noundef %22)
  %24 = load float, ptr %23, align 4, !tbaa !9
  %25 = fcmp olt float %20, %24
  br i1 %25, label %26, label %47

26:                                               ; preds = %16
  %27 = getelementptr inbounds %"class.Riemann::Sphere3", ptr %11, i32 0, i32 0
  %28 = load i32, ptr %9, align 4, !tbaa !11
  %29 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK5Maths8TVector3IfEixEi(ptr noundef nonnull align 4 dereferenceable(12) %27, i32 noundef %28)
  %30 = load float, ptr %29, align 4, !tbaa !9
  %31 = load ptr, ptr %6, align 8, !tbaa !5
  %32 = load i32, ptr %9, align 4, !tbaa !11
  %33 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK5Maths8TVector3IfEixEi(ptr noundef nonnull align 4 dereferenceable(12) %31, i32 noundef %32)
  %34 = load float, ptr %33, align 4, !tbaa !9
  %35 = fsub float %30, %34
  %36 = getelementptr inbounds %"class.Riemann::Sphere3", ptr %11, i32 0, i32 0
  %37 = load i32, ptr %9, align 4, !tbaa !11
  %38 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK5Maths8TVector3IfEixEi(ptr noundef nonnull align 4 dereferenceable(12) %36, i32 noundef %37)
  %39 = load float, ptr %38, align 4, !tbaa !9
  %40 = load ptr, ptr %6, align 8, !tbaa !5
  %41 = load i32, ptr %9, align 4, !tbaa !11
  %42 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK5Maths8TVector3IfEixEi(ptr noundef nonnull align 4 dereferenceable(12) %40, i32 noundef %41)
  %43 = load float, ptr %42, align 4, !tbaa !9
  %44 = fsub float %39, %43
  %45 = load float, ptr %8, align 4, !tbaa !9
  %46 = call float @llvm.fmuladd.f32(float %35, float %44, float %45)
  store float %46, ptr %8, align 4, !tbaa !9
  br label %79

47:                                               ; preds = %16
  %48 = getelementptr inbounds %"class.Riemann::Sphere3", ptr %11, i32 0, i32 0
  %49 = load i32, ptr %9, align 4, !tbaa !11
  %50 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK5Maths8TVector3IfEixEi(ptr noundef nonnull align 4 dereferenceable(12) %48, i32 noundef %49)
  %51 = load float, ptr %50, align 4, !tbaa !9
  %52 = load ptr, ptr %7, align 8, !tbaa !5
  %53 = load i32, ptr %9, align 4, !tbaa !11
  %54 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK5Maths8TVector3IfEixEi(ptr noundef nonnull align 4 dereferenceable(12) %52, i32 noundef %53)
  %55 = load float, ptr %54, align 4, !tbaa !9
  %56 = fcmp ogt float %51, %55
  br i1 %56, label %57, label %78

57:                                               ; preds = %47
  %58 = getelementptr inbounds %"class.Riemann::Sphere3", ptr %11, i32 0, i32 0
  %59 = load i32, ptr %9, align 4, !tbaa !11
  %60 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK5Maths8TVector3IfEixEi(ptr noundef nonnull align 4 dereferenceable(12) %58, i32 noundef %59)
  %61 = load float, ptr %60, align 4, !tbaa !9
  %62 = load ptr, ptr %7, align 8, !tbaa !5
  %63 = load i32, ptr %9, align 4, !tbaa !11
  %64 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK5Maths8TVector3IfEixEi(ptr noundef nonnull align 4 dereferenceable(12) %62, i32 noundef %63)
  %65 = load float, ptr %64, align 4, !tbaa !9
  %66 = fsub float %61, %65
  %67 = getelementptr inbounds %"class.Riemann::Sphere3", ptr %11, i32 0, i32 0
  %68 = load i32, ptr %9, align 4, !tbaa !11
  %69 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK5Maths8TVector3IfEixEi(ptr noundef nonnull align 4 dereferenceable(12) %67, i32 noundef %68)
  %70 = load float, ptr %69, align 4, !tbaa !9
  %71 = load ptr, ptr %7, align 8, !tbaa !5
  %72 = load i32, ptr %9, align 4, !tbaa !11
  %73 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK5Maths8TVector3IfEixEi(ptr noundef nonnull align 4 dereferenceable(12) %71, i32 noundef %72)
  %74 = load float, ptr %73, align 4, !tbaa !9
  %75 = fsub float %70, %74
  %76 = load float, ptr %8, align 4, !tbaa !9
  %77 = call float @llvm.fmuladd.f32(float %66, float %75, float %76)
  store float %77, ptr %8, align 4, !tbaa !9
  br label %78

78:                                               ; preds = %57, %47
  br label %79

79:                                               ; preds = %78, %26
  br label %80

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

83:                                               ; preds = %15
  %84 = load float, ptr %8, align 4, !tbaa !9
  %85 = getelementptr inbounds %"class.Riemann::Sphere3", ptr %11, i32 0, i32 1
  %86 = load float, ptr %85, align 4, !tbaa !15
  %87 = getelementptr inbounds %"class.Riemann::Sphere3", ptr %11, i32 0, i32 1
  %88 = load float, ptr %87, align 4, !tbaa !15
  %89 = fmul float %86, %88
  %90 = fcmp ole float %84, %89
  br i1 %90, label %91, label %92

91:                                               ; preds = %83
  store i1 true, ptr %4, align 1
  store i32 1, ptr %10, align 4
  br label %93

92:                                               ; preds = %83
  store i1 false, ptr %4, align 1
  store i32 1, ptr %10, align 4
  br label %93

93:                                               ; preds = %92, %91
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  %94 = load i1, ptr %4, align 1
  ret i1 %94
}

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

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

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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{!16, !10, i64 12}
!16 = !{!"_ZTSN7Riemann7Sphere3E", !17, i64 0, !10, i64 12}
!17 = !{!"_ZTSN5Maths8TVector3IfEE", !10, i64 0, !10, i64 4, !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"

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_ZNK7Riemann7Sphere313IntersectAABBERKN5Maths8TVector3IfEES5_(ptr noundef nonnull align 4 dereferenceable(16) %0, ptr noundef nonnull align 4 dereferenceable(12) %1, ptr noundef nonnull align 4 dereferenceable(12) %2) local_unnamed_addr #0 align 2 {
  %4 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK5Maths8TVector3IfEixEi(ptr noundef nonnull align 4 dereferenceable(12) %0, i32 noundef 0)
  %5 = load float, ptr %4, align 4, !tbaa !5
  %6 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK5Maths8TVector3IfEixEi(ptr noundef nonnull align 4 dereferenceable(12) %1, i32 noundef 0)
  %7 = load float, ptr %6, align 4, !tbaa !5
  %8 = fcmp olt float %5, %7
  %9 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK5Maths8TVector3IfEixEi(ptr noundef nonnull align 4 dereferenceable(12) %0, i32 noundef 0)
  %10 = load float, ptr %9, align 4, !tbaa !5
  br i1 %8, label %.sink.split, label %11

11:                                               ; preds = %3
  %12 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK5Maths8TVector3IfEixEi(ptr noundef nonnull align 4 dereferenceable(12) %2, i32 noundef 0)
  %13 = load float, ptr %12, align 4, !tbaa !5
  %14 = fcmp ogt float %10, %13
  br i1 %14, label %15, label %27

15:                                               ; preds = %11
  %16 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK5Maths8TVector3IfEixEi(ptr noundef nonnull align 4 dereferenceable(12) %0, i32 noundef 0)
  %17 = load float, ptr %16, align 4, !tbaa !5
  br label %.sink.split

.sink.split:                                      ; preds = %3, %15
  %.sink36 = phi ptr [ %2, %15 ], [ %1, %3 ]
  %.sink34 = phi float [ %17, %15 ], [ %10, %3 ]
  %18 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK5Maths8TVector3IfEixEi(ptr noundef nonnull align 4 dereferenceable(12) %.sink36, i32 noundef 0)
  %19 = load float, ptr %18, align 4, !tbaa !5
  %20 = fsub float %.sink34, %19
  %21 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK5Maths8TVector3IfEixEi(ptr noundef nonnull align 4 dereferenceable(12) %0, i32 noundef 0)
  %22 = load float, ptr %21, align 4, !tbaa !5
  %23 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK5Maths8TVector3IfEixEi(ptr noundef nonnull align 4 dereferenceable(12) %.sink36, i32 noundef 0)
  %24 = load float, ptr %23, align 4, !tbaa !5
  %25 = fsub float %22, %24
  %26 = tail call float @llvm.fmuladd.f32(float %20, float %25, float 0.000000e+00)
  br label %27

27:                                               ; preds = %.sink.split, %11
  %.1 = phi float [ 0.000000e+00, %11 ], [ %26, %.sink.split ]
  %28 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK5Maths8TVector3IfEixEi(ptr noundef nonnull align 4 dereferenceable(12) %0, i32 noundef 1)
  %29 = load float, ptr %28, align 4, !tbaa !5
  %30 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK5Maths8TVector3IfEixEi(ptr noundef nonnull align 4 dereferenceable(12) %1, i32 noundef 1)
  %31 = load float, ptr %30, align 4, !tbaa !5
  %32 = fcmp olt float %29, %31
  br i1 %32, label %.sink.split37, label %33

33:                                               ; preds = %27
  %34 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK5Maths8TVector3IfEixEi(ptr noundef nonnull align 4 dereferenceable(12) %0, i32 noundef 1)
  %35 = load float, ptr %34, align 4, !tbaa !5
  %36 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK5Maths8TVector3IfEixEi(ptr noundef nonnull align 4 dereferenceable(12) %2, i32 noundef 1)
  %37 = load float, ptr %36, align 4, !tbaa !5
  %38 = fcmp ogt float %35, %37
  br i1 %38, label %.sink.split37, label %50

.sink.split37:                                    ; preds = %27, %33
  %.sink46 = phi ptr [ %2, %33 ], [ %1, %27 ]
  %39 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK5Maths8TVector3IfEixEi(ptr noundef nonnull align 4 dereferenceable(12) %0, i32 noundef 1)
  %40 = load float, ptr %39, align 4, !tbaa !5
  %41 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK5Maths8TVector3IfEixEi(ptr noundef nonnull align 4 dereferenceable(12) %.sink46, i32 noundef 1)
  %42 = load float, ptr %41, align 4, !tbaa !5
  %43 = fsub float %40, %42
  %44 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK5Maths8TVector3IfEixEi(ptr noundef nonnull align 4 dereferenceable(12) %0, i32 noundef 1)
  %45 = load float, ptr %44, align 4, !tbaa !5
  %46 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK5Maths8TVector3IfEixEi(ptr noundef nonnull align 4 dereferenceable(12) %.sink46, i32 noundef 1)
  %47 = load float, ptr %46, align 4, !tbaa !5
  %48 = fsub float %45, %47
  %49 = tail call float @llvm.fmuladd.f32(float %43, float %48, float %.1)
  br label %50

50:                                               ; preds = %.sink.split37, %33
  %.1.1 = phi float [ %.1, %33 ], [ %49, %.sink.split37 ]
  %51 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK5Maths8TVector3IfEixEi(ptr noundef nonnull align 4 dereferenceable(12) %0, i32 noundef 2)
  %52 = load float, ptr %51, align 4, !tbaa !5
  %53 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK5Maths8TVector3IfEixEi(ptr noundef nonnull align 4 dereferenceable(12) %1, i32 noundef 2)
  %54 = load float, ptr %53, align 4, !tbaa !5
  %55 = fcmp olt float %52, %54
  br i1 %55, label %.sink.split47, label %56

56:                                               ; preds = %50
  %57 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK5Maths8TVector3IfEixEi(ptr noundef nonnull align 4 dereferenceable(12) %0, i32 noundef 2)
  %58 = load float, ptr %57, align 4, !tbaa !5
  %59 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK5Maths8TVector3IfEixEi(ptr noundef nonnull align 4 dereferenceable(12) %2, i32 noundef 2)
  %60 = load float, ptr %59, align 4, !tbaa !5
  %61 = fcmp ogt float %58, %60
  br i1 %61, label %.sink.split47, label %73

.sink.split47:                                    ; preds = %50, %56
  %.sink56 = phi ptr [ %2, %56 ], [ %1, %50 ]
  %62 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK5Maths8TVector3IfEixEi(ptr noundef nonnull align 4 dereferenceable(12) %0, i32 noundef 2)
  %63 = load float, ptr %62, align 4, !tbaa !5
  %64 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK5Maths8TVector3IfEixEi(ptr noundef nonnull align 4 dereferenceable(12) %.sink56, i32 noundef 2)
  %65 = load float, ptr %64, align 4, !tbaa !5
  %66 = fsub float %63, %65
  %67 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK5Maths8TVector3IfEixEi(ptr noundef nonnull align 4 dereferenceable(12) %0, i32 noundef 2)
  %68 = load float, ptr %67, align 4, !tbaa !5
  %69 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK5Maths8TVector3IfEixEi(ptr noundef nonnull align 4 dereferenceable(12) %.sink56, i32 noundef 2)
  %70 = load float, ptr %69, align 4, !tbaa !5
  %71 = fsub float %68, %70
  %72 = tail call float @llvm.fmuladd.f32(float %66, float %71, float %.1.1)
  br label %73

73:                                               ; preds = %.sink.split47, %56
  %.1.2 = phi float [ %.1.1, %56 ], [ %72, %.sink.split47 ]
  %74 = getelementptr inbounds i8, ptr %0, i64 12
  %75 = load float, ptr %74, align 4, !tbaa !9
  %76 = fmul float %75, %75
  %77 = fcmp ole float %.1.2, %76
  ret i1 %77
}

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

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #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" }
attributes #2 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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"}
!9 = !{!10, !6, i64 12}
!10 = !{!"_ZTSN7Riemann7Sphere3E", !11, i64 0, !6, i64 12}
!11 = !{!"_ZTSN5Maths8TVector3IfEE", !6, i64 0, !6, i64 4, !6, i64 8}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LCSSAPass,LoopRotatePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass