; LLVM IR from jrouwe/JoltPhysics :: Jolt/Physics/Collision/Shape (HeightFieldShape)

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

%"struct.JPH::AssertLastParam" = type { i8 }
%"class.JPH::HeightFieldShapeSettings" = type <{ %"class.JPH::ShapeSettings", %"class.JPH::Vec3", %"class.JPH::Vec3", i32, float, float, i32, i32, i32, %"class.JPH::Array", %"class.JPH::Array.6", %"class.JPH::Array.9", float, [12 x i8] }>
%"class.JPH::ShapeSettings" = type { %"class.JPH::SerializableObject", %"class.JPH::RefTarget", i64, %"class.JPH::Result" }
%"class.JPH::SerializableObject" = type { ptr }
%"class.JPH::RefTarget" = type { %"struct.std::atomic" }
%"struct.std::atomic" = type { %"struct.std::__atomic_base" }
%"struct.std::__atomic_base" = type { i32 }
%"class.JPH::Result" = type <{ %union.anon, i8, [7 x i8] }>
%union.anon = type { %"class.std::__cxx11::basic_string" }
%"class.std::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char, std::char_traits<char>, JPH::STLAllocator<char>>::_Alloc_hider", i64, %union.anon.2 }
%"struct.std::__cxx11::basic_string<char, std::char_traits<char>, JPH::STLAllocator<char>>::_Alloc_hider" = type { ptr }
%union.anon.2 = type { i64, [8 x i8] }
%"class.JPH::Vec3" = type { %union.anon.3 }
%union.anon.3 = type { <4 x float> }
%"class.JPH::Array" = type { i64, i64, ptr }
%"class.JPH::Array.6" = type { i64, i64, ptr }
%"class.JPH::Array.9" = type { i64, i64, ptr }
%"class.JPH::HeightFieldShape" = type <{ %"class.JPH::Shape.base", [6 x i8], %"class.JPH::Vec3", %"class.JPH::Vec3", i32, i32, i32, i32, i32, i8, i8, i16, i16, [6 x i8], ptr, ptr, ptr, %"class.JPH::Array.9", %"class.JPH::Array.6", i32, [4 x i8] }>
%"class.JPH::Shape.base" = type <{ ptr, %"class.JPH::RefTarget.12", [4 x i8], i64, i8, i8 }>
%"class.JPH::RefTarget.12" = type { %"struct.std::atomic" }

@.str.2 = external hidden unnamed_addr constant [102 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [39 x i8], align 1

; 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: alwaysinline mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN3JPH6SquareIjEET_S1_(i32 noundef) #1

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef, ptr noundef, i32 noundef) #2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3JPH16HeightFieldShape20StoreMaterialIndicesERKNS_24HeightFieldShapeSettingsE(ptr noundef nonnull align 16 dereferenceable(176) %0, ptr noundef nonnull align 16 dereferenceable(208) %1) #3 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i8, align 1
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i16, align 2
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca %"struct.JPH::AssertLastParam", align 1
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %17 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = getelementptr inbounds %"class.JPH::HeightFieldShapeSettings", ptr %18, i32 0, i32 3
  %20 = load i32, ptr %19, align 16, !tbaa !9
  %21 = sub i32 %20, 1
  store i32 %21, ptr %5, align 4, !tbaa !25
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  %22 = getelementptr inbounds %"class.JPH::HeightFieldShape", ptr %17, i32 0, i32 4
  %23 = load i32, ptr %22, align 16, !tbaa !26
  %24 = sub i32 %23, 1
  store i32 %24, ptr %6, align 4, !tbaa !25
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  %25 = getelementptr inbounds %"class.JPH::HeightFieldShape", ptr %17, i32 0, i32 17
  %26 = call noundef i64 @_ZNK3JPH5ArrayINS_8RefConstINS_15PhysicsMaterialEEENS_12STLAllocatorIS3_EEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %25)
  %27 = trunc i64 %26 to i32
  store i32 %27, ptr %7, align 4, !tbaa !25
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = getelementptr inbounds %"class.JPH::HeightFieldShapeSettings", ptr %28, i32 0, i32 6
  %30 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIjERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %7, ptr noundef nonnull align 4 dereferenceable(4) %29)
  %31 = load i32, ptr %30, align 4, !tbaa !25
  %32 = sub i32 %31, 1
  %33 = call noundef i32 @_ZN3JPH17CountLeadingZerosEj(i32 noundef %32)
  %34 = sub i32 32, %33
  %35 = getelementptr inbounds %"class.JPH::HeightFieldShape", ptr %17, i32 0, i32 19
  store i32 %34, ptr %35, align 8, !tbaa !33
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  %36 = getelementptr inbounds %"class.JPH::HeightFieldShape", ptr %17, i32 0, i32 18
  %37 = load i32, ptr %6, align 4, !tbaa !25
  %38 = call noundef i32 @_ZN3JPH6SquareIjEET_S1_(i32 noundef %37)
  %39 = getelementptr inbounds %"class.JPH::HeightFieldShape", ptr %17, i32 0, i32 19
  %40 = load i32, ptr %39, align 8, !tbaa !33
  %41 = mul i32 %38, %40
  %42 = add i32 %41, 7
  %43 = lshr i32 %42, 3
  %44 = add i32 %43, 1
  %45 = zext i32 %44 to i64
  call void @llvm.lifetime.start.p0(i64 1, ptr %8) #5
  store i8 0, ptr %8, align 1, !tbaa !34
  call void @_ZN3JPH5ArrayIhNS_12STLAllocatorIhEEE6resizeEmRKh(ptr noundef nonnull align 8 dereferenceable(24) %36, i64 noundef %45, ptr noundef nonnull align 1 dereferenceable(1) %8)
  call void @llvm.lifetime.end.p0(i64 1, ptr %8) #5
  %46 = getelementptr inbounds %"class.JPH::HeightFieldShape", ptr %17, i32 0, i32 17
  %47 = call noundef i64 @_ZNK3JPH5ArrayINS_8RefConstINS_15PhysicsMaterialEEENS_12STLAllocatorIS3_EEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %46)
  %48 = icmp ugt i64 %47, 1
  br i1 %48, label %49, label %150

49:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  store i32 0, ptr %9, align 4, !tbaa !25
  br label %50

50:                                               ; preds = %146, %49
  %51 = load i32, ptr %9, align 4, !tbaa !25
  %52 = load i32, ptr %6, align 4, !tbaa !25
  %53 = icmp ult i32 %51, %52
  br i1 %53, label %55, label %54

54:                                               ; preds = %50
  store i32 2, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  br label %149

55:                                               ; preds = %50
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  store i32 0, ptr %11, align 4, !tbaa !25
  br label %56

56:                                               ; preds = %142, %55
  %57 = load i32, ptr %11, align 4, !tbaa !25
  %58 = load i32, ptr %6, align 4, !tbaa !25
  %59 = icmp ult i32 %57, %58
  br i1 %59, label %61, label %60

60:                                               ; preds = %56
  store i32 5, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  br label %145

61:                                               ; preds = %56
  call void @llvm.lifetime.start.p0(i64 2, ptr %12) #5
  %62 = load i32, ptr %11, align 4, !tbaa !25
  %63 = load i32, ptr %5, align 4, !tbaa !25
  %64 = icmp ult i32 %62, %63
  br i1 %64, label %65, label %82

65:                                               ; preds = %61
  %66 = load i32, ptr %9, align 4, !tbaa !25
  %67 = load i32, ptr %5, align 4, !tbaa !25
  %68 = icmp ult i32 %66, %67
  br i1 %68, label %69, label %82

69:                                               ; preds = %65
  %70 = load ptr, ptr %4, align 8, !tbaa !5
  %71 = getelementptr inbounds %"class.JPH::HeightFieldShapeSettings", ptr %70, i32 0, i32 10
  %72 = load i32, ptr %11, align 4, !tbaa !25
  %73 = load i32, ptr %9, align 4, !tbaa !25
  %74 = load i32, ptr %5, align 4, !tbaa !25
  %75 = mul i32 %73, %74
  %76 = add i32 %72, %75
  %77 = zext i32 %76 to i64
  %78 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNK3JPH5ArrayIhNS_12STLAllocatorIhEEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %71, i64 noundef %77)
  %79 = load i8, ptr %78, align 1, !tbaa !34
  %80 = zext i8 %79 to i16
  %81 = zext i16 %80 to i32
  br label %83

82:                                               ; preds = %65, %61
  br label %83

