; 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.Maths::TVector3" = type { float, float, float }
%"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.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::HeightFieldHitOption" = type { i8, float }
%"struct.Riemann::HeightFieldHitResult" = type { float, %"class.Maths::TVector3", i32, i32 }

; Function Attrs: mustprogress uwtable
define dso_local 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 %3, i32 noundef %4, ptr noundef nonnull align 4 dereferenceable(8) %5, ptr noundef %6) #0 align 2 {
  %8 = alloca i1, align 1
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca float, align 4
  %17 = alloca float, align 4
  %18 = alloca i32, align 4
  %19 = alloca %"class.Maths::TVector3", align 4
  %20 = alloca %"class.Maths::TVector3", align 4
  %21 = alloca float, align 4
  %22 = alloca float, align 4
  %23 = alloca i8, align 1
  %24 = alloca float, align 4
  %25 = alloca [6 x %"class.Maths::TVector3"], align 16
  %26 = alloca i32, align 4
  %27 = alloca i32, align 4
  %28 = alloca float, align 4
  store ptr %0, ptr %9, align 8, !tbaa !5
  store ptr %1, ptr %10, align 8, !tbaa !5
  store ptr %2, ptr %11, align 8, !tbaa !5
  store i32 %3, ptr %12, align 4, !tbaa !9
  store i32 %4, ptr %13, align 4, !tbaa !9
  store ptr %5, ptr %14, align 8, !tbaa !5
  store ptr %6, ptr %15, align 8, !tbaa !5
  %29 = load ptr, ptr %9, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #6
  %30 = load i32, ptr %12, align 4, !tbaa !9
  %31 = load i32, ptr %13, align 4, !tbaa !9
  %32 = call noundef zeroext i1 @_ZNK7Riemann12HeightField314GetHeightRangeEiiRfS1_(ptr noundef nonnull align 8 dereferenceable(88) %29, i32 noundef %30, i32 noundef %31, ptr noundef nonnull align 4 dereferenceable(4) %16, ptr noundef nonnull align 4 dereferenceable(4) %17)
  %33 = load ptr, ptr %15, align 8, !tbaa !5
  call void @_ZN7Riemann20HeightFieldHitResult12AddTestCountEi(ptr noundef nonnull align 4 dereferenceable(24) %33, i32 noundef 1)
  %34 = load ptr, ptr %11, align 8, !tbaa !5
  %35 = getelementptr inbounds %"class.Maths::TVector3", ptr %34, i32 0, i32 1
  %36 = load float, ptr %35, align 4, !tbaa !11
  %37 = call float @llvm.fabs.f32(float %36)
  %38 = fcmp olt float %37, 0x3EB0C6F7A0000000
  br i1 %38, label %39, label %53

39:                                               ; preds = %7
  %40 = load ptr, ptr %10, align 8, !tbaa !5
  %41 = getelementptr inbounds %"class.Maths::TVector3", ptr %40, i32 0, i32 1
  %42 = load float, ptr %41, align 4, !tbaa !11
  %43 = load float, ptr %16, align 4, !tbaa !14
  %44 = fcmp olt float %42, %43
  br i1 %44, label %51, label %45

45:                                               ; preds = %39
  %46 = load ptr, ptr %10, align 8, !tbaa !5
  %47 = getelementptr inbounds %"class.Maths::TVector3", ptr %46, i32 0, i32 1
  %48 = load float, ptr %47, align 4, !tbaa !11
  %49 = load float, ptr %17, align 4, !tbaa !14
  %50 = fcmp ogt float %48, %49
  br i1 %50, label %51, label %52

51:                                               ; preds = %45, %39
  store i1 false, ptr %8, align 1
  store i32 1, ptr %18, align 4
  br label %170

52:                                               ; preds = %45
  br label %53

53:                                               ; preds = %52, %7
  call void @llvm.lifetime.start.p0(i64 12, ptr %19) #6
  %54 = getelementptr inbounds %"class.Riemann::HeightField3", ptr %29, i32 0, i32 2
  %55 = getelementptr inbounds %"class.Maths::TAABB3", ptr %54, i32 0, i32 0
  %56 = getelementptr inbounds %"class.Maths::TVector3", ptr %55, i32 0, i32 0
  %57 = load float, ptr %56, align 8, !tbaa !15
  %58 = load i32, ptr %12, align 4, !tbaa !9
  %59 = sitofp i32 %58 to float
  %60 = getelementptr inbounds %"class.Riemann::HeightField3", ptr %29, i32 0, i32 3
  %61 = load float, ptr %60, align 8, !tbaa !22
  %62 = call float @llvm.fmuladd.f32(float %59, float %61, float %57)
  %63 = load float, ptr %16, align 4, !tbaa !14
  %64 = getelementptr inbounds %"class.Riemann::HeightField3", ptr %29, i32 0, i32 2
  %65 = getelementptr inbounds %"class.Maths::TAABB3", ptr %64, i32 0, i32 0
  %66 = getelementptr inbounds %"class.Maths::TVector3", ptr %65, i32 0, i32 2
  %67 = load float, ptr %66, align 8, !tbaa !23
  %68 = load i32, ptr %13, align 4, !tbaa !9
  %69 = sitofp i32 %68 to float
  %70 = getelementptr inbounds %"class.Riemann::HeightField3", ptr %29, i32 0, i32 4
  %71 = load float, ptr %70, align 4, !tbaa !24
  %72 = call float @llvm.fmuladd.f32(float %69, float %71, float %67)
  call void @_ZN5Maths8TVector3IfEC2Efff(ptr noundef nonnull align 4 dereferenceable(12) %19, float noundef %62, float noundef %63, float noundef %72)
  call void @llvm.lifetime.start.p0(i64 12, ptr %20) #6
  %73 = getelementptr inbounds %"class.Riemann::HeightField3", ptr %29, i32 0, i32 2
  %74 = getelementptr inbounds %"class.Maths::TAABB3", ptr %73, i32 0, i32 0
  %75 = getelementptr inbounds %"class.Maths::TVector3", ptr %74, i32 0, i32 0
  %76 = load float, ptr %75, align 8, !tbaa !15
  %77 = load i32, ptr %12, align 4, !tbaa !9
  %78 = add nsw i32 %77, 1
  %79 = sitofp i32 %78 to float
  %80 = getelementptr inbounds %"class.Riemann::HeightField3", ptr %29, i32 0, i32 3
  %81 = load float, ptr %80, align 8, !tbaa !22
  %82 = call float @llvm.fmuladd.f32(float %79, float %81, float %76)
  %83 = load float, ptr %17, align 4, !tbaa !14
  %84 = getelementptr inbounds %"class.Riemann::HeightField3", ptr %29, i32 0, i32 2
  %85 = getelementptr inbounds %"class.Maths::TAABB3", ptr %84, i32 0, i32 0
  %86 = getelementptr inbounds %"class.Maths::TVector3", ptr %85, i32 0, i32 2
  %87 = load float, ptr %86, align 8, !tbaa !23
  %88 = load i32, ptr %13, align 4, !tbaa !9
  %89 = add nsw i32 %88, 1
  %90 = sitofp i32 %89 to float
  %91 = getelementptr inbounds %"class.Riemann::HeightField3", ptr %29, i32 0, i32 4
  %92 = load float, ptr %91, align 4, !tbaa !24
  %93 = call float @llvm.fmuladd.f32(float %90, float %92, float %87)
  call void @_ZN5Maths8TVector3IfEC2Efff(ptr noundef nonnull align 4 dereferenceable(12) %20, float noundef %82, float noundef %83, float noundef %93)
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #6
  %94 = load ptr, ptr %10, align 8, !tbaa !5
  %95 = load ptr, ptr %11, align 8, !tbaa !5
  %96 = load ptr, ptr %14, align 8, !tbaa !5
  %97 = getelementptr inbounds %"struct.Riemann::HeightFieldHitOption", ptr %96, i32 0, i32 1
  %98 = load float, ptr %97, align 4, !tbaa !25
  %99 = call noundef zeroext i1 @_ZN4Ray317RayIntersectAABB2ERKN5Maths8TVector3IfEES4_S4_S4_ffPfS5_(ptr noundef nonnull align 4 dereferenceable(12) %94, ptr noundef nonnull align 4 dereferenceable(12) %95, ptr noundef nonnull align 4 dereferenceable(12) %19, ptr noundef nonnull align 4 dereferenceable(12) %20, float noundef 0x3F1A36E2E0000000, float noundef %98, ptr noundef %21, ptr noundef %22)
  br i1 %99, label %101, label %100

