; LLVM IR from aap/librw :: src/d3d/d3d8.ll (ZN2rw4d3d814readNativeDataEPNS_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::Error" = type { i32, i32 }
%"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::d3d8::InstanceDataHeader" = type { %"struct.rw::InstanceDataHeader", i16, i16, ptr }
%"struct.rw::d3d8::InstanceData" = type { i32, i32, i32, i32, ptr, i32, i32, ptr, ptr, i32, i8, i8, i8 }

@_ZN2rw6Engine8memfuncsE = external global %"struct.rw::MemoryFunctions", align 8
@stderr = external global ptr, align 8
@.str = external hidden unnamed_addr constant [8 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [60 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [76 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [76 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [76 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [25 x i8], align 1
@__PRETTY_FUNCTION__._ZN2rw4d3d814readNativeDataEPNS_6StreamEiPvii = external hidden unnamed_addr constant [72 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [26 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: mustprogress uwtable
define dso_local noundef ptr @_ZN2rw4d3d814readNativeDataEPNS_6StreamEiPvii(ptr noundef %0, i32 noundef %1, ptr noundef %2, i32 noundef %3, i32 noundef %4) #1 {
  %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 %"struct.rw::Error", align 4
  %15 = alloca i32, align 4
  %16 = alloca %"struct.rw::Error", align 4
  %17 = alloca ptr, align 8
  %18 = alloca i32, align 4
  %19 = alloca ptr, align 8
  %20 = alloca ptr, align 8
  %21 = alloca ptr, align 8
  %22 = alloca i32, align 4
  %23 = alloca i32, align 4
  %24 = alloca i32, align 4
  %25 = alloca ptr, align 8
  %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) #6
  %27 = load ptr, ptr %9, align 8, !tbaa !5
  store ptr %27, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #6
  %28 = load ptr, ptr %7, align 8, !tbaa !5
  %29 = call noundef zeroext i1 @_ZN2rw9findChunkEPNS_6StreamEjPjS2_(ptr noundef %28, i32 noundef 1, ptr noundef null, ptr noundef null)
  br i1 %29, label %41, label %30

30:                                               ; preds = %5
  br label %31

31:                                               ; preds = %30
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #6
  %32 = getelementptr inbounds %"struct.rw::Error", ptr %14, i32 0, i32 0
  store i32 2, ptr %32, align 4, !tbaa !11
  %33 = getelementptr inbounds %"struct.rw::Error", ptr %14, i32 0, i32 1
  store i32 -2147483644, ptr %33, align 4, !tbaa !13
  %34 = load ptr, ptr @stderr, align 8, !tbaa !5
  %35 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %34, ptr noundef @.str, ptr noundef @.str.1, i32 noundef 108) #6
  %36 = load ptr, ptr @stderr, align 8, !tbaa !5
  %37 = call noundef ptr (i32, ...) @_ZN2rw9dbgsprintEjz(i32 noundef -2147483644, ptr noundef @.str.3)
  %38 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %36, ptr noundef @.str.2, ptr noundef %37) #6
  call void @_ZN2rw8setErrorEPNS_5ErrorE(ptr noundef %14)
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #6
  br label %39

39:                                               ; preds = %31
  br label %40

40:                                               ; preds = %39
  store ptr null, ptr %6, align 8
  store i32 1, ptr %15, align 4
  br label %285

41:                                               ; preds = %5
  %42 = load ptr, ptr %7, align 8, !tbaa !5
  %43 = call noundef i32 @_ZN2rw6Stream7readU32Ev(ptr noundef nonnull align 8 dereferenceable(8) %42)
  store i32 %43, ptr %13, align 4, !tbaa !9
  %44 = load i32, ptr %13, align 4, !tbaa !9
  %45 = icmp ne i32 %44, 8
  br i1 %45, label %46, label %58

46:                                               ; preds = %41
  br label %47

47:                                               ; preds = %46
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #6
  %48 = getelementptr inbounds %"struct.rw::Error", ptr %16, i32 0, i32 0
  store i32 2, ptr %48, align 4, !tbaa !11
  %49 = getelementptr inbounds %"struct.rw::Error", ptr %16, i32 0, i32 1
  store i32 -2147483642, ptr %49, align 4, !tbaa !13
  %50 = load ptr, ptr @stderr, align 8, !tbaa !5
  %51 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %50, ptr noundef @.str, ptr noundef @.str.1, i32 noundef 113) #6
  %52 = load ptr, ptr @stderr, align 8, !tbaa !5
  %53 = load i32, ptr %13, align 4, !tbaa !9
  %54 = call noundef ptr (i32, ...) @_ZN2rw9dbgsprintEjz(i32 noundef -2147483642, i32 noundef %53)
  %55 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %52, ptr noundef @.str.2, ptr noundef %54) #6
  call void @_ZN2rw8setErrorEPNS_5ErrorE(ptr noundef %16)
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #6
  br label %56

56:                                               ; preds = %47
  br label %57

57:                                               ; preds = %56
  store ptr null, ptr %6, align 8
  store i32 1, ptr %15, align 4
  br label %285

58:                                               ; preds = %41
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #6
  %59 = call noundef ptr @_ZN2rw14mustmalloc_LOCEmjPKc(i64 noundef 16, i32 noundef 196623, ptr noundef @.str.4)
  store ptr %59, ptr %17, align 8, !tbaa !5
  %60 = load ptr, ptr %17, align 8, !tbaa !5
  %61 = load ptr, ptr %12, align 8, !tbaa !5
  %62 = getelementptr inbounds %"struct.rw::Geometry", ptr %61, i32 0, i32 13
  store ptr %60, ptr %62, align 8, !tbaa !14
  %63 = load ptr, ptr %17, align 8, !tbaa !5
  %64 = getelementptr inbounds %"struct.rw::InstanceDataHeader", ptr %63, i32 0, i32 0
  store i32 8, ptr %64, align 8, !tbaa !19
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #6
  %65 = load ptr, ptr %7, align 8, !tbaa !5
  %66 = call noundef i32 @_ZN2rw6Stream7readI32Ev(ptr noundef nonnull align 8 dereferenceable(8) %65)
  store i32 %66, ptr %18, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #6
  %67 = load i32, ptr %18, align 4, !tbaa !9
  %68 = sext i32 %67 to i64
  %69 = mul i64 %68, 1
  %70 = call noundef ptr @_ZN2rw14mustmalloc_LOCEmjPKc(i64 noundef %69, i32 noundef 65551, ptr noundef @.str.5)
  store ptr %70, ptr %19, align 8, !tbaa !5
  %71 = load ptr, ptr %7, align 8, !tbaa !5
  %72 = load ptr, ptr %19, align 8, !tbaa !5
  %73 = load i32, ptr %18, align 4, !tbaa !9
  %74 = load ptr, ptr %71, align 8, !tbaa !21
  %75 = getelementptr inbounds ptr, ptr %74, i64 4
  %76 = load ptr, ptr %75, align 8
  %77 = call noundef i32 %76(ptr noundef nonnull align 8 dereferenceable(8) %71, ptr noundef %72, i32 noundef %73)
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #6
  %78 = load ptr, ptr %19, align 8, !tbaa !5
  store ptr %78, ptr %20, align 8, !tbaa !5
  %79 = load ptr, ptr %20, align 8, !tbaa !5
  %80 = load i16, ptr %79, align 2, !tbaa !23
  %81 = load ptr, ptr %17, align 8, !tbaa !5
  %82 = getelementptr inbounds %"struct.rw::d3d8::InstanceDataHeader", ptr %81, i32 0, i32 1
  store i16 %80, ptr %82, align 4, !tbaa !24
  %83 = load ptr, ptr %20, align 8, !tbaa !5
  %84 = getelementptr inbounds i8, ptr %83, i64 2
  store ptr %84, ptr %20, align 8, !tbaa !5
  %85 = load ptr, ptr %20, align 8, !tbaa !5
  %86 = load i16, ptr %85, align 2, !tbaa !23
  %87 = load ptr, ptr %17, align 8, !tbaa !5
  %88 = getelementptr inbounds %"struct.rw::d3d8::InstanceDataHeader", ptr %87, i32 0, i32 2
  store i16 %86, ptr %88, align 2, !tbaa !26
  %89 = load ptr, ptr %20, align 8, !tbaa !5
  %90 = getelementptr inbounds i8, ptr %89, i64 2
  store ptr %90, ptr %20, align 8, !tbaa !5
  %91 = load ptr, ptr %17, align 8, !tbaa !5
  %92 = getelementptr inbounds %"struct.rw::d3d8::InstanceDataHeader", ptr %91, i32 0, i32 2
  %93 = load i16, ptr %92, align 2, !tbaa !26
  %94 = zext i16 %93 to i64
  %95 = mul i64 %94, 56
  %96 = call noundef ptr @_ZN2rw14mustmalloc_LOCEmjPKc(i64 noundef %95, i32 noundef 196623, ptr noundef @.str.6)
  %97 = load ptr, ptr %17, align 8, !tbaa !5
  %98 = getelementptr inbounds %"struct.rw::d3d8::InstanceDataHeader", ptr %97, i32 0, i32 3
  store ptr %96, ptr %98, align 8, !tbaa !27
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #6
  %99 = load ptr, ptr %17, align 8, !tbaa !5
  %100 = getelementptr inbounds %"struct.rw::d3d8::InstanceDataHeader", ptr %99, i32 0, i32 3
  %101 = load ptr, ptr %100, align 8, !tbaa !27
  store ptr %101, ptr %21, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #6
  store i32 0, ptr %22, align 4, !tbaa !9
  br label %102

102:                                              ; preds = %188, %58
  %103 = load i32, ptr %22, align 4, !tbaa !9
  %104 = load ptr, ptr %17, align 8, !tbaa !5
  %105 = getelementptr inbounds %"struct.rw::d3d8::InstanceDataHeader", ptr %104, i32 0, i32 2
  %106 = load i16, ptr %105, align 2, !tbaa !26
  %107 = zext i16 %106 to i32
  %108 = icmp ult i32 %103, %107
  br i1 %108, label %110, label %109

109:                                              ; preds = %102
  store i32 6, ptr %15, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #6
  br label %191

110:                                              ; preds = %102
  %111 = load ptr, ptr %20, align 8, !tbaa !5
  %112 = load i32, ptr %111, align 4, !tbaa !9
  %113 = load ptr, ptr %21, align 8, !tbaa !5
  %114 = getelementptr inbounds %"struct.rw::d3d8::InstanceData", ptr %113, i32 0, i32 0
  store i32 %112, ptr %114, align 8, !tbaa !28
  %115 = load ptr, ptr %20, align 8, !tbaa !5
  %116 = getelementptr inbounds i8, ptr %115, i64 4
  store ptr %116, ptr %20, align 8, !tbaa !5
  %117 = load ptr, ptr %20, align 8, !tbaa !5
  %118 = load i32, ptr %117, align 4, !tbaa !9
  %119 = load ptr, ptr %21, align 8, !tbaa !5
  %120 = getelementptr inbounds %"struct.rw::d3d8::InstanceData", ptr %119, i32 0, i32 1
  store i32 %118, ptr %120, align 4, !tbaa !30
  %121 = load ptr, ptr %20, align 8, !tbaa !5
  %122 = getelementptr inbounds i8, ptr %121, i64 4
  store ptr %122, ptr %20, align 8, !tbaa !5
  %123 = load ptr, ptr %20, align 8, !tbaa !5
  %124 = load i32, ptr %123, align 4, !tbaa !9
  %125 = load ptr, ptr %21, align 8, !tbaa !5
  %126 = getelementptr inbounds %"struct.rw::d3d8::InstanceData", ptr %125, i32 0, i32 2
  store i32 %124, ptr %126, align 8, !tbaa !31
  %127 = load ptr, ptr %20, align 8, !tbaa !5
  %128 = getelementptr inbounds i8, ptr %127, i64 4
  store ptr %128, ptr %20, align 8, !tbaa !5
  %129 = load ptr, ptr %20, align 8, !tbaa !5
  %130 = load i32, ptr %129, align 4, !tbaa !9
  %131 = load ptr, ptr %21, align 8, !tbaa !5
  %132 = getelementptr inbounds %"struct.rw::d3d8::InstanceData", ptr %131, i32 0, i32 3
  store i32 %130, ptr %132, align 4, !tbaa !32
  %133 = load ptr, ptr %20, align 8, !tbaa !5
  %134 = getelementptr inbounds i8, ptr %133, i64 4
  store ptr %134, ptr %20, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %23) #6
  %135 = load ptr, ptr %20, align 8, !tbaa !5
  %136 = load i32, ptr %135, align 4, !tbaa !9
  store i32 %136, ptr %23, align 4, !tbaa !9
  %137 = load ptr, ptr %20, align 8, !tbaa !5
  %138 = getelementptr inbounds i8, ptr %137, i64 4
  store ptr %138, ptr %20, align 8, !tbaa !5
  %139 = load ptr, ptr %12, align 8, !tbaa !5
  %140 = getelementptr inbounds %"struct.rw::Geometry", ptr %139, i32 0, i32 11
  %141 = getelementptr inbounds %"struct.rw::MaterialList", ptr %140, i32 0, i32 0
  %142 = load ptr, ptr %141, align 8, !tbaa !33
  %143 = load i32, ptr %23, align 4, !tbaa !9
  %144 = zext i32 %143 to i64
  %145 = getelementptr inbounds ptr, ptr %142, i64 %144
  %146 = load ptr, ptr %145, align 8, !tbaa !5
  %147 = load ptr, ptr %21, align 8, !tbaa !5
  %148 = getelementptr inbounds %"struct.rw::d3d8::InstanceData", ptr %147, i32 0, i32 4
  store ptr %146, ptr %148, align 8, !tbaa !34
  %149 = load ptr, ptr %20, align 8, !tbaa !5
  %150 = load i32, ptr %149, align 4, !tbaa !9
  %151 = load ptr, ptr %21, align 8, !tbaa !5
  %152 = getelementptr inbounds %"struct.rw::d3d8::InstanceData", ptr %151, i32 0, i32 5
  store i32 %150, ptr %152, align 8, !tbaa !35
  %153 = load ptr, ptr %20, align 8, !tbaa !5
  %154 = getelementptr inbounds i8, ptr %153, i64 4
  store ptr %154, ptr %20, align 8, !tbaa !5
  %155 = load ptr, ptr %20, align 8, !tbaa !5
  %156 = load i32, ptr %155, align 4, !tbaa !9
  %157 = load ptr, ptr %21, align 8, !tbaa !5
  %158 = getelementptr inbounds %"struct.rw::d3d8::InstanceData", ptr %157, i32 0, i32 6
  store i32 %156, ptr %158, align 4, !tbaa !36
  %159 = load ptr, ptr %20, align 8, !tbaa !5
  %160 = getelementptr inbounds i8, ptr %159, i64 4
  store ptr %160, ptr %20, align 8, !tbaa !5
  %161 = load ptr, ptr %21, align 8, !tbaa !5
  %162 = getelementptr inbounds %"struct.rw::d3d8::InstanceData", ptr %161, i32 0, i32 7
  store ptr null, ptr %162, align 8, !tbaa !37
  %163 = load ptr, ptr %20, align 8, !tbaa !5
  %164 = getelementptr inbounds i8, ptr %163, i64 4
  store ptr %164, ptr %20, align 8, !tbaa !5
  %165 = load ptr, ptr %21, align 8, !tbaa !5
  %166 = getelementptr inbounds %"struct.rw::d3d8::InstanceData", ptr %165, i32 0, i32 8
  store ptr null, ptr %166, align 8, !tbaa !38
  %167 = load ptr, ptr %20, align 8, !tbaa !5
  %168 = getelementptr inbounds i8, ptr %167, i64 4
  store ptr %168, ptr %20, align 8, !tbaa !5
  %169 = load ptr, ptr %21, align 8, !tbaa !5
  %170 = getelementptr inbounds %"struct.rw::d3d8::InstanceData", ptr %169, i32 0, i32 9
  store i32 0, ptr %170, align 8, !tbaa !39
  %171 = load ptr, ptr %20, align 8, !tbaa !5
  %172 = getelementptr inbounds i8, ptr %171, i64 4
  store ptr %172, ptr %20, align 8, !tbaa !5
  %173 = load ptr, ptr %20, align 8, !tbaa !5
  %174 = getelementptr inbounds i8, ptr %173, i32 1
  store ptr %174, ptr %20, align 8, !tbaa !5
  %175 = load i8, ptr %173, align 1, !tbaa !40
  %176 = load ptr, ptr %21, align 8, !tbaa !5
  %177 = getelementptr inbounds %"struct.rw::d3d8::InstanceData", ptr %176, i32 0, i32 10
  store i8 %175, ptr %177, align 4, !tbaa !41
  %178 = load ptr, ptr %21, align 8, !tbaa !5
  %179 = getelementptr inbounds %"struct.rw::d3d8::InstanceData", ptr %178, i32 0, i32 11
  store i8 0, ptr %179, align 1, !tbaa !42
  %180 = load ptr, ptr %20, align 8, !tbaa !5
  %181 = getelementptr inbounds i8, ptr %180, i32 1
  store ptr %181, ptr %20, align 8, !tbaa !5
  %182 = load ptr, ptr %21, align 8, !tbaa !5
  %183 = getelementptr inbounds %"struct.rw::d3d8::InstanceData", ptr %182, i32 0, i32 12
  store i8 0, ptr %183, align 2, !tbaa !43
  %184 = load ptr, ptr %20, align 8, !tbaa !5
  %185 = getelementptr inbounds i8, ptr %184, i32 1
  store ptr %185, ptr %20, align 8, !tbaa !5
  %186 = load ptr, ptr %21, align 8, !tbaa !5
  %187 = getelementptr inbounds %"struct.rw::d3d8::InstanceData", ptr %186, i32 1
  store ptr %187, ptr %21, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %23) #6
  br label %188

188:                                              ; preds = %110
  %189 = load i32, ptr %22, align 4, !tbaa !9
  %190 = add i32 %189, 1
  store i32 %190, ptr %22, align 4, !tbaa !9
  br label %102, !llvm.loop !44

191:                                              ; preds = %109
  %192 = load ptr, ptr getelementptr inbounds (%"struct.rw::MemoryFunctions", ptr @_ZN2rw6Engine8memfuncsE, i32 0, i32 2), align 8, !tbaa !46
  %193 = load ptr, ptr %19, align 8, !tbaa !5
  call void %192(ptr noundef %193)
  %194 = load ptr, ptr %17, align 8, !tbaa !5
  %195 = getelementptr inbounds %"struct.rw::d3d8::InstanceDataHeader", ptr %194, i32 0, i32 3
  %196 = load ptr, ptr %195, align 8, !tbaa !27
  store ptr %196, ptr %21, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %24) #6
  store i32 0, ptr %24, align 4, !tbaa !9
  br label %197

197:                                              ; preds = %280, %191
  %198 = load i32, ptr %24, align 4, !tbaa !9
  %199 = load ptr, ptr %17, align 8, !tbaa !5
  %200 = getelementptr inbounds %"struct.rw::d3d8::InstanceDataHeader", ptr %199, i32 0, i32 2
  %201 = load i16, ptr %200, align 2, !tbaa !26
  %202 = zext i16 %201 to i32
  %203 = icmp ult i32 %198, %202
  br i1 %203, label %205, label %204

204:                                              ; preds = %197
  store i32 9, ptr %15, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %24) #6
  br label %283

205:                                              ; preds = %197
  %206 = load ptr, ptr %21, align 8, !tbaa !5
  %207 = getelementptr inbounds %"struct.rw::d3d8::InstanceData", ptr %206, i32 0, i32 7
  %208 = load ptr, ptr %207, align 8, !tbaa !37
  %209 = icmp eq ptr %208, null
  br i1 %209, label %210, label %211

210:                                              ; preds = %205
  br label %213

211:                                              ; preds = %205
  call void @__assert_fail(ptr noundef @.str.7, ptr noundef @.str.1, i32 noundef 150, ptr noundef @__PRETTY_FUNCTION__._ZN2rw4d3d814readNativeDataEPNS_6StreamEiPvii) #7
  unreachable

212:                                              ; No predecessors!
  br label %213

213:                                              ; preds = %212, %210
  %214 = load ptr, ptr %21, align 8, !tbaa !5
  %215 = getelementptr inbounds %"struct.rw::d3d8::InstanceData", ptr %214, i32 0, i32 3
  %216 = load i32, ptr %215, align 4, !tbaa !32
  %217 = mul nsw i32 %216, 2
  %218 = call noundef ptr @_ZN2rw3d3d17createIndexBufferEjb(i32 noundef %217, i1 noundef zeroext false)
  %219 = load ptr, ptr %21, align 8, !tbaa !5
  %220 = getelementptr inbounds %"struct.rw::d3d8::InstanceData", ptr %219, i32 0, i32 7
  store ptr %218, ptr %220, align 8, !tbaa !37
  call void @llvm.lifetime.start.p0(i64 8, ptr %25) #6
  %221 = load ptr, ptr %21, align 8, !tbaa !5
  %222 = getelementptr inbounds %"struct.rw::d3d8::InstanceData", ptr %221, i32 0, i32 7
  %223 = load ptr, ptr %222, align 8, !tbaa !37
  %224 = call noundef ptr @_ZN2rw3d3d11lockIndicesEPvjjj(ptr noundef %223, i32 noundef 0, i32 noundef 0, i32 noundef 0)
  store ptr %224, ptr %25, align 8, !tbaa !5
  %225 = load ptr, ptr %7, align 8, !tbaa !5
  %226 = load ptr, ptr %25, align 8, !tbaa !5
  %227 = load ptr, ptr %21, align 8, !tbaa !5
  %228 = getelementptr inbounds %"struct.rw::d3d8::InstanceData", ptr %227, i32 0, i32 3
  %229 = load i32, ptr %228, align 4, !tbaa !32
  %230 = mul nsw i32 2, %229
  %231 = load ptr, ptr %225, align 8, !tbaa !21
  %232 = getelementptr inbounds ptr, ptr %231, i64 4
  %233 = load ptr, ptr %232, align 8
  %234 = call noundef i32 %233(ptr noundef nonnull align 8 dereferenceable(8) %225, ptr noundef %226, i32 noundef %230)
  %235 = load ptr, ptr %21, align 8, !tbaa !5
  %236 = getelementptr inbounds %"struct.rw::d3d8::InstanceData", ptr %235, i32 0, i32 7
  %237 = load ptr, ptr %236, align 8, !tbaa !37
  call void @_ZN2rw3d3d13unlockIndicesEPv(ptr noundef %237)
  %238 = load ptr, ptr %21, align 8, !tbaa !5
  %239 = getelementptr inbounds %"struct.rw::d3d8::InstanceData", ptr %238, i32 0, i32 11
  store i8 1, ptr %239, align 1, !tbaa !42
  %240 = load ptr, ptr %21, align 8, !tbaa !5
  %241 = getelementptr inbounds %"struct.rw::d3d8::InstanceData", ptr %240, i32 0, i32 8
  %242 = load ptr, ptr %241, align 8, !tbaa !38
  %243 = icmp eq ptr %242, null
  br i1 %243, label %244, label %245

244:                                              ; preds = %213
  br label %247

245:                                              ; preds = %213
  call void @__assert_fail(ptr noundef @.str.8, ptr noundef @.str.1, i32 noundef 157, ptr noundef @__PRETTY_FUNCTION__._ZN2rw4d3d814readNativeDataEPNS_6StreamEiPvii) #7
  unreachable

246:                                              ; No predecessors!
  br label %247

247:                                              ; preds = %246, %244
  %248 = load ptr, ptr %21, align 8, !tbaa !5
  %249 = getelementptr inbounds %"struct.rw::d3d8::InstanceData", ptr %248, i32 0, i32 1
  %250 = load i32, ptr %249, align 4, !tbaa !30
  %251 = load ptr, ptr %21, align 8, !tbaa !5
  %252 = getelementptr inbounds %"struct.rw::d3d8::InstanceData", ptr %251, i32 0, i32 2
  %253 = load i32, ptr %252, align 8, !tbaa !31
  %254 = mul nsw i32 %250, %253
  %255 = call noundef ptr @_ZN2rw3d3d18createVertexBufferEjjb(i32 noundef %254, i32 noundef 0, i1 noundef zeroext false)
  %256 = load ptr, ptr %21, align 8, !tbaa !5
  %257 = getelementptr inbounds %"struct.rw::d3d8::InstanceData", ptr %256, i32 0, i32 8
  store ptr %255, ptr %257, align 8, !tbaa !38
  call void @llvm.lifetime.start.p0(i64 8, ptr %26) #6
  %258 = load ptr, ptr %21, align 8, !tbaa !5
  %259 = getelementptr inbounds %"struct.rw::d3d8::InstanceData", ptr %258, i32 0, i32 8
  %260 = load ptr, ptr %259, align 8, !tbaa !38
  %261 = call noundef ptr @_ZN2rw3d3d12lockVerticesEPvjjj(ptr noundef %260, i32 noundef 0, i32 noundef 0, i32 noundef 0)
  store ptr %261, ptr %26, align 8, !tbaa !5
  %262 = load ptr, ptr %7, align 8, !tbaa !5
  %263 = load ptr, ptr %26, align 8, !tbaa !5
  %264 = load ptr, ptr %21, align 8, !tbaa !5
  %265 = getelementptr inbounds %"struct.rw::d3d8::InstanceData", ptr %264, i32 0, i32 1
  %266 = load i32, ptr %265, align 4, !tbaa !30
  %267 = load ptr, ptr %21, align 8, !tbaa !5
  %268 = getelementptr inbounds %"struct.rw::d3d8::InstanceData", ptr %267, i32 0, i32 2
  %269 = load i32, ptr %268, align 8, !tbaa !31
  %270 = mul nsw i32 %266, %269
  %271 = load ptr, ptr %262, align 8, !tbaa !21
  %272 = getelementptr inbounds ptr, ptr %271, i64 4
  %273 = load ptr, ptr %272, align 8
  %274 = call noundef i32 %273(ptr noundef nonnull align 8 dereferenceable(8) %262, ptr noundef %263, i32 noundef %270)
  %275 = load ptr, ptr %21, align 8, !tbaa !5
  %276 = getelementptr inbounds %"struct.rw::d3d8::InstanceData", ptr %275, i32 0, i32 8
  %277 = load ptr, ptr %276, align 8, !tbaa !38
  call void @_ZN2rw3d3d14unlockVerticesEPv(ptr noundef %277)
  %278 = load ptr, ptr %21, align 8, !tbaa !5
  %279 = getelementptr inbounds %"struct.rw::d3d8::InstanceData", ptr %278, i32 1
  store ptr %279, ptr %21, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %26) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %25) #6
  br label %280

280:                                              ; preds = %247
  %281 = load i32, ptr %24, align 4, !tbaa !9
  %282 = add i32 %281, 1
  store i32 %282, ptr %24, align 4, !tbaa !9
  br label %197, !llvm.loop !48

283:                                              ; preds = %204
  %284 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %284, ptr %6, align 8
  store i32 1, ptr %15, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #6
  br label %285

285:                                              ; preds = %283, %57, %40
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #6
  %286 = load ptr, ptr %6, align 8
  ret ptr %286
}

declare noundef zeroext i1 @_ZN2rw9findChunkEPNS_6StreamEjPjS2_(ptr noundef, i32 noundef, ptr noundef, ptr noundef) #2

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #3

declare noundef ptr @_ZN2rw9dbgsprintEjz(i32 noundef, ...) #2

declare void @_ZN2rw8setErrorEPNS_5ErrorE(ptr noundef) #2

declare noundef i32 @_ZN2rw6Stream7readU32Ev(ptr noundef nonnull align 8 dereferenceable(8)) #2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZN2rw14mustmalloc_LOCEmjPKc(i64 noundef, i32 noundef, ptr noundef) #4

declare noundef i32 @_ZN2rw6Stream7readI32Ev(ptr noundef nonnull align 8 dereferenceable(8)) #2

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #5

declare noundef ptr @_ZN2rw3d3d17createIndexBufferEjb(i32 noundef, i1 noundef zeroext) #2

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

declare void @_ZN2rw3d3d13unlockIndicesEPv(ptr noundef) #2

declare noundef ptr @_ZN2rw3d3d18createVertexBufferEjjb(i32 noundef, i32 noundef, i1 noundef zeroext) #2

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

declare void @_ZN2rw3d3d14unlockVerticesEPv(ptr noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { "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 = { nounwind "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 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 = { noreturn nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #6 = { nounwind }
attributes #7 = { noreturn 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, !10, i64 0}
!12 = !{!"_ZTSN2rw5ErrorE", !10, i64 0, !10, i64 4}
!13 = !{!12, !10, i64 4}
!14 = !{!15, !6, i64 152}
!15 = !{!"_ZTSN2rw8GeometryE", !16, i64 0, !10, i64 16, !17, 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, !18, i64 128, !6, i64 144, !6, i64 152, !10, i64 160}
!16 = !{!"_ZTSN2rw6ObjectE", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3, !6, i64 8}
!17 = !{!"short", !7, i64 0}
!18 = !{!"_ZTSN2rw12MaterialListE", !6, i64 0, !10, i64 8, !10, i64 12}
!19 = !{!20, !10, i64 0}
!20 = !{!"_ZTSN2rw18InstanceDataHeaderE", !10, i64 0}
!21 = !{!22, !22, i64 0}
!22 = !{!"vtable pointer", !8, i64 0}
!23 = !{!17, !17, i64 0}
!24 = !{!25, !17, i64 4}
!25 = !{!"_ZTSN2rw4d3d818InstanceDataHeaderE", !20, i64 0, !17, i64 4, !17, i64 6, !6, i64 8}
!26 = !{!25, !17, i64 6}
!27 = !{!25, !6, i64 8}
!28 = !{!29, !10, i64 0}
!29 = !{!"_ZTSN2rw4d3d812InstanceDataE", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !6, i64 16, !10, i64 24, !10, i64 28, !6, i64 32, !6, i64 40, !10, i64 48, !7, i64 52, !7, i64 53, !7, i64 54}
!30 = !{!29, !10, i64 4}
!31 = !{!29, !10, i64 8}
!32 = !{!29, !10, i64 12}
!33 = !{!15, !6, i64 128}
!34 = !{!29, !6, i64 16}
!35 = !{!29, !10, i64 24}
!36 = !{!29, !10, i64 28}
!37 = !{!29, !6, i64 32}
!38 = !{!29, !6, i64 40}
!39 = !{!29, !10, i64 48}
!40 = !{!7, !7, i64 0}
!41 = !{!29, !7, i64 52}
!42 = !{!29, !7, i64 53}
!43 = !{!29, !7, i64 54}
!44 = distinct !{!44, !45}
!45 = !{!"llvm.loop.mustprogress"}
!46 = !{!47, !6, i64 16}
!47 = !{!"_ZTSN2rw15MemoryFunctionsE", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32}
!48 = distinct !{!48, !45}


; 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::Error" = type { i32, i32 }

@_ZN2rw6Engine8memfuncsE = external local_unnamed_addr global %"struct.rw::MemoryFunctions", align 8
@stderr = external local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [8 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [60 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [76 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [76 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [76 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [25 x i8], align 1
@__PRETTY_FUNCTION__._ZN2rw4d3d814readNativeDataEPNS_6StreamEiPvii = external hidden unnamed_addr constant [72 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [26 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: mustprogress uwtable
define dso_local noundef ptr @_ZN2rw4d3d814readNativeDataEPNS_6StreamEiPvii(ptr noundef %0, i32 noundef %1, ptr nocapture noundef %2, i32 noundef %3, i32 noundef %4) local_unnamed_addr #1 {
  %6 = alloca %"struct.rw::Error", align 4
  %7 = alloca %"struct.rw::Error", align 4
  %8 = tail call noundef zeroext i1 @_ZN2rw9findChunkEPNS_6StreamEjPjS2_(ptr noundef %0, i32 noundef 1, ptr noundef null, ptr noundef null)
  br i1 %8, label %16, label %9

9:                                                ; preds = %5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #7
  store i32 2, ptr %6, align 4, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %6, i64 4
  store i32 -2147483644, ptr %10, align 4, !tbaa !10
  %11 = load ptr, ptr @stderr, align 8, !tbaa !11
  %12 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %11, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 108) #8
  %13 = load ptr, ptr @stderr, align 8, !tbaa !11
  %14 = tail call noundef ptr (i32, ...) @_ZN2rw9dbgsprintEjz(i32 noundef -2147483644, ptr noundef nonnull @.str.3)
  %15 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %13, ptr noundef nonnull @.str.2, ptr noundef %14) #8
  call void @_ZN2rw8setErrorEPNS_5ErrorE(ptr noundef nonnull %6)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #7
  br label %.loopexit

16:                                               ; preds = %5
  %17 = tail call noundef i32 @_ZN2rw6Stream7readU32Ev(ptr noundef nonnull align 8 dereferenceable(8) %0)
  %.not = icmp eq i32 %17, 8
  br i1 %.not, label %25, label %18

18:                                               ; preds = %16
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #7
  store i32 2, ptr %7, align 4, !tbaa !5
  %19 = getelementptr inbounds i8, ptr %7, i64 4
  store i32 -2147483642, ptr %19, align 4, !tbaa !10
  %20 = load ptr, ptr @stderr, align 8, !tbaa !11
  %21 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %20, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 113) #8
  %22 = load ptr, ptr @stderr, align 8, !tbaa !11
  %23 = tail call noundef ptr (i32, ...) @_ZN2rw9dbgsprintEjz(i32 noundef -2147483642, i32 noundef %17)
  %24 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %22, ptr noundef nonnull @.str.2, ptr noundef %23) #8
  call void @_ZN2rw8setErrorEPNS_5ErrorE(ptr noundef nonnull %7)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #7
  br label %.loopexit

25:                                               ; preds = %16
  %26 = tail call noundef ptr @_ZN2rw14mustmalloc_LOCEmjPKc(i64 noundef 16, i32 noundef 196623, ptr noundef nonnull @.str.4)
  %27 = getelementptr inbounds i8, ptr %2, i64 152
  store ptr %26, ptr %27, align 8, !tbaa !13
  store i32 8, ptr %26, align 8, !tbaa !18
  %28 = tail call noundef i32 @_ZN2rw6Stream7readI32Ev(ptr noundef nonnull align 8 dereferenceable(8) %0)
  %29 = sext i32 %28 to i64
  %30 = tail call noundef ptr @_ZN2rw14mustmalloc_LOCEmjPKc(i64 noundef %29, i32 noundef 65551, ptr noundef nonnull @.str.5)
  %31 = load ptr, ptr %0, align 8, !tbaa !20
  %32 = getelementptr inbounds i8, ptr %31, i64 32
  %33 = load ptr, ptr %32, align 8
  %34 = tail call noundef i32 %33(ptr noundef nonnull align 8 dereferenceable(8) %0, ptr noundef %30, i32 noundef %28)
  %35 = load i16, ptr %30, align 2, !tbaa !22
  %36 = getelementptr inbounds i8, ptr %26, i64 4
  store i16 %35, ptr %36, align 4, !tbaa !23
  %37 = getelementptr inbounds i8, ptr %30, i64 2
  %38 = load i16, ptr %37, align 2, !tbaa !22
  %39 = getelementptr inbounds i8, ptr %26, i64 6
  store i16 %38, ptr %39, align 2, !tbaa !25
  %40 = zext i16 %38 to i64
  %41 = mul nuw nsw i64 %40, 56
  %42 = tail call noundef ptr @_ZN2rw14mustmalloc_LOCEmjPKc(i64 noundef %41, i32 noundef 196623, ptr noundef nonnull @.str.6)
  %43 = getelementptr inbounds i8, ptr %26, i64 8
  store ptr %42, ptr %43, align 8, !tbaa !26
  %44 = load i16, ptr %39, align 2, !tbaa !25
  %45 = zext i16 %44 to i32
  %.not100 = icmp eq i16 %44, 0
  br i1 %.not100, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %25
  %46 = getelementptr inbounds i8, ptr %30, i64 4
  %47 = getelementptr inbounds i8, ptr %2, i64 128
  %48 = load ptr, ptr %47, align 8, !tbaa !27
  br label %52

._crit_edge:                                      ; preds = %52, %25
  %49 = load ptr, ptr getelementptr inbounds (i8, ptr @_ZN2rw6Engine8memfuncsE, i64 16), align 8, !tbaa !28
  tail call void %49(ptr noundef nonnull %30)
  %50 = load i16, ptr %39, align 2, !tbaa !25
  %.not101 = icmp eq i16 %50, 0
  br i1 %.not101, label %.loopexit, label %.lr.ph99.preheader

.lr.ph99.preheader:                               ; preds = %._crit_edge
  %51 = load ptr, ptr %43, align 8, !tbaa !26
  br label %.lr.ph99

52:                                               ; preds = %.lr.ph, %52
  %.08995 = phi ptr [ %46, %.lr.ph ], [ %81, %52 ]
  %.09094 = phi i32 [ 0, %.lr.ph ], [ %83, %52 ]
  %.09193 = phi ptr [ %42, %.lr.ph ], [ %82, %52 ]
  %53 = load i32, ptr %.08995, align 4, !tbaa !30
  store i32 %53, ptr %.09193, align 8, !tbaa !31
  %54 = getelementptr inbounds i8, ptr %.08995, i64 4
  %55 = load i32, ptr %54, align 4, !tbaa !30
  %56 = getelementptr inbounds i8, ptr %.09193, i64 4
  store i32 %55, ptr %56, align 4, !tbaa !33
  %57 = getelementptr inbounds i8, ptr %.08995, i64 8
  %58 = load i32, ptr %57, align 4, !tbaa !30
  %59 = getelementptr inbounds i8, ptr %.09193, i64 8
  store i32 %58, ptr %59, align 8, !tbaa !34
  %60 = getelementptr inbounds i8, ptr %.08995, i64 12
  %61 = load i32, ptr %60, align 4, !tbaa !30
  %62 = getelementptr inbounds i8, ptr %.09193, i64 12
  store i32 %61, ptr %62, align 4, !tbaa !35
  %63 = getelementptr inbounds i8, ptr %.08995, i64 16
  %64 = load i32, ptr %63, align 4, !tbaa !30
  %65 = getelementptr inbounds i8, ptr %.08995, i64 20
  %66 = zext i32 %64 to i64
  %67 = getelementptr inbounds ptr, ptr %48, i64 %66
  %68 = load ptr, ptr %67, align 8, !tbaa !11
  %69 = getelementptr inbounds i8, ptr %.09193, i64 16
  store ptr %68, ptr %69, align 8, !tbaa !36
  %70 = load i32, ptr %65, align 4, !tbaa !30
  %71 = getelementptr inbounds i8, ptr %.09193, i64 24
  store i32 %70, ptr %71, align 8, !tbaa !37
  %72 = getelementptr inbounds i8, ptr %.08995, i64 24
  %73 = load i32, ptr %72, align 4, !tbaa !30
  %74 = getelementptr inbounds i8, ptr %.09193, i64 28
  store i32 %73, ptr %74, align 4, !tbaa !38
  %75 = getelementptr inbounds i8, ptr %.09193, i64 32
  %76 = getelementptr inbounds i8, ptr %.08995, i64 40
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(20) %75, i8 0, i64 20, i1 false)
  %77 = load i8, ptr %76, align 1, !tbaa !39
  %78 = getelementptr inbounds i8, ptr %.09193, i64 52
  store i8 %77, ptr %78, align 4, !tbaa !40
  %79 = getelementptr inbounds i8, ptr %.09193, i64 53
  store i8 0, ptr %79, align 1, !tbaa !41
  %80 = getelementptr inbounds i8, ptr %.09193, i64 54
  store i8 0, ptr %80, align 2, !tbaa !42
  %81 = getelementptr inbounds i8, ptr %.08995, i64 43
  %82 = getelementptr inbounds i8, ptr %.09193, i64 56
  %83 = add nuw nsw i32 %.09094, 1
  %exitcond.not = icmp eq i32 %83, %45
  br i1 %exitcond.not, label %._crit_edge, label %52, !llvm.loop !43

.lr.ph99:                                         ; preds = %.lr.ph99.preheader, %106
  %.08897 = phi i32 [ %123, %106 ], [ 0, %.lr.ph99.preheader ]
  %.196 = phi ptr [ %122, %106 ], [ %51, %.lr.ph99.preheader ]
  %84 = getelementptr inbounds i8, ptr %.196, i64 32
  %85 = load ptr, ptr %84, align 8, !tbaa !45
  %86 = icmp eq ptr %85, null
  br i1 %86, label %88, label %87

87:                                               ; preds = %.lr.ph99
  tail call void @__assert_fail(ptr noundef nonnull @.str.7, ptr noundef nonnull @.str.1, i32 noundef 150, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN2rw4d3d814readNativeDataEPNS_6StreamEiPvii) #9
  unreachable

88:                                               ; preds = %.lr.ph99
  %89 = getelementptr inbounds i8, ptr %.196, i64 12
  %90 = load i32, ptr %89, align 4, !tbaa !35
  %91 = shl nsw i32 %90, 1
  %92 = tail call noundef ptr @_ZN2rw3d3d17createIndexBufferEjb(i32 noundef %91, i1 noundef zeroext false)
  store ptr %92, ptr %84, align 8, !tbaa !45
  %93 = tail call noundef ptr @_ZN2rw3d3d11lockIndicesEPvjjj(ptr noundef %92, i32 noundef 0, i32 noundef 0, i32 noundef 0)
  %94 = load i32, ptr %89, align 4, !tbaa !35
  %95 = shl nsw i32 %94, 1
  %96 = load ptr, ptr %0, align 8, !tbaa !20
  %97 = getelementptr inbounds i8, ptr %96, i64 32
  %98 = load ptr, ptr %97, align 8
  %99 = tail call noundef i32 %98(ptr noundef nonnull align 8 dereferenceable(8) %0, ptr noundef %93, i32 noundef %95)
  %100 = load ptr, ptr %84, align 8, !tbaa !45
  tail call void @_ZN2rw3d3d13unlockIndicesEPv(ptr noundef %100)
  %101 = getelementptr inbounds i8, ptr %.196, i64 53
  store i8 1, ptr %101, align 1, !tbaa !41
  %102 = getelementptr inbounds i8, ptr %.196, i64 40
  %103 = load ptr, ptr %102, align 8, !tbaa !46
  %104 = icmp eq ptr %103, null
  br i1 %104, label %106, label %105

105:                                              ; preds = %88
  tail call void @__assert_fail(ptr noundef nonnull @.str.8, ptr noundef nonnull @.str.1, i32 noundef 157, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN2rw4d3d814readNativeDataEPNS_6StreamEiPvii) #9
  unreachable

106:                                              ; preds = %88
  %107 = getelementptr inbounds i8, ptr %.196, i64 4
  %108 = load i32, ptr %107, align 4, !tbaa !33
  %109 = getelementptr inbounds i8, ptr %.196, i64 8
  %110 = load i32, ptr %109, align 8, !tbaa !34
  %111 = mul nsw i32 %110, %108
  %112 = tail call noundef ptr @_ZN2rw3d3d18createVertexBufferEjjb(i32 noundef %111, i32 noundef 0, i1 noundef zeroext false)
  store ptr %112, ptr %102, align 8, !tbaa !46
  %113 = tail call noundef ptr @_ZN2rw3d3d12lockVerticesEPvjjj(ptr noundef %112, i32 noundef 0, i32 noundef 0, i32 noundef 0)
  %114 = load i32, ptr %107, align 4, !tbaa !33
  %115 = load i32, ptr %109, align 8, !tbaa !34
  %116 = mul nsw i32 %115, %114
  %117 = load ptr, ptr %0, align 8, !tbaa !20
  %118 = getelementptr inbounds i8, ptr %117, i64 32
  %119 = load ptr, ptr %118, align 8
  %120 = tail call noundef i32 %119(ptr noundef nonnull align 8 dereferenceable(8) %0, ptr noundef %113, i32 noundef %116)
  %121 = load ptr, ptr %102, align 8, !tbaa !46
  tail call void @_ZN2rw3d3d14unlockVerticesEPv(ptr noundef %121)
  %122 = getelementptr inbounds i8, ptr %.196, i64 56
  %123 = add nuw nsw i32 %.08897, 1
  %124 = load i16, ptr %39, align 2, !tbaa !25
  %125 = zext i16 %124 to i32
  %126 = icmp ult i32 %123, %125
  br i1 %126, label %.lr.ph99, label %.loopexit, !llvm.loop !47

.loopexit:                                        ; preds = %106, %._crit_edge, %18, %9
  %.0 = phi ptr [ null, %18 ], [ null, %9 ], [ %0, %._crit_edge ], [ %0, %106 ]
  ret ptr %.0
}

declare noundef zeroext i1 @_ZN2rw9findChunkEPNS_6StreamEjPjS2_(ptr noundef, i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #3

declare noundef ptr @_ZN2rw9dbgsprintEjz(i32 noundef, ...) local_unnamed_addr #2

declare void @_ZN2rw8setErrorEPNS_5ErrorE(ptr noundef) local_unnamed_addr #2

declare noundef i32 @_ZN2rw6Stream7readU32Ev(ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZN2rw14mustmalloc_LOCEmjPKc(i64 noundef, i32 noundef, ptr noundef) local_unnamed_addr #4

declare noundef i32 @_ZN2rw6Stream7readI32Ev(ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #2

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #5

declare noundef ptr @_ZN2rw3d3d17createIndexBufferEjb(i32 noundef, i1 noundef zeroext) local_unnamed_addr #2

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

declare void @_ZN2rw3d3d13unlockIndicesEPv(ptr noundef) local_unnamed_addr #2

declare noundef ptr @_ZN2rw3d3d18createVertexBufferEjjb(i32 noundef, i32 noundef, i1 noundef zeroext) local_unnamed_addr #2

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

declare void @_ZN2rw3d3d14unlockVerticesEPv(ptr noundef) local_unnamed_addr #2

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { "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 = { nofree nounwind "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 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 = { noreturn nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #6 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #7 = { nounwind }
attributes #8 = { cold nounwind }
attributes #9 = { noreturn nounwind }

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !7, i64 0}
!6 = !{!"_ZTSN2rw5ErrorE", !7, i64 0, !7, i64 4}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!6, !7, i64 4}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !8, i64 0}
!13 = !{!14, !12, i64 152}
!14 = !{!"_ZTSN2rw8GeometryE", !15, i64 0, !7, i64 16, !16, i64 20, !7, i64 24, !7, i64 28, !7, i64 32, !7, i64 36, !12, i64 40, !12, i64 48, !8, i64 56, !12, i64 120, !17, i64 128, !12, i64 144, !12, i64 152, !7, i64 160}
!15 = !{!"_ZTSN2rw6ObjectE", !8, i64 0, !8, i64 1, !8, i64 2, !8, i64 3, !12, i64 8}
!16 = !{!"short", !8, i64 0}
!17 = !{!"_ZTSN2rw12MaterialListE", !12, i64 0, !7, i64 8, !7, i64 12}
!18 = !{!19, !7, i64 0}
!19 = !{!"_ZTSN2rw18InstanceDataHeaderE", !7, i64 0}
!20 = !{!21, !21, i64 0}
!21 = !{!"vtable pointer", !9, i64 0}
!22 = !{!16, !16, i64 0}
!23 = !{!24, !16, i64 4}
!24 = !{!"_ZTSN2rw4d3d818InstanceDataHeaderE", !19, i64 0, !16, i64 4, !16, i64 6, !12, i64 8}
!25 = !{!24, !16, i64 6}
!26 = !{!24, !12, i64 8}
!27 = !{!14, !12, i64 128}
!28 = !{!29, !12, i64 16}
!29 = !{!"_ZTSN2rw15MemoryFunctionsE", !12, i64 0, !12, i64 8, !12, i64 16, !12, i64 24, !12, i64 32}
!30 = !{!7, !7, i64 0}
!31 = !{!32, !7, i64 0}
!32 = !{!"_ZTSN2rw4d3d812InstanceDataE", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !12, i64 16, !7, i64 24, !7, i64 28, !12, i64 32, !12, i64 40, !7, i64 48, !8, i64 52, !8, i64 53, !8, i64 54}
!33 = !{!32, !7, i64 4}
!34 = !{!32, !7, i64 8}
!35 = !{!32, !7, i64 12}
!36 = !{!32, !12, i64 16}
!37 = !{!32, !7, i64 24}
!38 = !{!32, !7, i64 28}
!39 = !{!8, !8, i64 0}
!40 = !{!32, !8, i64 52}
!41 = !{!32, !8, i64 53}
!42 = !{!32, !8, i64 54}
!43 = distinct !{!43, !44}
!44 = !{!"llvm.loop.mustprogress"}
!45 = !{!32, !12, i64 32}
!46 = !{!32, !12, i64 40}
!47 = distinct !{!47, !44}


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