83:                                               ; preds = %82, %69
  %84 = phi i32 [ %81, %69 ], [ 0, %82 ]
  %85 = trunc i32 %84 to i16
  store i16 %85, ptr %12, align 2, !tbaa !35
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  %86 = load i32, ptr %11, align 4, !tbaa !25
  %87 = load i32, ptr %9, align 4, !tbaa !25
  %88 = load i32, ptr %6, align 4, !tbaa !25
  %89 = mul i32 %87, %88
  %90 = add i32 %86, %89
  store i32 %90, ptr %13, align 4, !tbaa !25
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #5
  %91 = load i32, ptr %13, align 4, !tbaa !25
  %92 = getelementptr inbounds %"class.JPH::HeightFieldShape", ptr %17, i32 0, i32 19
  %93 = load i32, ptr %92, align 8, !tbaa !33
  %94 = mul i32 %91, %93
  store i32 %94, ptr %14, align 4, !tbaa !25
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #5
  %95 = load i32, ptr %14, align 4, !tbaa !25
  %96 = lshr i32 %95, 3
  store i32 %96, ptr %15, align 4, !tbaa !25
  %97 = load i32, ptr %14, align 4, !tbaa !25
  %98 = and i32 %97, 7
  store i32 %98, ptr %14, align 4, !tbaa !25
  %99 = load i32, ptr %14, align 4, !tbaa !25
  %100 = load i16, ptr %12, align 2, !tbaa !35
  %101 = zext i16 %100 to i32
  %102 = shl i32 %101, %99
  %103 = trunc i32 %102 to i16
  store i16 %103, ptr %12, align 2, !tbaa !35
  br label %104

104:                                              ; preds = %83
  %105 = load i32, ptr %15, align 4, !tbaa !25
  %106 = add i32 %105, 1
  %107 = zext i32 %106 to i64
  %108 = getelementptr inbounds %"class.JPH::HeightFieldShape", ptr %17, i32 0, i32 18
  %109 = call noundef i64 @_ZNK3JPH5ArrayIhNS_12STLAllocatorIhEEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %108)
  %110 = icmp ult i64 %107, %109
  br i1 %110, label %114, label %111

111:                                              ; preds = %104
  %112 = call noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef @.str.5, ptr noundef @.str.2, i32 noundef 411)
  br i1 %112, label %113, label %114

113:                                              ; preds = %111
  call void asm sideeffect "int $$0x3", "~{dirflag},~{fpsr},~{flags}"() #5, !srcloc !36
  br label %114

114:                                              ; preds = %113, %111, %104
  br label %115

115:                                              ; preds = %114
  br label %116

116:                                              ; preds = %115
  %117 = load i16, ptr %12, align 2, !tbaa !35
  %118 = trunc i16 %117 to i8
  %119 = zext i8 %118 to i32
  %120 = getelementptr inbounds %"class.JPH::HeightFieldShape", ptr %17, i32 0, i32 18
  %121 = load i32, ptr %15, align 4, !tbaa !25
  %122 = zext i32 %121 to i64
  %123 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZN3JPH5ArrayIhNS_12STLAllocatorIhEEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %120, i64 noundef %122)
  %124 = load i8, ptr %123, align 1, !tbaa !34
  %125 = zext i8 %124 to i32
  %126 = or i32 %125, %119
  %127 = trunc i32 %126 to i8
  store i8 %127, ptr %123, align 1, !tbaa !34
  %128 = load i16, ptr %12, align 2, !tbaa !35
  %129 = zext i16 %128 to i32
  %130 = ashr i32 %129, 8
  %131 = trunc i32 %130 to i8
  %132 = zext i8 %131 to i32
  %133 = getelementptr inbounds %"class.JPH::HeightFieldShape", ptr %17, i32 0, i32 18
  %134 = load i32, ptr %15, align 4, !tbaa !25
  %135 = add i32 %134, 1
  %136 = zext i32 %135 to i64
  %137 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZN3JPH5ArrayIhNS_12STLAllocatorIhEEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %133, i64 noundef %136)
  %138 = load i8, ptr %137, align 1, !tbaa !34
  %139 = zext i8 %138 to i32
  %140 = or i32 %139, %132
  %141 = trunc i32 %140 to i8
  store i8 %141, ptr %137, align 1, !tbaa !34
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 2, ptr %12) #5
  br label %142

142:                                              ; preds = %116
  %143 = load i32, ptr %11, align 4, !tbaa !25
  %144 = add i32 %143, 1
  store i32 %144, ptr %11, align 4, !tbaa !25
  br label %56, !llvm.loop !37

