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

; 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::Raster" = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, ptr, ptr, ptr, i32, i32, i32, ptr, i32, i32 }
%"struct.rw::d3d::D3dRaster" = type { ptr, ptr, ptr, i32, i32, i8, i8, i8 }
%"struct.rw::Image" = type { i32, i32, i32, i32, i32, i32, ptr, ptr }

@_ZN2rw3d3d18nativeRasterOffsetE = external dso_local global i32, align 4
@stderr = external global ptr, align 8
@.str.3 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [59 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [32 x i8], align 1
@__PRETTY_FUNCTION__._ZN2rw3d3d13rasterToImageEPNS_6RasterE = external hidden unnamed_addr constant [40 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: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #1

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

declare void @_ZN2rw8setErrorEPNS_5ErrorE(ptr noundef) #2

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

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

declare void @_ZN2rw27conv_ARGB1555_from_ARGB1555EPhS0_(ptr noundef, ptr noundef) #2

declare void @_ZN2rw27conv_RGBA8888_from_RGBA8888EPhS0_(ptr noundef, ptr noundef) #2

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

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

declare void @_ZN2rw5Image7destroyEv(ptr noundef nonnull align 8 dereferenceable(40)) #2

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

28:                                               ; preds = %1
  %29 = load ptr, ptr %3, align 8, !tbaa !5
  %30 = call noundef ptr @_ZN2rw6Raster4lockEii(ptr noundef nonnull align 8 dereferenceable(96) %29, i32 noundef 0, i32 noundef 2)
  store i8 1, ptr %6, align 1, !tbaa !9
  br label %31

31:                                               ; preds = %28, %1
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #6
  %32 = load ptr, ptr %3, align 8, !tbaa !5
  %33 = load i32, ptr @_ZN2rw3d3d18nativeRasterOffsetE, align 4, !tbaa !14
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds i8, ptr %32, i64 %34
  store ptr %35, ptr %7, align 8, !tbaa !5
  %36 = load ptr, ptr %7, align 8, !tbaa !5
  %37 = getelementptr inbounds %"struct.rw::d3d::D3dRaster", ptr %36, i32 0, i32 6
  %38 = load i8, ptr %37, align 1, !tbaa !15, !range !17, !noundef !18
  %39 = trunc i8 %38 to i1
  br i1 %39, label %40, label %107

40:                                               ; preds = %31
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  %41 = load ptr, ptr %3, align 8, !tbaa !5
  %42 = getelementptr inbounds %"struct.rw::Raster", ptr %41, i32 0, i32 5
  %43 = load i32, ptr %42, align 4, !tbaa !19
  store i32 %43, ptr %8, align 4, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  %44 = load ptr, ptr %3, align 8, !tbaa !5
  %45 = getelementptr inbounds %"struct.rw::Raster", ptr %44, i32 0, i32 6
  %46 = load i32, ptr %45, align 8, !tbaa !20
  store i32 %46, ptr %9, align 4, !tbaa !14
  %47 = load i32, ptr %8, align 4, !tbaa !14
  %48 = icmp slt i32 %47, 4
  br i1 %48, label %49, label %50

49:                                               ; preds = %40
  store i32 4, ptr %8, align 4, !tbaa !14
  br label %50

50:                                               ; preds = %49, %40
  %51 = load i32, ptr %9, align 4, !tbaa !14
  %52 = icmp slt i32 %51, 4
  br i1 %52, label %53, label %54

53:                                               ; preds = %50
  store i32 4, ptr %9, align 4, !tbaa !14
  br label %54

54:                                               ; preds = %53, %50
  %55 = load i32, ptr %8, align 4, !tbaa !14
  %56 = load i32, ptr %9, align 4, !tbaa !14
  %57 = call noundef ptr @_ZN2rw5Image6createEiii(i32 noundef %55, i32 noundef %56, i32 noundef 32)
  store ptr %57, ptr %5, align 8, !tbaa !5
  %58 = load ptr, ptr %5, align 8, !tbaa !5
  call void @_ZN2rw5Image8allocateEv(ptr noundef nonnull align 8 dereferenceable(40) %58)
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #6
  %59 = load ptr, ptr %3, align 8, !tbaa !5
  %60 = getelementptr inbounds %"struct.rw::Raster", ptr %59, i32 0, i32 9
  %61 = load ptr, ptr %60, align 8, !tbaa !11
  store ptr %61, ptr %10, align 8, !tbaa !5
  %62 = load ptr, ptr %7, align 8, !tbaa !5
  %63 = getelementptr inbounds %"struct.rw::d3d::D3dRaster", ptr %62, i32 0, i32 3
  %64 = load i32, ptr %63, align 8, !tbaa !21
  switch i32 %64, label %82 [
    i32 827611204, label %65
    i32 861165636, label %76
    i32 894720068, label %79
  ]

65:                                               ; preds = %54
  %66 = load ptr, ptr %5, align 8, !tbaa !5
  %67 = load ptr, ptr %10, align 8, !tbaa !5
  call void @_ZN2rw5Image12setPixelsDXTEiPh(ptr noundef nonnull align 8 dereferenceable(40) %66, i32 noundef 1, ptr noundef %67)
  %68 = load ptr, ptr %3, align 8, !tbaa !5
  %69 = getelementptr inbounds %"struct.rw::Raster", ptr %68, i32 0, i32 4
  %70 = load i32, ptr %69, align 8, !tbaa !22
  %71 = and i32 %70, 3840
  %72 = icmp eq i32 %71, 512
  br i1 %72, label %73, label %75

73:                                               ; preds = %65
  %74 = load ptr, ptr %5, align 8, !tbaa !5
  call void @_ZN2rw5Image10removeMaskEv(ptr noundef nonnull align 8 dereferenceable(40) %74)
  br label %75

75:                                               ; preds = %73, %65
  br label %89

76:                                               ; preds = %54
  %77 = load ptr, ptr %5, align 8, !tbaa !5
  %78 = load ptr, ptr %10, align 8, !tbaa !5
  call void @_ZN2rw5Image12setPixelsDXTEiPh(ptr noundef nonnull align 8 dereferenceable(40) %77, i32 noundef 3, ptr noundef %78)
  br label %89

79:                                               ; preds = %54
  %80 = load ptr, ptr %5, align 8, !tbaa !5
  %81 = load ptr, ptr %10, align 8, !tbaa !5
  call void @_ZN2rw5Image12setPixelsDXTEiPh(ptr noundef nonnull align 8 dereferenceable(40) %80, i32 noundef 5, ptr noundef %81)
  br label %89

82:                                               ; preds = %54
  %83 = load ptr, ptr %5, align 8, !tbaa !5
  call void @_ZN2rw5Image7destroyEv(ptr noundef nonnull align 8 dereferenceable(40) %83)
  %84 = load i8, ptr %6, align 1, !tbaa !9, !range !17, !noundef !18
  %85 = trunc i8 %84 to i1
  br i1 %85, label %86, label %88

86:                                               ; preds = %82
  %87 = load ptr, ptr %3, align 8, !tbaa !5
  call void @_ZN2rw6Raster6unlockEi(ptr noundef nonnull align 8 dereferenceable(96) %87, i32 noundef 0)
  br label %88

88:                                               ; preds = %86, %82
  store ptr null, ptr %2, align 8
  store i32 1, ptr %11, align 4
  br label %106

89:                                               ; preds = %79, %76, %75
  %90 = load ptr, ptr %3, align 8, !tbaa !5
  %91 = getelementptr inbounds %"struct.rw::Raster", ptr %90, i32 0, i32 5
  %92 = load i32, ptr %91, align 4, !tbaa !19
  %93 = load ptr, ptr %5, align 8, !tbaa !5
  %94 = getelementptr inbounds %"struct.rw::Image", ptr %93, i32 0, i32 1
  store i32 %92, ptr %94, align 4, !tbaa !23
  %95 = load ptr, ptr %3, align 8, !tbaa !5
  %96 = getelementptr inbounds %"struct.rw::Raster", ptr %95, i32 0, i32 6
  %97 = load i32, ptr %96, align 8, !tbaa !20
  %98 = load ptr, ptr %5, align 8, !tbaa !5
  %99 = getelementptr inbounds %"struct.rw::Image", ptr %98, i32 0, i32 2
  store i32 %97, ptr %99, align 8, !tbaa !25
  %100 = load i8, ptr %6, align 1, !tbaa !9, !range !17, !noundef !18
  %101 = trunc i8 %100 to i1
  br i1 %101, label %102, label %104

102:                                              ; preds = %89
  %103 = load ptr, ptr %3, align 8, !tbaa !5
  call void @_ZN2rw6Raster6unlockEi(ptr noundef nonnull align 8 dereferenceable(96) %103, i32 noundef 0)
  br label %104

104:                                              ; preds = %102, %89
  %105 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %105, ptr %2, align 8
  store i32 1, ptr %11, align 4
  br label %106

106:                                              ; preds = %104, %88
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  br label %266

107:                                              ; preds = %31
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #6
  store ptr null, ptr %12, align 8, !tbaa !5
  %108 = load ptr, ptr %3, align 8, !tbaa !5
  %109 = getelementptr inbounds %"struct.rw::Raster", ptr %108, i32 0, i32 4
  %110 = load i32, ptr %109, align 8, !tbaa !22
  %111 = and i32 %110, 3840
  switch i32 %111, label %116 [
    i32 256, label %112
    i32 1280, label %113
    i32 1536, label %114
    i32 2560, label %115
    i32 512, label %117
    i32 768, label %117
    i32 1024, label %117
  ]

112:                                              ; preds = %107
  store i32 16, ptr %4, align 4, !tbaa !14
  store ptr @_ZN2rw27conv_ARGB1555_from_ARGB1555EPhS0_, ptr %12, align 8, !tbaa !5
  br label %128

113:                                              ; preds = %107
  store i32 32, ptr %4, align 4, !tbaa !14
  store ptr @_ZN2rw27conv_RGBA8888_from_BGRA8888EPhS0_, ptr %12, align 8, !tbaa !5
  br label %128

114:                                              ; preds = %107
  store i32 24, ptr %4, align 4, !tbaa !14
  store ptr @_ZN2rw23conv_RGB888_from_BGR888EPhS0_, ptr %12, align 8, !tbaa !5
  br label %128

115:                                              ; preds = %107
  store i32 16, ptr %4, align 4, !tbaa !14
  store ptr @_ZN2rw25conv_ARGB1555_from_RGB555EPhS0_, ptr %12, align 8, !tbaa !5
  br label %128

116:                                              ; preds = %107
  br label %117

117:                                              ; preds = %116, %107, %107, %107
  br label %118

118:                                              ; preds = %117
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #6
  %119 = getelementptr inbounds %"struct.rw::Error", ptr %13, i32 0, i32 0
  store i32 2816, ptr %119, align 4, !tbaa !26
  %120 = getelementptr inbounds %"struct.rw::Error", ptr %13, i32 0, i32 1
  store i32 -2147483638, ptr %120, align 4, !tbaa !28
  %121 = load ptr, ptr @stderr, align 8, !tbaa !5
  %122 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %121, ptr noundef @.str.3, ptr noundef @.str.4, i32 noundef 910) #6
  %123 = load ptr, ptr @stderr, align 8, !tbaa !5
  %124 = call noundef ptr (i32, ...) @_ZN2rw9dbgsprintEjz(i32 noundef -2147483638)
  %125 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %123, ptr noundef @.str.5, ptr noundef %124) #6
  call void @_ZN2rw8setErrorEPNS_5ErrorE(ptr noundef %13)
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #6
  br label %126

126:                                              ; preds = %118
  br label %127

127:                                              ; preds = %126
  store ptr null, ptr %2, align 8
  store i32 1, ptr %11, align 4
  br label %265

128:                                              ; preds = %115, %114, %113, %112
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #6
  store i32 0, ptr %14, align 4, !tbaa !14
  %129 = load ptr, ptr %3, align 8, !tbaa !5
  %130 = getelementptr inbounds %"struct.rw::Raster", ptr %129, i32 0, i32 4
  %131 = load i32, ptr %130, align 8, !tbaa !22
  %132 = and i32 %131, 16384
  %133 = icmp eq i32 %132, 16384
  br i1 %133, label %134, label %135

134:                                              ; preds = %128
  store i32 4, ptr %4, align 4, !tbaa !14
  store i32 16, ptr %14, align 4, !tbaa !14
  br label %143

135:                                              ; preds = %128
  %136 = load ptr, ptr %3, align 8, !tbaa !5
  %137 = getelementptr inbounds %"struct.rw::Raster", ptr %136, i32 0, i32 4
  %138 = load i32, ptr %137, align 8, !tbaa !22
  %139 = and i32 %138, 8192
  %140 = icmp eq i32 %139, 8192
  br i1 %140, label %141, label %142

141:                                              ; preds = %135
  store i32 8, ptr %4, align 4, !tbaa !14
  store i32 256, ptr %14, align 4, !tbaa !14
  br label %142

142:                                              ; preds = %141, %135
  br label %143

143:                                              ; preds = %142, %134
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #6
  %144 = load ptr, ptr %3, align 8, !tbaa !5
  %145 = getelementptr inbounds %"struct.rw::Raster", ptr %144, i32 0, i32 5
  %146 = load i32, ptr %145, align 4, !tbaa !19
  %147 = load ptr, ptr %3, align 8, !tbaa !5
  %148 = getelementptr inbounds %"struct.rw::Raster", ptr %147, i32 0, i32 6
  %149 = load i32, ptr %148, align 8, !tbaa !20
  %150 = load i32, ptr %4, align 4, !tbaa !14
  %151 = call noundef ptr @_ZN2rw5Image6createEiii(i32 noundef %146, i32 noundef %149, i32 noundef %150)
  store ptr %151, ptr %5, align 8, !tbaa !5
  %152 = load ptr, ptr %5, align 8, !tbaa !5
  call void @_ZN2rw5Image8allocateEv(ptr noundef nonnull align 8 dereferenceable(40) %152)
  %153 = load i32, ptr %14, align 4, !tbaa !14
  %154 = icmp ne i32 %153, 0
  br i1 %154, label %155, label %178

155:                                              ; preds = %143
  %156 = load ptr, ptr %5, align 8, !tbaa !5
  %157 = getelementptr inbounds %"struct.rw::Image", ptr %156, i32 0, i32 7
  %158 = load ptr, ptr %157, align 8, !tbaa !29
  store ptr %158, ptr %16, align 8, !tbaa !5
  %159 = load ptr, ptr %7, align 8, !tbaa !5
  %160 = getelementptr inbounds %"struct.rw::d3d::D3dRaster", ptr %159, i32 0, i32 1
  %161 = load ptr, ptr %160, align 8, !tbaa !30
  store ptr %161, ptr %15, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #6
  store i32 0, ptr %17, align 4, !tbaa !14
  br label %162

162:                                              ; preds = %174, %155
  %163 = load i32, ptr %17, align 4, !tbaa !14
  %164 = load i32, ptr %14, align 4, !tbaa !14
  %165 = icmp slt i32 %163, %164
  br i1 %165, label %167, label %166

166:                                              ; preds = %162
  store i32 6, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #6
  br label %177

167:                                              ; preds = %162
  %168 = load ptr, ptr %16, align 8, !tbaa !5
  %169 = load ptr, ptr %15, align 8, !tbaa !5
  call void @_ZN2rw27conv_RGBA8888_from_RGBA8888EPhS0_(ptr noundef %168, ptr noundef %169)
  %170 = load ptr, ptr %15, align 8, !tbaa !5
  %171 = getelementptr inbounds i8, ptr %170, i64 4
  store ptr %171, ptr %15, align 8, !tbaa !5
  %172 = load ptr, ptr %16, align 8, !tbaa !5
  %173 = getelementptr inbounds i8, ptr %172, i64 4
  store ptr %173, ptr %16, align 8, !tbaa !5
  br label %174

174:                                              ; preds = %167
  %175 = load i32, ptr %17, align 4, !tbaa !14
  %176 = add nsw i32 %175, 1
  store i32 %176, ptr %17, align 4, !tbaa !14
  br label %162, !llvm.loop !31

177:                                              ; preds = %166
  br label %178

178:                                              ; preds = %177, %143
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #6
  %179 = load ptr, ptr %5, align 8, !tbaa !5
  %180 = getelementptr inbounds %"struct.rw::Image", ptr %179, i32 0, i32 6
  %181 = load ptr, ptr %180, align 8, !tbaa !33
  store ptr %181, ptr %18, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #6
  %182 = load ptr, ptr %3, align 8, !tbaa !5
  %183 = getelementptr inbounds %"struct.rw::Raster", ptr %182, i32 0, i32 9
  %184 = load ptr, ptr %183, align 8, !tbaa !11
  store ptr %184, ptr %19, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #6
  %185 = load ptr, ptr %5, align 8, !tbaa !5
  %186 = getelementptr inbounds %"struct.rw::Image", ptr %185, i32 0, i32 1
  %187 = load i32, ptr %186, align 4, !tbaa !23
  %188 = load ptr, ptr %3, align 8, !tbaa !5
  %189 = getelementptr inbounds %"struct.rw::Raster", ptr %188, i32 0, i32 5
  %190 = load i32, ptr %189, align 4, !tbaa !19
  %191 = icmp eq i32 %187, %190
  br i1 %191, label %192, label %193

192:                                              ; preds = %178
  br label %195

193:                                              ; preds = %178
  call void @__assert_fail(ptr noundef @.str.9, ptr noundef @.str.4, i32 noundef 940, ptr noundef @__PRETTY_FUNCTION__._ZN2rw3d3d13rasterToImageEPNS_6RasterE) #7
  unreachable

194:                                              ; No predecessors!
  br label %195

195:                                              ; preds = %194, %192
  %196 = load ptr, ptr %5, align 8, !tbaa !5
  %197 = getelementptr inbounds %"struct.rw::Image", ptr %196, i32 0, i32 2
  %198 = load i32, ptr %197, align 8, !tbaa !25
  %199 = load ptr, ptr %3, align 8, !tbaa !5
  %200 = getelementptr inbounds %"struct.rw::Raster", ptr %199, i32 0, i32 6
  %201 = load i32, ptr %200, align 8, !tbaa !20
  %202 = icmp eq i32 %198, %201
  br i1 %202, label %203, label %204

203:                                              ; preds = %195
  br label %206

204:                                              ; preds = %195
  call void @__assert_fail(ptr noundef @.str.10, ptr noundef @.str.4, i32 noundef 941, ptr noundef @__PRETTY_FUNCTION__._ZN2rw3d3d13rasterToImageEPNS_6RasterE) #7
  unreachable

205:                                              ; No predecessors!
  br label %206

206:                                              ; preds = %205, %203
  store i32 0, ptr %21, align 4, !tbaa !14
  br label %207

207:                                              ; preds = %254, %206
  %208 = load i32, ptr %21, align 4, !tbaa !14
  %209 = load ptr, ptr %5, align 8, !tbaa !5
  %210 = getelementptr inbounds %"struct.rw::Image", ptr %209, i32 0, i32 2
  %211 = load i32, ptr %210, align 8, !tbaa !25
  %212 = icmp slt i32 %208, %211
  br i1 %212, label %213, label %257

213:                                              ; preds = %207
  call void @llvm.lifetime.start.p0(i64 8, ptr %22) #6
  %214 = load ptr, ptr %18, align 8, !tbaa !5
  store ptr %214, ptr %22, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %23) #6
  %215 = load ptr, ptr %19, align 8, !tbaa !5
  store ptr %215, ptr %23, align 8, !tbaa !5
  store i32 0, ptr %20, align 4, !tbaa !14
  br label %216

216:                                              ; preds = %238, %213
  %217 = load i32, ptr %20, align 4, !tbaa !14
  %218 = load ptr, ptr %5, align 8, !tbaa !5
  %219 = getelementptr inbounds %"struct.rw::Image", ptr %218, i32 0, i32 1
  %220 = load i32, ptr %219, align 4, !tbaa !23
  %221 = icmp slt i32 %217, %220
  br i1 %221, label %222, label %241

222:                                              ; preds = %216
  %223 = load ptr, ptr %12, align 8, !tbaa !5
  %224 = load ptr, ptr %22, align 8, !tbaa !5
  %225 = load ptr, ptr %23, align 8, !tbaa !5
  call void %223(ptr noundef %224, ptr noundef %225)
  %226 = load ptr, ptr %5, align 8, !tbaa !5
  %227 = getelementptr inbounds %"struct.rw::Image", ptr %226, i32 0, i32 4
  %228 = load i32, ptr %227, align 8, !tbaa !34
  %229 = load ptr, ptr %22, align 8, !tbaa !5
  %230 = sext i32 %228 to i64
  %231 = getelementptr inbounds i8, ptr %229, i64 %230
  store ptr %231, ptr %22, align 8, !tbaa !5
  %232 = load ptr, ptr %7, align 8, !tbaa !5
  %233 = getelementptr inbounds %"struct.rw::d3d::D3dRaster", ptr %232, i32 0, i32 4
  %234 = load i32, ptr %233, align 4, !tbaa !35
  %235 = load ptr, ptr %23, align 8, !tbaa !5
  %236 = zext i32 %234 to i64
  %237 = getelementptr inbounds i8, ptr %235, i64 %236
  store ptr %237, ptr %23, align 8, !tbaa !5
  br label %238

238:                                              ; preds = %222
  %239 = load i32, ptr %20, align 4, !tbaa !14
  %240 = add nsw i32 %239, 1
  store i32 %240, ptr %20, align 4, !tbaa !14
  br label %216, !llvm.loop !36

241:                                              ; preds = %216
  %242 = load ptr, ptr %5, align 8, !tbaa !5
  %243 = getelementptr inbounds %"struct.rw::Image", ptr %242, i32 0, i32 5
  %244 = load i32, ptr %243, align 4, !tbaa !37
  %245 = load ptr, ptr %18, align 8, !tbaa !5
  %246 = sext i32 %244 to i64
  %247 = getelementptr inbounds i8, ptr %245, i64 %246
  store ptr %247, ptr %18, align 8, !tbaa !5
  %248 = load ptr, ptr %3, align 8, !tbaa !5
  %249 = getelementptr inbounds %"struct.rw::Raster", ptr %248, i32 0, i32 8
  %250 = load i32, ptr %249, align 8, !tbaa !38
  %251 = load ptr, ptr %19, align 8, !tbaa !5
  %252 = sext i32 %250 to i64
  %253 = getelementptr inbounds i8, ptr %251, i64 %252
  store ptr %253, ptr %19, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %23) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #6
  br label %254

254:                                              ; preds = %241
  %255 = load i32, ptr %21, align 4, !tbaa !14
  %256 = add nsw i32 %255, 1
  store i32 %256, ptr %21, align 4, !tbaa !14
  br label %207, !llvm.loop !39

257:                                              ; preds = %207
  %258 = load ptr, ptr %5, align 8, !tbaa !5
  call void @_ZN2rw5Image15compressPaletteEv(ptr noundef nonnull align 8 dereferenceable(40) %258)
  %259 = load i8, ptr %6, align 1, !tbaa !9, !range !17, !noundef !18
  %260 = trunc i8 %259 to i1
  br i1 %260, label %261, label %263

261:                                              ; preds = %257
  %262 = load ptr, ptr %3, align 8, !tbaa !5
  call void @_ZN2rw6Raster6unlockEi(ptr noundef nonnull align 8 dereferenceable(96) %262, i32 noundef 0)
  br label %263

263:                                              ; preds = %261, %257
  %264 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %264, ptr %2, align 8
  store i32 1, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #6
  br label %265

265:                                              ; preds = %263, %127
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #6
  br label %266

266:                                              ; preds = %265, %106
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 1, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  %267 = load ptr, ptr %2, align 8
  ret ptr %267
}

declare void @_ZN2rw5Image8allocateEv(ptr noundef nonnull align 8 dereferenceable(40)) #2

declare void @_ZN2rw5Image12setPixelsDXTEiPh(ptr noundef nonnull align 8 dereferenceable(40), i32 noundef, ptr noundef) #2

declare void @_ZN2rw5Image10removeMaskEv(ptr noundef nonnull align 8 dereferenceable(40)) #2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN2rw27conv_RGBA8888_from_BGRA8888EPhS0_(ptr noundef, ptr noundef) #5

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN2rw23conv_RGB888_from_BGR888EPhS0_(ptr noundef, ptr noundef) #5

declare void @_ZN2rw25conv_ARGB1555_from_RGB555EPhS0_(ptr noundef, ptr noundef) #2

declare void @_ZN2rw5Image15compressPaletteEv(ptr noundef nonnull align 8 dereferenceable(40)) #2

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

@_ZN2rw3d3d18nativeRasterOffsetE = external dso_local local_unnamed_addr global i32, align 4
@stderr = external local_unnamed_addr global ptr, align 8
@.str.3 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [59 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [32 x i8], align 1
@__PRETTY_FUNCTION__._ZN2rw3d3d13rasterToImageEPNS_6RasterE = external hidden unnamed_addr constant [40 x i8], align 1
@switch.table._ZN2rw3d3d13rasterToImageEPNS_6RasterE = private unnamed_addr constant [10 x i32] [i32 16, i32 16, i32 16, i32 16, i32 32, i32 24, i32 16, i32 16, i32 16, i32 16], align 4
@switch.table._ZN2rw3d3d13rasterToImageEPNS_6RasterE.1 = private unnamed_addr constant [10 x ptr] [ptr @_ZN2rw27conv_ARGB1555_from_ARGB1555EPhS0_, ptr @_ZN2rw27conv_ARGB1555_from_ARGB1555EPhS0_, ptr @_ZN2rw27conv_ARGB1555_from_ARGB1555EPhS0_, ptr @_ZN2rw27conv_ARGB1555_from_ARGB1555EPhS0_, ptr @_ZN2rw27conv_RGBA8888_from_BGRA8888EPhS0_, ptr @_ZN2rw23conv_RGB888_from_BGR888EPhS0_, ptr @_ZN2rw27conv_ARGB1555_from_ARGB1555EPhS0_, ptr @_ZN2rw27conv_ARGB1555_from_ARGB1555EPhS0_, ptr @_ZN2rw27conv_ARGB1555_from_ARGB1555EPhS0_, ptr @_ZN2rw25conv_ARGB1555_from_RGB555EPhS0_], align 8

; 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: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #1

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

declare void @_ZN2rw8setErrorEPNS_5ErrorE(ptr noundef) local_unnamed_addr #2

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

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

declare void @_ZN2rw27conv_ARGB1555_from_ARGB1555EPhS0_(ptr noundef, ptr noundef) local_unnamed_addr #2

declare void @_ZN2rw27conv_RGBA8888_from_RGBA8888EPhS0_(ptr noundef, ptr noundef) local_unnamed_addr #2

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

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

declare void @_ZN2rw5Image7destroyEv(ptr noundef nonnull align 8 dereferenceable(40)) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN2rw3d3d13rasterToImageEPNS_6RasterE(ptr noundef %0) local_unnamed_addr #4 {
  %2 = alloca %"struct.rw::Error", align 4
  %3 = getelementptr inbounds i8, ptr %0, i64 40
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %5 = icmp eq ptr %4, null
  br i1 %5, label %6, label %8

6:                                                ; preds = %1
  %7 = tail call noundef ptr @_ZN2rw6Raster4lockEii(ptr noundef nonnull align 8 dereferenceable(96) %0, i32 noundef 0, i32 noundef 2)
  br label %8

8:                                                ; preds = %6, %1
  %9 = load i32, ptr @_ZN2rw3d3d18nativeRasterOffsetE, align 4, !tbaa !11
  %10 = sext i32 %9 to i64
  %11 = getelementptr inbounds i8, ptr %0, i64 %10
  %12 = getelementptr inbounds i8, ptr %11, i64 33
  %13 = load i8, ptr %12, align 1, !tbaa !12, !range !15, !noundef !16
  %14 = trunc nuw i8 %13 to i1
  br i1 %14, label %15, label %38

15:                                               ; preds = %8
  %16 = getelementptr inbounds i8, ptr %0, i64 20
  %17 = load i32, ptr %16, align 4, !tbaa !17
  %18 = getelementptr inbounds i8, ptr %0, i64 24
  %19 = load i32, ptr %18, align 8, !tbaa !18
  %spec.store.select = tail call i32 @llvm.smax.i32(i32 %17, i32 4)
  %spec.store.select1 = tail call i32 @llvm.smax.i32(i32 %19, i32 4)
  %20 = tail call noundef ptr @_ZN2rw5Image6createEiii(i32 noundef %spec.store.select, i32 noundef %spec.store.select1, i32 noundef 32)
  tail call void @_ZN2rw5Image8allocateEv(ptr noundef nonnull align 8 dereferenceable(40) %20)
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  %22 = getelementptr inbounds i8, ptr %11, i64 24
  %23 = load i32, ptr %22, align 8, !tbaa !19
  switch i32 %23, label %32 [
    i32 827611204, label %24
    i32 861165636, label %30
    i32 894720068, label %31
  ]

24:                                               ; preds = %15
  tail call void @_ZN2rw5Image12setPixelsDXTEiPh(ptr noundef nonnull align 8 dereferenceable(40) %20, i32 noundef 1, ptr noundef %21)
  %25 = getelementptr inbounds i8, ptr %0, i64 16
  %26 = load i32, ptr %25, align 8, !tbaa !20
  %27 = and i32 %26, 3840
  %28 = icmp eq i32 %27, 512
  br i1 %28, label %29, label %34

29:                                               ; preds = %24
  tail call void @_ZN2rw5Image10removeMaskEv(ptr noundef nonnull align 8 dereferenceable(40) %20)
  br label %34

30:                                               ; preds = %15
  tail call void @_ZN2rw5Image12setPixelsDXTEiPh(ptr noundef nonnull align 8 dereferenceable(40) %20, i32 noundef 3, ptr noundef %21)
  br label %34

31:                                               ; preds = %15
  tail call void @_ZN2rw5Image12setPixelsDXTEiPh(ptr noundef nonnull align 8 dereferenceable(40) %20, i32 noundef 5, ptr noundef %21)
  br label %34

32:                                               ; preds = %15
  tail call void @_ZN2rw5Image7destroyEv(ptr noundef nonnull align 8 dereferenceable(40) %20)
  br i1 %5, label %33, label %114

33:                                               ; preds = %32
  tail call void @_ZN2rw6Raster6unlockEi(ptr noundef nonnull align 8 dereferenceable(96) %0, i32 noundef 0)
  br label %114

34:                                               ; preds = %24, %29, %31, %30
  %35 = getelementptr inbounds i8, ptr %20, i64 4
  %36 = load <2 x i32>, ptr %16, align 4, !tbaa !11
  store <2 x i32> %36, ptr %35, align 4, !tbaa !11
  br i1 %5, label %37, label %114

37:                                               ; preds = %34
  tail call void @_ZN2rw6Raster6unlockEi(ptr noundef nonnull align 8 dereferenceable(96) %0, i32 noundef 0)
  br label %114

38:                                               ; preds = %8
  %39 = getelementptr inbounds i8, ptr %0, i64 16
  %40 = load i32, ptr %39, align 8, !tbaa !20
  %41 = and i32 %40, 3840
  %42 = add nsw i32 %41, -256
  %43 = lshr exact i32 %42, 8
  %44 = icmp ult i32 %42, 2560
  br i1 %44, label %switch.hole_check, label %45

45:                                               ; preds = %switch.hole_check, %38
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #7
  store i32 2816, ptr %2, align 4, !tbaa !21
  %46 = getelementptr inbounds i8, ptr %2, i64 4
  store i32 -2147483638, ptr %46, align 4, !tbaa !23
  %47 = load ptr, ptr @stderr, align 8, !tbaa !24
  %48 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %47, ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.4, i32 noundef 910) #8
  %49 = load ptr, ptr @stderr, align 8, !tbaa !24
  %50 = tail call noundef ptr (i32, ...) @_ZN2rw9dbgsprintEjz(i32 noundef -2147483638)
  %51 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %49, ptr noundef nonnull @.str.5, ptr noundef %50) #8
  call void @_ZN2rw8setErrorEPNS_5ErrorE(ptr noundef nonnull %2)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #7
  br label %114

switch.hole_check:                                ; preds = %38
  %switch.maskindex = trunc nuw i32 %43 to i16
  %switch.shifted = lshr i16 561, %switch.maskindex
  %switch.lobit = trunc i16 %switch.shifted to i1
  br i1 %switch.lobit, label %switch.lookup, label %45

switch.lookup:                                    ; preds = %switch.hole_check
  %52 = zext nneg i32 %43 to i64
  %switch.gep108 = getelementptr inbounds [10 x ptr], ptr @switch.table._ZN2rw3d3d13rasterToImageEPNS_6RasterE.1, i64 0, i64 %52
  %switch.load109 = load ptr, ptr %switch.gep108, align 8
  %53 = and i32 %40, 16384
  %.not = icmp eq i32 %53, 0
  br i1 %.not, label %54, label %58

54:                                               ; preds = %switch.lookup
  %55 = zext nneg i32 %43 to i64
  %switch.gep = getelementptr inbounds [10 x i32], ptr @switch.table._ZN2rw3d3d13rasterToImageEPNS_6RasterE, i64 0, i64 %55
  %switch.load = load i32, ptr %switch.gep, align 4
  %56 = and i32 %40, 8192
  %.not92 = icmp eq i32 %56, 0
  br i1 %.not92, label %58, label %57

57:                                               ; preds = %54
  br label %58

58:                                               ; preds = %switch.lookup, %54, %57
  %.190 = phi i32 [ 8, %57 ], [ %switch.load, %54 ], [ 4, %switch.lookup ]
  %.not93 = phi i1 [ false, %57 ], [ true, %54 ], [ false, %switch.lookup ]
  %.086 = phi i32 [ 256, %57 ], [ 0, %54 ], [ 16, %switch.lookup ]
  %59 = getelementptr inbounds i8, ptr %0, i64 20
  %60 = load i32, ptr %59, align 4, !tbaa !17
  %61 = getelementptr inbounds i8, ptr %0, i64 24
  %62 = load i32, ptr %61, align 8, !tbaa !18
  %63 = tail call noundef ptr @_ZN2rw5Image6createEiii(i32 noundef %60, i32 noundef %62, i32 noundef %.190)
  tail call void @_ZN2rw5Image8allocateEv(ptr noundef nonnull align 8 dereferenceable(40) %63)
  br i1 %.not93, label %.loopexit, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %58
  %64 = getelementptr inbounds i8, ptr %11, i64 8
  %65 = load ptr, ptr %64, align 8, !tbaa !25
  %66 = getelementptr inbounds i8, ptr %63, i64 32
  %67 = load ptr, ptr %66, align 8, !tbaa !26
  %umax = tail call i32 @llvm.umax.i32(i32 %.086, i32 1)
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %.08397 = phi i32 [ %70, %.lr.ph ], [ 0, %.lr.ph.preheader ]
  %.08496 = phi ptr [ %69, %.lr.ph ], [ %67, %.lr.ph.preheader ]
  %.08595 = phi ptr [ %68, %.lr.ph ], [ %65, %.lr.ph.preheader ]
  tail call void @_ZN2rw27conv_RGBA8888_from_RGBA8888EPhS0_(ptr noundef %.08496, ptr noundef %.08595)
  %68 = getelementptr inbounds i8, ptr %.08595, i64 4
  %69 = getelementptr inbounds i8, ptr %.08496, i64 4
  %70 = add nuw nsw i32 %.08397, 1
  %exitcond.not = icmp eq i32 %70, %umax
  br i1 %exitcond.not, label %.loopexit, label %.lr.ph, !llvm.loop !28

.loopexit:                                        ; preds = %.lr.ph, %58
  %71 = getelementptr inbounds i8, ptr %63, i64 4
  %72 = load i32, ptr %71, align 4, !tbaa !30
  %73 = load i32, ptr %59, align 4, !tbaa !17
  %74 = icmp eq i32 %72, %73
  br i1 %74, label %76, label %75

75:                                               ; preds = %.loopexit
  tail call void @__assert_fail(ptr noundef nonnull @.str.9, ptr noundef nonnull @.str.4, i32 noundef 940, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN2rw3d3d13rasterToImageEPNS_6RasterE) #9
  unreachable

76:                                               ; preds = %.loopexit
  %77 = load ptr, ptr %3, align 8, !tbaa !5
  %78 = getelementptr inbounds i8, ptr %63, i64 24
  %79 = load ptr, ptr %78, align 8, !tbaa !31
  %80 = getelementptr inbounds i8, ptr %63, i64 8
  %81 = load i32, ptr %80, align 8, !tbaa !32
  %82 = load i32, ptr %61, align 8, !tbaa !18
  %83 = icmp eq i32 %81, %82
  br i1 %83, label %.preheader94, label %90

.preheader94:                                     ; preds = %76
  %84 = icmp sgt i32 %81, 0
  br i1 %84, label %.preheader.lr.ph, label %._crit_edge105

.preheader.lr.ph:                                 ; preds = %.preheader94
  %85 = getelementptr inbounds i8, ptr %63, i64 16
  %86 = getelementptr inbounds i8, ptr %11, i64 28
  %87 = getelementptr inbounds i8, ptr %63, i64 20
  %88 = getelementptr inbounds i8, ptr %0, i64 32
  %89 = icmp sgt i32 %72, 0
  br i1 %89, label %.preheader, label %._crit_edge105

90:                                               ; preds = %76
  tail call void @__assert_fail(ptr noundef nonnull @.str.10, ptr noundef nonnull @.str.4, i32 noundef 941, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN2rw3d3d13rasterToImageEPNS_6RasterE) #9
  unreachable

.preheader:                                       ; preds = %.preheader.lr.ph, %._crit_edge
  %91 = phi i32 [ %103, %._crit_edge ], [ %81, %.preheader.lr.ph ]
  %92 = phi i32 [ %104, %._crit_edge ], [ %72, %.preheader.lr.ph ]
  %.079104 = phi i32 [ %111, %._crit_edge ], [ 0, %.preheader.lr.ph ]
  %.081103 = phi ptr [ %110, %._crit_edge ], [ %77, %.preheader.lr.ph ]
  %.082102 = phi ptr [ %107, %._crit_edge ], [ %79, %.preheader.lr.ph ]
  %93 = icmp sgt i32 %92, 0
  br i1 %93, label %.lr.ph101, label %._crit_edge

.lr.ph101:                                        ; preds = %.preheader, %.lr.ph101
  %.0100 = phi ptr [ %99, %.lr.ph101 ], [ %.081103, %.preheader ]
  %.07899 = phi ptr [ %96, %.lr.ph101 ], [ %.082102, %.preheader ]
  %.08098 = phi i32 [ %100, %.lr.ph101 ], [ 0, %.preheader ]
  tail call void %switch.load109(ptr noundef %.07899, ptr noundef %.0100), !callees !33
  %94 = load i32, ptr %85, align 8, !tbaa !34
  %95 = sext i32 %94 to i64
  %96 = getelementptr inbounds i8, ptr %.07899, i64 %95
  %97 = load i32, ptr %86, align 4, !tbaa !35
  %98 = zext i32 %97 to i64
  %99 = getelementptr inbounds i8, ptr %.0100, i64 %98
  %100 = add nuw nsw i32 %.08098, 1
  %101 = load i32, ptr %71, align 4, !tbaa !30
  %102 = icmp slt i32 %100, %101
  br i1 %102, label %.lr.ph101, label %._crit_edge.loopexit, !llvm.loop !36

._crit_edge.loopexit:                             ; preds = %.lr.ph101
  %.pre = load i32, ptr %80, align 8, !tbaa !32
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %.preheader
  %103 = phi i32 [ %.pre, %._crit_edge.loopexit ], [ %91, %.preheader ]
  %104 = phi i32 [ %101, %._crit_edge.loopexit ], [ %92, %.preheader ]
  %105 = load i32, ptr %87, align 4, !tbaa !37
  %106 = sext i32 %105 to i64
  %107 = getelementptr inbounds i8, ptr %.082102, i64 %106
  %108 = load i32, ptr %88, align 8, !tbaa !38
  %109 = sext i32 %108 to i64
  %110 = getelementptr inbounds i8, ptr %.081103, i64 %109
  %111 = add nuw nsw i32 %.079104, 1
  %112 = icmp slt i32 %111, %103
  br i1 %112, label %.preheader, label %._crit_edge105, !llvm.loop !39

._crit_edge105:                                   ; preds = %._crit_edge, %.preheader.lr.ph, %.preheader94
  tail call void @_ZN2rw5Image15compressPaletteEv(ptr noundef nonnull align 8 dereferenceable(40) %63)
  br i1 %5, label %113, label %114

113:                                              ; preds = %._crit_edge105
  tail call void @_ZN2rw6Raster6unlockEi(ptr noundef nonnull align 8 dereferenceable(96) %0, i32 noundef 0)
  br label %114

114:                                              ; preds = %45, %113, %._crit_edge105, %33, %32, %37, %34
  %.2 = phi ptr [ null, %33 ], [ null, %32 ], [ %20, %37 ], [ %20, %34 ], [ null, %45 ], [ %63, %113 ], [ %63, %._crit_edge105 ]
  ret ptr %.2
}

declare void @_ZN2rw5Image8allocateEv(ptr noundef nonnull align 8 dereferenceable(40)) local_unnamed_addr #2

declare void @_ZN2rw5Image12setPixelsDXTEiPh(ptr noundef nonnull align 8 dereferenceable(40), i32 noundef, ptr noundef) local_unnamed_addr #2

declare void @_ZN2rw5Image10removeMaskEv(ptr noundef nonnull align 8 dereferenceable(40)) local_unnamed_addr #2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN2rw27conv_RGBA8888_from_BGRA8888EPhS0_(ptr noundef, ptr noundef) local_unnamed_addr #5

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN2rw23conv_RGB888_from_BGR888EPhS0_(ptr noundef, ptr noundef) local_unnamed_addr #5

declare void @_ZN2rw25conv_ARGB1555_from_RGB555EPhS0_(ptr noundef, ptr noundef) local_unnamed_addr #2

declare void @_ZN2rw5Image15compressPaletteEv(ptr noundef nonnull align 8 dereferenceable(40)) local_unnamed_addr #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smax.i32(i32, i32) #6

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.umax.i32(i32, i32) #6

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { 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 = { 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 #6 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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, !10, i64 40}
!6 = !{!"_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, !10, i64 40, !10, i64 48, !10, i64 56, !7, i64 64, !7, i64 68, !7, i64 72, !10, i64 80, !7, i64 88, !7, i64 92}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!7, !7, i64 0}
!12 = !{!13, !14, i64 33}
!13 = !{!"_ZTSN2rw3d3d9D3dRasterE", !10, i64 0, !10, i64 8, !10, i64 16, !7, i64 24, !7, i64 28, !14, i64 32, !14, i64 33, !14, i64 34}
!14 = !{!"bool", !8, i64 0}
!15 = !{i8 0, i8 2}
!16 = !{}
!17 = !{!6, !7, i64 20}
!18 = !{!6, !7, i64 24}
!19 = !{!13, !7, i64 24}
!20 = !{!6, !7, i64 16}
!21 = !{!22, !7, i64 0}
!22 = !{!"_ZTSN2rw5ErrorE", !7, i64 0, !7, i64 4}
!23 = !{!22, !7, i64 4}
!24 = !{!10, !10, i64 0}
!25 = !{!13, !10, i64 8}
!26 = !{!27, !10, i64 32}
!27 = !{!"_ZTSN2rw5ImageE", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20, !10, i64 24, !10, i64 32}
!28 = distinct !{!28, !29}
!29 = !{!"llvm.loop.mustprogress"}
!30 = !{!27, !7, i64 4}
!31 = !{!27, !10, i64 24}
!32 = !{!27, !7, i64 8}
!33 = !{ptr @_ZN2rw23conv_RGB888_from_BGR888EPhS0_, ptr @_ZN2rw25conv_ARGB1555_from_RGB555EPhS0_, ptr @_ZN2rw27conv_ARGB1555_from_ARGB1555EPhS0_, ptr @_ZN2rw27conv_RGBA8888_from_BGRA8888EPhS0_}
!34 = !{!27, !7, i64 16}
!35 = !{!13, !7, i64 28}
!36 = distinct !{!36, !29}
!37 = !{!27, !7, i64 20}
!38 = !{!6, !7, i64 32}
!39 = distinct !{!39, !29, !40}
!40 = !{!"llvm.loop.unswitch.partial.disable"}


; Effective O3 passes: CalledValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,SLPVectorizerPass,SROAPass,SimpleLoopUnswitchPass,SimplifyCFGPass,TailCallElimPass