100:                                              ; preds = %53
  store i1 false, ptr %8, align 1
  store i32 1, ptr %18, align 4
  br label %102

101:                                              ; preds = %53
  store i32 0, ptr %18, align 4
  br label %102

102:                                              ; preds = %101, %100
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #6
  call void @llvm.lifetime.end.p0(i64 12, ptr %20) #6
  call void @llvm.lifetime.end.p0(i64 12, ptr %19) #6
  %103 = load i32, ptr %18, align 4
  switch i32 %103, label %170 [
    i32 0, label %104
  ]

104:                                              ; preds = %102
  call void @llvm.lifetime.start.p0(i64 1, ptr %23) #6
  store i8 0, ptr %23, align 1, !tbaa !28
  call void @llvm.lifetime.start.p0(i64 4, ptr %24) #6
  store float 0x47EFFFFFE0000000, ptr %24, align 4, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 72, ptr %25) #6
  %105 = getelementptr inbounds [6 x %"class.Maths::TVector3"], ptr %25, i32 0, i32 0
  %106 = getelementptr inbounds %"class.Maths::TVector3", ptr %105, i64 6
  br label %107

107:                                              ; preds = %107, %104
  %108 = phi ptr [ %105, %104 ], [ %109, %107 ]
  call void @_ZN5Maths8TVector3IfEC2Ev(ptr noundef nonnull align 4 dereferenceable(12) %108)
  %109 = getelementptr inbounds %"class.Maths::TVector3", ptr %108, i64 1
  %110 = icmp eq ptr %109, %106
  br i1 %110, label %111, label %107

111:                                              ; preds = %107
  call void @llvm.lifetime.start.p0(i64 4, ptr %26) #6
  %112 = load i32, ptr %12, align 4, !tbaa !9
  %113 = load i32, ptr %13, align 4, !tbaa !9
  %114 = getelementptr inbounds [6 x %"class.Maths::TVector3"], ptr %25, i64 0, i64 0
  %115 = call noundef i32 @_ZNK7Riemann12HeightField315GetCellTriangleEiiPN5Maths8TVector3IfEE(ptr noundef nonnull align 8 dereferenceable(88) %29, i32 noundef %112, i32 noundef %113, ptr noundef %114)
  store i32 %115, ptr %26, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %27) #6
  store i32 0, ptr %27, align 4, !tbaa !9
  br label %116

116:                                              ; preds = %161, %111
  %117 = load i32, ptr %27, align 4, !tbaa !9
  %118 = load i32, ptr %26, align 4, !tbaa !9
  %119 = icmp slt i32 %117, %118
  br i1 %119, label %121, label %120

120:                                              ; preds = %116
  store i32 2, ptr %18, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %27) #6
  br label %164

121:                                              ; preds = %116
  call void @llvm.lifetime.start.p0(i64 4, ptr %28) #6
  %122 = load ptr, ptr %10, align 8, !tbaa !5
  %123 = load ptr, ptr %11, align 8, !tbaa !5
  %124 = load i32, ptr %27, align 4, !tbaa !9
  %125 = sext i32 %124 to i64
  %126 = getelementptr inbounds [6 x %"class.Maths::TVector3"], ptr %25, i64 0, i64 %125
  %127 = load i32, ptr %27, align 4, !tbaa !9
  %128 = add nsw i32 %127, 1
  %129 = sext i32 %128 to i64
  %130 = getelementptr inbounds [6 x %"class.Maths::TVector3"], ptr %25, i64 0, i64 %129
  %131 = load i32, ptr %27, align 4, !tbaa !9
  %132 = add nsw i32 %131, 2
  %133 = sext i32 %132 to i64
  %134 = getelementptr inbounds [6 x %"class.Maths::TVector3"], ptr %25, i64 0, i64 %133
  %135 = call noundef zeroext i1 @_ZN7Riemann9Triangle320RayIntersectTriangleERKN5Maths8TVector3IfEES5_S5_S5_S5_Pf(ptr noundef nonnull align 4 dereferenceable(12) %122, ptr noundef nonnull align 4 dereferenceable(12) %123, ptr noundef nonnull align 4 dereferenceable(12) %126, ptr noundef nonnull align 4 dereferenceable(12) %130, ptr noundef nonnull align 4 dereferenceable(12) %134, ptr noundef %28)
  br i1 %135, label %136, label %160

136:                                              ; preds = %121
  %137 = load float, ptr %28, align 4, !tbaa !14
  %138 = load float, ptr %24, align 4, !tbaa !14
  %139 = fcmp olt float %137, %138
  br i1 %139, label %140, label %160

140:                                              ; preds = %136
  %141 = load float, ptr %28, align 4, !tbaa !14
  store float %141, ptr %24, align 4, !tbaa !14
  %142 = load float, ptr %24, align 4, !tbaa !14
  %143 = load ptr, ptr %14, align 8, !tbaa !5
  %144 = getelementptr inbounds %"struct.Riemann::HeightFieldHitOption", ptr %143, i32 0, i32 1
  %145 = load float, ptr %144, align 4, !tbaa !25
  %146 = fcmp olt float %142, %145
  br i1 %146, label %147, label %159

147:                                              ; preds = %140
  %148 = load float, ptr %24, align 4, !tbaa !14
  %149 = load ptr, ptr %15, align 8, !tbaa !5
  %150 = getelementptr inbounds %"struct.Riemann::HeightFieldHitResult", ptr %149, i32 0, i32 0
  store float %148, ptr %150, align 4, !tbaa !29
  %151 = load i32, ptr %13, align 4, !tbaa !9
  %152 = getelementptr inbounds %"class.Riemann::HeightField3", ptr %29, i32 0, i32 0
  %153 = load i32, ptr %152, align 8, !tbaa !31
  %154 = mul i32 %151, %153
  %155 = load i32, ptr %12, align 4, !tbaa !9
  %156 = add i32 %154, %155
  %157 = load ptr, ptr %15, align 8, !tbaa !5
  %158 = getelementptr inbounds %"struct.Riemann::HeightFieldHitResult", ptr %157, i32 0, i32 2
  store i32 %156, ptr %158, align 4, !tbaa !32
  store i8 1, ptr %23, align 1, !tbaa !28
  br label %159

159:                                              ; preds = %147, %140
  br label %160

160:                                              ; preds = %159, %136, %121
  call void @llvm.lifetime.end.p0(i64 4, ptr %28) #6
  br label %161

161:                                              ; preds = %160
  %162 = load i32, ptr %27, align 4, !tbaa !9
  %163 = add nsw i32 %162, 3
  store i32 %163, ptr %27, align 4, !tbaa !9
  br label %116, !llvm.loop !33

164:                                              ; preds = %120
  %165 = load ptr, ptr %15, align 8, !tbaa !5
  %166 = load i32, ptr %26, align 4, !tbaa !9
  %167 = sdiv i32 %166, 3
  call void @_ZN7Riemann20HeightFieldHitResult12AddTestCountEi(ptr noundef nonnull align 4 dereferenceable(24) %165, i32 noundef %167)
  %168 = load i8, ptr %23, align 1, !tbaa !28, !range !35, !noundef !36
  %169 = trunc i8 %168 to i1
  store i1 %169, ptr %8, align 1
  store i32 1, ptr %18, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %26) #6
  call void @llvm.lifetime.end.p0(i64 72, ptr %25) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %24) #6
  call void @llvm.lifetime.end.p0(i64 1, ptr %23) #6
  br label %170

170:                                              ; preds = %164, %102, %51
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #6
  %171 = load i1, ptr %8, align 1
  ret i1 %171
}

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN7Riemann20HeightFieldHitResult12AddTestCountEi(ptr noundef nonnull align 4 dereferenceable(24), i32 noundef) #2 align 2

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

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

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

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZNK7Riemann12HeightField315GetCellTriangleEiiPN5Maths8TVector3IfEE(ptr noundef nonnull align 8 dereferenceable(88), i32 noundef, i32 noundef, ptr noundef) #0 align 2

declare noundef zeroext i1 @_ZN7Riemann9Triangle320RayIntersectTriangleERKN5Maths8TVector3IfEES5_S5_S5_S5_Pf(ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12), ptr noundef) #5

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 = { 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 = { 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 #5 = { "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 #6 = { 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, !13, i64 4}
!12 = !{!"_ZTSN5Maths8TVector3IfEE", !13, i64 0, !13, i64 4, !13, i64 8}
!13 = !{!"float", !7, i64 0}
!14 = !{!13, !13, i64 0}
!15 = !{!16, !13, i64 8}
!16 = !{!"_ZTSN7Riemann12HeightField3E", !10, i64 0, !10, i64 4, !17, i64 8, !13, i64 32, !13, i64 36, !13, i64 40, !13, i64 44, !13, i64 48, !18, i64 56, !6, i64 80}
!17 = !{!"_ZTSN5Maths6TAABB3IfEE", !12, i64 0, !12, i64 12}
!18 = !{!"_ZTSSt6vectorIN7Riemann12HeightField38CellInfoESaIS2_EE", !19, i64 0}
!19 = !{!"_ZTSSt12_Vector_baseIN7Riemann12HeightField38CellInfoESaIS2_EE", !20, i64 0}
!20 = !{!"_ZTSNSt12_Vector_baseIN7Riemann12HeightField38CellInfoESaIS2_EE12_Vector_implE", !21, i64 0}
!21 = !{!"_ZTSNSt12_Vector_baseIN7Riemann12HeightField38CellInfoESaIS2_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!22 = !{!16, !13, i64 32}
!23 = !{!16, !13, i64 16}
!24 = !{!16, !13, i64 36}
!25 = !{!26, !13, i64 4}
!26 = !{!"_ZTSN7Riemann20HeightFieldHitOptionE", !27, i64 0, !13, i64 4}
!27 = !{!"bool", !7, i64 0}
!28 = !{!27, !27, i64 0}
!29 = !{!30, !13, i64 0}
!30 = !{!"_ZTSN7Riemann20HeightFieldHitResultE", !13, i64 0, !12, i64 4, !10, i64 16, !10, i64 20}
!31 = !{!16, !10, i64 0}
!32 = !{!30, !10, i64 16}
!33 = distinct !{!33, !34}
!34 = !{!"llvm.loop.mustprogress"}
!35 = !{i8 0, i8 2}
!36 = !{}


; 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 @_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 %3, i32 noundef %4, ptr nocapture noundef nonnull readonly align 4 dereferenceable(8) %5, ptr noundef %6) local_unnamed_addr #0 align 2 {
  %8 = alloca float, align 4
  %9 = alloca float, align 4
  %10 = alloca %"class.Maths::TVector3", align 4
  %11 = alloca %"class.Maths::TVector3", align 4
  %12 = alloca float, align 4
  %13 = alloca float, align 4
  %14 = alloca [6 x %"class.Maths::TVector3"], align 16
  %15 = alloca float, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %8) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %9) #6
  %16 = call noundef zeroext i1 @_ZNK7Riemann12HeightField314GetHeightRangeEiiRfS1_(ptr noundef nonnull align 8 dereferenceable(88) %0, i32 noundef %3, i32 noundef %4, ptr noundef nonnull align 4 dereferenceable(4) %8, ptr noundef nonnull align 4 dereferenceable(4) %9)
  call void @_ZN7Riemann20HeightFieldHitResult12AddTestCountEi(ptr noundef nonnull align 4 dereferenceable(24) %6, i32 noundef 1)
  %17 = getelementptr inbounds i8, ptr %2, i64 4
  %18 = load float, ptr %17, align 4, !tbaa !5
  %19 = call float @llvm.fabs.f32(float %18)
  %20 = fcmp olt float %19, 0x3EB0C6F7A0000000
  %.pre = load float, ptr %8, align 4, !tbaa !10
  br i1 %20, label %21, label %27

21:                                               ; preds = %7
  %22 = getelementptr inbounds i8, ptr %1, i64 4
  %23 = load float, ptr %22, align 4, !tbaa !5
  %24 = fcmp olt float %23, %.pre
  %25 = load float, ptr %9, align 4
  %26 = fcmp ogt float %23, %25
  %or.cond = select i1 %24, i1 true, i1 %26
  br i1 %or.cond, label %79, label %27

27:                                               ; preds = %21, %7
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %10) #6
  %28 = getelementptr inbounds i8, ptr %0, i64 8
  %29 = load float, ptr %28, align 8, !tbaa !11
  %30 = sitofp i32 %3 to float
  %31 = getelementptr inbounds i8, ptr %0, i64 32
  %32 = load float, ptr %31, align 8, !tbaa !20
  %33 = call float @llvm.fmuladd.f32(float %30, float %32, float %29)
  %34 = getelementptr inbounds i8, ptr %0, i64 16
  %35 = load float, ptr %34, align 8, !tbaa !21
  %36 = sitofp i32 %4 to float
  %37 = getelementptr inbounds i8, ptr %0, i64 36
  %38 = load float, ptr %37, align 4, !tbaa !22
  %39 = call float @llvm.fmuladd.f32(float %36, float %38, float %35)
  call void @_ZN5Maths8TVector3IfEC2Efff(ptr noundef nonnull align 4 dereferenceable(12) %10, float noundef %33, float noundef %.pre, float noundef %39)
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %11) #6
  %40 = load float, ptr %28, align 8, !tbaa !11
  %41 = add nsw i32 %3, 1
  %42 = sitofp i32 %41 to float
  %43 = load float, ptr %31, align 8, !tbaa !20
  %44 = call float @llvm.fmuladd.f32(float %42, float %43, float %40)
  %45 = load float, ptr %9, align 4, !tbaa !10
  %46 = load float, ptr %34, align 8, !tbaa !21
  %47 = add nsw i32 %4, 1
  %48 = sitofp i32 %47 to float
  %49 = load float, ptr %37, align 4, !tbaa !22
  %50 = call float @llvm.fmuladd.f32(float %48, float %49, float %46)
  call void @_ZN5Maths8TVector3IfEC2Efff(ptr noundef nonnull align 4 dereferenceable(12) %11, float noundef %44, float noundef %45, float noundef %50)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %12) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %13) #6
  %51 = getelementptr inbounds i8, ptr %5, i64 4
  %52 = load float, ptr %51, align 4, !tbaa !23
  %53 = call noundef zeroext i1 @_ZN4Ray317RayIntersectAABB2ERKN5Maths8TVector3IfEES4_S4_S4_ffPfS5_(ptr noundef nonnull align 4 dereferenceable(12) %1, ptr noundef nonnull align 4 dereferenceable(12) %2, ptr noundef nonnull align 4 dereferenceable(12) %10, ptr noundef nonnull align 4 dereferenceable(12) %11, float noundef 0x3F1A36E2E0000000, float noundef %52, ptr noundef nonnull %12, ptr noundef nonnull %13)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %13) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %12) #6
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %11) #6
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %10) #6
  br i1 %53, label %54, label %79

54:                                               ; preds = %27
  call void @llvm.lifetime.start.p0(i64 72, ptr nonnull %14) #6
  call void @_ZN5Maths8TVector3IfEC2Ev(ptr noundef nonnull align 4 dereferenceable(12) %14)
  %.ptr.1 = getelementptr inbounds i8, ptr %14, i64 12
  call void @_ZN5Maths8TVector3IfEC2Ev(ptr noundef nonnull align 4 dereferenceable(12) %.ptr.1)
  %.ptr.2 = getelementptr inbounds i8, ptr %14, i64 24
  call void @_ZN5Maths8TVector3IfEC2Ev(ptr noundef nonnull align 4 dereferenceable(12) %.ptr.2)
  %.ptr.3 = getelementptr inbounds i8, ptr %14, i64 36
  call void @_ZN5Maths8TVector3IfEC2Ev(ptr noundef nonnull align 4 dereferenceable(12) %.ptr.3)
  %.ptr.4 = getelementptr inbounds i8, ptr %14, i64 48
  call void @_ZN5Maths8TVector3IfEC2Ev(ptr noundef nonnull align 4 dereferenceable(12) %.ptr.4)
  %.ptr.5 = getelementptr inbounds i8, ptr %14, i64 60
  call void @_ZN5Maths8TVector3IfEC2Ev(ptr noundef nonnull align 4 dereferenceable(12) %.ptr.5)
  %55 = call noundef i32 @_ZNK7Riemann12HeightField315GetCellTriangleEiiPN5Maths8TVector3IfEE(ptr noundef nonnull align 8 dereferenceable(88) %0, i32 noundef %3, i32 noundef %4, ptr noundef nonnull %14)
  %56 = icmp sgt i32 %55, 0
  br i1 %56, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %54
  %57 = getelementptr inbounds i8, ptr %6, i64 16
  br label %59

._crit_edge:                                      ; preds = %76, %54
  %.039.lcssa = phi i1 [ false, %54 ], [ %.140, %76 ]
  %58 = sdiv i32 %55, 3
  call void @_ZN7Riemann20HeightFieldHitResult12AddTestCountEi(ptr noundef nonnull align 4 dereferenceable(24) %6, i32 noundef %58)
  call void @llvm.lifetime.end.p0(i64 72, ptr nonnull %14) #6
  br label %79

59:                                               ; preds = %.lr.ph, %76
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %76 ]
  %.03748 = phi float [ 0x47EFFFFFE0000000, %.lr.ph ], [ %.138, %76 ]
  %.03947 = phi i1 [ false, %.lr.ph ], [ %.140, %76 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %15) #6
  %60 = getelementptr inbounds [6 x %"class.Maths::TVector3"], ptr %14, i64 0, i64 %indvars.iv
  %61 = add nuw nsw i64 %indvars.iv, 1
  %62 = getelementptr inbounds [6 x %"class.Maths::TVector3"], ptr %14, i64 0, i64 %61
  %63 = add nuw nsw i64 %indvars.iv, 2
  %64 = getelementptr inbounds [6 x %"class.Maths::TVector3"], ptr %14, i64 0, i64 %63
  %65 = call noundef zeroext i1 @_ZN7Riemann9Triangle320RayIntersectTriangleERKN5Maths8TVector3IfEES5_S5_S5_S5_Pf(ptr noundef nonnull align 4 dereferenceable(12) %1, ptr noundef nonnull align 4 dereferenceable(12) %2, ptr noundef nonnull align 4 dereferenceable(12) %60, ptr noundef nonnull align 4 dereferenceable(12) %62, ptr noundef nonnull align 4 dereferenceable(12) %64, ptr noundef nonnull %15)
  br i1 %65, label %66, label %76

66:                                               ; preds = %59
  %67 = load float, ptr %15, align 4, !tbaa !10
  %68 = fcmp olt float %67, %.03748
  br i1 %68, label %69, label %76

69:                                               ; preds = %66
  %70 = load float, ptr %51, align 4, !tbaa !23
  %71 = fcmp olt float %67, %70
  br i1 %71, label %72, label %76

72:                                               ; preds = %69
  store float %67, ptr %6, align 4, !tbaa !26
  %73 = load i32, ptr %0, align 8, !tbaa !28
  %74 = mul i32 %73, %4
  %75 = add i32 %74, %3
  store i32 %75, ptr %57, align 4, !tbaa !29
  br label %76

76:                                               ; preds = %69, %72, %66, %59
  %.140 = phi i1 [ true, %72 ], [ %.03947, %69 ], [ %.03947, %66 ], [ %.03947, %59 ]
  %.138 = phi float [ %67, %72 ], [ %67, %69 ], [ %.03748, %66 ], [ %.03748, %59 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %15) #6
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 3
  %77 = trunc nuw i64 %indvars.iv.next to i32
  %78 = icmp sgt i32 %55, %77
  br i1 %78, label %59, label %._crit_edge, !llvm.loop !30

79:                                               ; preds = %21, %27, %._crit_edge
  %.1 = phi i1 [ %.039.lcssa, %._crit_edge ], [ false, %27 ], [ false, %21 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %9) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %8) #6
  ret i1 %.1
}

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN7Riemann20HeightFieldHitResult12AddTestCountEi(ptr noundef nonnull align 4 dereferenceable(24), i32 noundef) local_unnamed_addr #2 align 2

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN4Ray317RayIntersectAABB2ERKN5Maths8TVector3IfEES4_S4_S4_ffPfS5_(ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12), float noundef, float noundef, ptr noundef, ptr noundef) local_unnamed_addr #0 align 2

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

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZNK7Riemann12HeightField315GetCellTriangleEiiPN5Maths8TVector3IfEE(ptr noundef nonnull align 8 dereferenceable(88), i32 noundef, i32 noundef, ptr noundef) local_unnamed_addr #0 align 2

declare noundef zeroext i1 @_ZN7Riemann9Triangle320RayIntersectTriangleERKN5Maths8TVector3IfEES5_S5_S5_S5_Pf(ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12), ptr noundef) local_unnamed_addr #5

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 willreturn memory(argmem: readwrite) }
attributes #2 = { 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 nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { 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 #5 = { "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 #6 = { 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 4}
!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 = !{!7, !7, i64 0}
!11 = !{!12, !7, i64 8}
!12 = !{!"_ZTSN7Riemann12HeightField3E", !13, i64 0, !13, i64 4, !14, i64 8, !7, i64 32, !7, i64 36, !7, i64 40, !7, i64 44, !7, i64 48, !15, i64 56, !19, i64 80}
!13 = !{!"int", !8, i64 0}
!14 = !{!"_ZTSN5Maths6TAABB3IfEE", !6, i64 0, !6, i64 12}
!15 = !{!"_ZTSSt6vectorIN7Riemann12HeightField38CellInfoESaIS2_EE", !16, i64 0}
!16 = !{!"_ZTSSt12_Vector_baseIN7Riemann12HeightField38CellInfoESaIS2_EE", !17, i64 0}
!17 = !{!"_ZTSNSt12_Vector_baseIN7Riemann12HeightField38CellInfoESaIS2_EE12_Vector_implE", !18, i64 0}
!18 = !{!"_ZTSNSt12_Vector_baseIN7Riemann12HeightField38CellInfoESaIS2_EE17_Vector_impl_dataE", !19, i64 0, !19, i64 8, !19, i64 16}
!19 = !{!"any pointer", !8, i64 0}
!20 = !{!12, !7, i64 32}
!21 = !{!12, !7, i64 16}
!22 = !{!12, !7, i64 36}
!23 = !{!24, !7, i64 4}
!24 = !{!"_ZTSN7Riemann20HeightFieldHitOptionE", !25, i64 0, !7, i64 4}
!25 = !{!"bool", !8, i64 0}
!26 = !{!27, !7, i64 0}
!27 = !{!"_ZTSN7Riemann20HeightFieldHitResultE", !7, i64 0, !6, i64 4, !13, i64 16, !13, i64 20}
!28 = !{!12, !13, i64 0}
!29 = !{!27, !13, i64 16}
!30 = distinct !{!30, !31}
!31 = !{!"llvm.loop.mustprogress"}


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