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

; 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::Error" = type { i32, i32 }
%"struct.rw::Texture" = type { ptr, ptr, %"struct.rw::LLLink", [32 x i8], [32 x i8], i32, i32, %"struct.rw::LLLink" }
%"struct.rw::LLLink" = type { ptr, ptr }
%"struct.rw::d3d::D3dRaster" = type { ptr, ptr, ptr, i32, i32, i8, i8, i8 }
%"struct.rw::Raster" = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, ptr, ptr, ptr, i32, i32, i32, ptr, i32, i32 }

@_ZN2rw3d3d18nativeRasterOffsetE = external global i32, align 4
@stderr = external global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [60 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [47 x i8], align 1
@__PRETTY_FUNCTION__._ZN2rw4d3d917readNativeTextureEPNS_6StreamE = external hidden unnamed_addr constant [47 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [32 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

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

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

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

declare void @_ZN2rw8setErrorEPNS_5ErrorE(ptr noundef) #1

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN2rw4d3d917readNativeTextureEPNS_6StreamE(ptr noundef %0) #4 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca %"struct.rw::Error", align 4
  %6 = alloca i32, align 4
  %7 = alloca %"struct.rw::Error", align 4
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca ptr, align 8
  %18 = alloca ptr, align 8
  %19 = alloca i32, align 4
  %20 = alloca ptr, align 8
  %21 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  %22 = load ptr, ptr %3, align 8, !tbaa !5
  %23 = call noundef zeroext i1 @_ZN2rw9findChunkEPNS_6StreamEjPjS2_(ptr noundef %22, i32 noundef 1, ptr noundef null, ptr noundef null)
  br i1 %23, label %35, label %24

24:                                               ; preds = %1
  br label %25

25:                                               ; preds = %24
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  %26 = getelementptr inbounds %"struct.rw::Error", ptr %5, i32 0, i32 0
  store i32 2, ptr %26, align 4, !tbaa !9
  %27 = getelementptr inbounds %"struct.rw::Error", ptr %5, i32 0, i32 1
  store i32 -2147483644, ptr %27, align 4, !tbaa !12
  %28 = load ptr, ptr @stderr, align 8, !tbaa !5
  %29 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %28, ptr noundef @.str.1, ptr noundef @.str.2, i32 noundef 708) #5
  %30 = load ptr, ptr @stderr, align 8, !tbaa !5
  %31 = call noundef ptr (i32, ...) @_ZN2rw9dbgsprintEjz(i32 noundef -2147483644, ptr noundef @.str.4)
  %32 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %30, ptr noundef @.str.3, ptr noundef %31) #5
  call void @_ZN2rw8setErrorEPNS_5ErrorE(ptr noundef %5)
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  br label %33

33:                                               ; preds = %25
  br label %34

34:                                               ; preds = %33
  store ptr null, ptr %2, align 8
  store i32 1, ptr %6, align 4
  br label %274

35:                                               ; preds = %1
  %36 = load ptr, ptr %3, align 8, !tbaa !5
  %37 = call noundef i32 @_ZN2rw6Stream7readU32Ev(ptr noundef nonnull align 8 dereferenceable(8) %36)
  store i32 %37, ptr %4, align 4, !tbaa !13
  %38 = load i32, ptr %4, align 4, !tbaa !13
  %39 = icmp ne i32 %38, 9
  br i1 %39, label %40, label %52

40:                                               ; preds = %35
  br label %41

41:                                               ; preds = %40
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %42 = getelementptr inbounds %"struct.rw::Error", ptr %7, i32 0, i32 0
  store i32 2, ptr %42, align 4, !tbaa !9
  %43 = getelementptr inbounds %"struct.rw::Error", ptr %7, i32 0, i32 1
  store i32 -2147483642, ptr %43, align 4, !tbaa !12
  %44 = load ptr, ptr @stderr, align 8, !tbaa !5
  %45 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %44, ptr noundef @.str.1, ptr noundef @.str.2, i32 noundef 713) #5
  %46 = load ptr, ptr @stderr, align 8, !tbaa !5
  %47 = load i32, ptr %4, align 4, !tbaa !13
  %48 = call noundef ptr (i32, ...) @_ZN2rw9dbgsprintEjz(i32 noundef -2147483642, i32 noundef %47)
  %49 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %46, ptr noundef @.str.3, ptr noundef %48) #5
  call void @_ZN2rw8setErrorEPNS_5ErrorE(ptr noundef %7)
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  br label %50

50:                                               ; preds = %41
  br label %51

51:                                               ; preds = %50
  store ptr null, ptr %2, align 8
  store i32 1, ptr %6, align 4
  br label %274

52:                                               ; preds = %35
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %53 = call noundef ptr @_ZN2rw7Texture6createEPNS_6RasterE(ptr noundef null)
  store ptr %53, ptr %8, align 8, !tbaa !5
  %54 = load ptr, ptr %8, align 8, !tbaa !5
  %55 = icmp eq ptr %54, null
  br i1 %55, label %56, label %57

56:                                               ; preds = %52
  store ptr null, ptr %2, align 8
  store i32 1, ptr %6, align 4
  br label %273

57:                                               ; preds = %52
  %58 = load ptr, ptr %3, align 8, !tbaa !5
  %59 = call noundef i32 @_ZN2rw6Stream7readU32Ev(ptr noundef nonnull align 8 dereferenceable(8) %58)
  %60 = load ptr, ptr %8, align 8, !tbaa !5
  %61 = getelementptr inbounds %"struct.rw::Texture", ptr %60, i32 0, i32 5
  store i32 %59, ptr %61, align 8, !tbaa !14
  %62 = load ptr, ptr %3, align 8, !tbaa !5
  %63 = load ptr, ptr %8, align 8, !tbaa !5
  %64 = getelementptr inbounds %"struct.rw::Texture", ptr %63, i32 0, i32 3
  %65 = getelementptr inbounds [32 x i8], ptr %64, i64 0, i64 0
  %66 = load ptr, ptr %62, align 8, !tbaa !17
  %67 = getelementptr inbounds ptr, ptr %66, i64 4
  %68 = load ptr, ptr %67, align 8
  %69 = call noundef i32 %68(ptr noundef nonnull align 8 dereferenceable(8) %62, ptr noundef %65, i32 noundef 32)
  %70 = load ptr, ptr %3, align 8, !tbaa !5
  %71 = load ptr, ptr %8, align 8, !tbaa !5
  %72 = getelementptr inbounds %"struct.rw::Texture", ptr %71, i32 0, i32 4
  %73 = getelementptr inbounds [32 x i8], ptr %72, i64 0, i64 0
  %74 = load ptr, ptr %70, align 8, !tbaa !17
  %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) %70, ptr noundef %73, i32 noundef 32)
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  %78 = load ptr, ptr %3, align 8, !tbaa !5
  %79 = call noundef i32 @_ZN2rw6Stream7readI32Ev(ptr noundef nonnull align 8 dereferenceable(8) %78)
  store i32 %79, ptr %9, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  %80 = load ptr, ptr %3, align 8, !tbaa !5
  %81 = call noundef i32 @_ZN2rw6Stream7readI32Ev(ptr noundef nonnull align 8 dereferenceable(8) %80)
  store i32 %81, ptr %10, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  %82 = load ptr, ptr %3, align 8, !tbaa !5
  %83 = call noundef zeroext i16 @_ZN2rw6Stream7readU16Ev(ptr noundef nonnull align 8 dereferenceable(8) %82)
  %84 = zext i16 %83 to i32
  store i32 %84, ptr %11, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  %85 = load ptr, ptr %3, align 8, !tbaa !5
  %86 = call noundef zeroext i16 @_ZN2rw6Stream7readU16Ev(ptr noundef nonnull align 8 dereferenceable(8) %85)
  %87 = zext i16 %86 to i32
  store i32 %87, ptr %12, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  %88 = load ptr, ptr %3, align 8, !tbaa !5
  %89 = call noundef zeroext i8 @_ZN2rw6Stream6readU8Ev(ptr noundef nonnull align 8 dereferenceable(8) %88)
  %90 = zext i8 %89 to i32
  store i32 %90, ptr %13, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #5
  %91 = load ptr, ptr %3, align 8, !tbaa !5
  %92 = call noundef zeroext i8 @_ZN2rw6Stream6readU8Ev(ptr noundef nonnull align 8 dereferenceable(8) %91)
  %93 = zext i8 %92 to i32
  store i32 %93, ptr %14, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #5
  %94 = load ptr, ptr %3, align 8, !tbaa !5
  %95 = call noundef zeroext i8 @_ZN2rw6Stream6readU8Ev(ptr noundef nonnull align 8 dereferenceable(8) %94)
  %96 = zext i8 %95 to i32
  store i32 %96, ptr %15, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #5
  %97 = load ptr, ptr %3, align 8, !tbaa !5
  %98 = call noundef zeroext i8 @_ZN2rw6Stream6readU8Ev(ptr noundef nonnull align 8 dereferenceable(8) %97)
  %99 = zext i8 %98 to i32
  store i32 %99, ptr %16, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #5
  %100 = load i32, ptr %16, align 4, !tbaa !13
  %101 = and i32 %100, 8
  %102 = icmp ne i32 %101, 0
  br i1 %102, label %103, label %177

103:                                              ; preds = %57
  %104 = load i32, ptr %16, align 4, !tbaa !13
  %105 = and i32 %104, 2
  %106 = icmp eq i32 %105, 0
  br i1 %106, label %107, label %108

107:                                              ; preds = %103
  br label %108

108:                                              ; preds = %107, %103
  %109 = phi i1 [ false, %103 ], [ true, %107 ]
  br i1 %109, label %110, label %111

110:                                              ; preds = %108
  br label %113

111:                                              ; preds = %108
  call void @__assert_fail(ptr noundef @.str.14, ptr noundef @.str.2, i32 noundef 746, ptr noundef @__PRETTY_FUNCTION__._ZN2rw4d3d917readNativeTextureEPNS_6StreamE) #6
  unreachable

112:                                              ; No predecessors!
  br label %113

113:                                              ; preds = %112, %110
  %114 = load i32, ptr %11, align 4, !tbaa !13
  %115 = load i32, ptr %12, align 4, !tbaa !13
  %116 = load i32, ptr %13, align 4, !tbaa !13
  %117 = load i32, ptr %9, align 4, !tbaa !13
  %118 = load i32, ptr %15, align 4, !tbaa !13
  %119 = or i32 %117, %118
  %120 = or i32 %119, 128
  %121 = call noundef ptr @_ZN2rw6Raster6createEiiiii(i32 noundef %114, i32 noundef %115, i32 noundef %116, i32 noundef %120, i32 noundef 9)
  store ptr %121, ptr %17, align 8, !tbaa !5
  %122 = load ptr, ptr %17, align 8, !tbaa !5
  %123 = icmp ne ptr %122, null
  br i1 %123, label %124, label %125

124:                                              ; preds = %113
  br label %127

125:                                              ; preds = %113
  call void @__assert_fail(ptr noundef @.str.15, ptr noundef @.str.2, i32 noundef 748, ptr noundef @__PRETTY_FUNCTION__._ZN2rw4d3d917readNativeTextureEPNS_6StreamE) #6
  unreachable

126:                                              ; No predecessors!
  br label %127

127:                                              ; preds = %126, %124
  %128 = load ptr, ptr %17, align 8, !tbaa !5
  %129 = load i32, ptr @_ZN2rw3d3d18nativeRasterOffsetE, align 4, !tbaa !13
  %130 = sext i32 %129 to i64
  %131 = getelementptr inbounds i8, ptr %128, i64 %130
  store ptr %131, ptr %18, align 8, !tbaa !5
  %132 = load i32, ptr %10, align 4, !tbaa !13
  %133 = load ptr, ptr %18, align 8, !tbaa !5
  %134 = getelementptr inbounds %"struct.rw::d3d::D3dRaster", ptr %133, i32 0, i32 3
  store i32 %132, ptr %134, align 8, !tbaa !19
  %135 = load i32, ptr %16, align 4, !tbaa !13
  %136 = and i32 %135, 1
  %137 = icmp ne i32 %136, 0
  %138 = load ptr, ptr %18, align 8, !tbaa !5
  %139 = getelementptr inbounds %"struct.rw::d3d::D3dRaster", ptr %138, i32 0, i32 5
  %140 = zext i1 %137 to i8
  store i8 %140, ptr %139, align 8, !tbaa !22
  %141 = load ptr, ptr %17, align 8, !tbaa !5
  %142 = getelementptr inbounds %"struct.rw::Raster", ptr %141, i32 0, i32 5
  %143 = load i32, ptr %142, align 4, !tbaa !23
  %144 = load ptr, ptr %17, align 8, !tbaa !5
  %145 = getelementptr inbounds %"struct.rw::Raster", ptr %144, i32 0, i32 6
  %146 = load i32, ptr %145, align 8, !tbaa !25
  %147 = load ptr, ptr %17, align 8, !tbaa !5
  %148 = getelementptr inbounds %"struct.rw::Raster", ptr %147, i32 0, i32 4
  %149 = load i32, ptr %148, align 8, !tbaa !26
  %150 = and i32 %149, 32768
  %151 = icmp ne i32 %150, 0
  br i1 %151, label %152, label %154

152:                                              ; preds = %127
  %153 = load i32, ptr %14, align 4, !tbaa !13
  br label %155

154:                                              ; preds = %127
  br label %155

155:                                              ; preds = %154, %152
  %156 = phi i32 [ %153, %152 ], [ 1, %154 ]
  %157 = load ptr, ptr %18, align 8, !tbaa !5
  %158 = getelementptr inbounds %"struct.rw::d3d::D3dRaster", ptr %157, i32 0, i32 3
  %159 = load i32, ptr %158, align 8, !tbaa !19
  %160 = call noundef ptr @_ZN2rw3d3d13createTextureEiiijj(i32 noundef %143, i32 noundef %146, i32 noundef %156, i32 noundef 0, i32 noundef %159)
  %161 = load ptr, ptr %18, align 8, !tbaa !5
  %162 = getelementptr inbounds %"struct.rw::d3d::D3dRaster", ptr %161, i32 0, i32 0
  store ptr %160, ptr %162, align 8, !tbaa !27
  %163 = load ptr, ptr %18, align 8, !tbaa !5
  %164 = getelementptr inbounds %"struct.rw::d3d::D3dRaster", ptr %163, i32 0, i32 0
  %165 = load ptr, ptr %164, align 8, !tbaa !27
  %166 = icmp ne ptr %165, null
  br i1 %166, label %167, label %168

167:                                              ; preds = %155
  br label %170

168:                                              ; preds = %155
  call void @__assert_fail(ptr noundef @.str.16, ptr noundef @.str.2, i32 noundef 756, ptr noundef @__PRETTY_FUNCTION__._ZN2rw4d3d917readNativeTextureEPNS_6StreamE) #6
  unreachable

169:                                              ; No predecessors!
  br label %170

170:                                              ; preds = %169, %167
  %171 = load ptr, ptr %17, align 8, !tbaa !5
  %172 = getelementptr inbounds %"struct.rw::Raster", ptr %171, i32 0, i32 2
  %173 = load i32, ptr %172, align 8, !tbaa !28
  %174 = and i32 %173, -129
  store i32 %174, ptr %172, align 8, !tbaa !28
  %175 = load ptr, ptr %18, align 8, !tbaa !5
  %176 = getelementptr inbounds %"struct.rw::d3d::D3dRaster", ptr %175, i32 0, i32 6
  store i8 1, ptr %176, align 1, !tbaa !29
  br label %201

177:                                              ; preds = %57
  %178 = load i32, ptr %16, align 4, !tbaa !13
  %179 = and i32 %178, 2
  %180 = icmp ne i32 %179, 0
  br i1 %180, label %181, label %182

181:                                              ; preds = %177
  call void @__assert_fail(ptr noundef @.str.17, ptr noundef @.str.2, i32 noundef 760, ptr noundef @__PRETTY_FUNCTION__._ZN2rw4d3d917readNativeTextureEPNS_6StreamE) #6
  unreachable

182:                                              ; preds = %177
  %183 = load i32, ptr %11, align 4, !tbaa !13
  %184 = load i32, ptr %12, align 4, !tbaa !13
  %185 = load i32, ptr %13, align 4, !tbaa !13
  %186 = load i32, ptr %9, align 4, !tbaa !13
  %187 = load i32, ptr %15, align 4, !tbaa !13
  %188 = or i32 %186, %187
  %189 = call noundef ptr @_ZN2rw6Raster6createEiiiii(i32 noundef %183, i32 noundef %184, i32 noundef %185, i32 noundef %188, i32 noundef 9)
  store ptr %189, ptr %17, align 8, !tbaa !5
  %190 = load ptr, ptr %17, align 8, !tbaa !5
  %191 = icmp ne ptr %190, null
  br i1 %191, label %192, label %193

192:                                              ; preds = %182
  br label %195

193:                                              ; preds = %182
  call void @__assert_fail(ptr noundef @.str.15, ptr noundef @.str.2, i32 noundef 763, ptr noundef @__PRETTY_FUNCTION__._ZN2rw4d3d917readNativeTextureEPNS_6StreamE) #6
  unreachable

194:                                              ; No predecessors!
  br label %195

195:                                              ; preds = %194, %192
  %196 = load ptr, ptr %17, align 8, !tbaa !5
  %197 = load i32, ptr @_ZN2rw3d3d18nativeRasterOffsetE, align 4, !tbaa !13
  %198 = sext i32 %197 to i64
  %199 = getelementptr inbounds i8, ptr %196, i64 %198
  store ptr %199, ptr %18, align 8, !tbaa !5
  br label %200

200:                                              ; preds = %195
  br label %201

201:                                              ; preds = %200, %170
  %202 = load ptr, ptr %17, align 8, !tbaa !5
  %203 = load ptr, ptr %8, align 8, !tbaa !5
  %204 = getelementptr inbounds %"struct.rw::Texture", ptr %203, i32 0, i32 0
  store ptr %202, ptr %204, align 8, !tbaa !30
  %205 = load ptr, ptr %17, align 8, !tbaa !5
  %206 = getelementptr inbounds %"struct.rw::Raster", ptr %205, i32 0, i32 4
  %207 = load i32, ptr %206, align 8, !tbaa !26
  %208 = and i32 %207, 16384
  %209 = icmp ne i32 %208, 0
  br i1 %209, label %210, label %219

210:                                              ; preds = %201
  %211 = load ptr, ptr %3, align 8, !tbaa !5
  %212 = load ptr, ptr %18, align 8, !tbaa !5
  %213 = getelementptr inbounds %"struct.rw::d3d::D3dRaster", ptr %212, i32 0, i32 1
  %214 = load ptr, ptr %213, align 8, !tbaa !31
  %215 = load ptr, ptr %211, align 8, !tbaa !17
  %216 = getelementptr inbounds ptr, ptr %215, i64 4
  %217 = load ptr, ptr %216, align 8
  %218 = call noundef i32 %217(ptr noundef nonnull align 8 dereferenceable(8) %211, ptr noundef %214, i32 noundef 128)
  br label %235

219:                                              ; preds = %201
  %220 = load ptr, ptr %17, align 8, !tbaa !5
  %221 = getelementptr inbounds %"struct.rw::Raster", ptr %220, i32 0, i32 4
  %222 = load i32, ptr %221, align 8, !tbaa !26
  %223 = and i32 %222, 8192
  %224 = icmp ne i32 %223, 0
  br i1 %224, label %225, label %234

225:                                              ; preds = %219
  %226 = load ptr, ptr %3, align 8, !tbaa !5
  %227 = load ptr, ptr %18, align 8, !tbaa !5
  %228 = getelementptr inbounds %"struct.rw::d3d::D3dRaster", ptr %227, i32 0, i32 1
  %229 = load ptr, ptr %228, align 8, !tbaa !31
  %230 = load ptr, ptr %226, align 8, !tbaa !17
  %231 = getelementptr inbounds ptr, ptr %230, i64 4
  %232 = load ptr, ptr %231, align 8
  %233 = call noundef i32 %232(ptr noundef nonnull align 8 dereferenceable(8) %226, ptr noundef %229, i32 noundef 1024)
  br label %234

234:                                              ; preds = %225, %219
  br label %235

235:                                              ; preds = %234, %210
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #5
  store i32 0, ptr %21, align 4, !tbaa !13
  br label %236

236:                                              ; preds = %268, %235
  %237 = load i32, ptr %21, align 4, !tbaa !13
  %238 = load i32, ptr %14, align 4, !tbaa !13
  %239 = icmp slt i32 %237, %238
  br i1 %239, label %241, label %240

240:                                              ; preds = %236
  store i32 6, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #5
  br label %271

241:                                              ; preds = %236
  %242 = load ptr, ptr %3, align 8, !tbaa !5
  %243 = call noundef i32 @_ZN2rw6Stream7readU32Ev(ptr noundef nonnull align 8 dereferenceable(8) %242)
  store i32 %243, ptr %19, align 4, !tbaa !13
  %244 = load i32, ptr %21, align 4, !tbaa !13
  %245 = load ptr, ptr %17, align 8, !tbaa !5
  %246 = call noundef i32 @_ZN2rw6Raster12getNumLevelsEv(ptr noundef nonnull align 8 dereferenceable(96) %245)
  %247 = icmp slt i32 %244, %246
  br i1 %247, label %248, label %261

248:                                              ; preds = %241
  %249 = load ptr, ptr %17, align 8, !tbaa !5
  %250 = load i32, ptr %21, align 4, !tbaa !13
  %251 = call noundef ptr @_ZN2rw6Raster4lockEii(ptr noundef nonnull align 8 dereferenceable(96) %249, i32 noundef %250, i32 noundef 5)
  store ptr %251, ptr %20, align 8, !tbaa !5
  %252 = load ptr, ptr %3, align 8, !tbaa !5
  %253 = load ptr, ptr %20, align 8, !tbaa !5
  %254 = load i32, ptr %19, align 4, !tbaa !13
  %255 = load ptr, ptr %252, align 8, !tbaa !17
  %256 = getelementptr inbounds ptr, ptr %255, i64 4
  %257 = load ptr, ptr %256, align 8
  %258 = call noundef i32 %257(ptr noundef nonnull align 8 dereferenceable(8) %252, ptr noundef %253, i32 noundef %254)
  %259 = load ptr, ptr %17, align 8, !tbaa !5
  %260 = load i32, ptr %21, align 4, !tbaa !13
  call void @_ZN2rw6Raster6unlockEi(ptr noundef nonnull align 8 dereferenceable(96) %259, i32 noundef %260)
  br label %267

261:                                              ; preds = %241
  %262 = load ptr, ptr %3, align 8, !tbaa !5
  %263 = load i32, ptr %19, align 4, !tbaa !13
  %264 = load ptr, ptr %262, align 8, !tbaa !17
  %265 = getelementptr inbounds ptr, ptr %264, i64 5
  %266 = load ptr, ptr %265, align 8
  call void %266(ptr noundef nonnull align 8 dereferenceable(8) %262, i32 noundef %263, i32 noundef 1)
  br label %267

267:                                              ; preds = %261, %248
  br label %268

268:                                              ; preds = %267
  %269 = load i32, ptr %21, align 4, !tbaa !13
  %270 = add nsw i32 %269, 1
  store i32 %270, ptr %21, align 4, !tbaa !13
  br label %236, !llvm.loop !32

271:                                              ; preds = %240
  %272 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %272, ptr %2, align 8
  store i32 1, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #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 4, ptr %16) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  br label %273

273:                                              ; preds = %271, %56
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  br label %274

274:                                              ; preds = %273, %51, %34
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  %275 = load ptr, ptr %2, align 8
  ret ptr %275
}

declare noundef ptr @_ZN2rw7Texture6createEPNS_6RasterE(ptr noundef) #1

declare noundef zeroext i16 @_ZN2rw6Stream7readU16Ev(ptr noundef nonnull align 8 dereferenceable(8)) #1

declare noundef zeroext i8 @_ZN2rw6Stream6readU8Ev(ptr noundef nonnull align 8 dereferenceable(8)) #1

declare noundef ptr @_ZN2rw6Raster6createEiiiii(i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) #1

declare noundef ptr @_ZN2rw3d3d13createTextureEiiijj(i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) #1

declare noundef i32 @_ZN2rw6Raster12getNumLevelsEv(ptr noundef nonnull align 8 dereferenceable(96)) #1

declare noundef ptr @_ZN2rw6Raster4lockEii(ptr noundef nonnull align 8 dereferenceable(96), i32 noundef, i32 noundef) #1

declare void @_ZN2rw6Raster6unlockEi(ptr noundef nonnull align 8 dereferenceable(96), i32 noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 = { 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 #3 = { 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 #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 }
attributes #6 = { 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, !11, i64 0}
!10 = !{!"_ZTSN2rw5ErrorE", !11, i64 0, !11, i64 4}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !11, i64 4}
!13 = !{!11, !11, i64 0}
!14 = !{!15, !11, i64 96}
!15 = !{!"_ZTSN2rw7TextureE", !6, i64 0, !6, i64 8, !16, i64 16, !7, i64 32, !7, i64 64, !11, i64 96, !11, i64 100, !16, i64 104}
!16 = !{!"_ZTSN2rw6LLLinkE", !6, i64 0, !6, i64 8}
!17 = !{!18, !18, i64 0}
!18 = !{!"vtable pointer", !8, i64 0}
!19 = !{!20, !11, i64 24}
!20 = !{!"_ZTSN2rw3d3d9D3dRasterE", !6, i64 0, !6, i64 8, !6, i64 16, !11, i64 24, !11, i64 28, !21, i64 32, !21, i64 33, !21, i64 34}
!21 = !{!"bool", !7, i64 0}
!22 = !{!20, !21, i64 32}
!23 = !{!24, !11, i64 20}
!24 = !{!"_ZTSN2rw6RasterE", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !11, i64 24, !11, i64 28, !11, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !11, i64 64, !11, i64 68, !11, i64 72, !6, i64 80, !11, i64 88, !11, i64 92}
!25 = !{!24, !11, i64 24}
!26 = !{!24, !11, i64 16}
!27 = !{!20, !6, i64 0}
!28 = !{!24, !11, i64 8}
!29 = !{!20, !21, i64 33}
!30 = !{!15, !6, i64 0}
!31 = !{!20, !6, i64 8}
!32 = distinct !{!32, !33}
!33 = !{!"llvm.loop.mustprogress"}


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

@_ZN2rw3d3d18nativeRasterOffsetE = external local_unnamed_addr global i32, align 4
@stderr = external local_unnamed_addr global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [60 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [47 x i8], align 1
@__PRETTY_FUNCTION__._ZN2rw4d3d917readNativeTextureEPNS_6StreamE = external hidden unnamed_addr constant [47 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [32 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

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

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

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

declare void @_ZN2rw8setErrorEPNS_5ErrorE(ptr noundef) local_unnamed_addr #1

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN2rw4d3d917readNativeTextureEPNS_6StreamE(ptr noundef %0) local_unnamed_addr #4 {
  %2 = alloca %"struct.rw::Error", align 4
  %3 = alloca %"struct.rw::Error", align 4
  %4 = tail call noundef zeroext i1 @_ZN2rw9findChunkEPNS_6StreamEjPjS2_(ptr noundef %0, i32 noundef 1, ptr noundef null, ptr noundef null)
  br i1 %4, label %12, label %5

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

12:                                               ; preds = %1
  %13 = tail call noundef i32 @_ZN2rw6Stream7readU32Ev(ptr noundef nonnull align 8 dereferenceable(8) %0)
  %.not = icmp eq i32 %13, 9
  br i1 %.not, label %21, label %14

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

21:                                               ; preds = %12
  %22 = tail call noundef ptr @_ZN2rw7Texture6createEPNS_6RasterE(ptr noundef null)
  %23 = icmp eq ptr %22, null
  br i1 %23, label %.loopexit, label %24

24:                                               ; preds = %21
  %25 = tail call noundef i32 @_ZN2rw6Stream7readU32Ev(ptr noundef nonnull align 8 dereferenceable(8) %0)
  %26 = getelementptr inbounds i8, ptr %22, i64 96
  store i32 %25, ptr %26, align 8, !tbaa !13
  %27 = getelementptr inbounds i8, ptr %22, i64 32
  %28 = load ptr, ptr %0, align 8, !tbaa !16
  %29 = getelementptr inbounds i8, ptr %28, i64 32
  %30 = load ptr, ptr %29, align 8
  %31 = tail call noundef i32 %30(ptr noundef nonnull align 8 dereferenceable(8) %0, ptr noundef nonnull %27, i32 noundef 32)
  %32 = getelementptr inbounds i8, ptr %22, i64 64
  %33 = load ptr, ptr %0, align 8, !tbaa !16
  %34 = getelementptr inbounds i8, ptr %33, i64 32
  %35 = load ptr, ptr %34, align 8
  %36 = tail call noundef i32 %35(ptr noundef nonnull align 8 dereferenceable(8) %0, ptr noundef nonnull %32, i32 noundef 32)
  %37 = tail call noundef i32 @_ZN2rw6Stream7readI32Ev(ptr noundef nonnull align 8 dereferenceable(8) %0)
  %38 = tail call noundef i32 @_ZN2rw6Stream7readI32Ev(ptr noundef nonnull align 8 dereferenceable(8) %0)
  %39 = tail call noundef zeroext i16 @_ZN2rw6Stream7readU16Ev(ptr noundef nonnull align 8 dereferenceable(8) %0)
  %40 = zext i16 %39 to i32
  %41 = tail call noundef zeroext i16 @_ZN2rw6Stream7readU16Ev(ptr noundef nonnull align 8 dereferenceable(8) %0)
  %42 = zext i16 %41 to i32
  %43 = tail call noundef zeroext i8 @_ZN2rw6Stream6readU8Ev(ptr noundef nonnull align 8 dereferenceable(8) %0)
  %44 = zext i8 %43 to i32
  %45 = tail call noundef zeroext i8 @_ZN2rw6Stream6readU8Ev(ptr noundef nonnull align 8 dereferenceable(8) %0)
  %46 = zext i8 %45 to i32
  %47 = tail call noundef zeroext i8 @_ZN2rw6Stream6readU8Ev(ptr noundef nonnull align 8 dereferenceable(8) %0)
  %48 = zext i8 %47 to i32
  %49 = tail call noundef zeroext i8 @_ZN2rw6Stream6readU8Ev(ptr noundef nonnull align 8 dereferenceable(8) %0)
  %50 = zext i8 %49 to i32
  %51 = and i32 %50, 8
  %.not80 = icmp eq i32 %51, 0
  %52 = and i32 %50, 2
  %.not81 = icmp eq i32 %52, 0
  br i1 %.not80, label %82, label %53

53:                                               ; preds = %24
  br i1 %.not81, label %55, label %54

54:                                               ; preds = %53
  tail call void @__assert_fail(ptr noundef nonnull @.str.14, ptr noundef nonnull @.str.2, i32 noundef 746, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN2rw4d3d917readNativeTextureEPNS_6StreamE) #7
  unreachable

55:                                               ; preds = %53
  %56 = or i32 %37, %48
  %57 = or i32 %56, 128
  %58 = tail call noundef ptr @_ZN2rw6Raster6createEiiiii(i32 noundef %40, i32 noundef %42, i32 noundef %44, i32 noundef %57, i32 noundef 9)
  %.not83 = icmp eq ptr %58, null
  br i1 %.not83, label %59, label %60

59:                                               ; preds = %55
  tail call void @__assert_fail(ptr noundef nonnull @.str.15, ptr noundef nonnull @.str.2, i32 noundef 748, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN2rw4d3d917readNativeTextureEPNS_6StreamE) #7
  unreachable

60:                                               ; preds = %55
  %61 = load i32, ptr @_ZN2rw3d3d18nativeRasterOffsetE, align 4, !tbaa !18
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds i8, ptr %58, i64 %62
  %64 = getelementptr inbounds i8, ptr %63, i64 24
  store i32 %38, ptr %64, align 8, !tbaa !19
  %65 = and i8 %49, 1
  %66 = getelementptr inbounds i8, ptr %63, i64 32
  store i8 %65, ptr %66, align 8, !tbaa !22
  %67 = getelementptr inbounds i8, ptr %58, i64 20
  %68 = load i32, ptr %67, align 4, !tbaa !23
  %69 = getelementptr inbounds i8, ptr %58, i64 24
  %70 = load i32, ptr %69, align 8, !tbaa !25
  %71 = getelementptr inbounds i8, ptr %58, i64 16
  %72 = load i32, ptr %71, align 8, !tbaa !26
  %73 = and i32 %72, 32768
  %.not84 = icmp eq i32 %73, 0
  %74 = select i1 %.not84, i32 1, i32 %46
  %75 = tail call noundef ptr @_ZN2rw3d3d13createTextureEiiijj(i32 noundef %68, i32 noundef %70, i32 noundef %74, i32 noundef 0, i32 noundef %38)
  store ptr %75, ptr %63, align 8, !tbaa !27
  %.not85 = icmp eq ptr %75, null
  br i1 %.not85, label %76, label %77

76:                                               ; preds = %60
  tail call void @__assert_fail(ptr noundef nonnull @.str.16, ptr noundef nonnull @.str.2, i32 noundef 756, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN2rw4d3d917readNativeTextureEPNS_6StreamE) #7
  unreachable

77:                                               ; preds = %60
  %78 = getelementptr inbounds i8, ptr %58, i64 8
  %79 = load i32, ptr %78, align 8, !tbaa !28
  %80 = and i32 %79, -129
  store i32 %80, ptr %78, align 8, !tbaa !28
  %81 = getelementptr inbounds i8, ptr %63, i64 33
  store i8 1, ptr %81, align 1, !tbaa !29
  br label %92

82:                                               ; preds = %24
  br i1 %.not81, label %84, label %83

83:                                               ; preds = %82
  tail call void @__assert_fail(ptr noundef nonnull @.str.17, ptr noundef nonnull @.str.2, i32 noundef 760, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN2rw4d3d917readNativeTextureEPNS_6StreamE) #7
  unreachable

84:                                               ; preds = %82
  %85 = or i32 %37, %48
  %86 = tail call noundef ptr @_ZN2rw6Raster6createEiiiii(i32 noundef %40, i32 noundef %42, i32 noundef %44, i32 noundef %85, i32 noundef 9)
  %.not82 = icmp eq ptr %86, null
  br i1 %.not82, label %87, label %88

87:                                               ; preds = %84
  tail call void @__assert_fail(ptr noundef nonnull @.str.15, ptr noundef nonnull @.str.2, i32 noundef 763, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN2rw4d3d917readNativeTextureEPNS_6StreamE) #7
  unreachable

88:                                               ; preds = %84
  %89 = load i32, ptr @_ZN2rw3d3d18nativeRasterOffsetE, align 4, !tbaa !18
  %90 = sext i32 %89 to i64
  %91 = getelementptr inbounds i8, ptr %86, i64 %90
  br label %92

92:                                               ; preds = %88, %77
  %.075 = phi ptr [ %58, %77 ], [ %86, %88 ]
  %.074 = phi ptr [ %63, %77 ], [ %91, %88 ]
  store ptr %.075, ptr %22, align 8, !tbaa !30
  %93 = getelementptr inbounds i8, ptr %.075, i64 16
  %94 = load i32, ptr %93, align 8, !tbaa !26
  %95 = and i32 %94, 16384
  %.not86 = icmp eq i32 %95, 0
  br i1 %.not86, label %96, label %.sink.split

96:                                               ; preds = %92
  %97 = and i32 %94, 8192
  %.not87 = icmp eq i32 %97, 0
  br i1 %.not87, label %104, label %.sink.split

.sink.split:                                      ; preds = %96, %92
  %.sink90 = phi i32 [ 128, %92 ], [ 1024, %96 ]
  %98 = getelementptr inbounds i8, ptr %.074, i64 8
  %99 = load ptr, ptr %98, align 8, !tbaa !31
  %100 = load ptr, ptr %0, align 8, !tbaa !16
  %101 = getelementptr inbounds i8, ptr %100, i64 32
  %102 = load ptr, ptr %101, align 8
  %103 = tail call noundef i32 %102(ptr noundef nonnull align 8 dereferenceable(8) %0, ptr noundef %99, i32 noundef %.sink90)
  br label %104

104:                                              ; preds = %.sink.split, %96
  %.not89 = icmp eq i8 %45, 0
  br i1 %.not89, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %104, %118
  %.088 = phi i32 [ %119, %118 ], [ 0, %104 ]
  %105 = tail call noundef i32 @_ZN2rw6Stream7readU32Ev(ptr noundef nonnull align 8 dereferenceable(8) %0)
  %106 = tail call noundef i32 @_ZN2rw6Raster12getNumLevelsEv(ptr noundef nonnull align 8 dereferenceable(96) %.075)
  %107 = icmp slt i32 %.088, %106
  br i1 %107, label %108, label %114

108:                                              ; preds = %.lr.ph
  %109 = tail call noundef ptr @_ZN2rw6Raster4lockEii(ptr noundef nonnull align 8 dereferenceable(96) %.075, i32 noundef %.088, i32 noundef 5)
  %110 = load ptr, ptr %0, align 8, !tbaa !16
  %111 = getelementptr inbounds i8, ptr %110, i64 32
  %112 = load ptr, ptr %111, align 8
  %113 = tail call noundef i32 %112(ptr noundef nonnull align 8 dereferenceable(8) %0, ptr noundef %109, i32 noundef %105)
  tail call void @_ZN2rw6Raster6unlockEi(ptr noundef nonnull align 8 dereferenceable(96) %.075, i32 noundef %.088)
  br label %118

114:                                              ; preds = %.lr.ph
  %115 = load ptr, ptr %0, align 8, !tbaa !16
  %116 = getelementptr inbounds i8, ptr %115, i64 40
  %117 = load ptr, ptr %116, align 8
  tail call void %117(ptr noundef nonnull align 8 dereferenceable(8) %0, i32 noundef %105, i32 noundef 1)
  br label %118

118:                                              ; preds = %108, %114
  %119 = add nuw nsw i32 %.088, 1
  %exitcond.not = icmp eq i32 %119, %46
  br i1 %exitcond.not, label %.loopexit, label %.lr.ph, !llvm.loop !32

.loopexit:                                        ; preds = %118, %104, %21, %14, %5
  %.1 = phi ptr [ null, %14 ], [ null, %5 ], [ null, %21 ], [ %22, %104 ], [ %22, %118 ]
  ret ptr %.1
}

declare noundef ptr @_ZN2rw7Texture6createEPNS_6RasterE(ptr noundef) local_unnamed_addr #1

declare noundef zeroext i16 @_ZN2rw6Stream7readU16Ev(ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #1

declare noundef zeroext i8 @_ZN2rw6Stream6readU8Ev(ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #1

declare noundef ptr @_ZN2rw6Raster6createEiiiii(i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

declare noundef ptr @_ZN2rw3d3d13createTextureEiiijj(i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

declare noundef i32 @_ZN2rw6Raster12getNumLevelsEv(ptr noundef nonnull align 8 dereferenceable(96)) local_unnamed_addr #1

declare noundef ptr @_ZN2rw6Raster4lockEii(ptr noundef nonnull align 8 dereferenceable(96), i32 noundef, i32 noundef) local_unnamed_addr #1

declare void @_ZN2rw6Raster6unlockEi(ptr noundef nonnull align 8 dereferenceable(96), i32 noundef) local_unnamed_addr #1

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 = { 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 #3 = { 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 #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 }
attributes #6 = { cold 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, !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, !7, i64 96}
!14 = !{!"_ZTSN2rw7TextureE", !12, i64 0, !12, i64 8, !15, i64 16, !8, i64 32, !8, i64 64, !7, i64 96, !7, i64 100, !15, i64 104}
!15 = !{!"_ZTSN2rw6LLLinkE", !12, i64 0, !12, i64 8}
!16 = !{!17, !17, i64 0}
!17 = !{!"vtable pointer", !9, i64 0}
!18 = !{!7, !7, i64 0}
!19 = !{!20, !7, i64 24}
!20 = !{!"_ZTSN2rw3d3d9D3dRasterE", !12, i64 0, !12, i64 8, !12, i64 16, !7, i64 24, !7, i64 28, !21, i64 32, !21, i64 33, !21, i64 34}
!21 = !{!"bool", !8, i64 0}
!22 = !{!20, !21, i64 32}
!23 = !{!24, !7, i64 20}
!24 = !{!"_ZTSN2rw6RasterE", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20, !7, i64 24, !7, i64 28, !7, i64 32, !12, i64 40, !12, i64 48, !12, i64 56, !7, i64 64, !7, i64 68, !7, i64 72, !12, i64 80, !7, i64 88, !7, i64 92}
!25 = !{!24, !7, i64 24}
!26 = !{!24, !7, i64 16}
!27 = !{!20, !12, i64 0}
!28 = !{!24, !7, i64 8}
!29 = !{!20, !21, i64 33}
!30 = !{!14, !12, i64 0}
!31 = !{!20, !12, i64 8}
!32 = distinct !{!32, !33}
!33 = !{!"llvm.loop.mustprogress"}


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