; LLVM IR from aap/librw :: src/d3d/d3d9.ll (ZN2rw4d3d915writeNativeDataEPNS_6StreamEiPvii)

; 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.rw::MemoryFunctions" = type { ptr, ptr, ptr, ptr, ptr }
%"struct.rw::d3d9::VertexElement" = type { i16, i16, i8, i8, i8, i8 }
%"struct.rw::Geometry" = type { %"struct.rw::Object", i32, i16, i32, i32, i32, i32, ptr, ptr, [8 x ptr], ptr, %"struct.rw::MaterialList", ptr, ptr, i32 }
%"struct.rw::Object" = type { i8, i8, i8, i8, ptr }
%"struct.rw::MaterialList" = type { ptr, i32, i32 }
%"struct.rw::InstanceDataHeader" = type { i32 }
%"struct.rw::MeshHeader" = type { i32, i16, i16, i32, i32 }
%"struct.rw::d3d9::InstanceDataHeader" = type { %"struct.rw::InstanceDataHeader", i32, i32, ptr, i32, [2 x %"struct.rw::d3d9::VertexStream"], i32, ptr, i32, i32, ptr }
%"struct.rw::d3d9::VertexStream" = type { ptr, i32, i32, i16, i8, i8 }
%"struct.rw::d3d9::InstanceData" = type { i32, i32, ptr, i32, ptr, i32, i32, i32, i32 }

@_ZN2rw6Engine8memfuncsE = external global %"struct.rw::MemoryFunctions", align 8
@.str.10 = external hidden unnamed_addr constant [76 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: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZN2rw14mustmalloc_LOCEmjPKc(i64 noundef, i32 noundef, ptr noundef) #1

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN2rw4d3d914getDeclarationEPvPNS0_13VertexElementE(ptr noundef, ptr noundef) #2

declare noundef ptr @_ZN2rw3d3d11lockIndicesEPvjjj(ptr noundef, i32 noundef, i32 noundef, i32 noundef) #3

declare void @_ZN2rw3d3d13unlockIndicesEPv(ptr noundef) #3

declare noundef ptr @_ZN2rw3d3d12lockVerticesEPvjjj(ptr noundef, i32 noundef, i32 noundef, i32 noundef) #3

declare void @_ZN2rw3d3d14unlockVerticesEPv(ptr noundef) #3

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN2rw4d3d915writeNativeDataEPNS_6StreamEiPvii(ptr noundef %0, i32 noundef %1, ptr noundef %2, i32 noundef %3, i32 noundef %4) #4 {
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  %14 = alloca ptr, align 8
  %15 = alloca i32, align 4
  %16 = alloca ptr, align 8
  %17 = alloca ptr, align 8
  %18 = alloca ptr, align 8
  %19 = alloca i32, align 4
  %20 = alloca i32, align 4
  %21 = alloca [12 x %"struct.rw::d3d9::VertexElement"], align 16
  %22 = alloca i32, align 4
  %23 = alloca ptr, align 8
  %24 = alloca ptr, align 8
  %25 = alloca i32, align 4
  %26 = alloca ptr, align 8
  store ptr %0, ptr %7, align 8, !tbaa !5
  store i32 %1, ptr %8, align 4, !tbaa !9
  store ptr %2, ptr %9, align 8, !tbaa !5
  store i32 %3, ptr %10, align 4, !tbaa !9
  store i32 %4, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  %27 = load ptr, ptr %9, align 8, !tbaa !5
  store ptr %27, ptr %12, align 8, !tbaa !5
  %28 = load ptr, ptr %7, align 8, !tbaa !5
  %29 = load i32, ptr %8, align 4, !tbaa !9
  %30 = sub nsw i32 %29, 12
  %31 = call noundef zeroext i1 @_ZN2rw16writeChunkHeaderEPNS_6StreamEii(ptr noundef %28, i32 noundef 1, i32 noundef %30)
  %32 = load ptr, ptr %12, align 8, !tbaa !5
  %33 = getelementptr inbounds %"struct.rw::Geometry", ptr %32, i32 0, i32 13
  %34 = load ptr, ptr %33, align 8, !tbaa !11
  %35 = icmp eq ptr %34, null
  br i1 %35, label %43, label %36

36:                                               ; preds = %5
  %37 = load ptr, ptr %12, align 8, !tbaa !5
  %38 = getelementptr inbounds %"struct.rw::Geometry", ptr %37, i32 0, i32 13
  %39 = load ptr, ptr %38, align 8, !tbaa !11
  %40 = getelementptr inbounds %"struct.rw::InstanceDataHeader", ptr %39, i32 0, i32 0
  %41 = load i32, ptr %40, align 4, !tbaa !16
  %42 = icmp ne i32 %41, 9
  br i1 %42, label %43, label %45

43:                                               ; preds = %36, %5
  %44 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %44, ptr %6, align 8
  store i32 1, ptr %13, align 4
  br label %308

45:                                               ; preds = %36
  %46 = load ptr, ptr %7, align 8, !tbaa !5
  %47 = call noundef i32 @_ZN2rw6Stream8writeU32Ej(ptr noundef nonnull align 8 dereferenceable(8) %46, i32 noundef 9)
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #5
  %48 = load ptr, ptr %12, align 8, !tbaa !5
  %49 = getelementptr inbounds %"struct.rw::Geometry", ptr %48, i32 0, i32 13
  %50 = load ptr, ptr %49, align 8, !tbaa !11
  store ptr %50, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #5
  %51 = load ptr, ptr %12, align 8, !tbaa !5
  %52 = getelementptr inbounds %"struct.rw::Geometry", ptr %51, i32 0, i32 12
  %53 = load ptr, ptr %52, align 8, !tbaa !18
  %54 = getelementptr inbounds %"struct.rw::MeshHeader", ptr %53, i32 0, i32 1
  %55 = load i16, ptr %54, align 4, !tbaa !19
  %56 = zext i16 %55 to i32
  %57 = mul nsw i32 %56, 36
  %58 = add nsw i32 64, %57
  store i32 %58, ptr %15, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #5
  %59 = load i32, ptr %15, align 4, !tbaa !9
  %60 = sext i32 %59 to i64
  %61 = mul i64 %60, 1
  %62 = call noundef ptr @_ZN2rw14mustmalloc_LOCEmjPKc(i64 noundef %61, i32 noundef 65551, ptr noundef @.str.10)
  store ptr %62, ptr %16, align 8, !tbaa !5
  %63 = load ptr, ptr %7, align 8, !tbaa !5
  %64 = load i32, ptr %15, align 4, !tbaa !9
  %65 = call noundef i32 @_ZN2rw6Stream8writeI32Ei(ptr noundef nonnull align 8 dereferenceable(8) %63, i32 noundef %64)
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #5
  %66 = load ptr, ptr %16, align 8, !tbaa !5
  store ptr %66, ptr %17, align 8, !tbaa !5
  %67 = load ptr, ptr %14, align 8, !tbaa !5
  %68 = getelementptr inbounds %"struct.rw::d3d9::InstanceDataHeader", ptr %67, i32 0, i32 1
  %69 = load i32, ptr %68, align 4, !tbaa !21
  %70 = load ptr, ptr %17, align 8, !tbaa !5
  store i32 %69, ptr %70, align 4, !tbaa !9
  %71 = load ptr, ptr %17, align 8, !tbaa !5
  %72 = getelementptr inbounds i8, ptr %71, i64 4
  store ptr %72, ptr %17, align 8, !tbaa !5
  %73 = load ptr, ptr %14, align 8, !tbaa !5
  %74 = getelementptr inbounds %"struct.rw::d3d9::InstanceDataHeader", ptr %73, i32 0, i32 2
  %75 = load i32, ptr %74, align 8, !tbaa !23
  %76 = load ptr, ptr %17, align 8, !tbaa !5
  store i32 %75, ptr %76, align 4, !tbaa !9
  %77 = load ptr, ptr %17, align 8, !tbaa !5
  %78 = getelementptr inbounds i8, ptr %77, i64 4
  store ptr %78, ptr %17, align 8, !tbaa !5
  %79 = load ptr, ptr %17, align 8, !tbaa !5
  %80 = getelementptr inbounds i8, ptr %79, i64 4
  store ptr %80, ptr %17, align 8, !tbaa !5
  %81 = load ptr, ptr %14, align 8, !tbaa !5
  %82 = getelementptr inbounds %"struct.rw::d3d9::InstanceDataHeader", ptr %81, i32 0, i32 4
  %83 = load i32, ptr %82, align 8, !tbaa !24
  %84 = load ptr, ptr %17, align 8, !tbaa !5
  store i32 %83, ptr %84, align 4, !tbaa !9
  %85 = load ptr, ptr %17, align 8, !tbaa !5
  %86 = getelementptr inbounds i8, ptr %85, i64 4
  store ptr %86, ptr %17, align 8, !tbaa !5
  %87 = load ptr, ptr %17, align 8, !tbaa !5
  %88 = getelementptr inbounds i8, ptr %87, i64 32
  store ptr %88, ptr %17, align 8, !tbaa !5
  %89 = load ptr, ptr %14, align 8, !tbaa !5
  %90 = getelementptr inbounds %"struct.rw::d3d9::InstanceDataHeader", ptr %89, i32 0, i32 6
  %91 = load i32, ptr %90, align 8, !tbaa !25
  %92 = load ptr, ptr %17, align 8, !tbaa !5
  store i32 %91, ptr %92, align 4, !tbaa !9
  %93 = load ptr, ptr %17, align 8, !tbaa !5
  %94 = getelementptr inbounds i8, ptr %93, i64 4
  store ptr %94, ptr %17, align 8, !tbaa !5
  %95 = load ptr, ptr %17, align 8, !tbaa !5
  %96 = getelementptr inbounds i8, ptr %95, i64 4
  store ptr %96, ptr %17, align 8, !tbaa !5
  %97 = load ptr, ptr %14, align 8, !tbaa !5
  %98 = getelementptr inbounds %"struct.rw::d3d9::InstanceDataHeader", ptr %97, i32 0, i32 8
  %99 = load i32, ptr %98, align 8, !tbaa !26
  %100 = load ptr, ptr %17, align 8, !tbaa !5
  store i32 %99, ptr %100, align 4, !tbaa !9
  %101 = load ptr, ptr %17, align 8, !tbaa !5
  %102 = getelementptr inbounds i8, ptr %101, i64 4
  store ptr %102, ptr %17, align 8, !tbaa !5
  %103 = load ptr, ptr %14, align 8, !tbaa !5
  %104 = getelementptr inbounds %"struct.rw::d3d9::InstanceDataHeader", ptr %103, i32 0, i32 9
  %105 = load i32, ptr %104, align 4, !tbaa !27
  %106 = load ptr, ptr %17, align 8, !tbaa !5
  store i32 %105, ptr %106, align 4, !tbaa !9
  %107 = load ptr, ptr %17, align 8, !tbaa !5
  %108 = getelementptr inbounds i8, ptr %107, i64 4
  store ptr %108, ptr %17, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #5
  %109 = load ptr, ptr %14, align 8, !tbaa !5
  %110 = getelementptr inbounds %"struct.rw::d3d9::InstanceDataHeader", ptr %109, i32 0, i32 10
  %111 = load ptr, ptr %110, align 8, !tbaa !28
  store ptr %111, ptr %18, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #5
  store i32 0, ptr %19, align 4, !tbaa !9
  br label %112

112:                                              ; preds = %177, %45
  %113 = load i32, ptr %19, align 4, !tbaa !9
  %114 = load ptr, ptr %14, align 8, !tbaa !5
  %115 = getelementptr inbounds %"struct.rw::d3d9::InstanceDataHeader", ptr %114, i32 0, i32 2
  %116 = load i32, ptr %115, align 8, !tbaa !23
  %117 = icmp ult i32 %113, %116
  br i1 %117, label %119, label %118

118:                                              ; preds = %112
  store i32 2, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #5
  br label %180

119:                                              ; preds = %112
  %120 = load ptr, ptr %18, align 8, !tbaa !5
  %121 = getelementptr inbounds %"struct.rw::d3d9::InstanceData", ptr %120, i32 0, i32 0
  %122 = load i32, ptr %121, align 8, !tbaa !29
  %123 = load ptr, ptr %17, align 8, !tbaa !5
  store i32 %122, ptr %123, align 4, !tbaa !9
  %124 = load ptr, ptr %17, align 8, !tbaa !5
  %125 = getelementptr inbounds i8, ptr %124, i64 4
  store ptr %125, ptr %17, align 8, !tbaa !5
  %126 = load ptr, ptr %18, align 8, !tbaa !5
  %127 = getelementptr inbounds %"struct.rw::d3d9::InstanceData", ptr %126, i32 0, i32 1
  %128 = load i32, ptr %127, align 4, !tbaa !31
  %129 = load ptr, ptr %17, align 8, !tbaa !5
  store i32 %128, ptr %129, align 4, !tbaa !9
  %130 = load ptr, ptr %17, align 8, !tbaa !5
  %131 = getelementptr inbounds i8, ptr %130, i64 4
  store ptr %131, ptr %17, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #5
  %132 = load ptr, ptr %12, align 8, !tbaa !5
  %133 = getelementptr inbounds %"struct.rw::Geometry", ptr %132, i32 0, i32 11
  %134 = load ptr, ptr %18, align 8, !tbaa !5
  %135 = getelementptr inbounds %"struct.rw::d3d9::InstanceData", ptr %134, i32 0, i32 2
  %136 = load ptr, ptr %135, align 8, !tbaa !32
  %137 = call noundef i32 @_ZN2rw12MaterialList9findIndexEPNS_8MaterialE(ptr noundef nonnull align 8 dereferenceable(16) %133, ptr noundef %136)
  store i32 %137, ptr %20, align 4, !tbaa !9
  %138 = load i32, ptr %20, align 4, !tbaa !9
  %139 = load ptr, ptr %17, align 8, !tbaa !5
  store i32 %138, ptr %139, align 4, !tbaa !9
  %140 = load ptr, ptr %17, align 8, !tbaa !5
  %141 = getelementptr inbounds i8, ptr %140, i64 4
  store ptr %141, ptr %17, align 8, !tbaa !5
  %142 = load ptr, ptr %18, align 8, !tbaa !5
  %143 = getelementptr inbounds %"struct.rw::d3d9::InstanceData", ptr %142, i32 0, i32 3
  %144 = load i32, ptr %143, align 8, !tbaa !33
  %145 = load ptr, ptr %17, align 8, !tbaa !5
  store i32 %144, ptr %145, align 4, !tbaa !9
  %146 = load ptr, ptr %17, align 8, !tbaa !5
  %147 = getelementptr inbounds i8, ptr %146, i64 4
  store ptr %147, ptr %17, align 8, !tbaa !5
  %148 = load ptr, ptr %17, align 8, !tbaa !5
  store i32 0, ptr %148, align 4, !tbaa !9
  %149 = load ptr, ptr %17, align 8, !tbaa !5
  %150 = getelementptr inbounds i8, ptr %149, i64 4
  store ptr %150, ptr %17, align 8, !tbaa !5
  %151 = load ptr, ptr %18, align 8, !tbaa !5
  %152 = getelementptr inbounds %"struct.rw::d3d9::InstanceData", ptr %151, i32 0, i32 5
  %153 = load i32, ptr %152, align 8, !tbaa !34
  %154 = load ptr, ptr %17, align 8, !tbaa !5
  store i32 %153, ptr %154, align 4, !tbaa !9
  %155 = load ptr, ptr %17, align 8, !tbaa !5
  %156 = getelementptr inbounds i8, ptr %155, i64 4
  store ptr %156, ptr %17, align 8, !tbaa !5
  %157 = load ptr, ptr %18, align 8, !tbaa !5
  %158 = getelementptr inbounds %"struct.rw::d3d9::InstanceData", ptr %157, i32 0, i32 6
  %159 = load i32, ptr %158, align 4, !tbaa !35
  %160 = load ptr, ptr %17, align 8, !tbaa !5
  store i32 %159, ptr %160, align 4, !tbaa !9
  %161 = load ptr, ptr %17, align 8, !tbaa !5
  %162 = getelementptr inbounds i8, ptr %161, i64 4
  store ptr %162, ptr %17, align 8, !tbaa !5
  %163 = load ptr, ptr %18, align 8, !tbaa !5
  %164 = getelementptr inbounds %"struct.rw::d3d9::InstanceData", ptr %163, i32 0, i32 7
  %165 = load i32, ptr %164, align 8, !tbaa !36
  %166 = load ptr, ptr %17, align 8, !tbaa !5
  store i32 %165, ptr %166, align 4, !tbaa !9
  %167 = load ptr, ptr %17, align 8, !tbaa !5
  %168 = getelementptr inbounds i8, ptr %167, i64 4
  store ptr %168, ptr %17, align 8, !tbaa !5
  %169 = load ptr, ptr %18, align 8, !tbaa !5
  %170 = getelementptr inbounds %"struct.rw::d3d9::InstanceData", ptr %169, i32 0, i32 8
  %171 = load i32, ptr %170, align 4, !tbaa !37
  %172 = load ptr, ptr %17, align 8, !tbaa !5
  store i32 %171, ptr %172, align 4, !tbaa !9
  %173 = load ptr, ptr %17, align 8, !tbaa !5
  %174 = getelementptr inbounds i8, ptr %173, i64 4
  store ptr %174, ptr %17, align 8, !tbaa !5
  %175 = load ptr, ptr %18, align 8, !tbaa !5
  %176 = getelementptr inbounds %"struct.rw::d3d9::InstanceData", ptr %175, i32 1
  store ptr %176, ptr %18, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #5
  br label %177

177:                                              ; preds = %119
  %178 = load i32, ptr %19, align 4, !tbaa !9
  %179 = add i32 %178, 1
  store i32 %179, ptr %19, align 4, !tbaa !9
  br label %112, !llvm.loop !38

180:                                              ; preds = %118
  %181 = load ptr, ptr %7, align 8, !tbaa !5
  %182 = load ptr, ptr %16, align 8, !tbaa !5
  %183 = load i32, ptr %15, align 4, !tbaa !9
  %184 = load ptr, ptr %181, align 8, !tbaa !40
  %185 = getelementptr inbounds ptr, ptr %184, i64 3
  %186 = load ptr, ptr %185, align 8
  %187 = call noundef i32 %186(ptr noundef nonnull align 8 dereferenceable(8) %181, ptr noundef %182, i32 noundef %183)
  call void @llvm.lifetime.start.p0(i64 96, ptr %21) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #5
  %188 = load ptr, ptr %14, align 8, !tbaa !5
  %189 = getelementptr inbounds %"struct.rw::d3d9::InstanceDataHeader", ptr %188, i32 0, i32 7
  %190 = load ptr, ptr %189, align 8, !tbaa !42
  %191 = getelementptr inbounds [12 x %"struct.rw::d3d9::VertexElement"], ptr %21, i64 0, i64 0
  %192 = call noundef i32 @_ZN2rw4d3d914getDeclarationEPvPNS0_13VertexElementE(ptr noundef %190, ptr noundef %191)
  store i32 %192, ptr %22, align 4, !tbaa !9
  %193 = load ptr, ptr %7, align 8, !tbaa !5
  %194 = load i32, ptr %22, align 4, !tbaa !9
  %195 = call noundef i32 @_ZN2rw6Stream8writeU32Ej(ptr noundef nonnull align 8 dereferenceable(8) %193, i32 noundef %194)
  %196 = load ptr, ptr %7, align 8, !tbaa !5
  %197 = getelementptr inbounds [12 x %"struct.rw::d3d9::VertexElement"], ptr %21, i64 0, i64 0
  %198 = load i32, ptr %22, align 4, !tbaa !9
  %199 = mul i32 8, %198
  %200 = load ptr, ptr %196, align 8, !tbaa !40
  %201 = getelementptr inbounds ptr, ptr %200, i64 3
  %202 = load ptr, ptr %201, align 8
  %203 = call noundef i32 %202(ptr noundef nonnull align 8 dereferenceable(8) %196, ptr noundef %197, i32 noundef %199)
  call void @llvm.lifetime.start.p0(i64 8, ptr %23) #5
  %204 = load ptr, ptr %14, align 8, !tbaa !5
  %205 = getelementptr inbounds %"struct.rw::d3d9::InstanceDataHeader", ptr %204, i32 0, i32 3
  %206 = load ptr, ptr %205, align 8, !tbaa !43
  %207 = call noundef ptr @_ZN2rw3d3d11lockIndicesEPvjjj(ptr noundef %206, i32 noundef 0, i32 noundef 0, i32 noundef 0)
  store ptr %207, ptr %23, align 8, !tbaa !5
  %208 = load ptr, ptr %7, align 8, !tbaa !5
  %209 = load ptr, ptr %23, align 8, !tbaa !5
  %210 = load ptr, ptr %14, align 8, !tbaa !5
  %211 = getelementptr inbounds %"struct.rw::d3d9::InstanceDataHeader", ptr %210, i32 0, i32 8
  %212 = load i32, ptr %211, align 8, !tbaa !26
  %213 = mul i32 2, %212
  %214 = load ptr, ptr %208, align 8, !tbaa !40
  %215 = getelementptr inbounds ptr, ptr %214, i64 3
  %216 = load ptr, ptr %215, align 8
  %217 = call noundef i32 %216(ptr noundef nonnull align 8 dereferenceable(8) %208, ptr noundef %209, i32 noundef %213)
  %218 = load ptr, ptr %14, align 8, !tbaa !5
  %219 = getelementptr inbounds %"struct.rw::d3d9::InstanceDataHeader", ptr %218, i32 0, i32 3
  %220 = load ptr, ptr %219, align 8, !tbaa !43
  call void @_ZN2rw3d3d13unlockIndicesEPv(ptr noundef %220)
  call void @llvm.lifetime.start.p0(i64 8, ptr %24) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %25) #5
  store i32 0, ptr %25, align 4, !tbaa !9
  br label %221

221:                                              ; preds = %301, %180
  %222 = load i32, ptr %25, align 4, !tbaa !9
  %223 = icmp slt i32 %222, 2
  br i1 %223, label %225, label %224

224:                                              ; preds = %221
  store i32 5, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %25) #5
  br label %304

225:                                              ; preds = %221
  %226 = load ptr, ptr %14, align 8, !tbaa !5
  %227 = getelementptr inbounds %"struct.rw::d3d9::InstanceDataHeader", ptr %226, i32 0, i32 5
  %228 = load i32, ptr %25, align 4, !tbaa !9
  %229 = sext i32 %228 to i64
  %230 = getelementptr inbounds [2 x %"struct.rw::d3d9::VertexStream"], ptr %227, i64 0, i64 %229
  store ptr %230, ptr %24, align 8, !tbaa !5
  %231 = load ptr, ptr %16, align 8, !tbaa !5
  store ptr %231, ptr %17, align 8, !tbaa !5
  %232 = load ptr, ptr %24, align 8, !tbaa !5
  %233 = getelementptr inbounds %"struct.rw::d3d9::VertexStream", ptr %232, i32 0, i32 0
  %234 = load ptr, ptr %233, align 8, !tbaa !44
  %235 = icmp ne ptr %234, null
  %236 = zext i1 %235 to i64
  %237 = select i1 %235, i32 -1159811074, i32 0
  %238 = load ptr, ptr %17, align 8, !tbaa !5
  store i32 %237, ptr %238, align 4, !tbaa !9
  %239 = load ptr, ptr %17, align 8, !tbaa !5
  %240 = getelementptr inbounds i8, ptr %239, i64 4
  store ptr %240, ptr %17, align 8, !tbaa !5
  %241 = load ptr, ptr %24, align 8, !tbaa !5
  %242 = getelementptr inbounds %"struct.rw::d3d9::VertexStream", ptr %241, i32 0, i32 1
  %243 = load i32, ptr %242, align 8, !tbaa !46
  %244 = load ptr, ptr %17, align 8, !tbaa !5
  store i32 %243, ptr %244, align 4, !tbaa !9
  %245 = load ptr, ptr %17, align 8, !tbaa !5
  %246 = getelementptr inbounds i8, ptr %245, i64 4
  store ptr %246, ptr %17, align 8, !tbaa !5
  %247 = load ptr, ptr %24, align 8, !tbaa !5
  %248 = getelementptr inbounds %"struct.rw::d3d9::VertexStream", ptr %247, i32 0, i32 2
  %249 = load i32, ptr %248, align 4, !tbaa !47
  %250 = load ptr, ptr %17, align 8, !tbaa !5
  store i32 %249, ptr %250, align 4, !tbaa !9
  %251 = load ptr, ptr %17, align 8, !tbaa !5
  %252 = getelementptr inbounds i8, ptr %251, i64 4
  store ptr %252, ptr %17, align 8, !tbaa !5
  %253 = load ptr, ptr %24, align 8, !tbaa !5
  %254 = getelementptr inbounds %"struct.rw::d3d9::VertexStream", ptr %253, i32 0, i32 3
  %255 = load i16, ptr %254, align 8, !tbaa !48
  %256 = load ptr, ptr %17, align 8, !tbaa !5
  store i16 %255, ptr %256, align 2, !tbaa !49
  %257 = load ptr, ptr %17, align 8, !tbaa !5
  %258 = getelementptr inbounds i8, ptr %257, i64 2
  store ptr %258, ptr %17, align 8, !tbaa !5
  %259 = load ptr, ptr %24, align 8, !tbaa !5
  %260 = getelementptr inbounds %"struct.rw::d3d9::VertexStream", ptr %259, i32 0, i32 4
  %261 = load i8, ptr %260, align 2, !tbaa !50
  %262 = load ptr, ptr %17, align 8, !tbaa !5
  %263 = getelementptr inbounds i8, ptr %262, i32 1
  store ptr %263, ptr %17, align 8, !tbaa !5
  store i8 %261, ptr %262, align 1, !tbaa !51
  %264 = load ptr, ptr %24, align 8, !tbaa !5
  %265 = getelementptr inbounds %"struct.rw::d3d9::VertexStream", ptr %264, i32 0, i32 5
  %266 = load i8, ptr %265, align 1, !tbaa !52
  %267 = load ptr, ptr %17, align 8, !tbaa !5
  %268 = getelementptr inbounds i8, ptr %267, i32 1
  store ptr %268, ptr %17, align 8, !tbaa !5
  store i8 %266, ptr %267, align 1, !tbaa !51
  %269 = load ptr, ptr %7, align 8, !tbaa !5
  %270 = load ptr, ptr %16, align 8, !tbaa !5
  %271 = load ptr, ptr %269, align 8, !tbaa !40
  %272 = getelementptr inbounds ptr, ptr %271, i64 3
  %273 = load ptr, ptr %272, align 8
  %274 = call noundef i32 %273(ptr noundef nonnull align 8 dereferenceable(8) %269, ptr noundef %270, i32 noundef 16)
  %275 = load ptr, ptr %24, align 8, !tbaa !5
  %276 = getelementptr inbounds %"struct.rw::d3d9::VertexStream", ptr %275, i32 0, i32 0
  %277 = load ptr, ptr %276, align 8, !tbaa !44
  %278 = icmp eq ptr %277, null
  br i1 %278, label %279, label %280

279:                                              ; preds = %225
  br label %301

280:                                              ; preds = %225
  call void @llvm.lifetime.start.p0(i64 8, ptr %26) #5
  %281 = load ptr, ptr %24, align 8, !tbaa !5
  %282 = getelementptr inbounds %"struct.rw::d3d9::VertexStream", ptr %281, i32 0, i32 0
  %283 = load ptr, ptr %282, align 8, !tbaa !44
  %284 = call noundef ptr @_ZN2rw3d3d12lockVerticesEPvjjj(ptr noundef %283, i32 noundef 0, i32 noundef 0, i32 noundef 0)
  store ptr %284, ptr %26, align 8, !tbaa !5
  %285 = load ptr, ptr %7, align 8, !tbaa !5
  %286 = load ptr, ptr %26, align 8, !tbaa !5
  %287 = load ptr, ptr %24, align 8, !tbaa !5
  %288 = getelementptr inbounds %"struct.rw::d3d9::VertexStream", ptr %287, i32 0, i32 2
  %289 = load i32, ptr %288, align 4, !tbaa !47
  %290 = load ptr, ptr %14, align 8, !tbaa !5
  %291 = getelementptr inbounds %"struct.rw::d3d9::InstanceDataHeader", ptr %290, i32 0, i32 9
  %292 = load i32, ptr %291, align 4, !tbaa !27
  %293 = mul i32 %289, %292
  %294 = load ptr, ptr %285, align 8, !tbaa !40
  %295 = getelementptr inbounds ptr, ptr %294, i64 3
  %296 = load ptr, ptr %295, align 8
  %297 = call noundef i32 %296(ptr noundef nonnull align 8 dereferenceable(8) %285, ptr noundef %286, i32 noundef %293)
  %298 = load ptr, ptr %24, align 8, !tbaa !5
  %299 = getelementptr inbounds %"struct.rw::d3d9::VertexStream", ptr %298, i32 0, i32 0
  %300 = load ptr, ptr %299, align 8, !tbaa !44
  call void @_ZN2rw3d3d14unlockVerticesEPv(ptr noundef %300)
  call void @llvm.lifetime.end.p0(i64 8, ptr %26) #5
  br label %301

301:                                              ; preds = %280, %279
  %302 = load i32, ptr %25, align 4, !tbaa !9
  %303 = add nsw i32 %302, 1
  store i32 %303, ptr %25, align 4, !tbaa !9
  br label %221, !llvm.loop !53

304:                                              ; preds = %224
  %305 = load ptr, ptr getelementptr inbounds (%"struct.rw::MemoryFunctions", ptr @_ZN2rw6Engine8memfuncsE, i32 0, i32 2), align 8, !tbaa !54
  %306 = load ptr, ptr %16, align 8, !tbaa !5
  call void %305(ptr noundef %306)
  %307 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %307, ptr %6, align 8
  store i32 1, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %24) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %23) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #5
  call void @llvm.lifetime.end.p0(i64 96, ptr %21) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #5
  br label %308

308:                                              ; preds = %304, %43
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  %309 = load ptr, ptr %6, align 8
  ret ptr %309
}

declare noundef zeroext i1 @_ZN2rw16writeChunkHeaderEPNS_6StreamEii(ptr noundef, i32 noundef, i32 noundef) #3

declare noundef i32 @_ZN2rw6Stream8writeU32Ej(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) #3

declare noundef i32 @_ZN2rw6Stream8writeI32Ei(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) #3

declare noundef i32 @_ZN2rw12MaterialList9findIndexEPNS_8MaterialE(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef) #3

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 = { 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 = { "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 = { 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 #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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 152}
!12 = !{!"_ZTSN2rw8GeometryE", !13, i64 0, !10, i64 16, !14, i64 20, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !6, i64 40, !6, i64 48, !7, i64 56, !6, i64 120, !15, i64 128, !6, i64 144, !6, i64 152, !10, i64 160}
!13 = !{!"_ZTSN2rw6ObjectE", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3, !6, i64 8}
!14 = !{!"short", !7, i64 0}
!15 = !{!"_ZTSN2rw12MaterialListE", !6, i64 0, !10, i64 8, !10, i64 12}
!16 = !{!17, !10, i64 0}
!17 = !{!"_ZTSN2rw18InstanceDataHeaderE", !10, i64 0}
!18 = !{!12, !6, i64 144}
!19 = !{!20, !14, i64 4}
!20 = !{!"_ZTSN2rw10MeshHeaderE", !10, i64 0, !14, i64 4, !14, i64 6, !10, i64 8, !10, i64 12}
!21 = !{!22, !10, i64 4}
!22 = !{!"_ZTSN2rw4d3d918InstanceDataHeaderE", !17, i64 0, !10, i64 4, !10, i64 8, !6, i64 16, !10, i64 24, !7, i64 32, !10, i64 80, !6, i64 88, !10, i64 96, !10, i64 100, !6, i64 104}
!23 = !{!22, !10, i64 8}
!24 = !{!22, !10, i64 24}
!25 = !{!22, !10, i64 80}
!26 = !{!22, !10, i64 96}
!27 = !{!22, !10, i64 100}
!28 = !{!22, !6, i64 104}
!29 = !{!30, !10, i64 0}
!30 = !{!"_ZTSN2rw4d3d912InstanceDataE", !10, i64 0, !10, i64 4, !6, i64 8, !10, i64 16, !6, i64 24, !10, i64 32, !10, i64 36, !10, i64 40, !10, i64 44}
!31 = !{!30, !10, i64 4}
!32 = !{!30, !6, i64 8}
!33 = !{!30, !10, i64 16}
!34 = !{!30, !10, i64 32}
!35 = !{!30, !10, i64 36}
!36 = !{!30, !10, i64 40}
!37 = !{!30, !10, i64 44}
!38 = distinct !{!38, !39}
!39 = !{!"llvm.loop.mustprogress"}
!40 = !{!41, !41, i64 0}
!41 = !{!"vtable pointer", !8, i64 0}
!42 = !{!22, !6, i64 88}
!43 = !{!22, !6, i64 16}
!44 = !{!45, !6, i64 0}
!45 = !{!"_ZTSN2rw4d3d912VertexStreamE", !6, i64 0, !10, i64 8, !10, i64 12, !14, i64 16, !7, i64 18, !7, i64 19}
!46 = !{!45, !10, i64 8}
!47 = !{!45, !10, i64 12}
!48 = !{!45, !14, i64 16}
!49 = !{!14, !14, i64 0}
!50 = !{!45, !7, i64 18}
!51 = !{!7, !7, i64 0}
!52 = !{!45, !7, i64 19}
!53 = distinct !{!53, !39}
!54 = !{!55, !6, i64 16}
!55 = !{!"_ZTSN2rw15MemoryFunctionsE", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32}


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

%"struct.rw::MemoryFunctions" = type { ptr, ptr, ptr, ptr, ptr }
%"struct.rw::d3d9::VertexElement" = type { i16, i16, i8, i8, i8, i8 }

@_ZN2rw6Engine8memfuncsE = external local_unnamed_addr global %"struct.rw::MemoryFunctions", align 8
@.str.10 = external hidden unnamed_addr constant [76 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: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZN2rw14mustmalloc_LOCEmjPKc(i64 noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN2rw4d3d914getDeclarationEPvPNS0_13VertexElementE(ptr noundef, ptr noundef) local_unnamed_addr #2

declare noundef ptr @_ZN2rw3d3d11lockIndicesEPvjjj(ptr noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #3

declare void @_ZN2rw3d3d13unlockIndicesEPv(ptr noundef) local_unnamed_addr #3

declare noundef ptr @_ZN2rw3d3d12lockVerticesEPvjjj(ptr noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #3

declare void @_ZN2rw3d3d14unlockVerticesEPv(ptr noundef) local_unnamed_addr #3

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN2rw4d3d915writeNativeDataEPNS_6StreamEiPvii(ptr noundef returned %0, i32 noundef %1, ptr noundef %2, i32 noundef %3, i32 noundef %4) local_unnamed_addr #4 {
  %6 = alloca [12 x %"struct.rw::d3d9::VertexElement"], align 16
  %7 = add nsw i32 %1, -12
  %8 = tail call noundef zeroext i1 @_ZN2rw16writeChunkHeaderEPNS_6StreamEii(ptr noundef %0, i32 noundef 1, i32 noundef %7)
  %9 = getelementptr inbounds i8, ptr %2, i64 152
  %10 = load ptr, ptr %9, align 8, !tbaa !5
  %11 = icmp eq ptr %10, null
  br i1 %11, label %166, label %12

12:                                               ; preds = %5
  %13 = load i32, ptr %10, align 4, !tbaa !14
  %.not = icmp eq i32 %13, 9
  br i1 %.not, label %14, label %166

14:                                               ; preds = %12
  %15 = tail call noundef i32 @_ZN2rw6Stream8writeU32Ej(ptr noundef nonnull align 8 dereferenceable(8) %0, i32 noundef 9)
  %16 = load ptr, ptr %9, align 8, !tbaa !5
  %17 = getelementptr inbounds i8, ptr %2, i64 144
  %18 = load ptr, ptr %17, align 8, !tbaa !16
  %19 = getelementptr inbounds i8, ptr %18, i64 4
  %20 = load i16, ptr %19, align 4, !tbaa !17
  %21 = zext i16 %20 to i32
  %22 = mul nuw nsw i32 %21, 36
  %23 = add nuw nsw i32 %22, 64
  %24 = zext nneg i32 %23 to i64
  %25 = tail call noundef ptr @_ZN2rw14mustmalloc_LOCEmjPKc(i64 noundef %24, i32 noundef 65551, ptr noundef nonnull @.str.10)
  %26 = tail call noundef i32 @_ZN2rw6Stream8writeI32Ei(ptr noundef nonnull align 8 dereferenceable(8) %0, i32 noundef %23)
  %27 = getelementptr inbounds i8, ptr %16, i64 4
  %28 = load i32, ptr %27, align 4, !tbaa !19
  store i32 %28, ptr %25, align 4, !tbaa !21
  %29 = getelementptr inbounds i8, ptr %25, i64 4
  %30 = getelementptr inbounds i8, ptr %16, i64 8
  %31 = load i32, ptr %30, align 8, !tbaa !22
  store i32 %31, ptr %29, align 4, !tbaa !21
  %32 = getelementptr inbounds i8, ptr %25, i64 8
  %33 = getelementptr inbounds i8, ptr %25, i64 12
  %34 = getelementptr inbounds i8, ptr %16, i64 24
  %35 = load i32, ptr %34, align 8, !tbaa !23
  store i32 %35, ptr %33, align 4, !tbaa !21
  %36 = getelementptr inbounds i8, ptr %25, i64 48
  %37 = getelementptr inbounds i8, ptr %16, i64 80
  %38 = load i32, ptr %37, align 8, !tbaa !24
  store i32 %38, ptr %36, align 4, !tbaa !21
  %39 = getelementptr inbounds i8, ptr %25, i64 56
  %40 = getelementptr inbounds i8, ptr %16, i64 96
  %41 = load i32, ptr %40, align 8, !tbaa !25
  store i32 %41, ptr %39, align 4, !tbaa !21
  %42 = getelementptr inbounds i8, ptr %25, i64 60
  %43 = getelementptr inbounds i8, ptr %16, i64 100
  %44 = load i32, ptr %43, align 4, !tbaa !26
  store i32 %44, ptr %42, align 4, !tbaa !21
  %45 = load i32, ptr %30, align 8, !tbaa !22
  %.not122 = icmp eq i32 %45, 0
  br i1 %.not122, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %14
  %46 = getelementptr inbounds i8, ptr %16, i64 104
  %47 = load ptr, ptr %46, align 8, !tbaa !27
  %48 = getelementptr inbounds i8, ptr %25, i64 64
  %49 = getelementptr inbounds i8, ptr %2, i64 128
  br label %94

._crit_edge:                                      ; preds = %94, %14
  %50 = load ptr, ptr %0, align 8, !tbaa !28
  %51 = getelementptr inbounds i8, ptr %50, i64 24
  %52 = load ptr, ptr %51, align 8
  %53 = tail call noundef i32 %52(ptr noundef nonnull align 8 dereferenceable(8) %0, ptr noundef nonnull %25, i32 noundef %23)
  call void @llvm.lifetime.start.p0(i64 96, ptr nonnull %6) #5
  %54 = getelementptr inbounds i8, ptr %16, i64 88
  %55 = load ptr, ptr %54, align 8, !tbaa !30
  %56 = call noundef i32 @_ZN2rw4d3d914getDeclarationEPvPNS0_13VertexElementE(ptr noundef %55, ptr noundef nonnull %6)
  %57 = call noundef i32 @_ZN2rw6Stream8writeU32Ej(ptr noundef nonnull align 8 dereferenceable(8) %0, i32 noundef %56)
  %58 = shl i32 %56, 3
  %59 = load ptr, ptr %0, align 8, !tbaa !28
  %60 = getelementptr inbounds i8, ptr %59, i64 24
  %61 = load ptr, ptr %60, align 8
  %62 = call noundef i32 %61(ptr noundef nonnull align 8 dereferenceable(8) %0, ptr noundef nonnull %6, i32 noundef %58)
  %63 = getelementptr inbounds i8, ptr %16, i64 16
  %64 = load ptr, ptr %63, align 8, !tbaa !31
  %65 = call noundef ptr @_ZN2rw3d3d11lockIndicesEPvjjj(ptr noundef %64, i32 noundef 0, i32 noundef 0, i32 noundef 0)
  %66 = load i32, ptr %40, align 8, !tbaa !25
  %67 = shl i32 %66, 1
  %68 = load ptr, ptr %0, align 8, !tbaa !28
  %69 = getelementptr inbounds i8, ptr %68, i64 24
  %70 = load ptr, ptr %69, align 8
  %71 = call noundef i32 %70(ptr noundef nonnull align 8 dereferenceable(8) %0, ptr noundef %65, i32 noundef %67)
  %72 = load ptr, ptr %63, align 8, !tbaa !31
  call void @_ZN2rw3d3d13unlockIndicesEPv(ptr noundef %72)
  %73 = getelementptr inbounds i8, ptr %16, i64 32
  %74 = getelementptr inbounds i8, ptr %25, i64 14
  %75 = getelementptr inbounds i8, ptr %25, i64 15
  %76 = load ptr, ptr %73, align 8, !tbaa !32
  %.not117 = icmp eq ptr %76, null
  %77 = select i1 %.not117, i32 0, i32 -1159811074
  store i32 %77, ptr %25, align 4, !tbaa !21
  %78 = getelementptr inbounds i8, ptr %16, i64 40
  %79 = load i32, ptr %78, align 8, !tbaa !34
  store i32 %79, ptr %29, align 4, !tbaa !21
  %80 = getelementptr inbounds i8, ptr %16, i64 44
  %81 = load i32, ptr %80, align 4, !tbaa !35
  store i32 %81, ptr %32, align 4, !tbaa !21
  %82 = getelementptr inbounds i8, ptr %16, i64 48
  %83 = load i16, ptr %82, align 8, !tbaa !36
  store i16 %83, ptr %33, align 2, !tbaa !37
  %84 = getelementptr inbounds i8, ptr %16, i64 50
  %85 = load i8, ptr %84, align 2, !tbaa !38
  store i8 %85, ptr %74, align 1, !tbaa !39
  %86 = getelementptr inbounds i8, ptr %16, i64 51
  %87 = load i8, ptr %86, align 1, !tbaa !40
  store i8 %87, ptr %75, align 1, !tbaa !39
  %88 = load ptr, ptr %0, align 8, !tbaa !28
  %89 = getelementptr inbounds i8, ptr %88, i64 24
  %90 = load ptr, ptr %89, align 8
  %91 = call noundef i32 %90(ptr noundef nonnull align 8 dereferenceable(8) %0, ptr noundef nonnull %25, i32 noundef 16)
  %92 = load ptr, ptr %73, align 8, !tbaa !32
  %93 = icmp eq ptr %92, null
  br i1 %93, label %134, label %124

94:                                               ; preds = %.lr.ph, %94
  %.0113120 = phi ptr [ %48, %.lr.ph ], [ %119, %94 ]
  %.0114119 = phi ptr [ %47, %.lr.ph ], [ %120, %94 ]
  %.0115118 = phi i32 [ 0, %.lr.ph ], [ %121, %94 ]
  %95 = load i32, ptr %.0114119, align 8, !tbaa !41
  store i32 %95, ptr %.0113120, align 4, !tbaa !21
  %96 = getelementptr inbounds i8, ptr %.0113120, i64 4
  %97 = getelementptr inbounds i8, ptr %.0114119, i64 4
  %98 = load i32, ptr %97, align 4, !tbaa !43
  store i32 %98, ptr %96, align 4, !tbaa !21
  %99 = getelementptr inbounds i8, ptr %.0113120, i64 8
  %100 = getelementptr inbounds i8, ptr %.0114119, i64 8
  %101 = load ptr, ptr %100, align 8, !tbaa !44
  %102 = tail call noundef i32 @_ZN2rw12MaterialList9findIndexEPNS_8MaterialE(ptr noundef nonnull align 8 dereferenceable(16) %49, ptr noundef %101)
  store i32 %102, ptr %99, align 4, !tbaa !21
  %103 = getelementptr inbounds i8, ptr %.0113120, i64 12
  %104 = getelementptr inbounds i8, ptr %.0114119, i64 16
  %105 = load i32, ptr %104, align 8, !tbaa !45
  store i32 %105, ptr %103, align 4, !tbaa !21
  %106 = getelementptr inbounds i8, ptr %.0113120, i64 16
  store i32 0, ptr %106, align 4, !tbaa !21
  %107 = getelementptr inbounds i8, ptr %.0113120, i64 20
  %108 = getelementptr inbounds i8, ptr %.0114119, i64 32
  %109 = load i32, ptr %108, align 8, !tbaa !46
  store i32 %109, ptr %107, align 4, !tbaa !21
  %110 = getelementptr inbounds i8, ptr %.0113120, i64 24
  %111 = getelementptr inbounds i8, ptr %.0114119, i64 36
  %112 = load i32, ptr %111, align 4, !tbaa !47
  store i32 %112, ptr %110, align 4, !tbaa !21
  %113 = getelementptr inbounds i8, ptr %.0113120, i64 28
  %114 = getelementptr inbounds i8, ptr %.0114119, i64 40
  %115 = load i32, ptr %114, align 8, !tbaa !48
  store i32 %115, ptr %113, align 4, !tbaa !21
  %116 = getelementptr inbounds i8, ptr %.0113120, i64 32
  %117 = getelementptr inbounds i8, ptr %.0114119, i64 44
  %118 = load i32, ptr %117, align 4, !tbaa !49
  store i32 %118, ptr %116, align 4, !tbaa !21
  %119 = getelementptr inbounds i8, ptr %.0113120, i64 36
  %120 = getelementptr inbounds i8, ptr %.0114119, i64 48
  %121 = add nuw i32 %.0115118, 1
  %122 = load i32, ptr %30, align 8, !tbaa !22
  %123 = icmp ult i32 %121, %122
  br i1 %123, label %94, label %._crit_edge, !llvm.loop !50

124:                                              ; preds = %._crit_edge
  %125 = call noundef ptr @_ZN2rw3d3d12lockVerticesEPvjjj(ptr noundef nonnull %92, i32 noundef 0, i32 noundef 0, i32 noundef 0)
  %126 = load i32, ptr %80, align 4, !tbaa !35
  %127 = load i32, ptr %43, align 4, !tbaa !26
  %128 = mul i32 %127, %126
  %129 = load ptr, ptr %0, align 8, !tbaa !28
  %130 = getelementptr inbounds i8, ptr %129, i64 24
  %131 = load ptr, ptr %130, align 8
  %132 = call noundef i32 %131(ptr noundef nonnull align 8 dereferenceable(8) %0, ptr noundef %125, i32 noundef %128)
  %133 = load ptr, ptr %73, align 8, !tbaa !32
  call void @_ZN2rw3d3d14unlockVerticesEPv(ptr noundef %133)
  br label %134

134:                                              ; preds = %._crit_edge, %124
  %135 = getelementptr inbounds i8, ptr %16, i64 56
  %136 = load ptr, ptr %135, align 8, !tbaa !32
  %.not117.1 = icmp eq ptr %136, null
  %137 = select i1 %.not117.1, i32 0, i32 -1159811074
  store i32 %137, ptr %25, align 4, !tbaa !21
  %138 = getelementptr inbounds i8, ptr %16, i64 64
  %139 = load i32, ptr %138, align 8, !tbaa !34
  store i32 %139, ptr %29, align 4, !tbaa !21
  %140 = getelementptr inbounds i8, ptr %16, i64 68
  %141 = load i32, ptr %140, align 4, !tbaa !35
  store i32 %141, ptr %32, align 4, !tbaa !21
  %142 = getelementptr inbounds i8, ptr %16, i64 72
  %143 = load i16, ptr %142, align 8, !tbaa !36
  store i16 %143, ptr %33, align 2, !tbaa !37
  %144 = getelementptr inbounds i8, ptr %16, i64 74
  %145 = load i8, ptr %144, align 2, !tbaa !38
  store i8 %145, ptr %74, align 1, !tbaa !39
  %146 = getelementptr inbounds i8, ptr %16, i64 75
  %147 = load i8, ptr %146, align 1, !tbaa !40
  store i8 %147, ptr %75, align 1, !tbaa !39
  %148 = load ptr, ptr %0, align 8, !tbaa !28
  %149 = getelementptr inbounds i8, ptr %148, i64 24
  %150 = load ptr, ptr %149, align 8
  %151 = call noundef i32 %150(ptr noundef nonnull align 8 dereferenceable(8) %0, ptr noundef nonnull %25, i32 noundef 16)
  %152 = load ptr, ptr %135, align 8, !tbaa !32
  %153 = icmp eq ptr %152, null
  br i1 %153, label %164, label %154

154:                                              ; preds = %134
  %155 = call noundef ptr @_ZN2rw3d3d12lockVerticesEPvjjj(ptr noundef nonnull %152, i32 noundef 0, i32 noundef 0, i32 noundef 0)
  %156 = load i32, ptr %140, align 4, !tbaa !35
  %157 = load i32, ptr %43, align 4, !tbaa !26
  %158 = mul i32 %157, %156
  %159 = load ptr, ptr %0, align 8, !tbaa !28
  %160 = getelementptr inbounds i8, ptr %159, i64 24
  %161 = load ptr, ptr %160, align 8
  %162 = call noundef i32 %161(ptr noundef nonnull align 8 dereferenceable(8) %0, ptr noundef %155, i32 noundef %158)
  %163 = load ptr, ptr %135, align 8, !tbaa !32
  call void @_ZN2rw3d3d14unlockVerticesEPv(ptr noundef %163)
  br label %164

164:                                              ; preds = %154, %134
  %165 = load ptr, ptr getelementptr inbounds (i8, ptr @_ZN2rw6Engine8memfuncsE, i64 16), align 8, !tbaa !52
  call void %165(ptr noundef nonnull %25)
  call void @llvm.lifetime.end.p0(i64 96, ptr nonnull %6) #5
  br label %166

166:                                              ; preds = %5, %12, %164
  ret ptr %0
}

declare noundef zeroext i1 @_ZN2rw16writeChunkHeaderEPNS_6StreamEii(ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #3

declare noundef i32 @_ZN2rw6Stream8writeU32Ej(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) local_unnamed_addr #3

declare noundef i32 @_ZN2rw6Stream8writeI32Ei(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) local_unnamed_addr #3

declare noundef i32 @_ZN2rw12MaterialList9findIndexEPNS_8MaterialE(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef) local_unnamed_addr #3

attributes #0 = { mustprogress 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 = { 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 = { "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 = { 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 #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, !10, i64 152}
!6 = !{!"_ZTSN2rw8GeometryE", !7, i64 0, !11, i64 16, !12, i64 20, !11, i64 24, !11, i64 28, !11, i64 32, !11, i64 36, !10, i64 40, !10, i64 48, !8, i64 56, !10, i64 120, !13, i64 128, !10, i64 144, !10, i64 152, !11, i64 160}
!7 = !{!"_ZTSN2rw6ObjectE", !8, i64 0, !8, i64 1, !8, i64 2, !8, i64 3, !10, i64 8}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"int", !8, i64 0}
!12 = !{!"short", !8, i64 0}
!13 = !{!"_ZTSN2rw12MaterialListE", !10, i64 0, !11, i64 8, !11, i64 12}
!14 = !{!15, !11, i64 0}
!15 = !{!"_ZTSN2rw18InstanceDataHeaderE", !11, i64 0}
!16 = !{!6, !10, i64 144}
!17 = !{!18, !12, i64 4}
!18 = !{!"_ZTSN2rw10MeshHeaderE", !11, i64 0, !12, i64 4, !12, i64 6, !11, i64 8, !11, i64 12}
!19 = !{!20, !11, i64 4}
!20 = !{!"_ZTSN2rw4d3d918InstanceDataHeaderE", !15, i64 0, !11, i64 4, !11, i64 8, !10, i64 16, !11, i64 24, !8, i64 32, !11, i64 80, !10, i64 88, !11, i64 96, !11, i64 100, !10, i64 104}
!21 = !{!11, !11, i64 0}
!22 = !{!20, !11, i64 8}
!23 = !{!20, !11, i64 24}
!24 = !{!20, !11, i64 80}
!25 = !{!20, !11, i64 96}
!26 = !{!20, !11, i64 100}
!27 = !{!20, !10, i64 104}
!28 = !{!29, !29, i64 0}
!29 = !{!"vtable pointer", !9, i64 0}
!30 = !{!20, !10, i64 88}
!31 = !{!20, !10, i64 16}
!32 = !{!33, !10, i64 0}
!33 = !{!"_ZTSN2rw4d3d912VertexStreamE", !10, i64 0, !11, i64 8, !11, i64 12, !12, i64 16, !8, i64 18, !8, i64 19}
!34 = !{!33, !11, i64 8}
!35 = !{!33, !11, i64 12}
!36 = !{!33, !12, i64 16}
!37 = !{!12, !12, i64 0}
!38 = !{!33, !8, i64 18}
!39 = !{!8, !8, i64 0}
!40 = !{!33, !8, i64 19}
!41 = !{!42, !11, i64 0}
!42 = !{!"_ZTSN2rw4d3d912InstanceDataE", !11, i64 0, !11, i64 4, !10, i64 8, !11, i64 16, !10, i64 24, !11, i64 32, !11, i64 36, !11, i64 40, !11, i64 44}
!43 = !{!42, !11, i64 4}
!44 = !{!42, !10, i64 8}
!45 = !{!42, !11, i64 16}
!46 = !{!42, !11, i64 32}
!47 = !{!42, !11, i64 36}
!48 = !{!42, !11, i64 40}
!49 = !{!42, !11, i64 44}
!50 = distinct !{!50, !51}
!51 = !{!"llvm.loop.mustprogress"}
!52 = !{!53, !10, i64 16}
!53 = !{!"_ZTSN2rw15MemoryFunctionsE", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32}


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