145:                                              ; preds = %60
  br label %146

146:                                              ; preds = %145
  %147 = load i32, ptr %9, align 4, !tbaa !25
  %148 = add i32 %147, 1
  store i32 %148, ptr %9, align 4, !tbaa !25
  br label %50, !llvm.loop !39

149:                                              ; preds = %54
  br label %150

150:                                              ; preds = %149, %2
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN3JPH17CountLeadingZerosEj(i32 noundef) #4

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNK3JPH5ArrayINS_8RefConstINS_15PhysicsMaterialEEENS_12STLAllocatorIS3_EEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) #4 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN3JPH5ArrayIhNS_12STLAllocatorIhEEE6resizeEmRKh(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef, ptr noundef nonnull align 1 dereferenceable(1)) #2 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef nonnull align 1 dereferenceable(1) ptr @_ZNK3JPH5ArrayIhNS_12STLAllocatorIhEEEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #2 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNK3JPH5ArrayIhNS_12STLAllocatorIhEEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) #4 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef nonnull align 1 dereferenceable(1) ptr @_ZN3JPH5ArrayIhNS_12STLAllocatorIhEEEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #2 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { alwaysinline 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 = { 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 #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 = { 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 = { 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, !16, i64 96}
!10 = !{!"_ZTSN3JPH24HeightFieldShapeSettingsE", !11, i64 0, !20, i64 64, !20, i64 80, !16, i64 96, !21, i64 100, !21, i64 104, !16, i64 108, !16, i64 112, !16, i64 116, !22, i64 120, !23, i64 144, !24, i64 168, !21, i64 192}
!11 = !{!"_ZTSN3JPH13ShapeSettingsE", !12, i64 0, !13, i64 8, !17, i64 16, !18, i64 24}
!12 = !{!"_ZTSN3JPH18SerializableObjectE"}
!13 = !{!"_ZTSN3JPH9RefTargetINS_13ShapeSettingsEEE", !14, i64 0}
!14 = !{!"_ZTSSt6atomicIjE", !15, i64 0}
!15 = !{!"_ZTSSt13__atomic_baseIjE", !16, i64 0}
!16 = !{!"int", !7, i64 0}
!17 = !{!"long", !7, i64 0}
!18 = !{!"_ZTSN3JPH6ResultINS_3RefINS_5ShapeEEEEE", !7, i64 0, !19, i64 32}
!19 = !{!"_ZTSN3JPH6ResultINS_3RefINS_5ShapeEEEE6EStateE", !7, i64 0}
!20 = !{!"_ZTSN3JPH4Vec3E", !7, i64 0}
!21 = !{!"float", !7, i64 0}
!22 = !{!"_ZTSN3JPH5ArrayIfNS_12STLAllocatorIfEEEE", !17, i64 0, !17, i64 8, !6, i64 16}
!23 = !{!"_ZTSN3JPH5ArrayIhNS_12STLAllocatorIhEEEE", !17, i64 0, !17, i64 8, !6, i64 16}
!24 = !{!"_ZTSN3JPH5ArrayINS_8RefConstINS_15PhysicsMaterialEEENS_12STLAllocatorIS3_EEEE", !17, i64 0, !17, i64 8, !6, i64 16}
!25 = !{!16, !16, i64 0}
!26 = !{!27, !16, i64 64}
!27 = !{!"_ZTSN3JPH16HeightFieldShapeE", !28, i64 0, !20, i64 32, !20, i64 48, !16, i64 64, !16, i64 68, !16, i64 72, !16, i64 76, !16, i64 80, !7, i64 84, !7, i64 85, !32, i64 86, !32, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !24, i64 120, !23, i64 144, !16, i64 168}
!28 = !{!"_ZTSN3JPH5ShapeE", !29, i64 8, !17, i64 16, !30, i64 24, !31, i64 25}
!29 = !{!"_ZTSN3JPH9RefTargetINS_5ShapeEEE", !14, i64 0}
!30 = !{!"_ZTSN3JPH10EShapeTypeE", !7, i64 0}
!31 = !{!"_ZTSN3JPH13EShapeSubTypeE", !7, i64 0}
!32 = !{!"short", !7, i64 0}
!33 = !{!27, !16, i64 168}
!34 = !{!7, !7, i64 0}
!35 = !{!32, !32, i64 0}
!36 = !{i64 2158605344}
!37 = distinct !{!37, !38}
!38 = !{!"llvm.loop.mustprogress"}
!39 = distinct !{!39, !38}


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

@.str.2 = external hidden unnamed_addr constant [102 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [39 x i8], align 1

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

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

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN3JPH6SquareIjEET_S1_(i32 noundef) local_unnamed_addr #1

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3JPH16HeightFieldShape20StoreMaterialIndicesERKNS_24HeightFieldShapeSettingsE(ptr noundef nonnull align 16 dereferenceable(176) %0, ptr noundef nonnull align 16 dereferenceable(208) %1) local_unnamed_addr #3 align 2 {
  %3 = alloca i32, align 4
  %4 = alloca i8, align 1
  %5 = getelementptr inbounds i8, ptr %1, i64 96
  %6 = load i32, ptr %5, align 16, !tbaa !5
  %7 = add i32 %6, -1
  %8 = getelementptr inbounds i8, ptr %0, i64 64
  %9 = load i32, ptr %8, align 16, !tbaa !24
  %10 = add i32 %9, -1
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #5
  %11 = getelementptr inbounds i8, ptr %0, i64 120
  %12 = tail call noundef i64 @_ZNK3JPH5ArrayINS_8RefConstINS_15PhysicsMaterialEEENS_12STLAllocatorIS3_EEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %11)
  %13 = trunc i64 %12 to i32
  store i32 %13, ptr %3, align 4, !tbaa !31
  %14 = getelementptr inbounds i8, ptr %1, i64 108
  %15 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIjERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %3, ptr noundef nonnull align 4 dereferenceable(4) %14)
  %16 = load i32, ptr %15, align 4, !tbaa !31
  %17 = add i32 %16, -1
  %18 = call noundef i32 @_ZN3JPH17CountLeadingZerosEj(i32 noundef %17)
  %19 = sub i32 32, %18
  %20 = getelementptr inbounds i8, ptr %0, i64 168
  store i32 %19, ptr %20, align 8, !tbaa !32
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #5
  %21 = getelementptr inbounds i8, ptr %0, i64 144
  %22 = call noundef i32 @_ZN3JPH6SquareIjEET_S1_(i32 noundef %10)
  %23 = load i32, ptr %20, align 8, !tbaa !32
  %24 = mul i32 %23, %22
  %25 = add i32 %24, 7
  %26 = lshr i32 %25, 3
  %27 = add nuw nsw i32 %26, 1
  %28 = zext nneg i32 %27 to i64
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %4) #5
  store i8 0, ptr %4, align 1, !tbaa !33
  call void @_ZN3JPH5ArrayIhNS_12STLAllocatorIhEEE6resizeEmRKh(ptr noundef nonnull align 8 dereferenceable(24) %21, i64 noundef %28, ptr noundef nonnull align 1 dereferenceable(1) %4)
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %4) #5
  %29 = call noundef i64 @_ZNK3JPH5ArrayINS_8RefConstINS_15PhysicsMaterialEEENS_12STLAllocatorIS3_EEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %11)
  %30 = icmp ugt i64 %29, 1
  %31 = icmp ne i32 %10, 0
  %or.cond = select i1 %30, i1 %31, i1 false
  br i1 %or.cond, label %.preheader.lr.ph, label %.loopexit

.preheader.lr.ph:                                 ; preds = %2
  %32 = getelementptr inbounds i8, ptr %1, i64 144
  %33 = zext i32 %7 to i64
  %wide.trip.count = zext i32 %10 to i64
  br label %.preheader

.preheader:                                       ; preds = %.preheader.lr.ph, %.split.us
  %.035 = phi i32 [ 0, %.preheader.lr.ph ], [ %53, %.split.us ]
  %34 = icmp ult i32 %.035, %7
  %35 = mul i32 %.035, %7
  %36 = mul i32 %.035, %10
  %.fr = freeze i1 %34
  br i1 %.fr, label %.preheader.split, label %.preheader.split.us

.preheader.split.us:                              ; preds = %.preheader, %48
  %.03034.us = phi i32 [ %52, %48 ], [ 0, %.preheader ]
  %37 = add i32 %.03034.us, %36
  %38 = load i32, ptr %20, align 8, !tbaa !32
  %39 = mul i32 %38, %37
  %40 = lshr i32 %39, 3
  %41 = add nuw nsw i32 %40, 1
  %42 = zext nneg i32 %41 to i64
  %43 = call noundef i64 @_ZNK3JPH5ArrayIhNS_12STLAllocatorIhEEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %21)
  %44 = icmp ugt i64 %43, %42
  br i1 %44, label %48, label %45

45:                                               ; preds = %.preheader.split.us
  %46 = call noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef nonnull @.str.5, ptr noundef nonnull @.str.2, i32 noundef 411)
  br i1 %46, label %47, label %48

47:                                               ; preds = %45
  call void asm sideeffect "int $$0x3", "~{dirflag},~{fpsr},~{flags}"() #5, !srcloc !34
  br label %48

48:                                               ; preds = %47, %45, %.preheader.split.us
  %49 = zext nneg i32 %40 to i64
  %50 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZN3JPH5ArrayIhNS_12STLAllocatorIhEEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %21, i64 noundef %49)
  %51 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZN3JPH5ArrayIhNS_12STLAllocatorIhEEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %21, i64 noundef %42)
  %52 = add nuw i32 %.03034.us, 1
  %exitcond.not = icmp eq i32 %52, %10
  br i1 %exitcond.not, label %.split.us, label %.preheader.split.us, !llvm.loop !35

.split.us:                                        ; preds = %48, %76
  %53 = add nuw i32 %.035, 1
  %exitcond39.not = icmp eq i32 %53, %10
  br i1 %exitcond39.not, label %.loopexit, label %.preheader, !llvm.loop !37

.preheader.split:                                 ; preds = %.preheader, %76
  %indvars.iv = phi i64 [ %indvars.iv.next, %76 ], [ 0, %.preheader ]
  %54 = icmp ult i64 %indvars.iv, %33
  %55 = trunc nuw i64 %indvars.iv to i32
  br i1 %54, label %56, label %.preheader.split._crit_edge

56:                                               ; preds = %.preheader.split
  %57 = add i32 %35, %55
  %58 = zext i32 %57 to i64
  %59 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNK3JPH5ArrayIhNS_12STLAllocatorIhEEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %32, i64 noundef %58)
  %60 = load i8, ptr %59, align 1, !tbaa !33
  %61 = zext i8 %60 to i32
  br label %.preheader.split._crit_edge

.preheader.split._crit_edge:                      ; preds = %.preheader.split, %56
  %62 = phi i32 [ %61, %56 ], [ 0, %.preheader.split ]
  %63 = add i32 %36, %55
  %64 = load i32, ptr %20, align 8, !tbaa !32
  %65 = mul i32 %64, %63
  %66 = lshr i32 %65, 3
  %67 = and i32 %65, 7
  %68 = shl nuw nsw i32 %62, %67
  %69 = add nuw nsw i32 %66, 1
  %70 = zext nneg i32 %69 to i64
  %71 = call noundef i64 @_ZNK3JPH5ArrayIhNS_12STLAllocatorIhEEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %21)
  %72 = icmp ugt i64 %71, %70
  br i1 %72, label %76, label %73

73:                                               ; preds = %.preheader.split._crit_edge
  %74 = call noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef nonnull @.str.5, ptr noundef nonnull @.str.2, i32 noundef 411)
  br i1 %74, label %75, label %76

75:                                               ; preds = %73
  call void asm sideeffect "int $$0x3", "~{dirflag},~{fpsr},~{flags}"() #5, !srcloc !34
  br label %76

76:                                               ; preds = %75, %73, %.preheader.split._crit_edge
  %77 = zext nneg i32 %66 to i64
  %78 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZN3JPH5ArrayIhNS_12STLAllocatorIhEEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %21, i64 noundef %77)
  %79 = load i8, ptr %78, align 1, !tbaa !33
  %80 = trunc i32 %68 to i8
  %81 = or i8 %79, %80
  store i8 %81, ptr %78, align 1, !tbaa !33
  %82 = lshr i32 %68, 8
  %83 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZN3JPH5ArrayIhNS_12STLAllocatorIhEEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %21, i64 noundef %70)
  %84 = load i8, ptr %83, align 1, !tbaa !33
  %85 = trunc nuw nsw i32 %82 to i8
  %86 = or i8 %84, %85
  store i8 %86, ptr %83, align 1, !tbaa !33
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond38.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond38.not, label %.split.us, label %.preheader.split, !llvm.loop !35

.loopexit:                                        ; preds = %.split.us, %2
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN3JPH17CountLeadingZerosEj(i32 noundef) local_unnamed_addr #4

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIjERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #4

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNK3JPH5ArrayINS_8RefConstINS_15PhysicsMaterialEEENS_12STLAllocatorIS3_EEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #4 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN3JPH5ArrayIhNS_12STLAllocatorIhEEE6resizeEmRKh(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef, ptr noundef nonnull align 1 dereferenceable(1)) local_unnamed_addr #2 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef nonnull align 1 dereferenceable(1) ptr @_ZNK3JPH5ArrayIhNS_12STLAllocatorIhEEEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #2 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNK3JPH5ArrayIhNS_12STLAllocatorIhEEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #4 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef nonnull align 1 dereferenceable(1) ptr @_ZN3JPH5ArrayIhNS_12STLAllocatorIhEEEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #2 align 2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { alwaysinline 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 = { 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 #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 = { 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 = { 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, !12, i64 96}
!6 = !{!"_ZTSN3JPH24HeightFieldShapeSettingsE", !7, i64 0, !18, i64 64, !18, i64 80, !12, i64 96, !19, i64 100, !19, i64 104, !12, i64 108, !12, i64 112, !12, i64 116, !20, i64 120, !22, i64 144, !23, i64 168, !19, i64 192}
!7 = !{!"_ZTSN3JPH13ShapeSettingsE", !8, i64 0, !9, i64 8, !15, i64 16, !16, i64 24}
!8 = !{!"_ZTSN3JPH18SerializableObjectE"}
!9 = !{!"_ZTSN3JPH9RefTargetINS_13ShapeSettingsEEE", !10, i64 0}
!10 = !{!"_ZTSSt6atomicIjE", !11, i64 0}
!11 = !{!"_ZTSSt13__atomic_baseIjE", !12, i64 0}
!12 = !{!"int", !13, i64 0}
!13 = !{!"omnipotent char", !14, i64 0}
!14 = !{!"Simple C++ TBAA"}
!15 = !{!"long", !13, i64 0}
!16 = !{!"_ZTSN3JPH6ResultINS_3RefINS_5ShapeEEEEE", !13, i64 0, !17, i64 32}
!17 = !{!"_ZTSN3JPH6ResultINS_3RefINS_5ShapeEEEE6EStateE", !13, i64 0}
!18 = !{!"_ZTSN3JPH4Vec3E", !13, i64 0}
!19 = !{!"float", !13, i64 0}
!20 = !{!"_ZTSN3JPH5ArrayIfNS_12STLAllocatorIfEEEE", !15, i64 0, !15, i64 8, !21, i64 16}
!21 = !{!"any pointer", !13, i64 0}
!22 = !{!"_ZTSN3JPH5ArrayIhNS_12STLAllocatorIhEEEE", !15, i64 0, !15, i64 8, !21, i64 16}
!23 = !{!"_ZTSN3JPH5ArrayINS_8RefConstINS_15PhysicsMaterialEEENS_12STLAllocatorIS3_EEEE", !15, i64 0, !15, i64 8, !21, i64 16}
!24 = !{!25, !12, i64 64}
!25 = !{!"_ZTSN3JPH16HeightFieldShapeE", !26, i64 0, !18, i64 32, !18, i64 48, !12, i64 64, !12, i64 68, !12, i64 72, !12, i64 76, !12, i64 80, !13, i64 84, !13, i64 85, !30, i64 86, !30, i64 88, !21, i64 96, !21, i64 104, !21, i64 112, !23, i64 120, !22, i64 144, !12, i64 168}
!26 = !{!"_ZTSN3JPH5ShapeE", !27, i64 8, !15, i64 16, !28, i64 24, !29, i64 25}
!27 = !{!"_ZTSN3JPH9RefTargetINS_5ShapeEEE", !10, i64 0}
!28 = !{!"_ZTSN3JPH10EShapeTypeE", !13, i64 0}
!29 = !{!"_ZTSN3JPH13EShapeSubTypeE", !13, i64 0}
!30 = !{!"short", !13, i64 0}
!31 = !{!12, !12, i64 0}
!32 = !{!25, !12, i64 168}
!33 = !{!13, !13, i64 0}
!34 = !{i64 2158605344}
!35 = distinct !{!35, !36}
!36 = !{!"llvm.loop.mustprogress"}
!37 = distinct !{!37, !36}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass