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

; 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::HeightField3" = type { i32, i32, %"class.Maths::TAABB3", float, float, float, float, float, %"class.std::vector", ptr }
%"class.Maths::TAABB3" = type { %"class.Maths::TVector3", %"class.Maths::TVector3" }
%"class.Maths::TVector3" = type { float, float, float }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<Riemann::HeightField3::CellInfo, std::allocator<Riemann::HeightField3::CellInfo>>::_Vector_impl" }
%"struct.std::_Vector_base<Riemann::HeightField3::CellInfo, std::allocator<Riemann::HeightField3::CellInfo>>::_Vector_impl" = type { %"struct.std::_Vector_base<Riemann::HeightField3::CellInfo, std::allocator<Riemann::HeightField3::CellInfo>>::_Vector_impl_data" }
%"struct.std::_Vector_base<Riemann::HeightField3::CellInfo, std::allocator<Riemann::HeightField3::CellInfo>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"struct.Riemann::HeightFieldHitResult" = type { float, %"class.Maths::TVector3", i32, i32 }

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZNK7Riemann12HeightField316IntersectRayCellERKN5Maths8TVector3IfEES5_iiRKNS_20HeightFieldHitOptionEPNS_20HeightFieldHitResultE(ptr noundef nonnull align 8 dereferenceable(88), ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12), i32 noundef, i32 noundef, ptr noundef nonnull align 4 dereferenceable(8), ptr noundef) #0 align 2

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZNK7Riemann12HeightField322IntersectRayBruteForceERKN5Maths8TVector3IfEES5_RKNS_20HeightFieldHitOptionEPNS_20HeightFieldHitResultE(ptr noundef nonnull align 8 dereferenceable(88) %0, ptr noundef nonnull align 4 dereferenceable(12) %1, ptr noundef nonnull align 4 dereferenceable(12) %2, ptr noundef nonnull align 4 dereferenceable(8) %3, ptr noundef %4) #0 align 2 {
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca float, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !5
  store ptr %3, ptr %9, align 8, !tbaa !5
  store ptr %4, ptr %10, align 8, !tbaa !5
  %15 = load ptr, ptr %6, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #2
  store float 0x47EFFFFFE0000000, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #2
  store i32 0, ptr %12, align 4, !tbaa !11
  br label %16

16:                                               ; preds = %55, %5
  %17 = load i32, ptr %12, align 4, !tbaa !11
  %18 = getelementptr inbounds %"class.Riemann::HeightField3", ptr %15, i32 0, i32 0
  %19 = load i32, ptr %18, align 8, !tbaa !13
  %20 = sub i32 %19, 1
  %21 = icmp ult i32 %17, %20
  br i1 %21, label %23, label %22

22:                                               ; preds = %16
  store i32 2, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #2
  br label %58

23:                                               ; preds = %16
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #2
  store i32 0, ptr %14, align 4, !tbaa !11
  br label %24

24:                                               ; preds = %51, %23
  %25 = load i32, ptr %14, align 4, !tbaa !11
  %26 = getelementptr inbounds %"class.Riemann::HeightField3", ptr %15, i32 0, i32 1
  %27 = load i32, ptr %26, align 4, !tbaa !21
  %28 = sub i32 %27, 1
  %29 = icmp ult i32 %25, %28
  br i1 %29, label %31, label %30

30:                                               ; preds = %24
  store i32 5, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #2
  br label %54

31:                                               ; preds = %24
  %32 = load ptr, ptr %7, align 8, !tbaa !5
  %33 = load ptr, ptr %8, align 8, !tbaa !5
  %34 = load i32, ptr %12, align 4, !tbaa !11
  %35 = load i32, ptr %14, align 4, !tbaa !11
  %36 = load ptr, ptr %9, align 8, !tbaa !5
  %37 = load ptr, ptr %10, align 8, !tbaa !5
  %38 = call noundef zeroext i1 @_ZNK7Riemann12HeightField316IntersectRayCellERKN5Maths8TVector3IfEES5_iiRKNS_20HeightFieldHitOptionEPNS_20HeightFieldHitResultE(ptr noundef nonnull align 8 dereferenceable(88) %15, ptr noundef nonnull align 4 dereferenceable(12) %32, ptr noundef nonnull align 4 dereferenceable(12) %33, i32 noundef %34, i32 noundef %35, ptr noundef nonnull align 4 dereferenceable(8) %36, ptr noundef %37)
  br i1 %38, label %39, label %50

39:                                               ; preds = %31
  %40 = load ptr, ptr %10, align 8, !tbaa !5
  %41 = getelementptr inbounds %"struct.Riemann::HeightFieldHitResult", ptr %40, i32 0, i32 0
  %42 = load float, ptr %41, align 4, !tbaa !22
  %43 = load float, ptr %11, align 4, !tbaa !9
  %44 = fcmp olt float %42, %43
  br i1 %44, label %45, label %49

45:                                               ; preds = %39
  %46 = load ptr, ptr %10, align 8, !tbaa !5
  %47 = getelementptr inbounds %"struct.Riemann::HeightFieldHitResult", ptr %46, i32 0, i32 0
  %48 = load float, ptr %47, align 4, !tbaa !22
  store float %48, ptr %11, align 4, !tbaa !9
  br label %49

49:                                               ; preds = %45, %39
  br label %50

50:                                               ; preds = %49, %31
  br label %51

51:                                               ; preds = %50
  %52 = load i32, ptr %14, align 4, !tbaa !11
  %53 = add i32 %52, 1
  store i32 %53, ptr %14, align 4, !tbaa !11
  br label %24, !llvm.loop !24

54:                                               ; preds = %30
  br label %55

55:                                               ; preds = %54
  %56 = load i32, ptr %12, align 4, !tbaa !11
  %57 = add i32 %56, 1
  store i32 %57, ptr %12, align 4, !tbaa !11
  br label %16, !llvm.loop !26

58:                                               ; preds = %22
  %59 = load float, ptr %11, align 4, !tbaa !9
  %60 = load ptr, ptr %10, align 8, !tbaa !5
  %61 = getelementptr inbounds %"struct.Riemann::HeightFieldHitResult", ptr %60, i32 0, i32 0
  store float %59, ptr %61, align 4, !tbaa !22
  %62 = load float, ptr %11, align 4, !tbaa !9
  %63 = fcmp une float %62, 0x47EFFFFFE0000000
  store i32 1, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #2
  ret i1 %63
}

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 willreturn memory(argmem: readwrite) }
attributes #2 = { 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 = !{!14, !12, i64 0}
!14 = !{!"_ZTSN7Riemann12HeightField3E", !12, i64 0, !12, i64 4, !15, i64 8, !10, i64 32, !10, i64 36, !10, i64 40, !10, i64 44, !10, i64 48, !17, i64 56, !6, i64 80}
!15 = !{!"_ZTSN5Maths6TAABB3IfEE", !16, i64 0, !16, i64 12}
!16 = !{!"_ZTSN5Maths8TVector3IfEE", !10, i64 0, !10, i64 4, !10, i64 8}
!17 = !{!"_ZTSSt6vectorIN7Riemann12HeightField38CellInfoESaIS2_EE", !18, i64 0}
!18 = !{!"_ZTSSt12_Vector_baseIN7Riemann12HeightField38CellInfoESaIS2_EE", !19, i64 0}
!19 = !{!"_ZTSNSt12_Vector_baseIN7Riemann12HeightField38CellInfoESaIS2_EE12_Vector_implE", !20, i64 0}
!20 = !{!"_ZTSNSt12_Vector_baseIN7Riemann12HeightField38CellInfoESaIS2_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!21 = !{!14, !12, i64 4}
!22 = !{!23, !10, i64 0}
!23 = !{!"_ZTSN7Riemann20HeightFieldHitResultE", !10, i64 0, !16, i64 4, !12, i64 16, !12, i64 20}
!24 = distinct !{!24, !25}
!25 = !{!"llvm.loop.mustprogress"}
!26 = distinct !{!26, !25}


; 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 uwtable
declare dso_local noundef zeroext i1 @_ZNK7Riemann12HeightField316IntersectRayCellERKN5Maths8TVector3IfEES5_iiRKNS_20HeightFieldHitOptionEPNS_20HeightFieldHitResultE(ptr noundef nonnull align 8 dereferenceable(88), ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12), i32 noundef, i32 noundef, ptr noundef nonnull align 4 dereferenceable(8), ptr noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZNK7Riemann12HeightField322IntersectRayBruteForceERKN5Maths8TVector3IfEES5_RKNS_20HeightFieldHitOptionEPNS_20HeightFieldHitResultE(ptr noundef nonnull align 8 dereferenceable(88) %0, ptr noundef nonnull align 4 dereferenceable(12) %1, ptr noundef nonnull align 4 dereferenceable(12) %2, ptr noundef nonnull align 4 dereferenceable(8) %3, ptr noundef %4) local_unnamed_addr #0 align 2 {
  %6 = load i32, ptr %0, align 8, !tbaa !5
  %.not = icmp eq i32 %6, 1
  br i1 %.not, label %._crit_edge23, label %.preheader.lr.ph

.preheader.lr.ph:                                 ; preds = %5
  %7 = getelementptr inbounds i8, ptr %0, i64 4
  %.pre = load i32, ptr %7, align 4, !tbaa !18
  br label %.preheader

.preheader:                                       ; preds = %.preheader.lr.ph, %._crit_edge
  %8 = phi i32 [ %6, %.preheader.lr.ph ], [ %11, %._crit_edge ]
  %9 = phi i32 [ %.pre, %.preheader.lr.ph ], [ %12, %._crit_edge ]
  %.01622 = phi i32 [ 0, %.preheader.lr.ph ], [ %13, %._crit_edge ]
  %.01721 = phi float [ 0x47EFFFFFE0000000, %.preheader.lr.ph ], [ %.1.lcssa, %._crit_edge ]
  %.not25 = icmp eq i32 %9, 1
  br i1 %.not25, label %._crit_edge, label %.lr.ph

._crit_edge23:                                    ; preds = %._crit_edge, %5
  %.017.lcssa = phi float [ 0x47EFFFFFE0000000, %5 ], [ %.1.lcssa, %._crit_edge ]
  store float %.017.lcssa, ptr %4, align 4, !tbaa !19
  %10 = fcmp une float %.017.lcssa, 0x47EFFFFFE0000000
  ret i1 %10

._crit_edge.loopexit:                             ; preds = %21
  %.pre26 = load i32, ptr %0, align 8, !tbaa !5
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %.preheader
  %11 = phi i32 [ %8, %.preheader ], [ %.pre26, %._crit_edge.loopexit ]
  %12 = phi i32 [ 1, %.preheader ], [ %23, %._crit_edge.loopexit ]
  %.1.lcssa = phi float [ %.01721, %.preheader ], [ %.2, %._crit_edge.loopexit ]
  %13 = add nuw i32 %.01622, 1
  %14 = add i32 %11, -1
  %15 = icmp ult i32 %13, %14
  br i1 %15, label %.preheader, label %._crit_edge23, !llvm.loop !21

.lr.ph:                                           ; preds = %.preheader, %21
  %.020 = phi i32 [ %22, %21 ], [ 0, %.preheader ]
  %.119 = phi float [ %.2, %21 ], [ %.01721, %.preheader ]
  %16 = tail call noundef zeroext i1 @_ZNK7Riemann12HeightField316IntersectRayCellERKN5Maths8TVector3IfEES5_iiRKNS_20HeightFieldHitOptionEPNS_20HeightFieldHitResultE(ptr noundef nonnull align 8 dereferenceable(88) %0, ptr noundef nonnull align 4 dereferenceable(12) %1, ptr noundef nonnull align 4 dereferenceable(12) %2, i32 noundef %.01622, i32 noundef %.020, ptr noundef nonnull align 4 dereferenceable(8) %3, ptr noundef %4)
  br i1 %16, label %17, label %21

17:                                               ; preds = %.lr.ph
  %18 = load float, ptr %4, align 4, !tbaa !19
  %19 = fcmp olt float %18, %.119
  br i1 %19, label %20, label %21

20:                                               ; preds = %17
  br label %21

21:                                               ; preds = %.lr.ph, %20, %17
  %.2 = phi float [ %18, %20 ], [ %.119, %17 ], [ %.119, %.lr.ph ]
  %22 = add nuw i32 %.020, 1
  %23 = load i32, ptr %7, align 4, !tbaa !18
  %24 = add i32 %23, -1
  %25 = icmp ult i32 %22, %24
  br i1 %25, label %.lr.ph, label %._crit_edge.loopexit, !llvm.loop !23
}

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

!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 = !{!"_ZTSN7Riemann12HeightField3E", !7, i64 0, !7, i64 4, !10, i64 8, !12, i64 32, !12, i64 36, !12, i64 40, !12, i64 44, !12, i64 48, !13, i64 56, !17, i64 80}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTSN5Maths6TAABB3IfEE", !11, i64 0, !11, i64 12}
!11 = !{!"_ZTSN5Maths8TVector3IfEE", !12, i64 0, !12, i64 4, !12, i64 8}
!12 = !{!"float", !8, i64 0}
!13 = !{!"_ZTSSt6vectorIN7Riemann12HeightField38CellInfoESaIS2_EE", !14, i64 0}
!14 = !{!"_ZTSSt12_Vector_baseIN7Riemann12HeightField38CellInfoESaIS2_EE", !15, i64 0}
!15 = !{!"_ZTSNSt12_Vector_baseIN7Riemann12HeightField38CellInfoESaIS2_EE12_Vector_implE", !16, i64 0}
!16 = !{!"_ZTSNSt12_Vector_baseIN7Riemann12HeightField38CellInfoESaIS2_EE17_Vector_impl_dataE", !17, i64 0, !17, i64 8, !17, i64 16}
!17 = !{!"any pointer", !8, i64 0}
!18 = !{!6, !7, i64 4}
!19 = !{!20, !12, i64 0}
!20 = !{!"_ZTSN7Riemann20HeightFieldHitResultE", !12, i64 0, !11, i64 4, !7, i64 16, !7, i64 20}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}
!23 = distinct !{!23, !22}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass