; LLVM IR from aap/librw :: src/ps2/ps2raster.ll (ZN2rw3ps213rasterToImageEPNS_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::Raster" = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, ptr, ptr, ptr, i32, i32, i32, ptr, i32, i32 }
%"struct.rw::Image" = type { i32, i32, i32, i32, i32, i32, ptr, ptr }
%"struct.rw::ps2::Ps2Raster" = type { i64, i32, i16, i8, i8, i64, i64, i32, i32, i32, i8, ptr, i32 }

@_ZN2rw3ps218nativeRasterOffsetE = external dso_local global i32, align 4
@.str.2 = external hidden unnamed_addr constant [65 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [37 x i8], align 1
@__PRETTY_FUNCTION__._ZN2rw3ps213rasterToImageEPNS_6RasterE = external hidden unnamed_addr constant [40 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [33 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: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #1

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @_ZN2rw3ps2L15transferMinSizeEiiPiS1_(i32 noundef, i32 noundef, ptr noundef, ptr noundef) #2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

declare noundef ptr @_ZN2rw6Raster11lockPaletteEi(ptr noundef nonnull align 8 dereferenceable(96), i32 noundef) #4

declare void @_ZN2rw6Raster13unlockPaletteEv(ptr noundef nonnull align 8 dereferenceable(96)) #4

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

declare void @_ZN2rw8copyPal8EPhjS0_jii(ptr noundef, i32 noundef, ptr noundef, i32 noundef, i32 noundef, i32 noundef) #4

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN2rw3ps213rasterToImageEPNS_6RasterE(ptr noundef %0) #6 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca ptr, align 8
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #7
  %18 = load ptr, ptr %2, align 8, !tbaa !5
  %19 = load i32, ptr @_ZN2rw3ps218nativeRasterOffsetE, align 4, !tbaa !9
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds i8, ptr %18, i64 %20
  store ptr %21, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #7
  %22 = load ptr, ptr %2, align 8, !tbaa !5
  %23 = getelementptr inbounds %"struct.rw::Raster", ptr %22, i32 0, i32 4
  %24 = load i32, ptr %23, align 8, !tbaa !11
  %25 = and i32 %24, 3840
  store i32 %25, ptr %6, align 4, !tbaa !9
  %26 = load i32, ptr %6, align 4, !tbaa !9
  switch i32 %26, label %31 [
    i32 256, label %27
    i32 1280, label %28
    i32 1536, label %29
    i32 2560, label %30
    i32 512, label %32
    i32 768, label %32
    i32 1024, label %32
  ]

27:                                               ; preds = %1
  store i32 16, ptr %4, align 4, !tbaa !9
  br label %33

28:                                               ; preds = %1
  store i32 32, ptr %4, align 4, !tbaa !9
  br label %33

29:                                               ; preds = %1
  store i32 24, ptr %4, align 4, !tbaa !9
  br label %33

30:                                               ; preds = %1
  store i32 16, ptr %4, align 4, !tbaa !9
  br label %33

31:                                               ; preds = %1
  br label %32

32:                                               ; preds = %31, %1, %1, %1
  call void @__assert_fail(ptr noundef @.str.7, ptr noundef @.str.2, i32 noundef 1732, ptr noundef @__PRETTY_FUNCTION__._ZN2rw3ps213rasterToImageEPNS_6RasterE) #8
  unreachable

33:                                               ; preds = %30, %29, %28, %27
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #7
  store i32 0, ptr %7, align 4, !tbaa !9
  %34 = load ptr, ptr %2, align 8, !tbaa !5
  %35 = getelementptr inbounds %"struct.rw::Raster", ptr %34, i32 0, i32 4
  %36 = load i32, ptr %35, align 8, !tbaa !11
  %37 = and i32 %36, 16384
  %38 = icmp eq i32 %37, 16384
  br i1 %38, label %39, label %40

39:                                               ; preds = %33
  store i32 4, ptr %4, align 4, !tbaa !9
  store i32 16, ptr %7, align 4, !tbaa !9
  br label %48

40:                                               ; preds = %33
  %41 = load ptr, ptr %2, align 8, !tbaa !5
  %42 = getelementptr inbounds %"struct.rw::Raster", ptr %41, i32 0, i32 4
  %43 = load i32, ptr %42, align 8, !tbaa !11
  %44 = and i32 %43, 8192
  %45 = icmp eq i32 %44, 8192
  br i1 %45, label %46, label %47

46:                                               ; preds = %40
  store i32 8, ptr %4, align 4, !tbaa !9
  store i32 256, ptr %7, align 4, !tbaa !9
  br label %47

47:                                               ; preds = %46, %40
  br label %48

48:                                               ; preds = %47, %39
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #7
  %49 = load ptr, ptr %2, align 8, !tbaa !5
  %50 = getelementptr inbounds %"struct.rw::Raster", ptr %49, i32 0, i32 5
  %51 = load i32, ptr %50, align 4, !tbaa !13
  %52 = load ptr, ptr %2, align 8, !tbaa !5
  %53 = getelementptr inbounds %"struct.rw::Raster", ptr %52, i32 0, i32 6
  %54 = load i32, ptr %53, align 8, !tbaa !14
  %55 = load i32, ptr %4, align 4, !tbaa !9
  %56 = call noundef ptr @_ZN2rw5Image6createEiii(i32 noundef %51, i32 noundef %54, i32 noundef %55)
  store ptr %56, ptr %3, align 8, !tbaa !5
  %57 = load ptr, ptr %3, align 8, !tbaa !5
  call void @_ZN2rw5Image8allocateEv(ptr noundef nonnull align 8 dereferenceable(40) %57)
  %58 = load i32, ptr %7, align 4, !tbaa !9
  %59 = icmp ne i32 %58, 0
  br i1 %59, label %60, label %103

60:                                               ; preds = %48
  %61 = load ptr, ptr %3, align 8, !tbaa !5
  %62 = getelementptr inbounds %"struct.rw::Image", ptr %61, i32 0, i32 7
  %63 = load ptr, ptr %62, align 8, !tbaa !15
  store ptr %63, ptr %9, align 8, !tbaa !5
  %64 = load ptr, ptr %2, align 8, !tbaa !5
  %65 = call noundef ptr @_ZN2rw6Raster11lockPaletteEi(ptr noundef nonnull align 8 dereferenceable(96) %64, i32 noundef 2)
  store ptr %65, ptr %8, align 8, !tbaa !5
  %66 = load i32, ptr %6, align 4, !tbaa !9
  %67 = icmp eq i32 %66, 1280
  br i1 %67, label %68, label %95

68:                                               ; preds = %60
  %69 = load ptr, ptr %9, align 8, !tbaa !5
  %70 = load ptr, ptr %8, align 8, !tbaa !5
  %71 = load i32, ptr %7, align 4, !tbaa !9
  %72 = mul nsw i32 %71, 4
  %73 = sext i32 %72 to i64
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %69, ptr align 1 %70, i64 %73, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #7
  store i32 0, ptr %10, align 4, !tbaa !9
  br label %74

74:                                               ; preds = %91, %68
  %75 = load i32, ptr %10, align 4, !tbaa !9
  %76 = load i32, ptr %7, align 4, !tbaa !9
  %77 = icmp slt i32 %75, %76
  br i1 %77, label %79, label %78

78:                                               ; preds = %74
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #7
  br label %94

79:                                               ; preds = %74
  %80 = load ptr, ptr %9, align 8, !tbaa !5
  %81 = getelementptr inbounds i8, ptr %80, i64 3
  %82 = load i8, ptr %81, align 1, !tbaa !17
  %83 = zext i8 %82 to i32
  %84 = mul nsw i32 %83, 255
  %85 = sdiv i32 %84, 128
  %86 = trunc i32 %85 to i8
  %87 = load ptr, ptr %9, align 8, !tbaa !5
  %88 = getelementptr inbounds i8, ptr %87, i64 3
  store i8 %86, ptr %88, align 1, !tbaa !17
  %89 = load ptr, ptr %9, align 8, !tbaa !5
  %90 = getelementptr inbounds i8, ptr %89, i64 4
  store ptr %90, ptr %9, align 8, !tbaa !5
  br label %91

91:                                               ; preds = %79
  %92 = load i32, ptr %10, align 4, !tbaa !9
  %93 = add nsw i32 %92, 1
  store i32 %93, ptr %10, align 4, !tbaa !9
  br label %74, !llvm.loop !18

94:                                               ; preds = %78
  br label %101

95:                                               ; preds = %60
  %96 = load ptr, ptr %9, align 8, !tbaa !5
  %97 = load ptr, ptr %8, align 8, !tbaa !5
  %98 = load i32, ptr %7, align 4, !tbaa !9
  %99 = mul nsw i32 %98, 2
  %100 = sext i32 %99 to i64
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %96, ptr align 1 %97, i64 %100, i1 false)
  br label %101

101:                                              ; preds = %95, %94
  %102 = load ptr, ptr %2, align 8, !tbaa !5
  call void @_ZN2rw6Raster13unlockPaletteEv(ptr noundef nonnull align 8 dereferenceable(96) %102)
  br label %103

103:                                              ; preds = %101, %48
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #7
  %104 = load i32, ptr %4, align 4, !tbaa !9
  %105 = icmp eq i32 %104, 4
  %106 = zext i1 %105 to i64
  %107 = select i1 %105, i32 20, i32 19
  %108 = load ptr, ptr %5, align 8, !tbaa !5
  %109 = getelementptr inbounds %"struct.rw::ps2::Ps2Raster", ptr %108, i32 0, i32 10
  %110 = load i8, ptr %109, align 4, !tbaa !20
  %111 = sext i8 %110 to i32
  call void @_ZN2rw3ps2L15transferMinSizeEiiPiS1_(i32 noundef %107, i32 noundef %111, ptr noundef %11, ptr noundef %12)
  %112 = load ptr, ptr %2, align 8, !tbaa !5
  %113 = getelementptr inbounds %"struct.rw::Raster", ptr %112, i32 0, i32 5
  %114 = load i32, ptr %113, align 4, !tbaa !13
  %115 = load i32, ptr %11, align 4, !tbaa !9
  %116 = icmp sgt i32 %114, %115
  br i1 %116, label %117, label %121

117:                                              ; preds = %103
  %118 = load ptr, ptr %2, align 8, !tbaa !5
  %119 = getelementptr inbounds %"struct.rw::Raster", ptr %118, i32 0, i32 5
  %120 = load i32, ptr %119, align 4, !tbaa !13
  br label %123

121:                                              ; preds = %103
  %122 = load i32, ptr %11, align 4, !tbaa !9
  br label %123

123:                                              ; preds = %121, %117
  %124 = phi i32 [ %120, %117 ], [ %122, %121 ]
  store i32 %124, ptr %13, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #7
  %125 = load ptr, ptr %3, align 8, !tbaa !5
  %126 = getelementptr inbounds %"struct.rw::Image", ptr %125, i32 0, i32 6
  %127 = load ptr, ptr %126, align 8, !tbaa !24
  store ptr %127, ptr %14, align 8, !tbaa !5
  %128 = load ptr, ptr %2, align 8, !tbaa !5
  %129 = call noundef ptr @_ZN2rw6Raster4lockEii(ptr noundef nonnull align 8 dereferenceable(96) %128, i32 noundef 0, i32 noundef 2)
  store ptr %129, ptr %8, align 8, !tbaa !5
  %130 = load i32, ptr %4, align 4, !tbaa !9
  %131 = icmp eq i32 %130, 4
  br i1 %131, label %132, label %146

132:                                              ; preds = %123
  %133 = load ptr, ptr %14, align 8, !tbaa !5
  %134 = load ptr, ptr %3, align 8, !tbaa !5
  %135 = getelementptr inbounds %"struct.rw::Image", ptr %134, i32 0, i32 5
  %136 = load i32, ptr %135, align 4, !tbaa !25
  %137 = load ptr, ptr %8, align 8, !tbaa !5
  %138 = load i32, ptr %13, align 4, !tbaa !9
  %139 = sdiv i32 %138, 2
  %140 = load ptr, ptr %2, align 8, !tbaa !5
  %141 = getelementptr inbounds %"struct.rw::Raster", ptr %140, i32 0, i32 5
  %142 = load i32, ptr %141, align 4, !tbaa !13
  %143 = load ptr, ptr %2, align 8, !tbaa !5
  %144 = getelementptr inbounds %"struct.rw::Raster", ptr %143, i32 0, i32 6
  %145 = load i32, ptr %144, align 8, !tbaa !14
  call void @_ZN2rw10expandPal4EPhjS0_jii(ptr noundef %133, i32 noundef %136, ptr noundef %137, i32 noundef %139, i32 noundef %142, i32 noundef %145)
  br label %268

146:                                              ; preds = %123
  %147 = load i32, ptr %4, align 4, !tbaa !9
  %148 = icmp eq i32 %147, 8
  br i1 %148, label %149, label %162

149:                                              ; preds = %146
  %150 = load ptr, ptr %14, align 8, !tbaa !5
  %151 = load ptr, ptr %3, align 8, !tbaa !5
  %152 = getelementptr inbounds %"struct.rw::Image", ptr %151, i32 0, i32 5
  %153 = load i32, ptr %152, align 4, !tbaa !25
  %154 = load ptr, ptr %8, align 8, !tbaa !5
  %155 = load i32, ptr %13, align 4, !tbaa !9
  %156 = load ptr, ptr %2, align 8, !tbaa !5
  %157 = getelementptr inbounds %"struct.rw::Raster", ptr %156, i32 0, i32 5
  %158 = load i32, ptr %157, align 4, !tbaa !13
  %159 = load ptr, ptr %2, align 8, !tbaa !5
  %160 = getelementptr inbounds %"struct.rw::Raster", ptr %159, i32 0, i32 6
  %161 = load i32, ptr %160, align 8, !tbaa !14
  call void @_ZN2rw8copyPal8EPhjS0_jii(ptr noundef %150, i32 noundef %153, ptr noundef %154, i32 noundef %155, i32 noundef %158, i32 noundef %161)
  br label %267

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

163:                                              ; preds = %263, %162
  %164 = load i32, ptr %15, align 4, !tbaa !9
  %165 = load ptr, ptr %3, align 8, !tbaa !5
  %166 = getelementptr inbounds %"struct.rw::Image", ptr %165, i32 0, i32 2
  %167 = load i32, ptr %166, align 8, !tbaa !26
  %168 = icmp slt i32 %164, %167
  br i1 %168, label %170, label %169

169:                                              ; preds = %163
  store i32 6, ptr %16, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #7
  br label %266

170:                                              ; preds = %163
  %171 = load ptr, ptr %14, align 8, !tbaa !5
  store ptr %171, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #7
  store i32 0, ptr %17, align 4, !tbaa !9
  br label %172

172:                                              ; preds = %253, %170
  %173 = load i32, ptr %17, align 4, !tbaa !9
  %174 = load ptr, ptr %3, align 8, !tbaa !5
  %175 = getelementptr inbounds %"struct.rw::Image", ptr %174, i32 0, i32 1
  %176 = load i32, ptr %175, align 4, !tbaa !27
  %177 = icmp slt i32 %173, %176
  br i1 %177, label %179, label %178

178:                                              ; preds = %172
  store i32 9, ptr %16, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #7
  br label %256

179:                                              ; preds = %172
  %180 = load ptr, ptr %2, align 8, !tbaa !5
  %181 = getelementptr inbounds %"struct.rw::Raster", ptr %180, i32 0, i32 4
  %182 = load i32, ptr %181, align 8, !tbaa !11
  %183 = and i32 %182, 3840
  switch i32 %183, label %245 [
    i32 1280, label %184
    i32 1536, label %211
    i32 256, label %229
    i32 2560, label %234
  ]

184:                                              ; preds = %179
  %185 = load ptr, ptr %8, align 8, !tbaa !5
  %186 = getelementptr inbounds i8, ptr %185, i64 0
  %187 = load i8, ptr %186, align 1, !tbaa !17
  %188 = load ptr, ptr %9, align 8, !tbaa !5
  %189 = getelementptr inbounds i8, ptr %188, i64 0
  store i8 %187, ptr %189, align 1, !tbaa !17
  %190 = load ptr, ptr %8, align 8, !tbaa !5
  %191 = getelementptr inbounds i8, ptr %190, i64 1
  %192 = load i8, ptr %191, align 1, !tbaa !17
  %193 = load ptr, ptr %9, align 8, !tbaa !5
  %194 = getelementptr inbounds i8, ptr %193, i64 1
  store i8 %192, ptr %194, align 1, !tbaa !17
  %195 = load ptr, ptr %8, align 8, !tbaa !5
  %196 = getelementptr inbounds i8, ptr %195, i64 2
  %197 = load i8, ptr %196, align 1, !tbaa !17
  %198 = load ptr, ptr %9, align 8, !tbaa !5
  %199 = getelementptr inbounds i8, ptr %198, i64 2
  store i8 %197, ptr %199, align 1, !tbaa !17
  %200 = load ptr, ptr %8, align 8, !tbaa !5
  %201 = getelementptr inbounds i8, ptr %200, i64 3
  %202 = load i8, ptr %201, align 1, !tbaa !17
  %203 = zext i8 %202 to i32
  %204 = mul nsw i32 %203, 255
  %205 = sdiv i32 %204, 128
  %206 = trunc i32 %205 to i8
  %207 = load ptr, ptr %9, align 8, !tbaa !5
  %208 = getelementptr inbounds i8, ptr %207, i64 3
  store i8 %206, ptr %208, align 1, !tbaa !17
  %209 = load ptr, ptr %8, align 8, !tbaa !5
  %210 = getelementptr inbounds i8, ptr %209, i64 4
  store ptr %210, ptr %8, align 8, !tbaa !5
  br label %246

211:                                              ; preds = %179
  %212 = load ptr, ptr %8, align 8, !tbaa !5
  %213 = getelementptr inbounds i8, ptr %212, i64 0
  %214 = load i8, ptr %213, align 1, !tbaa !17
  %215 = load ptr, ptr %9, align 8, !tbaa !5
  %216 = getelementptr inbounds i8, ptr %215, i64 0
  store i8 %214, ptr %216, align 1, !tbaa !17
  %217 = load ptr, ptr %8, align 8, !tbaa !5
  %218 = getelementptr inbounds i8, ptr %217, i64 1
  %219 = load i8, ptr %218, align 1, !tbaa !17
  %220 = load ptr, ptr %9, align 8, !tbaa !5
  %221 = getelementptr inbounds i8, ptr %220, i64 1
  store i8 %219, ptr %221, align 1, !tbaa !17
  %222 = load ptr, ptr %8, align 8, !tbaa !5
  %223 = getelementptr inbounds i8, ptr %222, i64 2
  %224 = load i8, ptr %223, align 1, !tbaa !17
  %225 = load ptr, ptr %9, align 8, !tbaa !5
  %226 = getelementptr inbounds i8, ptr %225, i64 2
  store i8 %224, ptr %226, align 1, !tbaa !17
  %227 = load ptr, ptr %8, align 8, !tbaa !5
  %228 = getelementptr inbounds i8, ptr %227, i64 4
  store ptr %228, ptr %8, align 8, !tbaa !5
  br label %246

229:                                              ; preds = %179
  %230 = load ptr, ptr %9, align 8, !tbaa !5
  %231 = load ptr, ptr %8, align 8, !tbaa !5
  call void @_ZN2rw27conv_ARGB1555_from_ABGR1555EPhS0_(ptr noundef %230, ptr noundef %231)
  %232 = load ptr, ptr %8, align 8, !tbaa !5
  %233 = getelementptr inbounds i8, ptr %232, i64 2
  store ptr %233, ptr %8, align 8, !tbaa !5
  br label %246

234:                                              ; preds = %179
  %235 = load ptr, ptr %9, align 8, !tbaa !5
  %236 = load ptr, ptr %8, align 8, !tbaa !5
  call void @_ZN2rw27conv_ARGB1555_from_ABGR1555EPhS0_(ptr noundef %235, ptr noundef %236)
  %237 = load ptr, ptr %9, align 8, !tbaa !5
  %238 = getelementptr inbounds i8, ptr %237, i64 1
  %239 = load i8, ptr %238, align 1, !tbaa !17
  %240 = zext i8 %239 to i32
  %241 = or i32 %240, 128
  %242 = trunc i32 %241 to i8
  store i8 %242, ptr %238, align 1, !tbaa !17
  %243 = load ptr, ptr %8, align 8, !tbaa !5
  %244 = getelementptr inbounds i8, ptr %243, i64 2
  store ptr %244, ptr %8, align 8, !tbaa !5
  br label %246

245:                                              ; preds = %179
  call void @__assert_fail(ptr noundef @.str.8, ptr noundef @.str.2, i32 noundef 1799, ptr noundef @__PRETTY_FUNCTION__._ZN2rw3ps213rasterToImageEPNS_6RasterE) #8
  unreachable

246:                                              ; preds = %234, %229, %211, %184
  %247 = load ptr, ptr %3, align 8, !tbaa !5
  %248 = getelementptr inbounds %"struct.rw::Image", ptr %247, i32 0, i32 4
  %249 = load i32, ptr %248, align 8, !tbaa !28
  %250 = load ptr, ptr %9, align 8, !tbaa !5
  %251 = sext i32 %249 to i64
  %252 = getelementptr inbounds i8, ptr %250, i64 %251
  store ptr %252, ptr %9, align 8, !tbaa !5
  br label %253

253:                                              ; preds = %246
  %254 = load i32, ptr %17, align 4, !tbaa !9
  %255 = add nsw i32 %254, 1
  store i32 %255, ptr %17, align 4, !tbaa !9
  br label %172, !llvm.loop !29

256:                                              ; preds = %178
  %257 = load ptr, ptr %3, align 8, !tbaa !5
  %258 = getelementptr inbounds %"struct.rw::Image", ptr %257, i32 0, i32 5
  %259 = load i32, ptr %258, align 4, !tbaa !25
  %260 = load ptr, ptr %14, align 8, !tbaa !5
  %261 = sext i32 %259 to i64
  %262 = getelementptr inbounds i8, ptr %260, i64 %261
  store ptr %262, ptr %14, align 8, !tbaa !5
  br label %263

263:                                              ; preds = %256
  %264 = load i32, ptr %15, align 4, !tbaa !9
  %265 = add nsw i32 %264, 1
  store i32 %265, ptr %15, align 4, !tbaa !9
  br label %163, !llvm.loop !30

266:                                              ; preds = %169
  br label %267

267:                                              ; preds = %266, %149
  br label %268

268:                                              ; preds = %267, %132
  %269 = load ptr, ptr %2, align 8, !tbaa !5
  call void @_ZN2rw6Raster6unlockEi(ptr noundef nonnull align 8 dereferenceable(96) %269, i32 noundef 0)
  %270 = load ptr, ptr %3, align 8, !tbaa !5
  store i32 1, ptr %16, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #7
  ret ptr %270
}

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

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

declare void @_ZN2rw10expandPal4EPhjS0_jii(ptr noundef, i32 noundef, ptr noundef, i32 noundef, i32 noundef, i32 noundef) #4

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

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 16}
!12 = !{!"_ZTSN2rw6RasterE", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !10, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !10, i64 64, !10, i64 68, !10, i64 72, !6, i64 80, !10, i64 88, !10, i64 92}
!13 = !{!12, !10, i64 20}
!14 = !{!12, !10, i64 24}
!15 = !{!16, !6, i64 32}
!16 = !{!"_ZTSN2rw5ImageE", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !6, i64 24, !6, i64 32}
!17 = !{!7, !7, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = !{!21, !7, i64 44}
!21 = !{!"_ZTSN2rw3ps29Ps2RasterE", !22, i64 0, !10, i64 8, !23, i64 12, !7, i64 14, !7, i64 15, !22, i64 16, !22, i64 24, !10, i64 32, !10, i64 36, !10, i64 40, !7, i64 44, !6, i64 48, !10, i64 56}
!22 = !{!"long", !7, i64 0}
!23 = !{!"short", !7, i64 0}
!24 = !{!16, !6, i64 24}
!25 = !{!16, !10, i64 20}
!26 = !{!16, !10, i64 8}
!27 = !{!16, !10, i64 4}
!28 = !{!16, !10, i64 16}
!29 = distinct !{!29, !19}
!30 = distinct !{!30, !19}


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

@_ZN2rw3ps218nativeRasterOffsetE = external dso_local local_unnamed_addr global i32, align 4
@.str.2 = external hidden unnamed_addr constant [65 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [37 x i8], align 1
@__PRETTY_FUNCTION__._ZN2rw3ps213rasterToImageEPNS_6RasterE = external hidden unnamed_addr constant [40 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [33 x i8], align 1
@switch.table._ZN2rw3ps213rasterToImageEPNS_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

; 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: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @_ZN2rw3ps2L15transferMinSizeEiiPiS1_(i32 noundef, i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

declare noundef ptr @_ZN2rw6Raster11lockPaletteEi(ptr noundef nonnull align 8 dereferenceable(96), i32 noundef) local_unnamed_addr #4

declare void @_ZN2rw6Raster13unlockPaletteEv(ptr noundef nonnull align 8 dereferenceable(96)) local_unnamed_addr #4

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

declare void @_ZN2rw8copyPal8EPhjS0_jii(ptr noundef, i32 noundef, ptr noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #4

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN2rw3ps213rasterToImageEPNS_6RasterE(ptr noundef %0) local_unnamed_addr #6 {
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = load i32, ptr @_ZN2rw3ps218nativeRasterOffsetE, align 4, !tbaa !5
  %5 = sext i32 %4 to i64
  %6 = getelementptr inbounds i8, ptr %0, i64 %5
  %7 = getelementptr inbounds i8, ptr %0, i64 16
  %8 = load i32, ptr %7, align 8, !tbaa !9
  %9 = and i32 %8, 3840
  %10 = add nsw i32 %9, -256
  %11 = lshr exact i32 %10, 8
  %12 = icmp ult i32 %10, 2560
  br i1 %12, label %switch.hole_check, label %13

13:                                               ; preds = %switch.hole_check, %1
  tail call void @__assert_fail(ptr noundef nonnull @.str.7, ptr noundef nonnull @.str.2, i32 noundef 1732, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN2rw3ps213rasterToImageEPNS_6RasterE) #8
  unreachable

switch.hole_check:                                ; preds = %1
  %switch.maskindex = trunc nuw i32 %11 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 %13

switch.lookup:                                    ; preds = %switch.hole_check
  %14 = and i32 %8, 16384
  %.not = icmp eq i32 %14, 0
  br i1 %.not, label %15, label %19

15:                                               ; preds = %switch.lookup
  %16 = zext nneg i32 %11 to i64
  %switch.gep = getelementptr inbounds [10 x i32], ptr @switch.table._ZN2rw3ps213rasterToImageEPNS_6RasterE, i64 0, i64 %16
  %switch.load = load i32, ptr %switch.gep, align 4
  %17 = and i32 %8, 8192
  %.not93 = icmp eq i32 %17, 0
  br i1 %.not93, label %19, label %18

18:                                               ; preds = %15
  br label %19

19:                                               ; preds = %switch.lookup, %15, %18
  %.not94 = phi i1 [ false, %18 ], [ true, %15 ], [ false, %switch.lookup ]
  %20 = phi i1 [ true, %18 ], [ false, %15 ], [ true, %switch.lookup ]
  %.090 = phi i32 [ 256, %18 ], [ 0, %15 ], [ 16, %switch.lookup ]
  %.1 = phi i32 [ 8, %18 ], [ %switch.load, %15 ], [ 4, %switch.lookup ]
  %21 = getelementptr inbounds i8, ptr %0, i64 20
  %22 = load i32, ptr %21, align 4, !tbaa !12
  %23 = getelementptr inbounds i8, ptr %0, i64 24
  %24 = load i32, ptr %23, align 8, !tbaa !13
  %25 = tail call noundef ptr @_ZN2rw5Image6createEiii(i32 noundef %22, i32 noundef %24, i32 noundef %.1)
  tail call void @_ZN2rw5Image8allocateEv(ptr noundef nonnull align 8 dereferenceable(40) %25)
  br i1 %.not94, label %69, label %26

26:                                               ; preds = %19
  %27 = getelementptr inbounds i8, ptr %25, i64 32
  %28 = load ptr, ptr %27, align 8, !tbaa !14
  %29 = tail call noundef ptr @_ZN2rw6Raster11lockPaletteEi(ptr noundef nonnull align 8 dereferenceable(96) %0, i32 noundef 2)
  %30 = icmp eq i32 %9, 1280
  br i1 %30, label %31, label %59

31:                                               ; preds = %26
  %32 = shl nuw nsw i32 %.090, 2
  %33 = zext nneg i32 %32 to i64
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 1 %28, ptr align 1 %29, i64 %33, i1 false)
  br i1 %20, label %.lr.ph.preheader, label %.loopexit96

.lr.ph.preheader:                                 ; preds = %31
  %umax = tail call i32 @llvm.umax.i32(i32 %.090, i32 1)
  %xtraiter = and i32 %umax, 1
  br i1 %.not94, label %.loopexit96.loopexit.unr-lcssa, label %.lr.ph.preheader.new

.lr.ph.preheader.new:                             ; preds = %.lr.ph.preheader
  %unroll_iter = and i32 %umax, 272
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph, %.lr.ph.preheader.new
  %.08698 = phi ptr [ %28, %.lr.ph.preheader.new ], [ %58, %.lr.ph ]
  %niter = phi i32 [ 0, %.lr.ph.preheader.new ], [ %niter.next.3, %.lr.ph ]
  %34 = getelementptr inbounds i8, ptr %.08698, i64 3
  %35 = load i8, ptr %34, align 1, !tbaa !16
  %36 = zext i8 %35 to i16
  %37 = mul nuw i16 %36, 255
  %38 = lshr i16 %37, 7
  %39 = trunc i16 %38 to i8
  store i8 %39, ptr %34, align 1, !tbaa !16
  %40 = getelementptr inbounds i8, ptr %.08698, i64 7
  %41 = load i8, ptr %40, align 1, !tbaa !16
  %42 = zext i8 %41 to i16
  %43 = mul nuw i16 %42, 255
  %44 = lshr i16 %43, 7
  %45 = trunc i16 %44 to i8
  store i8 %45, ptr %40, align 1, !tbaa !16
  %46 = getelementptr inbounds i8, ptr %.08698, i64 11
  %47 = load i8, ptr %46, align 1, !tbaa !16
  %48 = zext i8 %47 to i16
  %49 = mul nuw i16 %48, 255
  %50 = lshr i16 %49, 7
  %51 = trunc i16 %50 to i8
  store i8 %51, ptr %46, align 1, !tbaa !16
  %52 = getelementptr inbounds i8, ptr %.08698, i64 15
  %53 = load i8, ptr %52, align 1, !tbaa !16
  %54 = zext i8 %53 to i16
  %55 = mul nuw i16 %54, 255
  %56 = lshr i16 %55, 7
  %57 = trunc i16 %56 to i8
  store i8 %57, ptr %52, align 1, !tbaa !16
  %58 = getelementptr inbounds i8, ptr %.08698, i64 16
  %niter.next.3 = add i32 %niter, 4
  %niter.ncmp.3 = icmp eq i32 %niter.next.3, %unroll_iter
  br i1 %niter.ncmp.3, label %.loopexit96.loopexit.unr-lcssa, label %.lr.ph, !llvm.loop !17

59:                                               ; preds = %26
  %60 = shl nuw nsw i32 %.090, 1
  %61 = zext nneg i32 %60 to i64
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 1 %28, ptr align 1 %29, i64 %61, i1 false)
  br label %.loopexit96

.loopexit96.loopexit.unr-lcssa:                   ; preds = %.lr.ph, %.lr.ph.preheader
  %.08698.unr = phi ptr [ %28, %.lr.ph.preheader ], [ %58, %.lr.ph ]
  %lcmp.mod.not = icmp eq i32 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.loopexit96, label %.lr.ph.epil

.lr.ph.epil:                                      ; preds = %.loopexit96.loopexit.unr-lcssa, %.lr.ph.epil
  %.08698.epil = phi ptr [ %68, %.lr.ph.epil ], [ %.08698.unr, %.loopexit96.loopexit.unr-lcssa ]
  %epil.iter = phi i32 [ %epil.iter.next, %.lr.ph.epil ], [ 0, %.loopexit96.loopexit.unr-lcssa ]
  %62 = getelementptr inbounds i8, ptr %.08698.epil, i64 3
  %63 = load i8, ptr %62, align 1, !tbaa !16
  %64 = zext i8 %63 to i16
  %65 = mul nuw i16 %64, 255
  %66 = lshr i16 %65, 7
  %67 = trunc i16 %66 to i8
  store i8 %67, ptr %62, align 1, !tbaa !16
  %68 = getelementptr inbounds i8, ptr %.08698.epil, i64 4
  %epil.iter.next = add i32 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i32 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %.loopexit96, label %.lr.ph.epil, !llvm.loop !19

.loopexit96:                                      ; preds = %.loopexit96.loopexit.unr-lcssa, %.lr.ph.epil, %31, %59
  tail call void @_ZN2rw6Raster13unlockPaletteEv(ptr noundef nonnull align 8 dereferenceable(96) %0)
  br label %69

69:                                               ; preds = %.loopexit96, %19
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #9
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #9
  %70 = icmp eq i32 %.1, 4
  %71 = select i1 %70, i32 20, i32 19
  %72 = getelementptr inbounds i8, ptr %6, i64 44
  %73 = load i8, ptr %72, align 4, !tbaa !21
  %74 = sext i8 %73 to i32
  call void @_ZN2rw3ps2L15transferMinSizeEiiPiS1_(i32 noundef %71, i32 noundef %74, ptr noundef nonnull %2, ptr noundef nonnull %3)
  %75 = load i32, ptr %21, align 4, !tbaa !12
  %76 = load i32, ptr %2, align 4, !tbaa !5
  %. = call i32 @llvm.smax.i32(i32 %75, i32 %76)
  %77 = getelementptr inbounds i8, ptr %25, i64 24
  %78 = load ptr, ptr %77, align 8, !tbaa !25
  %79 = call noundef ptr @_ZN2rw6Raster4lockEii(ptr noundef nonnull align 8 dereferenceable(96) %0, i32 noundef 0, i32 noundef 2)
  br i1 %70, label %80, label %86

80:                                               ; preds = %69
  %81 = getelementptr inbounds i8, ptr %25, i64 20
  %82 = load i32, ptr %81, align 4, !tbaa !26
  %83 = sdiv i32 %., 2
  %84 = load i32, ptr %21, align 4, !tbaa !12
  %85 = load i32, ptr %23, align 8, !tbaa !13
  call void @_ZN2rw10expandPal4EPhjS0_jii(ptr noundef %78, i32 noundef %82, ptr noundef %79, i32 noundef %83, i32 noundef %84, i32 noundef %85)
  br label %.loopexit

86:                                               ; preds = %69
  %87 = icmp eq i32 %.1, 8
  br i1 %87, label %96, label %.preheader95

.preheader95:                                     ; preds = %86
  %88 = getelementptr inbounds i8, ptr %25, i64 8
  %89 = load i32, ptr %88, align 8, !tbaa !27
  %90 = icmp sgt i32 %89, 0
  br i1 %90, label %.preheader.lr.ph, label %.loopexit

.preheader.lr.ph:                                 ; preds = %.preheader95
  %91 = getelementptr inbounds i8, ptr %25, i64 4
  %92 = getelementptr inbounds i8, ptr %25, i64 16
  %93 = getelementptr inbounds i8, ptr %25, i64 20
  %94 = load i32, ptr %91, align 4, !tbaa !28
  %95 = icmp sgt i32 %94, 0
  br i1 %95, label %.preheader, label %.loopexit

96:                                               ; preds = %86
  %97 = getelementptr inbounds i8, ptr %25, i64 20
  %98 = load i32, ptr %97, align 4, !tbaa !26
  %99 = load i32, ptr %21, align 4, !tbaa !12
  %100 = load i32, ptr %23, align 8, !tbaa !13
  call void @_ZN2rw8copyPal8EPhjS0_jii(ptr noundef %78, i32 noundef %98, ptr noundef %79, i32 noundef %., i32 noundef %99, i32 noundef %100)
  br label %.loopexit

.preheader:                                       ; preds = %.preheader.lr.ph, %._crit_edge
  %101 = phi i32 [ %104, %._crit_edge ], [ %89, %.preheader.lr.ph ]
  %102 = phi i32 [ %105, %._crit_edge ], [ %94, %.preheader.lr.ph ]
  %.082106 = phi i32 [ %109, %._crit_edge ], [ 0, %.preheader.lr.ph ]
  %.083105 = phi ptr [ %108, %._crit_edge ], [ %78, %.preheader.lr.ph ]
  %.088104 = phi ptr [ %.189.lcssa, %._crit_edge ], [ %79, %.preheader.lr.ph ]
  %103 = icmp sgt i32 %102, 0
  br i1 %103, label %.lr.ph103, label %._crit_edge

._crit_edge.loopexit:                             ; preds = %144
  %.pre = load i32, ptr %88, align 8, !tbaa !27
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %.preheader
  %104 = phi i32 [ %101, %.preheader ], [ %.pre, %._crit_edge.loopexit ]
  %105 = phi i32 [ %102, %.preheader ], [ %150, %._crit_edge.loopexit ]
  %.189.lcssa = phi ptr [ %.088104, %.preheader ], [ %145, %._crit_edge.loopexit ]
  %106 = load i32, ptr %93, align 4, !tbaa !26
  %107 = sext i32 %106 to i64
  %108 = getelementptr inbounds i8, ptr %.083105, i64 %107
  %109 = add nuw nsw i32 %.082106, 1
  %110 = icmp slt i32 %109, %104
  br i1 %110, label %.preheader, label %.loopexit, !llvm.loop !29

.lr.ph103:                                        ; preds = %.preheader, %144
  %.0102 = phi i32 [ %149, %144 ], [ 0, %.preheader ]
  %.187101 = phi ptr [ %148, %144 ], [ %.083105, %.preheader ]
  %.189100 = phi ptr [ %145, %144 ], [ %.088104, %.preheader ]
  %111 = load i32, ptr %7, align 8, !tbaa !9
  %112 = and i32 %111, 3840
  %113 = add nsw i32 %112, -256
  %114 = lshr exact i32 %113, 8
  switch i32 %114, label %143 [
    i32 4, label %115
    i32 5, label %130
    i32 0, label %138
    i32 9, label %139
  ]

115:                                              ; preds = %.lr.ph103
  %116 = load i8, ptr %.189100, align 1, !tbaa !16
  store i8 %116, ptr %.187101, align 1, !tbaa !16
  %117 = getelementptr inbounds i8, ptr %.189100, i64 1
  %118 = load i8, ptr %117, align 1, !tbaa !16
  %119 = getelementptr inbounds i8, ptr %.187101, i64 1
  store i8 %118, ptr %119, align 1, !tbaa !16
  %120 = getelementptr inbounds i8, ptr %.189100, i64 2
  %121 = load i8, ptr %120, align 1, !tbaa !16
  %122 = getelementptr inbounds i8, ptr %.187101, i64 2
  store i8 %121, ptr %122, align 1, !tbaa !16
  %123 = getelementptr inbounds i8, ptr %.189100, i64 3
  %124 = load i8, ptr %123, align 1, !tbaa !16
  %125 = zext i8 %124 to i16
  %126 = mul nuw i16 %125, 255
  %127 = lshr i16 %126, 7
  %128 = trunc i16 %127 to i8
  %129 = getelementptr inbounds i8, ptr %.187101, i64 3
  store i8 %128, ptr %129, align 1, !tbaa !16
  br label %144

130:                                              ; preds = %.lr.ph103
  %131 = load i8, ptr %.189100, align 1, !tbaa !16
  store i8 %131, ptr %.187101, align 1, !tbaa !16
  %132 = getelementptr inbounds i8, ptr %.189100, i64 1
  %133 = load i8, ptr %132, align 1, !tbaa !16
  %134 = getelementptr inbounds i8, ptr %.187101, i64 1
  store i8 %133, ptr %134, align 1, !tbaa !16
  %135 = getelementptr inbounds i8, ptr %.189100, i64 2
  %136 = load i8, ptr %135, align 1, !tbaa !16
  %137 = getelementptr inbounds i8, ptr %.187101, i64 2
  store i8 %136, ptr %137, align 1, !tbaa !16
  br label %144

138:                                              ; preds = %.lr.ph103
  call void @_ZN2rw27conv_ARGB1555_from_ABGR1555EPhS0_(ptr noundef %.187101, ptr noundef %.189100)
  br label %144

139:                                              ; preds = %.lr.ph103
  call void @_ZN2rw27conv_ARGB1555_from_ABGR1555EPhS0_(ptr noundef %.187101, ptr noundef %.189100)
  %140 = getelementptr inbounds i8, ptr %.187101, i64 1
  %141 = load i8, ptr %140, align 1, !tbaa !16
  %142 = or i8 %141, -128
  store i8 %142, ptr %140, align 1, !tbaa !16
  br label %144

143:                                              ; preds = %.lr.ph103
  call void @__assert_fail(ptr noundef nonnull @.str.8, ptr noundef nonnull @.str.2, i32 noundef 1799, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN2rw3ps213rasterToImageEPNS_6RasterE) #8
  unreachable

144:                                              ; preds = %139, %138, %130, %115
  %.sink = phi i64 [ 2, %139 ], [ 2, %138 ], [ 4, %130 ], [ 4, %115 ]
  %145 = getelementptr inbounds i8, ptr %.189100, i64 %.sink
  %146 = load i32, ptr %92, align 8, !tbaa !31
  %147 = sext i32 %146 to i64
  %148 = getelementptr inbounds i8, ptr %.187101, i64 %147
  %149 = add nuw nsw i32 %.0102, 1
  %150 = load i32, ptr %91, align 4, !tbaa !28
  %151 = icmp slt i32 %149, %150
  br i1 %151, label %.lr.ph103, label %._crit_edge.loopexit, !llvm.loop !32

.loopexit:                                        ; preds = %._crit_edge, %.preheader.lr.ph, %.preheader95, %96, %80
  call void @_ZN2rw6Raster6unlockEi(ptr noundef nonnull align 8 dereferenceable(96) %0, i32 noundef 0)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #9
  ret ptr %25
}

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

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

declare void @_ZN2rw10expandPal4EPhjS0_jii(ptr noundef, i32 noundef, ptr noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #4

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

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { "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 = { 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 #7 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #8 = { noreturn nounwind }
attributes #9 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !6, i64 16}
!10 = !{!"_ZTSN2rw6RasterE", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12, !6, i64 16, !6, i64 20, !6, i64 24, !6, i64 28, !6, i64 32, !11, i64 40, !11, i64 48, !11, i64 56, !6, i64 64, !6, i64 68, !6, i64 72, !11, i64 80, !6, i64 88, !6, i64 92}
!11 = !{!"any pointer", !7, i64 0}
!12 = !{!10, !6, i64 20}
!13 = !{!10, !6, i64 24}
!14 = !{!15, !11, i64 32}
!15 = !{!"_ZTSN2rw5ImageE", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12, !6, i64 16, !6, i64 20, !11, i64 24, !11, i64 32}
!16 = !{!7, !7, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.unroll.disable"}
!21 = !{!22, !7, i64 44}
!22 = !{!"_ZTSN2rw3ps29Ps2RasterE", !23, i64 0, !6, i64 8, !24, i64 12, !7, i64 14, !7, i64 15, !23, i64 16, !23, i64 24, !6, i64 32, !6, i64 36, !6, i64 40, !7, i64 44, !11, i64 48, !6, i64 56}
!23 = !{!"long", !7, i64 0}
!24 = !{!"short", !7, i64 0}
!25 = !{!15, !11, i64 24}
!26 = !{!15, !6, i64 20}
!27 = !{!15, !6, i64 8}
!28 = !{!15, !6, i64 4}
!29 = distinct !{!29, !18, !30}
!30 = !{!"llvm.loop.unswitch.partial.disable"}
!31 = !{!15, !6, i64 16}
!32 = distinct !{!32, !18}


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