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

; 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 }
%"class.Riemann::AxisAlignedBox3" = type { %"class.Maths::TVector3", %"class.Maths::TVector3" }

; 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: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN5Maths8TVector3IfEC2ERKS1_(ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12)) unnamed_addr #1 align 2

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK7Riemann15AxisAlignedBox319ClosestPointToPointERKN5Maths8TVector3IfEE(ptr dead_on_unwind noalias writable sret(%"class.Maths::TVector3") align 4 %0, ptr noundef nonnull align 4 dereferenceable(24) %1, ptr noundef nonnull align 4 dereferenceable(12) %2) #2 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  store ptr %0, ptr %4, align 8
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  %8 = load ptr, ptr %5, align 8
  %9 = load ptr, ptr %6, align 8, !tbaa !5
  call void @_ZN5Maths8TVector3IfEC2ERKS1_(ptr noundef nonnull align 4 dereferenceable(12) %0, ptr noundef nonnull align 4 dereferenceable(12) %9)
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  store i32 0, ptr %7, align 4, !tbaa !9
  br label %10

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

13:                                               ; preds = %10
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  br label %51

14:                                               ; preds = %10
  %15 = load i32, ptr %7, align 4, !tbaa !9
  %16 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN5Maths8TVector3IfEixEi(ptr noundef nonnull align 4 dereferenceable(12) %0, i32 noundef %15)
  %17 = load float, ptr %16, align 4, !tbaa !11
  %18 = getelementptr inbounds %"class.Riemann::AxisAlignedBox3", ptr %8, i32 0, i32 0
  %19 = load i32, ptr %7, align 4, !tbaa !9
  %20 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK5Maths8TVector3IfEixEi(ptr noundef nonnull align 4 dereferenceable(12) %18, i32 noundef %19)
  %21 = load float, ptr %20, align 4, !tbaa !11
  %22 = fcmp olt float %17, %21
  br i1 %22, label %23, label %30

23:                                               ; preds = %14
  %24 = getelementptr inbounds %"class.Riemann::AxisAlignedBox3", ptr %8, i32 0, i32 0
  %25 = load i32, ptr %7, align 4, !tbaa !9
  %26 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK5Maths8TVector3IfEixEi(ptr noundef nonnull align 4 dereferenceable(12) %24, i32 noundef %25)
  %27 = load float, ptr %26, align 4, !tbaa !11
  %28 = load i32, ptr %7, align 4, !tbaa !9
  %29 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN5Maths8TVector3IfEixEi(ptr noundef nonnull align 4 dereferenceable(12) %0, i32 noundef %28)
  store float %27, ptr %29, align 4, !tbaa !11
  br label %47

30:                                               ; preds = %14
  %31 = load i32, ptr %7, align 4, !tbaa !9
  %32 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN5Maths8TVector3IfEixEi(ptr noundef nonnull align 4 dereferenceable(12) %0, i32 noundef %31)
  %33 = load float, ptr %32, align 4, !tbaa !11
  %34 = getelementptr inbounds %"class.Riemann::AxisAlignedBox3", ptr %8, i32 0, i32 1
  %35 = load i32, ptr %7, align 4, !tbaa !9
  %36 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK5Maths8TVector3IfEixEi(ptr noundef nonnull align 4 dereferenceable(12) %34, i32 noundef %35)
  %37 = load float, ptr %36, align 4, !tbaa !11
  %38 = fcmp ogt float %33, %37
  br i1 %38, label %39, label %46

39:                                               ; preds = %30
  %40 = getelementptr inbounds %"class.Riemann::AxisAlignedBox3", ptr %8, i32 0, i32 1
  %41 = load i32, ptr %7, align 4, !tbaa !9
  %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 !11
  %44 = load i32, ptr %7, align 4, !tbaa !9
  %45 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN5Maths8TVector3IfEixEi(ptr noundef nonnull align 4 dereferenceable(12) %0, i32 noundef %44)
  store float %43, ptr %45, align 4, !tbaa !11
  br label %46

46:                                               ; preds = %39, %30
  br label %47

47:                                               ; preds = %46, %23
  br label %48

48:                                               ; preds = %47
  %49 = load i32, ptr %7, align 4, !tbaa !9
  %50 = add nsw i32 %49, 1
  store i32 %50, ptr %7, align 4, !tbaa !9
  br label %10, !llvm.loop !13

51:                                               ; preds = %13
  ret void
}

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 = { 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 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


; 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: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN5Maths8TVector3IfEC2ERKS1_(ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12)) unnamed_addr #0 align 2

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

; 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 #0 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZNK7Riemann15AxisAlignedBox319ClosestPointToPointERKN5Maths8TVector3IfEE(ptr dead_on_unwind noalias nonnull writable sret(%"class.Maths::TVector3") align 4 %0, ptr noundef nonnull align 4 dereferenceable(24) %1, ptr noundef nonnull align 4 dereferenceable(12) %2) local_unnamed_addr #1 align 2 {
  tail call void @_ZN5Maths8TVector3IfEC2ERKS1_(ptr noundef nonnull align 4 dereferenceable(12) %0, ptr noundef nonnull align 4 dereferenceable(12) %2)
  %4 = getelementptr inbounds i8, ptr %1, i64 12
  %5 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN5Maths8TVector3IfEixEi(ptr noundef nonnull align 4 dereferenceable(12) %0, i32 noundef 0)
  %6 = load float, ptr %5, align 4, !tbaa !5
  %7 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK5Maths8TVector3IfEixEi(ptr noundef nonnull align 4 dereferenceable(12) %1, i32 noundef 0)
  %8 = load float, ptr %7, align 4, !tbaa !5
  %9 = fcmp olt float %6, %8
  br i1 %9, label %.sink.split, label %10

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

.sink.split:                                      ; preds = %10, %3
  %.sink = phi ptr [ %1, %3 ], [ %4, %10 ]
  %16 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK5Maths8TVector3IfEixEi(ptr noundef nonnull align 4 dereferenceable(12) %.sink, i32 noundef 0)
  %17 = load float, ptr %16, align 4, !tbaa !5
  %18 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN5Maths8TVector3IfEixEi(ptr noundef nonnull align 4 dereferenceable(12) %0, i32 noundef 0)
  store float %17, ptr %18, align 4, !tbaa !5
  br label %19

19:                                               ; preds = %.sink.split, %10
  %20 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN5Maths8TVector3IfEixEi(ptr noundef nonnull align 4 dereferenceable(12) %0, i32 noundef 1)
  %21 = load float, ptr %20, align 4, !tbaa !5
  %22 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK5Maths8TVector3IfEixEi(ptr noundef nonnull align 4 dereferenceable(12) %1, i32 noundef 1)
  %23 = load float, ptr %22, align 4, !tbaa !5
  %24 = fcmp olt float %21, %23
  br i1 %24, label %.sink.split14, label %25

25:                                               ; preds = %19
  %26 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN5Maths8TVector3IfEixEi(ptr noundef nonnull align 4 dereferenceable(12) %0, i32 noundef 1)
  %27 = load float, ptr %26, align 4, !tbaa !5
  %28 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK5Maths8TVector3IfEixEi(ptr noundef nonnull align 4 dereferenceable(12) %4, i32 noundef 1)
  %29 = load float, ptr %28, align 4, !tbaa !5
  %30 = fcmp ogt float %27, %29
  br i1 %30, label %.sink.split14, label %34

.sink.split14:                                    ; preds = %19, %25
  %.sink18 = phi ptr [ %4, %25 ], [ %1, %19 ]
  %31 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK5Maths8TVector3IfEixEi(ptr noundef nonnull align 4 dereferenceable(12) %.sink18, i32 noundef 1)
  %32 = load float, ptr %31, align 4, !tbaa !5
  %33 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN5Maths8TVector3IfEixEi(ptr noundef nonnull align 4 dereferenceable(12) %0, i32 noundef 1)
  store float %32, ptr %33, align 4, !tbaa !5
  br label %34

34:                                               ; preds = %.sink.split14, %25
  %35 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN5Maths8TVector3IfEixEi(ptr noundef nonnull align 4 dereferenceable(12) %0, i32 noundef 2)
  %36 = load float, ptr %35, align 4, !tbaa !5
  %37 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK5Maths8TVector3IfEixEi(ptr noundef nonnull align 4 dereferenceable(12) %1, i32 noundef 2)
  %38 = load float, ptr %37, align 4, !tbaa !5
  %39 = fcmp olt float %36, %38
  br i1 %39, label %.sink.split19, label %40

40:                                               ; preds = %34
  %41 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN5Maths8TVector3IfEixEi(ptr noundef nonnull align 4 dereferenceable(12) %0, i32 noundef 2)
  %42 = load float, ptr %41, align 4, !tbaa !5
  %43 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK5Maths8TVector3IfEixEi(ptr noundef nonnull align 4 dereferenceable(12) %4, i32 noundef 2)
  %44 = load float, ptr %43, align 4, !tbaa !5
  %45 = fcmp ogt float %42, %44
  br i1 %45, label %.sink.split19, label %49

.sink.split19:                                    ; preds = %34, %40
  %.sink23 = phi ptr [ %4, %40 ], [ %1, %34 ]
  %46 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK5Maths8TVector3IfEixEi(ptr noundef nonnull align 4 dereferenceable(12) %.sink23, i32 noundef 2)
  %47 = load float, ptr %46, align 4, !tbaa !5
  %48 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN5Maths8TVector3IfEixEi(ptr noundef nonnull align 4 dereferenceable(12) %0, i32 noundef 2)
  store float %47, ptr %48, align 4, !tbaa !5
  br label %49

49:                                               ; preds = %.sink.split19, %40
  ret void
}

attributes #0 = { 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 #1 = { 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" }

!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,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass