; 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::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" }
%"struct.std::atomic" = type { %"struct.std::__atomic_base" }
%"struct.std::__atomic_base" = type { i32 }
%"class.JPH::Vec3" = type { %union.anon.3 }
%union.anon.3 = type { <4 x float> }
%"class.JPH::Array.9" = type { i64, i64, ptr }
%"class.JPH::Array.6" = type { i64, i64, ptr }

@.str.2 = external hidden unnamed_addr constant [102 x i8], align 1
@.str.22 = external hidden unnamed_addr constant [41 x i8], align 1
@.str.25 = external hidden unnamed_addr constant [61 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: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef, ptr noundef, i32 noundef) #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK3JPH5ArrayIhNS_12STLAllocatorIhEEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(24)) #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK3JPH16HeightFieldShape12GetMaterialsEjjjjPhl(ptr noundef nonnull align 16 dereferenceable(176) %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4, ptr noundef %5, i64 noundef %6) #3 align 2 {
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca ptr, align 8
  %14 = alloca i64, align 8
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca ptr, align 8
  %18 = alloca i32, align 4
  %19 = alloca %"struct.JPH::AssertLastParam", align 1
  %20 = alloca %"struct.JPH::AssertLastParam", align 1
  %21 = alloca i32, align 4
  %22 = alloca i16, align 2
  %23 = alloca i32, align 4
  %24 = alloca i32, align 4
  %25 = alloca ptr, align 8
  %26 = alloca ptr, align 8
  %27 = alloca i32, align 4
  %28 = alloca i16, align 2
  store ptr %0, ptr %8, align 8, !tbaa !5
  store i32 %1, ptr %9, align 4, !tbaa !9
  store i32 %2, ptr %10, align 4, !tbaa !9
  store i32 %3, ptr %11, align 4, !tbaa !9
  store i32 %4, ptr %12, align 4, !tbaa !9
  store ptr %5, ptr %13, align 8, !tbaa !5
  store i64 %6, ptr %14, align 8, !tbaa !11
  %29 = load ptr, ptr %8, align 8
  %30 = load i32, ptr %11, align 4, !tbaa !9
  %31 = icmp eq i32 %30, 0
  br i1 %31, label %35, label %32

32:                                               ; preds = %7
  %33 = load i32, ptr %12, align 4, !tbaa !9
  %34 = icmp eq i32 %33, 0
  br i1 %34, label %35, label %36

35:                                               ; preds = %32, %7
  br label %197

36:                                               ; preds = %32
  %37 = getelementptr inbounds %"class.JPH::HeightFieldShape", ptr %29, i32 0, i32 18
  %38 = call noundef zeroext i1 @_ZNK3JPH5ArrayIhNS_12STLAllocatorIhEEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(24) %37)
  br i1 %38, label %39, label %68

39:                                               ; preds = %36
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #4
  store i32 0, ptr %15, align 4, !tbaa !9
  br label %40

40:                                               ; preds = %64, %39
  %41 = load i32, ptr %15, align 4, !tbaa !9
  %42 = load i32, ptr %12, align 4, !tbaa !9
  %43 = icmp ult i32 %41, %42
  br i1 %43, label %45, label %44

44:                                               ; preds = %40
  store i32 2, ptr %16, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #4
  br label %67

45:                                               ; preds = %40
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #4
  %46 = load ptr, ptr %13, align 8, !tbaa !5
  %47 = load i32, ptr %15, align 4, !tbaa !9
  %48 = zext i32 %47 to i64
  %49 = load i64, ptr %14, align 8, !tbaa !11
  %50 = mul nsw i64 %48, %49
  %51 = getelementptr inbounds i8, ptr %46, i64 %50
  store ptr %51, ptr %17, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #4
  store i32 0, ptr %18, align 4, !tbaa !9
  br label %52

52:                                               ; preds = %60, %45
  %53 = load i32, ptr %18, align 4, !tbaa !9
  %54 = load i32, ptr %11, align 4, !tbaa !9
  %55 = icmp ult i32 %53, %54
  br i1 %55, label %57, label %56

56:                                               ; preds = %52
  store i32 5, ptr %16, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #4
  br label %63

57:                                               ; preds = %52
  %58 = load ptr, ptr %17, align 8, !tbaa !5
  %59 = getelementptr inbounds i8, ptr %58, i32 1
  store ptr %59, ptr %17, align 8, !tbaa !5
  store i8 0, ptr %58, align 1, !tbaa !13
  br label %60

60:                                               ; preds = %57
  %61 = load i32, ptr %18, align 4, !tbaa !9
  %62 = add i32 %61, 1
  store i32 %62, ptr %18, align 4, !tbaa !9
  br label %52, !llvm.loop !14

63:                                               ; preds = %56
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #4
  br label %64

64:                                               ; preds = %63
  %65 = load i32, ptr %15, align 4, !tbaa !9
  %66 = add i32 %65, 1
  store i32 %66, ptr %15, align 4, !tbaa !9
  br label %40, !llvm.loop !16

67:                                               ; preds = %44
  br label %197

68:                                               ; preds = %36
  br label %69

69:                                               ; preds = %68
  %70 = load i32, ptr %9, align 4, !tbaa !9
  %71 = getelementptr inbounds %"class.JPH::HeightFieldShape", ptr %29, i32 0, i32 4
  %72 = load i32, ptr %71, align 16, !tbaa !17
  %73 = icmp ult i32 %70, %72
  br i1 %73, label %74, label %79

74:                                               ; preds = %69
  %75 = load i32, ptr %10, align 4, !tbaa !9
  %76 = getelementptr inbounds %"class.JPH::HeightFieldShape", ptr %29, i32 0, i32 4
  %77 = load i32, ptr %76, align 16, !tbaa !17
  %78 = icmp ult i32 %75, %77
  br i1 %78, label %82, label %79

79:                                               ; preds = %74, %69
  %80 = call noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef @.str.22, ptr noundef @.str.2, i32 noundef 1248)
  br i1 %80, label %81, label %82

81:                                               ; preds = %79
  call void asm sideeffect "int $$0x3", "~{dirflag},~{fpsr},~{flags}"() #4, !srcloc !29
  br label %82

82:                                               ; preds = %81, %79, %74
  br label %83

83:                                               ; preds = %82
  br label %84

84:                                               ; preds = %83
  %85 = load i32, ptr %9, align 4, !tbaa !9
  %86 = load i32, ptr %11, align 4, !tbaa !9
  %87 = add i32 %85, %86
  %88 = getelementptr inbounds %"class.JPH::HeightFieldShape", ptr %29, i32 0, i32 4
  %89 = load i32, ptr %88, align 16, !tbaa !17
  %90 = icmp ult i32 %87, %89
  br i1 %90, label %91, label %98

91:                                               ; preds = %84
  %92 = load i32, ptr %10, align 4, !tbaa !9
  %93 = load i32, ptr %12, align 4, !tbaa !9
  %94 = add i32 %92, %93
  %95 = getelementptr inbounds %"class.JPH::HeightFieldShape", ptr %29, i32 0, i32 4
  %96 = load i32, ptr %95, align 16, !tbaa !17
  %97 = icmp ult i32 %94, %96
  br i1 %97, label %101, label %98

98:                                               ; preds = %91, %84
  %99 = call noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef @.str.25, ptr noundef @.str.2, i32 noundef 1249)
  br i1 %99, label %100, label %101

100:                                              ; preds = %98
  call void asm sideeffect "int $$0x3", "~{dirflag},~{fpsr},~{flags}"() #4, !srcloc !30
  br label %101

101:                                              ; preds = %100, %98, %91
  br label %102

102:                                              ; preds = %101
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #4
  %103 = getelementptr inbounds %"class.JPH::HeightFieldShape", ptr %29, i32 0, i32 4
  %104 = load i32, ptr %103, align 16, !tbaa !17
  %105 = sub i32 %104, 1
  store i32 %105, ptr %21, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 2, ptr %22) #4
  %106 = getelementptr inbounds %"class.JPH::HeightFieldShape", ptr %29, i32 0, i32 19
  %107 = load i32, ptr %106, align 8, !tbaa !31
  %108 = shl i32 1, %107
  %109 = sub nsw i32 %108, 1
  %110 = trunc i32 %109 to i16
  store i16 %110, ptr %22, align 2, !tbaa !32
  call void @llvm.lifetime.start.p0(i64 4, ptr %23) #4
  store i32 0, ptr %23, align 4, !tbaa !9
  br label %111

111:                                              ; preds = %193, %102
  %112 = load i32, ptr %23, align 4, !tbaa !9
  %113 = load i32, ptr %12, align 4, !tbaa !9
  %114 = icmp ult i32 %112, %113
  br i1 %114, label %116, label %115

115:                                              ; preds = %111
  store i32 12, ptr %16, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %23) #4
  br label %196

116:                                              ; preds = %111
  call void @llvm.lifetime.start.p0(i64 4, ptr %24) #4
  %117 = load i32, ptr %9, align 4, !tbaa !9
  %118 = load i32, ptr %10, align 4, !tbaa !9
  %119 = load i32, ptr %23, align 4, !tbaa !9
  %120 = add i32 %118, %119
  %121 = load i32, ptr %21, align 4, !tbaa !9
  %122 = mul i32 %120, %121
  %123 = add i32 %117, %122
  %124 = getelementptr inbounds %"class.JPH::HeightFieldShape", ptr %29, i32 0, i32 19
  %125 = load i32, ptr %124, align 8, !tbaa !31
  %126 = mul i32 %123, %125
  store i32 %126, ptr %24, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %25) #4
  %127 = getelementptr inbounds %"class.JPH::HeightFieldShape", ptr %29, i32 0, i32 18
  %128 = call noundef ptr @_ZNK3JPH5ArrayIhNS_12STLAllocatorIhEEE4dataEv(ptr noundef nonnull align 8 dereferenceable(24) %127)
  %129 = load i32, ptr %24, align 4, !tbaa !9
  %130 = lshr i32 %129, 3
  %131 = zext i32 %130 to i64
  %132 = getelementptr inbounds i8, ptr %128, i64 %131
  store ptr %132, ptr %25, align 8, !tbaa !5
  %133 = load i32, ptr %24, align 4, !tbaa !9
  %134 = and i32 %133, 7
  store i32 %134, ptr %24, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %26) #4
  %135 = load ptr, ptr %13, align 8, !tbaa !5
  %136 = load i32, ptr %23, align 4, !tbaa !9
  %137 = zext i32 %136 to i64
  %138 = load i64, ptr %14, align 8, !tbaa !11
  %139 = mul nsw i64 %137, %138
  %140 = getelementptr inbounds i8, ptr %135, i64 %139
  store ptr %140, ptr %26, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %27) #4
  store i32 0, ptr %27, align 4, !tbaa !9
  br label %141

141:                                              ; preds = %189, %116
  %142 = load i32, ptr %27, align 4, !tbaa !9
  %143 = load i32, ptr %11, align 4, !tbaa !9
  %144 = icmp ult i32 %142, %143
  br i1 %144, label %146, label %145

145:                                              ; preds = %141
  store i32 15, ptr %16, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %27) #4
  br label %192

146:                                              ; preds = %141
  call void @llvm.lifetime.start.p0(i64 2, ptr %28) #4
  %147 = load ptr, ptr %25, align 8, !tbaa !5
  %148 = getelementptr inbounds i8, ptr %147, i64 0
  %149 = load i8, ptr %148, align 1, !tbaa !13
  %150 = zext i8 %149 to i16
  %151 = zext i16 %150 to i32
  %152 = load ptr, ptr %25, align 8, !tbaa !5
  %153 = getelementptr inbounds i8, ptr %152, i64 1
  %154 = load i8, ptr %153, align 1, !tbaa !13
  %155 = zext i8 %154 to i16
  %156 = zext i16 %155 to i32
  %157 = shl i32 %156, 8
  %158 = trunc i32 %157 to i16
  %159 = zext i16 %158 to i32
  %160 = add nsw i32 %151, %159
  %161 = trunc i32 %160 to i16
  store i16 %161, ptr %28, align 2, !tbaa !32
  %162 = load i32, ptr %24, align 4, !tbaa !9
  %163 = load i16, ptr %28, align 2, !tbaa !32
  %164 = zext i16 %163 to i32
  %165 = ashr i32 %164, %162
  %166 = trunc i32 %165 to i16
  store i16 %166, ptr %28, align 2, !tbaa !32
  %167 = load i16, ptr %22, align 2, !tbaa !32
  %168 = zext i16 %167 to i32
  %169 = load i16, ptr %28, align 2, !tbaa !32
  %170 = zext i16 %169 to i32
  %171 = and i32 %170, %168
  %172 = trunc i32 %171 to i16
  store i16 %172, ptr %28, align 2, !tbaa !32
  %173 = load i16, ptr %28, align 2, !tbaa !32
  %174 = trunc i16 %173 to i8
  %175 = load ptr, ptr %26, align 8, !tbaa !5
  store i8 %174, ptr %175, align 1, !tbaa !13
  %176 = getelementptr inbounds %"class.JPH::HeightFieldShape", ptr %29, i32 0, i32 19
  %177 = load i32, ptr %176, align 8, !tbaa !31
  %178 = load i32, ptr %24, align 4, !tbaa !9
  %179 = add i32 %178, %177
  store i32 %179, ptr %24, align 4, !tbaa !9
  %180 = load i32, ptr %24, align 4, !tbaa !9
  %181 = lshr i32 %180, 3
  %182 = load ptr, ptr %25, align 8, !tbaa !5
  %183 = zext i32 %181 to i64
  %184 = getelementptr inbounds i8, ptr %182, i64 %183
  store ptr %184, ptr %25, align 8, !tbaa !5
  %185 = load i32, ptr %24, align 4, !tbaa !9
  %186 = and i32 %185, 7
  store i32 %186, ptr %24, align 4, !tbaa !9
  %187 = load ptr, ptr %26, align 8, !tbaa !5
  %188 = getelementptr inbounds i8, ptr %187, i32 1
  store ptr %188, ptr %26, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 2, ptr %28) #4
  br label %189

189:                                              ; preds = %146
  %190 = load i32, ptr %27, align 4, !tbaa !9
  %191 = add i32 %190, 1
  store i32 %191, ptr %27, align 4, !tbaa !9
  br label %141, !llvm.loop !33

192:                                              ; preds = %145
  call void @llvm.lifetime.end.p0(i64 8, ptr %26) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %25) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %24) #4
  br label %193

193:                                              ; preds = %192
  %194 = load i32, ptr %23, align 4, !tbaa !9
  %195 = add i32 %194, 1
  store i32 %195, ptr %23, align 4, !tbaa !9
  br label %111, !llvm.loop !34

196:                                              ; preds = %115
  call void @llvm.lifetime.end.p0(i64 2, ptr %22) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #4
  br label %197

197:                                              ; preds = %196, %67, %35
  ret void
}

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { inlinehint mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { 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 = { 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 = !{!"long", !7, i64 0}
!13 = !{!7, !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = distinct !{!16, !15}
!17 = !{!18, !10, i64 64}
!18 = !{!"_ZTSN3JPH16HeightFieldShapeE", !19, i64 0, !25, i64 32, !25, i64 48, !10, i64 64, !10, i64 68, !10, i64 72, !10, i64 76, !10, i64 80, !7, i64 84, !7, i64 85, !26, i64 86, !26, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !27, i64 120, !28, i64 144, !10, i64 168}
!19 = !{!"_ZTSN3JPH5ShapeE", !20, i64 8, !12, i64 16, !23, i64 24, !24, i64 25}
!20 = !{!"_ZTSN3JPH9RefTargetINS_5ShapeEEE", !21, i64 0}
!21 = !{!"_ZTSSt6atomicIjE", !22, i64 0}
!22 = !{!"_ZTSSt13__atomic_baseIjE", !10, i64 0}
!23 = !{!"_ZTSN3JPH10EShapeTypeE", !7, i64 0}
!24 = !{!"_ZTSN3JPH13EShapeSubTypeE", !7, i64 0}
!25 = !{!"_ZTSN3JPH4Vec3E", !7, i64 0}
!26 = !{!"short", !7, i64 0}
!27 = !{!"_ZTSN3JPH5ArrayINS_8RefConstINS_15PhysicsMaterialEEENS_12STLAllocatorIS3_EEEE", !12, i64 0, !12, i64 8, !6, i64 16}
!28 = !{!"_ZTSN3JPH5ArrayIhNS_12STLAllocatorIhEEEE", !12, i64 0, !12, i64 8, !6, i64 16}
!29 = !{i64 2158618423}
!30 = !{i64 2158618854}
!31 = !{!18, !10, i64 168}
!32 = !{!26, !26, i64 0}
!33 = distinct !{!33, !15}
!34 = distinct !{!34, !15}


; 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.22 = external hidden unnamed_addr constant [41 x i8], align 1
@.str.25 = external hidden unnamed_addr constant [61 x i8], align 1

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK3JPH5ArrayIhNS_12STLAllocatorIhEEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK3JPH16HeightFieldShape12GetMaterialsEjjjjPhl(ptr noundef nonnull align 16 dereferenceable(176) %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4, ptr nocapture noundef writeonly %5, i64 noundef %6) local_unnamed_addr #2 align 2 {
  %8 = icmp eq i32 %3, 0
  %9 = icmp eq i32 %4, 0
  %or.cond = or i1 %8, %9
  br i1 %or.cond, label %.loopexit, label %10

10:                                               ; preds = %7
  %11 = getelementptr inbounds i8, ptr %0, i64 144
  %12 = tail call noundef zeroext i1 @_ZNK3JPH5ArrayIhNS_12STLAllocatorIhEEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(24) %11)
  br i1 %12, label %.lr.ph.us73.preheader, label %24

.lr.ph.us73.preheader:                            ; preds = %10
  %13 = zext i32 %3 to i64
  %wide.trip.count85 = zext i32 %4 to i64
  %14 = add nsw i64 %wide.trip.count85, -1
  %xtraiter91 = and i64 %wide.trip.count85, 7
  %15 = icmp ult i64 %14, 7
  br i1 %15, label %.loopexit.loopexit.unr-lcssa, label %.lr.ph.us73.preheader.new

.lr.ph.us73.preheader.new:                        ; preds = %.lr.ph.us73.preheader
  %unroll_iter93 = and i64 %wide.trip.count85, 4294967288
  br label %.lr.ph.us73

.lr.ph.us73:                                      ; preds = %.lr.ph.us73, %.lr.ph.us73.preheader.new
  %indvar = phi i64 [ 0, %.lr.ph.us73.preheader.new ], [ %indvar.next.7, %.lr.ph.us73 ]
  %niter94 = phi i64 [ 0, %.lr.ph.us73.preheader.new ], [ %niter94.next.7, %.lr.ph.us73 ]
  %16 = mul i64 %indvar, %6
  %scevgep = getelementptr i8, ptr %5, i64 %16
  tail call void @llvm.memset.p0.i64(ptr align 1 %scevgep, i8 0, i64 %13, i1 false), !tbaa !5
  %indvar.next = or disjoint i64 %indvar, 1
  %17 = mul i64 %indvar.next, %6
  %scevgep.1 = getelementptr i8, ptr %5, i64 %17
  tail call void @llvm.memset.p0.i64(ptr align 1 %scevgep.1, i8 0, i64 %13, i1 false), !tbaa !5
  %indvar.next.1 = or disjoint i64 %indvar, 2
  %18 = mul i64 %indvar.next.1, %6
  %scevgep.2 = getelementptr i8, ptr %5, i64 %18
  tail call void @llvm.memset.p0.i64(ptr align 1 %scevgep.2, i8 0, i64 %13, i1 false), !tbaa !5
  %indvar.next.2 = or disjoint i64 %indvar, 3
  %19 = mul i64 %indvar.next.2, %6
  %scevgep.3 = getelementptr i8, ptr %5, i64 %19
  tail call void @llvm.memset.p0.i64(ptr align 1 %scevgep.3, i8 0, i64 %13, i1 false), !tbaa !5
  %indvar.next.3 = or disjoint i64 %indvar, 4
  %20 = mul i64 %indvar.next.3, %6
  %scevgep.4 = getelementptr i8, ptr %5, i64 %20
  tail call void @llvm.memset.p0.i64(ptr align 1 %scevgep.4, i8 0, i64 %13, i1 false), !tbaa !5
  %indvar.next.4 = or disjoint i64 %indvar, 5
  %21 = mul i64 %indvar.next.4, %6
  %scevgep.5 = getelementptr i8, ptr %5, i64 %21
  tail call void @llvm.memset.p0.i64(ptr align 1 %scevgep.5, i8 0, i64 %13, i1 false), !tbaa !5
  %indvar.next.5 = or disjoint i64 %indvar, 6
  %22 = mul i64 %indvar.next.5, %6
  %scevgep.6 = getelementptr i8, ptr %5, i64 %22
  tail call void @llvm.memset.p0.i64(ptr align 1 %scevgep.6, i8 0, i64 %13, i1 false), !tbaa !5
  %indvar.next.6 = or disjoint i64 %indvar, 7
  %23 = mul i64 %indvar.next.6, %6
  %scevgep.7 = getelementptr i8, ptr %5, i64 %23
  tail call void @llvm.memset.p0.i64(ptr align 1 %scevgep.7, i8 0, i64 %13, i1 false), !tbaa !5
  %indvar.next.7 = add nuw nsw i64 %indvar, 8
  %niter94.next.7 = add i64 %niter94, 8
  %niter94.ncmp.7 = icmp eq i64 %niter94.next.7, %unroll_iter93
  br i1 %niter94.ncmp.7, label %.loopexit.loopexit.unr-lcssa, label %.lr.ph.us73, !llvm.loop !8

24:                                               ; preds = %10
  %25 = getelementptr inbounds i8, ptr %0, i64 64
  %26 = load i32, ptr %25, align 16, !tbaa !10
  %27 = icmp ugt i32 %26, %1
  %28 = icmp ugt i32 %26, %2
  %or.cond58 = and i1 %27, %28
  br i1 %or.cond58, label %32, label %29

29:                                               ; preds = %24
  %30 = tail call noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef nonnull @.str.22, ptr noundef nonnull @.str.2, i32 noundef 1248)
  br i1 %30, label %31, label %32

31:                                               ; preds = %29
  tail call void asm sideeffect "int $$0x3", "~{dirflag},~{fpsr},~{flags}"() #4, !srcloc !25
  br label %32

32:                                               ; preds = %24, %31, %29
  %33 = add i32 %3, %1
  %34 = load i32, ptr %25, align 16, !tbaa !10
  %35 = icmp ult i32 %33, %34
  %36 = add i32 %4, %2
  %37 = icmp ult i32 %36, %34
  %or.cond60 = and i1 %35, %37
  br i1 %or.cond60, label %.lr.ph.us.preheader, label %38

38:                                               ; preds = %32
  %39 = tail call noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef nonnull @.str.25, ptr noundef nonnull @.str.2, i32 noundef 1249)
  br i1 %39, label %40, label %.lr.ph.us.preheader

40:                                               ; preds = %38
  tail call void asm sideeffect "int $$0x3", "~{dirflag},~{fpsr},~{flags}"() #4, !srcloc !26
  br label %.lr.ph.us.preheader

.lr.ph.us.preheader:                              ; preds = %32, %38, %40
  %41 = load i32, ptr %25, align 16, !tbaa !10
  %42 = add i32 %41, -1
  %43 = getelementptr inbounds i8, ptr %0, i64 168
  %44 = load i32, ptr %43, align 8, !tbaa !27
  %notmask = shl nsw i32 -1, %44
  %45 = xor i32 %notmask, -1
  %wide.trip.count = zext i32 %4 to i64
  %xtraiter = and i32 %3, 1
  %46 = icmp eq i32 %3, 1
  %unroll_iter = and i32 %3, -2
  %lcmp.mod.not = icmp eq i32 %xtraiter, 0
  br label %.lr.ph.us

.lr.ph.us:                                        ; preds = %.lr.ph.us.preheader, %._crit_edge.us
  %47 = phi i32 [ %44, %.lr.ph.us.preheader ], [ %.lcssa, %._crit_edge.us ]
  %indvars.iv = phi i64 [ 0, %.lr.ph.us.preheader ], [ %indvars.iv.next, %._crit_edge.us ]
  %48 = trunc nuw i64 %indvars.iv to i32
  %49 = add i32 %48, %2
  %50 = mul i32 %49, %42
  %51 = add i32 %50, %1
  %52 = mul i32 %47, %51
  %53 = tail call noundef ptr @_ZNK3JPH5ArrayIhNS_12STLAllocatorIhEEE4dataEv(ptr noundef nonnull align 8 dereferenceable(24) %11)
  %54 = lshr i32 %52, 3
  %55 = zext nneg i32 %54 to i64
  %56 = getelementptr inbounds i8, ptr %53, i64 %55
  %57 = mul nsw i64 %indvars.iv, %6
  %58 = getelementptr inbounds i8, ptr %5, i64 %57
  br i1 %46, label %._crit_edge.us.unr-lcssa, label %.lr.ph.us.new

.lr.ph.us.new:                                    ; preds = %.lr.ph.us, %.lr.ph.us.new
  %.04864.us = phi ptr [ %80, %.lr.ph.us.new ], [ %58, %.lr.ph.us ]
  %.04963.us = phi ptr [ %79, %.lr.ph.us.new ], [ %56, %.lr.ph.us ]
  %.050.in62.us = phi i32 [ %76, %.lr.ph.us.new ], [ %52, %.lr.ph.us ]
  %niter = phi i32 [ %niter.next.1, %.lr.ph.us.new ], [ 0, %.lr.ph.us ]
  %.050.us = and i32 %.050.in62.us, 7
  %59 = load i16, ptr %.04963.us, align 1
  %60 = zext i16 %59 to i32
  %61 = lshr i32 %60, %.050.us
  %62 = and i32 %61, %45
  %63 = trunc i32 %62 to i8
  store i8 %63, ptr %.04864.us, align 1, !tbaa !5
  %64 = load i32, ptr %43, align 8, !tbaa !27
  %65 = add i32 %64, %.050.us
  %66 = lshr i32 %65, 3
  %67 = zext nneg i32 %66 to i64
  %68 = getelementptr inbounds i8, ptr %.04963.us, i64 %67
  %69 = getelementptr inbounds i8, ptr %.04864.us, i64 1
  %.050.us.1 = and i32 %65, 7
  %70 = load i16, ptr %68, align 1
  %71 = zext i16 %70 to i32
  %72 = lshr i32 %71, %.050.us.1
  %73 = and i32 %72, %45
  %74 = trunc i32 %73 to i8
  store i8 %74, ptr %69, align 1, !tbaa !5
  %75 = load i32, ptr %43, align 8, !tbaa !27
  %76 = add i32 %75, %.050.us.1
  %77 = lshr i32 %76, 3
  %78 = zext nneg i32 %77 to i64
  %79 = getelementptr inbounds i8, ptr %68, i64 %78
  %80 = getelementptr inbounds i8, ptr %.04864.us, i64 2
  %niter.next.1 = add i32 %niter, 2
  %niter.ncmp.1 = icmp eq i32 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %._crit_edge.us.unr-lcssa, label %.lr.ph.us.new, !llvm.loop !28

._crit_edge.us.unr-lcssa:                         ; preds = %.lr.ph.us.new, %.lr.ph.us
  %.lcssa.ph = phi i32 [ poison, %.lr.ph.us ], [ %75, %.lr.ph.us.new ]
  %.04864.us.unr = phi ptr [ %58, %.lr.ph.us ], [ %80, %.lr.ph.us.new ]
  %.04963.us.unr = phi ptr [ %56, %.lr.ph.us ], [ %79, %.lr.ph.us.new ]
  %.050.in62.us.unr = phi i32 [ %52, %.lr.ph.us ], [ %76, %.lr.ph.us.new ]
  br i1 %lcmp.mod.not, label %._crit_edge.us, label %._crit_edge.us.epilog-lcssa

._crit_edge.us.epilog-lcssa:                      ; preds = %._crit_edge.us.unr-lcssa
  %.050.us.epil = and i32 %.050.in62.us.unr, 7
  %81 = load i16, ptr %.04963.us.unr, align 1
  %82 = zext i16 %81 to i32
  %83 = lshr i32 %82, %.050.us.epil
  %84 = and i32 %83, %45
  %85 = trunc i32 %84 to i8
  store i8 %85, ptr %.04864.us.unr, align 1, !tbaa !5
  %86 = load i32, ptr %43, align 8, !tbaa !27
  br label %._crit_edge.us

._crit_edge.us:                                   ; preds = %._crit_edge.us.unr-lcssa, %._crit_edge.us.epilog-lcssa
  %.lcssa = phi i32 [ %.lcssa.ph, %._crit_edge.us.unr-lcssa ], [ %86, %._crit_edge.us.epilog-lcssa ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond82.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond82.not, label %.loopexit, label %.lr.ph.us, !llvm.loop !29

.loopexit.loopexit.unr-lcssa:                     ; preds = %.lr.ph.us73, %.lr.ph.us73.preheader
  %indvar.unr = phi i64 [ 0, %.lr.ph.us73.preheader ], [ %indvar.next.7, %.lr.ph.us73 ]
  %lcmp.mod92.not = icmp eq i64 %xtraiter91, 0
  br i1 %lcmp.mod92.not, label %.loopexit, label %.lr.ph.us73.epil

.lr.ph.us73.epil:                                 ; preds = %.loopexit.loopexit.unr-lcssa, %.lr.ph.us73.epil
  %indvar.epil = phi i64 [ %indvar.next.epil, %.lr.ph.us73.epil ], [ %indvar.unr, %.loopexit.loopexit.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.lr.ph.us73.epil ], [ 0, %.loopexit.loopexit.unr-lcssa ]
  %87 = mul i64 %indvar.epil, %6
  %scevgep.epil = getelementptr i8, ptr %5, i64 %87
  tail call void @llvm.memset.p0.i64(ptr align 1 %scevgep.epil, i8 0, i64 %13, i1 false), !tbaa !5
  %indvar.next.epil = add nuw nsw i64 %indvar.epil, 1
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter91
  br i1 %epil.iter.cmp.not, label %.loopexit, label %.lr.ph.us73.epil, !llvm.loop !30

.loopexit:                                        ; preds = %._crit_edge.us, %.loopexit.loopexit.unr-lcssa, %.lr.ph.us73.epil, %7
  ret void
}

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

attributes #0 = { 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 #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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = distinct !{!8, !9}
!9 = !{!"llvm.loop.mustprogress"}
!10 = !{!11, !16, i64 64}
!11 = !{!"_ZTSN3JPH16HeightFieldShapeE", !12, i64 0, !20, i64 32, !20, i64 48, !16, i64 64, !16, i64 68, !16, i64 72, !16, i64 76, !16, i64 80, !6, i64 84, !6, i64 85, !21, i64 86, !21, i64 88, !22, i64 96, !22, i64 104, !22, i64 112, !23, i64 120, !24, i64 144, !16, i64 168}
!12 = !{!"_ZTSN3JPH5ShapeE", !13, i64 8, !17, i64 16, !18, i64 24, !19, i64 25}
!13 = !{!"_ZTSN3JPH9RefTargetINS_5ShapeEEE", !14, i64 0}
!14 = !{!"_ZTSSt6atomicIjE", !15, i64 0}
!15 = !{!"_ZTSSt13__atomic_baseIjE", !16, i64 0}
!16 = !{!"int", !6, i64 0}
!17 = !{!"long", !6, i64 0}
!18 = !{!"_ZTSN3JPH10EShapeTypeE", !6, i64 0}
!19 = !{!"_ZTSN3JPH13EShapeSubTypeE", !6, i64 0}
!20 = !{!"_ZTSN3JPH4Vec3E", !6, i64 0}
!21 = !{!"short", !6, i64 0}
!22 = !{!"any pointer", !6, i64 0}
!23 = !{!"_ZTSN3JPH5ArrayINS_8RefConstINS_15PhysicsMaterialEEENS_12STLAllocatorIS3_EEEE", !17, i64 0, !17, i64 8, !22, i64 16}
!24 = !{!"_ZTSN3JPH5ArrayIhNS_12STLAllocatorIhEEEE", !17, i64 0, !17, i64 8, !22, i64 16}
!25 = !{i64 2158618423}
!26 = !{i64 2158618854}
!27 = !{!11, !16, i64 168}
!28 = distinct !{!28, !9}
!29 = distinct !{!29, !9}
!30 = distinct !{!30, !31}
!31 = !{!"llvm.loop.unroll.disable"}


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