; LLVM IR from aap/librw :: src/bmp.ll (ZN2rw7readBMPEPKc)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%"struct.rw::MemoryFunctions" = type { ptr, ptr, ptr, ptr, ptr }
%"class.rw::StreamMemory" = type <{ %"class.rw::Stream", ptr, i32, i32, i32, [4 x i8] }>
%"class.rw::Stream" = type { ptr }
%"struct.rw::BMPheader" = type { i16, i32, [2 x i16], i32 }
%"struct.rw::DIBheader" = type { i32, i32, i32, i16, i16, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }
%"struct.rw::Image" = type { i32, i32, i32, i32, i32, i32, ptr, ptr }

@_ZN2rw6Engine8memfuncsE = external global %"struct.rw::MemoryFunctions", align 8

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN2rw9BMPheader4readEPNS_6StreamE(ptr noundef nonnull align 4 dereferenceable(16), ptr noundef) #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN2rw7readBMPEPKc(ptr noundef %0) #0 personality ptr @__gxx_personality_v0 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca %"class.rw::StreamMemory", align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca %"struct.rw::BMPheader", align 4
  %17 = alloca %"struct.rw::DIBheader", align 4
  %18 = alloca i32, align 4
  %19 = alloca ptr, align 8
  %20 = alloca ptr, align 8
  %21 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.start.p0(i64 32, ptr %7) #5
  call void @_ZN2rw12StreamMemoryC2Ev(ptr noundef nonnull align 8 dereferenceable(28) %7) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  %22 = load ptr, ptr %3, align 8, !tbaa !5
  %23 = invoke noundef ptr @_ZN2rw15getFileContentsEPKcPj(ptr noundef %22, ptr noundef %5)
          to label %24 unwind label %28

24:                                               ; preds = %1
  store ptr %23, ptr %6, align 8, !tbaa !5
  %25 = load ptr, ptr %6, align 8, !tbaa !5
  %26 = icmp eq ptr %25, null
  br i1 %26, label %27, label %32

27:                                               ; preds = %24
  store ptr null, ptr %2, align 8
  store i32 1, ptr %15, align 4
  br label %356

28:                                               ; preds = %32, %1
  %29 = landingpad { ptr, i32 }
          cleanup
  %30 = extractvalue { ptr, i32 } %29, 0
  store ptr %30, ptr %13, align 8
  %31 = extractvalue { ptr, i32 } %29, 1
  store i32 %31, ptr %14, align 4
  br label %358

32:                                               ; preds = %24
  %33 = load ptr, ptr %6, align 8, !tbaa !5
  %34 = load i32, ptr %5, align 4, !tbaa !9
  %35 = invoke noundef ptr @_ZN2rw12StreamMemory4openEPhjj(ptr noundef nonnull align 8 dereferenceable(28) %7, ptr noundef %33, i32 noundef %34, i32 noundef 0)
          to label %36 unwind label %28

36:                                               ; preds = %32
  call void @llvm.lifetime.start.p0(i64 16, ptr %16) #5
  call void @llvm.lifetime.start.p0(i64 56, ptr %17) #5
  %37 = invoke noundef i32 @_ZN2rw9BMPheader4readEPNS_6StreamE(ptr noundef nonnull align 4 dereferenceable(16) %16, ptr noundef %7)
          to label %38 unwind label %41

38:                                               ; preds = %36
  %39 = icmp ne i32 %37, 0
  br i1 %39, label %45, label %40

40:                                               ; preds = %38
  br label %349

41:                                               ; preds = %350, %349, %344, %343, %330, %300, %292, %284, %282, %267, %259, %257, %242, %240, %233, %210, %167, %102, %93, %47, %45, %36
  %42 = landingpad { ptr, i32 }
          cleanup
  %43 = extractvalue { ptr, i32 } %42, 0
  store ptr %43, ptr %13, align 8
  %44 = extractvalue { ptr, i32 } %42, 1
  store i32 %44, ptr %14, align 4
  br label %355

45:                                               ; preds = %38
  %46 = invoke noundef i32 @_ZN2rw12StreamMemory5read8EPvj(ptr noundef nonnull align 8 dereferenceable(28) %7, ptr noundef %17, i32 noundef 56)
          to label %47 unwind label %41

47:                                               ; preds = %45
  %48 = getelementptr inbounds %"struct.rw::DIBheader", ptr %17, i32 0, i32 0
  %49 = load i32, ptr %48, align 4, !tbaa !11
  %50 = zext i32 %49 to i64
  %51 = sub i64 %50, 56
  %52 = trunc i64 %51 to i32
  invoke void @_ZN2rw12StreamMemory4seekEii(ptr noundef nonnull align 8 dereferenceable(28) %7, i32 noundef %52, i32 noundef 1)
          to label %53 unwind label %41

53:                                               ; preds = %47
  %54 = getelementptr inbounds %"struct.rw::DIBheader", ptr %17, i32 0, i32 0
  %55 = load i32, ptr %54, align 4, !tbaa !11
  %56 = icmp ule i32 %55, 16
  br i1 %56, label %57, label %60

57:                                               ; preds = %53
  %58 = getelementptr inbounds %"struct.rw::DIBheader", ptr %17, i32 0, i32 5
  store i32 0, ptr %58, align 4, !tbaa !14
  %59 = getelementptr inbounds %"struct.rw::DIBheader", ptr %17, i32 0, i32 9
  store i32 0, ptr %59, align 4, !tbaa !15
  br label %60

60:                                               ; preds = %57, %53
  store i32 1, ptr %11, align 4, !tbaa !9
  %61 = getelementptr inbounds %"struct.rw::DIBheader", ptr %17, i32 0, i32 5
  %62 = load i32, ptr %61, align 4, !tbaa !14
  %63 = icmp eq i32 %62, 3
  br i1 %63, label %64, label %88

64:                                               ; preds = %60
  %65 = getelementptr inbounds %"struct.rw::DIBheader", ptr %17, i32 0, i32 11
  %66 = load i32, ptr %65, align 4, !tbaa !16
  %67 = icmp ne i32 %66, 16711680
  br i1 %67, label %76, label %68

68:                                               ; preds = %64
  %69 = getelementptr inbounds %"struct.rw::DIBheader", ptr %17, i32 0, i32 12
  %70 = load i32, ptr %69, align 4, !tbaa !17
  %71 = icmp ne i32 %70, 65280
  br i1 %71, label %76, label %72

72:                                               ; preds = %68
  %73 = getelementptr inbounds %"struct.rw::DIBheader", ptr %17, i32 0, i32 13
  %74 = load i32, ptr %73, align 4, !tbaa !18
  %75 = icmp ne i32 %74, 255
  br i1 %75, label %76, label %77

76:                                               ; preds = %72, %68, %64
  br label %349

77:                                               ; preds = %72
  %78 = getelementptr inbounds %"struct.rw::DIBheader", ptr %17, i32 0, i32 5
  store i32 0, ptr %78, align 4, !tbaa !14
  %79 = getelementptr inbounds %"struct.rw::DIBheader", ptr %17, i32 0, i32 0
  %80 = load i32, ptr %79, align 4, !tbaa !11
  %81 = icmp ugt i32 %80, 52
  br i1 %81, label %82, label %87

82:                                               ; preds = %77
  %83 = getelementptr inbounds %"struct.rw::DIBheader", ptr %17, i32 0, i32 14
  %84 = load i32, ptr %83, align 4, !tbaa !19
  %85 = icmp eq i32 %84, -16777216
  br i1 %85, label %86, label %87

86:                                               ; preds = %82
  store i32 0, ptr %11, align 4, !tbaa !9
  br label %87

87:                                               ; preds = %86, %82, %77
  br label %88

88:                                               ; preds = %87, %60
  %89 = getelementptr inbounds %"struct.rw::DIBheader", ptr %17, i32 0, i32 5
  %90 = load i32, ptr %89, align 4, !tbaa !14
  %91 = icmp ne i32 %90, 0
  br i1 %91, label %92, label %93

92:                                               ; preds = %88
  br label %349

93:                                               ; preds = %88
  %94 = getelementptr inbounds %"struct.rw::DIBheader", ptr %17, i32 0, i32 1
  %95 = load i32, ptr %94, align 4, !tbaa !20
  %96 = getelementptr inbounds %"struct.rw::DIBheader", ptr %17, i32 0, i32 2
  %97 = load i32, ptr %96, align 4, !tbaa !21
  %98 = getelementptr inbounds %"struct.rw::DIBheader", ptr %17, i32 0, i32 4
  %99 = load i16, ptr %98, align 2, !tbaa !22
  %100 = sext i16 %99 to i32
  %101 = invoke noundef ptr @_ZN2rw5Image6createEiii(i32 noundef %95, i32 noundef %97, i32 noundef %100)
          to label %102 unwind label %41

102:                                              ; preds = %93
  store ptr %101, ptr %4, align 8, !tbaa !5
  %103 = load ptr, ptr %4, align 8, !tbaa !5
  invoke void @_ZN2rw5Image8allocateEv(ptr noundef nonnull align 8 dereferenceable(40) %103)
          to label %104 unwind label %41

104:                                              ; preds = %102
  %105 = load ptr, ptr %4, align 8, !tbaa !5
  %106 = getelementptr inbounds %"struct.rw::Image", ptr %105, i32 0, i32 7
  %107 = load ptr, ptr %106, align 8, !tbaa !23
  %108 = icmp ne ptr %107, null
  br i1 %108, label %109, label %167

109:                                              ; preds = %104
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #5
  %110 = getelementptr inbounds %"struct.rw::DIBheader", ptr %17, i32 0, i32 4
  %111 = load i16, ptr %110, align 2, !tbaa !22
  %112 = sext i16 %111 to i32
  %113 = shl i32 1, %112
  store i32 %113, ptr %18, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #5
  %114 = load ptr, ptr %4, align 8, !tbaa !5
  %115 = getelementptr inbounds %"struct.rw::Image", ptr %114, i32 0, i32 7
  %116 = load ptr, ptr %115, align 8, !tbaa !23
  store ptr %116, ptr %19, align 8, !tbaa !5
  store i32 0, ptr %8, align 4, !tbaa !9
  br label %117

117:                                              ; preds = %163, %109
  %118 = load i32, ptr %8, align 4, !tbaa !9
  %119 = load i32, ptr %18, align 4, !tbaa !9
  %120 = icmp slt i32 %118, %119
  br i1 %120, label %121, label %166

121:                                              ; preds = %117
  %122 = invoke noundef zeroext i8 @_ZN2rw6Stream6readU8Ev(ptr noundef nonnull align 8 dereferenceable(8) %7)
          to label %123 unwind label %158

123:                                              ; preds = %121
  %124 = load ptr, ptr %19, align 8, !tbaa !5
  %125 = load i32, ptr %8, align 4, !tbaa !9
  %126 = sext i32 %125 to i64
  %127 = getelementptr inbounds [4 x i8], ptr %124, i64 %126
  %128 = getelementptr inbounds [4 x i8], ptr %127, i64 0, i64 2
  store i8 %122, ptr %128, align 1, !tbaa !25
  %129 = invoke noundef zeroext i8 @_ZN2rw6Stream6readU8Ev(ptr noundef nonnull align 8 dereferenceable(8) %7)
          to label %130 unwind label %158

130:                                              ; preds = %123
  %131 = load ptr, ptr %19, align 8, !tbaa !5
  %132 = load i32, ptr %8, align 4, !tbaa !9
  %133 = sext i32 %132 to i64
  %134 = getelementptr inbounds [4 x i8], ptr %131, i64 %133
  %135 = getelementptr inbounds [4 x i8], ptr %134, i64 0, i64 1
  store i8 %129, ptr %135, align 1, !tbaa !25
  %136 = invoke noundef zeroext i8 @_ZN2rw6Stream6readU8Ev(ptr noundef nonnull align 8 dereferenceable(8) %7)
          to label %137 unwind label %158

137:                                              ; preds = %130
  %138 = load ptr, ptr %19, align 8, !tbaa !5
  %139 = load i32, ptr %8, align 4, !tbaa !9
  %140 = sext i32 %139 to i64
  %141 = getelementptr inbounds [4 x i8], ptr %138, i64 %140
  %142 = getelementptr inbounds [4 x i8], ptr %141, i64 0, i64 0
  store i8 %136, ptr %142, align 1, !tbaa !25
  %143 = invoke noundef zeroext i8 @_ZN2rw6Stream6readU8Ev(ptr noundef nonnull align 8 dereferenceable(8) %7)
          to label %144 unwind label %158

144:                                              ; preds = %137
  %145 = load ptr, ptr %19, align 8, !tbaa !5
  %146 = load i32, ptr %8, align 4, !tbaa !9
  %147 = sext i32 %146 to i64
  %148 = getelementptr inbounds [4 x i8], ptr %145, i64 %147
  %149 = getelementptr inbounds [4 x i8], ptr %148, i64 0, i64 3
  store i8 %143, ptr %149, align 1, !tbaa !25
  %150 = load i32, ptr %11, align 4, !tbaa !9
  %151 = icmp ne i32 %150, 0
  br i1 %151, label %152, label %162

152:                                              ; preds = %144
  %153 = load ptr, ptr %19, align 8, !tbaa !5
  %154 = load i32, ptr %8, align 4, !tbaa !9
  %155 = sext i32 %154 to i64
  %156 = getelementptr inbounds [4 x i8], ptr %153, i64 %155
  %157 = getelementptr inbounds [4 x i8], ptr %156, i64 0, i64 3
  store i8 -1, ptr %157, align 1, !tbaa !25
  br label %162

158:                                              ; preds = %137, %130, %123, %121
  %159 = landingpad { ptr, i32 }
          cleanup
  %160 = extractvalue { ptr, i32 } %159, 0
  store ptr %160, ptr %13, align 8
  %161 = extractvalue { ptr, i32 } %159, 1
  store i32 %161, ptr %14, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #5
  br label %355

162:                                              ; preds = %152, %144
  br label %163

163:                                              ; preds = %162
  %164 = load i32, ptr %8, align 4, !tbaa !9
  %165 = add nsw i32 %164, 1
  store i32 %165, ptr %8, align 4, !tbaa !9
  br label %117, !llvm.loop !26

166:                                              ; preds = %117
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #5
  br label %167

167:                                              ; preds = %166, %104
  %168 = getelementptr inbounds %"struct.rw::BMPheader", ptr %16, i32 0, i32 3
  %169 = load i32, ptr %168, align 4, !tbaa !28
  invoke void @_ZN2rw12StreamMemory4seekEii(ptr noundef nonnull align 8 dereferenceable(28) %7, i32 noundef %169, i32 noundef 0)
          to label %170 unwind label %41

170:                                              ; preds = %167
  %171 = load ptr, ptr %4, align 8, !tbaa !5
  %172 = getelementptr inbounds %"struct.rw::Image", ptr %171, i32 0, i32 1
  %173 = load i32, ptr %172, align 4, !tbaa !30
  %174 = load ptr, ptr %4, align 8, !tbaa !5
  %175 = getelementptr inbounds %"struct.rw::Image", ptr %174, i32 0, i32 4
  %176 = load i32, ptr %175, align 8, !tbaa !31
  %177 = mul nsw i32 %173, %176
  %178 = srem i32 %177, 4
  store i32 %178, ptr %12, align 4, !tbaa !9
  %179 = load ptr, ptr %4, align 8, !tbaa !5
  %180 = getelementptr inbounds %"struct.rw::Image", ptr %179, i32 0, i32 6
  %181 = load ptr, ptr %180, align 8, !tbaa !32
  %182 = load ptr, ptr %4, align 8, !tbaa !5
  %183 = getelementptr inbounds %"struct.rw::Image", ptr %182, i32 0, i32 2
  %184 = load i32, ptr %183, align 8, !tbaa !33
  %185 = sub nsw i32 %184, 1
  %186 = load ptr, ptr %4, align 8, !tbaa !5
  %187 = getelementptr inbounds %"struct.rw::Image", ptr %186, i32 0, i32 5
  %188 = load i32, ptr %187, align 4, !tbaa !34
  %189 = mul nsw i32 %185, %188
  %190 = sext i32 %189 to i64
  %191 = getelementptr inbounds i8, ptr %181, i64 %190
  store ptr %191, ptr %21, align 8, !tbaa !5
  store i32 0, ptr %10, align 4, !tbaa !9
  br label %192

192:                                              ; preds = %340, %170
  %193 = load i32, ptr %10, align 4, !tbaa !9
  %194 = load ptr, ptr %4, align 8, !tbaa !5
  %195 = getelementptr inbounds %"struct.rw::Image", ptr %194, i32 0, i32 2
  %196 = load i32, ptr %195, align 8, !tbaa !33
  %197 = icmp slt i32 %193, %196
  br i1 %197, label %198, label %343

198:                                              ; preds = %192
  %199 = load ptr, ptr %21, align 8, !tbaa !5
  store ptr %199, ptr %20, align 8, !tbaa !5
  store i32 0, ptr %9, align 4, !tbaa !9
  br label %200

200:                                              ; preds = %327, %198
  %201 = load i32, ptr %9, align 4, !tbaa !9
  %202 = load ptr, ptr %4, align 8, !tbaa !5
  %203 = getelementptr inbounds %"struct.rw::Image", ptr %202, i32 0, i32 1
  %204 = load i32, ptr %203, align 4, !tbaa !30
  %205 = icmp slt i32 %201, %204
  br i1 %205, label %206, label %330

206:                                              ; preds = %200
  %207 = load ptr, ptr %4, align 8, !tbaa !5
  %208 = getelementptr inbounds %"struct.rw::Image", ptr %207, i32 0, i32 3
  %209 = load i32, ptr %208, align 4, !tbaa !35
  switch i32 %209, label %325 [
    i32 4, label %210
    i32 8, label %233
    i32 16, label %240
    i32 24, label %257
    i32 32, label %282
  ]

210:                                              ; preds = %206
  %211 = invoke noundef zeroext i8 @_ZN2rw6Stream6readU8Ev(ptr noundef nonnull align 8 dereferenceable(8) %7)
          to label %212 unwind label %41

212:                                              ; preds = %210
  %213 = zext i8 %211 to i32
  store i32 %213, ptr %8, align 4, !tbaa !9
  %214 = load i32, ptr %8, align 4, !tbaa !9
  %215 = ashr i32 %214, 4
  %216 = and i32 %215, 15
  %217 = trunc i32 %216 to i8
  %218 = load ptr, ptr %20, align 8, !tbaa !5
  %219 = load i32, ptr %9, align 4, !tbaa !9
  %220 = add nsw i32 %219, 0
  %221 = sext i32 %220 to i64
  %222 = getelementptr inbounds i8, ptr %218, i64 %221
  store i8 %217, ptr %222, align 1, !tbaa !25
  %223 = load i32, ptr %8, align 4, !tbaa !9
  %224 = and i32 %223, 15
  %225 = trunc i32 %224 to i8
  %226 = load ptr, ptr %20, align 8, !tbaa !5
  %227 = load i32, ptr %9, align 4, !tbaa !9
  %228 = add nsw i32 %227, 1
  %229 = sext i32 %228 to i64
  %230 = getelementptr inbounds i8, ptr %226, i64 %229
  store i8 %225, ptr %230, align 1, !tbaa !25
  %231 = load i32, ptr %9, align 4, !tbaa !9
  %232 = add nsw i32 %231, 1
  store i32 %232, ptr %9, align 4, !tbaa !9
  br label %326

233:                                              ; preds = %206
  %234 = invoke noundef zeroext i8 @_ZN2rw6Stream6readU8Ev(ptr noundef nonnull align 8 dereferenceable(8) %7)
          to label %235 unwind label %41

235:                                              ; preds = %233
  %236 = load ptr, ptr %20, align 8, !tbaa !5
  %237 = load i32, ptr %9, align 4, !tbaa !9
  %238 = sext i32 %237 to i64
  %239 = getelementptr inbounds i8, ptr %236, i64 %238
  store i8 %234, ptr %239, align 1, !tbaa !25
  br label %326

240:                                              ; preds = %206
  %241 = invoke noundef zeroext i8 @_ZN2rw6Stream6readU8Ev(ptr noundef nonnull align 8 dereferenceable(8) %7)
          to label %242 unwind label %41

242:                                              ; preds = %240
  %243 = load ptr, ptr %20, align 8, !tbaa !5
  %244 = load i32, ptr %9, align 4, !tbaa !9
  %245 = mul nsw i32 %244, 2
  %246 = add nsw i32 %245, 0
  %247 = sext i32 %246 to i64
  %248 = getelementptr inbounds i8, ptr %243, i64 %247
  store i8 %241, ptr %248, align 1, !tbaa !25
  %249 = invoke noundef zeroext i8 @_ZN2rw6Stream6readU8Ev(ptr noundef nonnull align 8 dereferenceable(8) %7)
          to label %250 unwind label %41

250:                                              ; preds = %242
  %251 = load ptr, ptr %20, align 8, !tbaa !5
  %252 = load i32, ptr %9, align 4, !tbaa !9
  %253 = mul nsw i32 %252, 2
  %254 = add nsw i32 %253, 1
  %255 = sext i32 %254 to i64
  %256 = getelementptr inbounds i8, ptr %251, i64 %255
  store i8 %249, ptr %256, align 1, !tbaa !25
  br label %326

257:                                              ; preds = %206
  %258 = invoke noundef zeroext i8 @_ZN2rw6Stream6readU8Ev(ptr noundef nonnull align 8 dereferenceable(8) %7)
          to label %259 unwind label %41

259:                                              ; preds = %257
  %260 = load ptr, ptr %20, align 8, !tbaa !5
  %261 = load i32, ptr %9, align 4, !tbaa !9
  %262 = mul nsw i32 %261, 3
  %263 = add nsw i32 %262, 2
  %264 = sext i32 %263 to i64
  %265 = getelementptr inbounds i8, ptr %260, i64 %264
  store i8 %258, ptr %265, align 1, !tbaa !25
  %266 = invoke noundef zeroext i8 @_ZN2rw6Stream6readU8Ev(ptr noundef nonnull align 8 dereferenceable(8) %7)
          to label %267 unwind label %41

267:                                              ; preds = %259
  %268 = load ptr, ptr %20, align 8, !tbaa !5
  %269 = load i32, ptr %9, align 4, !tbaa !9
  %270 = mul nsw i32 %269, 3
  %271 = add nsw i32 %270, 1
  %272 = sext i32 %271 to i64
  %273 = getelementptr inbounds i8, ptr %268, i64 %272
  store i8 %266, ptr %273, align 1, !tbaa !25
  %274 = invoke noundef zeroext i8 @_ZN2rw6Stream6readU8Ev(ptr noundef nonnull align 8 dereferenceable(8) %7)
          to label %275 unwind label %41

275:                                              ; preds = %267
  %276 = load ptr, ptr %20, align 8, !tbaa !5
  %277 = load i32, ptr %9, align 4, !tbaa !9
  %278 = mul nsw i32 %277, 3
  %279 = add nsw i32 %278, 0
  %280 = sext i32 %279 to i64
  %281 = getelementptr inbounds i8, ptr %276, i64 %280
  store i8 %274, ptr %281, align 1, !tbaa !25
  br label %326

282:                                              ; preds = %206
  %283 = invoke noundef zeroext i8 @_ZN2rw6Stream6readU8Ev(ptr noundef nonnull align 8 dereferenceable(8) %7)
          to label %284 unwind label %41

284:                                              ; preds = %282
  %285 = load ptr, ptr %20, align 8, !tbaa !5
  %286 = load i32, ptr %9, align 4, !tbaa !9
  %287 = mul nsw i32 %286, 4
  %288 = add nsw i32 %287, 2
  %289 = sext i32 %288 to i64
  %290 = getelementptr inbounds i8, ptr %285, i64 %289
  store i8 %283, ptr %290, align 1, !tbaa !25
  %291 = invoke noundef zeroext i8 @_ZN2rw6Stream6readU8Ev(ptr noundef nonnull align 8 dereferenceable(8) %7)
          to label %292 unwind label %41

292:                                              ; preds = %284
  %293 = load ptr, ptr %20, align 8, !tbaa !5
  %294 = load i32, ptr %9, align 4, !tbaa !9
  %295 = mul nsw i32 %294, 4
  %296 = add nsw i32 %295, 1
  %297 = sext i32 %296 to i64
  %298 = getelementptr inbounds i8, ptr %293, i64 %297
  store i8 %291, ptr %298, align 1, !tbaa !25
  %299 = invoke noundef zeroext i8 @_ZN2rw6Stream6readU8Ev(ptr noundef nonnull align 8 dereferenceable(8) %7)
          to label %300 unwind label %41

300:                                              ; preds = %292
  %301 = load ptr, ptr %20, align 8, !tbaa !5
  %302 = load i32, ptr %9, align 4, !tbaa !9
  %303 = mul nsw i32 %302, 4
  %304 = add nsw i32 %303, 0
  %305 = sext i32 %304 to i64
  %306 = getelementptr inbounds i8, ptr %301, i64 %305
  store i8 %299, ptr %306, align 1, !tbaa !25
  %307 = invoke noundef zeroext i8 @_ZN2rw6Stream6readU8Ev(ptr noundef nonnull align 8 dereferenceable(8) %7)
          to label %308 unwind label %41

308:                                              ; preds = %300
  %309 = load ptr, ptr %20, align 8, !tbaa !5
  %310 = load i32, ptr %9, align 4, !tbaa !9
  %311 = mul nsw i32 %310, 4
  %312 = add nsw i32 %311, 3
  %313 = sext i32 %312 to i64
  %314 = getelementptr inbounds i8, ptr %309, i64 %313
  store i8 %307, ptr %314, align 1, !tbaa !25
  %315 = load i32, ptr %11, align 4, !tbaa !9
  %316 = icmp ne i32 %315, 0
  br i1 %316, label %317, label %324

317:                                              ; preds = %308
  %318 = load ptr, ptr %20, align 8, !tbaa !5
  %319 = load i32, ptr %9, align 4, !tbaa !9
  %320 = mul nsw i32 %319, 4
  %321 = add nsw i32 %320, 3
  %322 = sext i32 %321 to i64
  %323 = getelementptr inbounds i8, ptr %318, i64 %322
  store i8 -1, ptr %323, align 1, !tbaa !25
  br label %324

324:                                              ; preds = %317, %308
  br label %326

325:                                              ; preds = %206
  br label %349

326:                                              ; preds = %324, %275, %250, %235, %212
  br label %327

327:                                              ; preds = %326
  %328 = load i32, ptr %9, align 4, !tbaa !9
  %329 = add nsw i32 %328, 1
  store i32 %329, ptr %9, align 4, !tbaa !9
  br label %200, !llvm.loop !36

330:                                              ; preds = %200
  %331 = load ptr, ptr %4, align 8, !tbaa !5
  %332 = getelementptr inbounds %"struct.rw::Image", ptr %331, i32 0, i32 5
  %333 = load i32, ptr %332, align 4, !tbaa !34
  %334 = load ptr, ptr %21, align 8, !tbaa !5
  %335 = sext i32 %333 to i64
  %336 = sub i64 0, %335
  %337 = getelementptr inbounds i8, ptr %334, i64 %336
  store ptr %337, ptr %21, align 8, !tbaa !5
  %338 = load i32, ptr %12, align 4, !tbaa !9
  invoke void @_ZN2rw12StreamMemory4seekEii(ptr noundef nonnull align 8 dereferenceable(28) %7, i32 noundef %338, i32 noundef 1)
          to label %339 unwind label %41

339:                                              ; preds = %330
  br label %340

340:                                              ; preds = %339
  %341 = load i32, ptr %10, align 4, !tbaa !9
  %342 = add nsw i32 %341, 1
  store i32 %342, ptr %10, align 4, !tbaa !9
  br label %192, !llvm.loop !37

343:                                              ; preds = %192
  invoke void @_ZN2rw12StreamMemory5closeEv(ptr noundef nonnull align 8 dereferenceable(28) %7)
          to label %344 unwind label %41

344:                                              ; preds = %343
  %345 = load ptr, ptr getelementptr inbounds (%"struct.rw::MemoryFunctions", ptr @_ZN2rw6Engine8memfuncsE, i32 0, i32 2), align 8, !tbaa !38
  %346 = load ptr, ptr %6, align 8, !tbaa !5
  invoke void %345(ptr noundef %346)
          to label %347 unwind label %41

347:                                              ; preds = %344
  %348 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %348, ptr %2, align 8
  store i32 1, ptr %15, align 4
  br label %354

349:                                              ; preds = %325, %92, %76, %40
  invoke void @_ZN2rw12StreamMemory5closeEv(ptr noundef nonnull align 8 dereferenceable(28) %7)
          to label %350 unwind label %41

350:                                              ; preds = %349
  %351 = load ptr, ptr getelementptr inbounds (%"struct.rw::MemoryFunctions", ptr @_ZN2rw6Engine8memfuncsE, i32 0, i32 2), align 8, !tbaa !38
  %352 = load ptr, ptr %6, align 8, !tbaa !5
  invoke void %351(ptr noundef %352)
          to label %353 unwind label %41

353:                                              ; preds = %350
  store ptr null, ptr %2, align 8
  store i32 1, ptr %15, align 4
  br label %354

354:                                              ; preds = %353, %347
  call void @llvm.lifetime.end.p0(i64 56, ptr %17) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr %16) #5
  br label %356

355:                                              ; preds = %158, %41
  call void @llvm.lifetime.end.p0(i64 56, ptr %17) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr %16) #5
  br label %358

356:                                              ; preds = %354, %27
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  call void @_ZN2rw6StreamD2Ev(ptr noundef nonnull align 8 dereferenceable(28) %7) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  %357 = load ptr, ptr %2, align 8
  ret ptr %357

358:                                              ; preds = %355, %28
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  call void @_ZN2rw6StreamD2Ev(ptr noundef nonnull align 8 dereferenceable(28) %7) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  br label %359

359:                                              ; preds = %358
  %360 = load ptr, ptr %13, align 8
  %361 = load i32, ptr %14, align 4
  %362 = insertvalue { ptr, i32 } poison, ptr %360, 0
  %363 = insertvalue { ptr, i32 } %362, i32 %361, 1
  resume { ptr, i32 } %363
}

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN2rw12StreamMemoryC2Ev(ptr noundef nonnull align 8 dereferenceable(28)) unnamed_addr #2 align 2

declare noundef ptr @_ZN2rw15getFileContentsEPKcPj(ptr noundef, ptr noundef) #3

declare i32 @__gxx_personality_v0(...)

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

declare noundef i32 @_ZN2rw12StreamMemory5read8EPvj(ptr noundef nonnull align 8 dereferenceable(28), ptr noundef, i32 noundef) unnamed_addr #3

declare void @_ZN2rw12StreamMemory4seekEii(ptr noundef nonnull align 8 dereferenceable(28), i32 noundef, i32 noundef) unnamed_addr #3

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

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

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

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

declare void @_ZN2rw12StreamMemory5closeEv(ptr noundef nonnull align 8 dereferenceable(28)) unnamed_addr #3

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN2rw6StreamD2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #4 align 2

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

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"_ZTSN2rw9DIBheaderE", !10, i64 0, !10, i64 4, !10, i64 8, !13, i64 12, !13, i64 14, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !10, i64 40, !10, i64 44, !10, i64 48, !10, i64 52}
!13 = !{!"short", !7, i64 0}
!14 = !{!12, !10, i64 16}
!15 = !{!12, !10, i64 32}
!16 = !{!12, !10, i64 40}
!17 = !{!12, !10, i64 44}
!18 = !{!12, !10, i64 48}
!19 = !{!12, !10, i64 52}
!20 = !{!12, !10, i64 4}
!21 = !{!12, !10, i64 8}
!22 = !{!12, !13, i64 14}
!23 = !{!24, !6, i64 32}
!24 = !{!"_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}
!25 = !{!7, !7, i64 0}
!26 = distinct !{!26, !27}
!27 = !{!"llvm.loop.mustprogress"}
!28 = !{!29, !10, i64 12}
!29 = !{!"_ZTSN2rw9BMPheaderE", !13, i64 0, !10, i64 4, !7, i64 8, !10, i64 12}
!30 = !{!24, !10, i64 4}
!31 = !{!24, !10, i64 16}
!32 = !{!24, !6, i64 24}
!33 = !{!24, !10, i64 8}
!34 = !{!24, !10, i64 20}
!35 = !{!24, !10, i64 12}
!36 = distinct !{!36, !27}
!37 = distinct !{!37, !27}
!38 = !{!39, !6, i64 16}
!39 = !{!"_ZTSN2rw15MemoryFunctionsE", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%"struct.rw::MemoryFunctions" = type { ptr, ptr, ptr, ptr, ptr }
%"class.rw::StreamMemory" = type <{ %"class.rw::Stream", ptr, i32, i32, i32, [4 x i8] }>
%"class.rw::Stream" = type { ptr }
%"struct.rw::BMPheader" = type { i16, i32, [2 x i16], i32 }
%"struct.rw::DIBheader" = type { i32, i32, i32, i16, i16, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }

@_ZN2rw6Engine8memfuncsE = external local_unnamed_addr global %"struct.rw::MemoryFunctions", align 8

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN2rw9BMPheader4readEPNS_6StreamE(ptr noundef nonnull align 4 dereferenceable(16), ptr noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN2rw7readBMPEPKc(ptr noundef %0) local_unnamed_addr #0 personality ptr @__gxx_personality_v0 {
  %2 = alloca i32, align 4
  %3 = alloca %"class.rw::StreamMemory", align 8
  %4 = alloca %"struct.rw::BMPheader", align 4
  %5 = alloca %"struct.rw::DIBheader", align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #6
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %3) #6
  call void @_ZN2rw12StreamMemoryC2Ev(ptr noundef nonnull align 8 dereferenceable(28) %3) #6
  %6 = invoke noundef ptr @_ZN2rw15getFileContentsEPKcPj(ptr noundef %0, ptr noundef nonnull %2)
          to label %7 unwind label %9

7:                                                ; preds = %1
  %8 = icmp eq ptr %6, null
  br i1 %8, label %193, label %11

9:                                                ; preds = %11, %1
  %10 = landingpad { ptr, i32 }
          cleanup
  br label %194

11:                                               ; preds = %7
  %12 = load i32, ptr %2, align 4, !tbaa !5
  %13 = invoke noundef ptr @_ZN2rw12StreamMemory4openEPhjj(ptr noundef nonnull align 8 dereferenceable(28) %3, ptr noundef nonnull %6, i32 noundef %12, i32 noundef 0)
          to label %14 unwind label %9

14:                                               ; preds = %11
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %4) #6
  call void @llvm.lifetime.start.p0(i64 56, ptr nonnull %5) #6
  %15 = invoke noundef i32 @_ZN2rw9BMPheader4readEPNS_6StreamE(ptr noundef nonnull align 4 dereferenceable(16) %4, ptr noundef nonnull %3)
          to label %16 unwind label %.loopexit.split-lp.loopexit.split-lp

16:                                               ; preds = %14
  %.not = icmp eq i32 %15, 0
  br i1 %.not, label %.loopexit, label %17

.loopexit98:                                      ; preds = %113, %123, %128, %130, %139, %141, %147, %155, %157, %163, %168
  %lpad.loopexit = landingpad { ptr, i32 }
          cleanup
  br label %.loopexit.split-lp

.loopexit.split-lp.loopexit:                      ; preds = %._crit_edge
  %lpad.loopexit99 = landingpad { ptr, i32 }
          cleanup
  br label %.loopexit.split-lp

.loopexit.split-lp.loopexit.split-lp:             ; preds = %190, %.loopexit, %188, %._crit_edge108, %.loopexit102, %53, %.thread119, %19, %17, %14
  %lpad.loopexit.split-lp100 = landingpad { ptr, i32 }
          cleanup
  br label %.loopexit.split-lp

17:                                               ; preds = %16
  %18 = invoke noundef i32 @_ZN2rw12StreamMemory5read8EPvj(ptr noundef nonnull align 8 dereferenceable(28) %3, ptr noundef nonnull %5, i32 noundef 56)
          to label %19 unwind label %.loopexit.split-lp.loopexit.split-lp

19:                                               ; preds = %17
  %20 = load i32, ptr %5, align 4, !tbaa !9
  %21 = add i32 %20, -56
  invoke void @_ZN2rw12StreamMemory4seekEii(ptr noundef nonnull align 8 dereferenceable(28) %3, i32 noundef %21, i32 noundef 1)
          to label %22 unwind label %.loopexit.split-lp.loopexit.split-lp

22:                                               ; preds = %19
  %23 = load i32, ptr %5, align 4, !tbaa !9
  %24 = icmp ult i32 %23, 17
  %25 = getelementptr inbounds i8, ptr %5, i64 16
  br i1 %24, label %.thread, label %27

.thread:                                          ; preds = %22
  store i32 0, ptr %25, align 4, !tbaa !12
  %26 = getelementptr inbounds i8, ptr %5, i64 32
  store i32 0, ptr %26, align 4, !tbaa !13
  br label %.thread119

27:                                               ; preds = %22
  %.pre = load i32, ptr %25, align 4, !tbaa !12
  %28 = getelementptr inbounds i8, ptr %5, i64 16
  switch i32 %.pre, label %.loopexit [
    i32 3, label %29
    i32 0, label %.thread119
  ]

29:                                               ; preds = %27
  %30 = getelementptr inbounds i8, ptr %5, i64 40
  %31 = load i32, ptr %30, align 4, !tbaa !14
  %32 = icmp ne i32 %31, 16711680
  %33 = getelementptr inbounds i8, ptr %5, i64 44
  %34 = load i32, ptr %33, align 4
  %35 = icmp ne i32 %34, 65280
  %or.cond = select i1 %32, i1 true, i1 %35
  %36 = getelementptr inbounds i8, ptr %5, i64 48
  %37 = load i32, ptr %36, align 4
  %38 = icmp ne i32 %37, 255
  %or.cond5 = select i1 %or.cond, i1 true, i1 %38
  br i1 %or.cond5, label %.loopexit, label %39

39:                                               ; preds = %29
  store i32 0, ptr %28, align 4, !tbaa !12
  %40 = icmp ugt i32 %23, 52
  %41 = getelementptr inbounds i8, ptr %5, i64 52
  %42 = load i32, ptr %41, align 4
  %43 = icmp eq i32 %42, -16777216
  %or.cond8 = select i1 %40, i1 %43, i1 false
  %44 = freeze i1 %or.cond8
  br label %.thread119

.thread119:                                       ; preds = %27, %.thread, %39
  %.not93.fr123 = phi i1 [ false, %.thread ], [ %44, %39 ], [ false, %27 ]
  %45 = getelementptr inbounds i8, ptr %5, i64 4
  %46 = load i32, ptr %45, align 4, !tbaa !15
  %47 = getelementptr inbounds i8, ptr %5, i64 8
  %48 = load i32, ptr %47, align 4, !tbaa !16
  %49 = getelementptr inbounds i8, ptr %5, i64 14
  %50 = load i16, ptr %49, align 2, !tbaa !17
  %51 = sext i16 %50 to i32
  %52 = invoke noundef ptr @_ZN2rw5Image6createEiii(i32 noundef %46, i32 noundef %48, i32 noundef %51)
          to label %53 unwind label %.loopexit.split-lp.loopexit.split-lp

53:                                               ; preds = %.thread119
  invoke void @_ZN2rw5Image8allocateEv(ptr noundef nonnull align 8 dereferenceable(40) %52)
          to label %54 unwind label %.loopexit.split-lp.loopexit.split-lp

54:                                               ; preds = %53
  %55 = getelementptr inbounds i8, ptr %52, i64 32
  %56 = load ptr, ptr %55, align 8, !tbaa !18
  %.not92 = icmp eq ptr %56, null
  br i1 %.not92, label %.loopexit102, label %57

57:                                               ; preds = %54
  %58 = load i16, ptr %49, align 2, !tbaa !17
  %.not109 = icmp eq i16 %58, 31
  br i1 %.not109, label %.loopexit102, label %.lr.ph

.lr.ph:                                           ; preds = %57
  %59 = zext nneg i16 %58 to i32
  %60 = shl nuw i32 1, %59
  %smax115 = call i32 @llvm.smax.i32(i32 %60, i32 1)
  %wide.trip.count116 = zext nneg i32 %smax115 to i64
  br i1 %.not93.fr123, label %.lr.ph.split.us, label %.lr.ph.split

.lr.ph.split.us:                                  ; preds = %.lr.ph, %71
  %indvars.iv112 = phi i64 [ %indvars.iv.next113, %71 ], [ 0, %.lr.ph ]
  %61 = invoke noundef zeroext i8 @_ZN2rw6Stream6readU8Ev(ptr noundef nonnull align 8 dereferenceable(8) %3)
          to label %62 unwind label %.split.us

62:                                               ; preds = %.lr.ph.split.us
  %63 = getelementptr inbounds [4 x i8], ptr %56, i64 %indvars.iv112
  %64 = getelementptr inbounds i8, ptr %63, i64 2
  store i8 %61, ptr %64, align 1, !tbaa !21
  %65 = invoke noundef zeroext i8 @_ZN2rw6Stream6readU8Ev(ptr noundef nonnull align 8 dereferenceable(8) %3)
          to label %66 unwind label %.split.us

66:                                               ; preds = %62
  %67 = getelementptr inbounds i8, ptr %63, i64 1
  store i8 %65, ptr %67, align 1, !tbaa !21
  %68 = invoke noundef zeroext i8 @_ZN2rw6Stream6readU8Ev(ptr noundef nonnull align 8 dereferenceable(8) %3)
          to label %69 unwind label %.split.us

69:                                               ; preds = %66
  store i8 %68, ptr %63, align 1, !tbaa !21
  %70 = invoke noundef zeroext i8 @_ZN2rw6Stream6readU8Ev(ptr noundef nonnull align 8 dereferenceable(8) %3)
          to label %71 unwind label %.split.us

71:                                               ; preds = %69
  %72 = getelementptr inbounds i8, ptr %63, i64 3
  store i8 %70, ptr %72, align 1, !tbaa !21
  %indvars.iv.next113 = add nuw nsw i64 %indvars.iv112, 1
  %exitcond117.not = icmp eq i64 %indvars.iv.next113, %wide.trip.count116
  br i1 %exitcond117.not, label %.loopexit102, label %.lr.ph.split.us, !llvm.loop !22

.split.us:                                        ; preds = %69, %66, %62, %.lr.ph.split.us
  %73 = landingpad { ptr, i32 }
          cleanup
  br label %.loopexit.split-lp

.lr.ph.split:                                     ; preds = %.lr.ph, %84
  %indvars.iv = phi i64 [ %indvars.iv.next, %84 ], [ 0, %.lr.ph ]
  %74 = invoke noundef zeroext i8 @_ZN2rw6Stream6readU8Ev(ptr noundef nonnull align 8 dereferenceable(8) %3)
          to label %75 unwind label %.split

75:                                               ; preds = %.lr.ph.split
  %76 = getelementptr inbounds [4 x i8], ptr %56, i64 %indvars.iv
  %77 = getelementptr inbounds i8, ptr %76, i64 2
  store i8 %74, ptr %77, align 1, !tbaa !21
  %78 = invoke noundef zeroext i8 @_ZN2rw6Stream6readU8Ev(ptr noundef nonnull align 8 dereferenceable(8) %3)
          to label %79 unwind label %.split

79:                                               ; preds = %75
  %80 = getelementptr inbounds i8, ptr %76, i64 1
  store i8 %78, ptr %80, align 1, !tbaa !21
  %81 = invoke noundef zeroext i8 @_ZN2rw6Stream6readU8Ev(ptr noundef nonnull align 8 dereferenceable(8) %3)
          to label %82 unwind label %.split

82:                                               ; preds = %79
  store i8 %81, ptr %76, align 1, !tbaa !21
  %83 = invoke noundef zeroext i8 @_ZN2rw6Stream6readU8Ev(ptr noundef nonnull align 8 dereferenceable(8) %3)
          to label %84 unwind label %.split

84:                                               ; preds = %82
  %85 = getelementptr inbounds i8, ptr %76, i64 3
  store i8 -1, ptr %85, align 1, !tbaa !21
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count116
  br i1 %exitcond.not, label %.loopexit102, label %.lr.ph.split, !llvm.loop !22

.split:                                           ; preds = %82, %79, %75, %.lr.ph.split
  %86 = landingpad { ptr, i32 }
          cleanup
  br label %.loopexit.split-lp

.loopexit102:                                     ; preds = %84, %71, %57, %54
  %87 = getelementptr inbounds i8, ptr %4, i64 12
  %88 = load i32, ptr %87, align 4, !tbaa !24
  invoke void @_ZN2rw12StreamMemory4seekEii(ptr noundef nonnull align 8 dereferenceable(28) %3, i32 noundef %88, i32 noundef 0)
          to label %89 unwind label %.loopexit.split-lp.loopexit.split-lp

89:                                               ; preds = %.loopexit102
  %90 = getelementptr inbounds i8, ptr %52, i64 4
  %91 = load i32, ptr %90, align 4, !tbaa !26
  %92 = getelementptr inbounds i8, ptr %52, i64 16
  %93 = load i32, ptr %92, align 8, !tbaa !27
  %94 = mul nsw i32 %93, %91
  %95 = srem i32 %94, 4
  %96 = getelementptr inbounds i8, ptr %52, i64 8
  %97 = getelementptr inbounds i8, ptr %52, i64 20
  %98 = load i32, ptr %96, align 8, !tbaa !28
  %99 = icmp sgt i32 %98, 0
  br i1 %99, label %.preheader.lr.ph, label %._crit_edge108

.preheader.lr.ph:                                 ; preds = %89
  %100 = getelementptr inbounds i8, ptr %52, i64 24
  %101 = load ptr, ptr %100, align 8, !tbaa !29
  %102 = add nsw i32 %98, -1
  %103 = load i32, ptr %97, align 4, !tbaa !30
  %104 = mul nsw i32 %102, %103
  %105 = sext i32 %104 to i64
  %106 = getelementptr inbounds i8, ptr %101, i64 %105
  %107 = getelementptr inbounds i8, ptr %52, i64 12
  br label %.preheader

.preheader:                                       ; preds = %.preheader.lr.ph, %181
  %.0107 = phi ptr [ %106, %.preheader.lr.ph ], [ %184, %181 ]
  %.087106 = phi i32 [ 0, %.preheader.lr.ph ], [ %185, %181 ]
  %108 = load i32, ptr %90, align 4, !tbaa !26
  %109 = icmp sgt i32 %108, 0
  br i1 %109, label %.lr.ph105, label %._crit_edge

.lr.ph105:                                        ; preds = %.preheader, %176
  %.081104 = phi i32 [ %177, %176 ], [ 0, %.preheader ]
  %110 = load i32, ptr %107, align 4, !tbaa !31
  %111 = add i32 %110, -4
  %112 = call i32 @llvm.fshl.i32(i32 %111, i32 %111, i32 30)
  switch i32 %112, label %.loopexit [
    i32 0, label %113
    i32 1, label %123
    i32 3, label %128
    i32 5, label %139
    i32 7, label %155
  ]

113:                                              ; preds = %.lr.ph105
  %114 = invoke noundef zeroext i8 @_ZN2rw6Stream6readU8Ev(ptr noundef nonnull align 8 dereferenceable(8) %3)
          to label %115 unwind label %.loopexit98

115:                                              ; preds = %113
  %116 = lshr i8 %114, 4
  %117 = sext i32 %.081104 to i64
  %118 = getelementptr inbounds i8, ptr %.0107, i64 %117
  store i8 %116, ptr %118, align 1, !tbaa !21
  %119 = and i8 %114, 15
  %120 = add nsw i32 %.081104, 1
  %121 = sext i32 %120 to i64
  %122 = getelementptr inbounds i8, ptr %.0107, i64 %121
  store i8 %119, ptr %122, align 1, !tbaa !21
  br label %176

123:                                              ; preds = %.lr.ph105
  %124 = invoke noundef zeroext i8 @_ZN2rw6Stream6readU8Ev(ptr noundef nonnull align 8 dereferenceable(8) %3)
          to label %125 unwind label %.loopexit98

125:                                              ; preds = %123
  %126 = sext i32 %.081104 to i64
  %127 = getelementptr inbounds i8, ptr %.0107, i64 %126
  store i8 %124, ptr %127, align 1, !tbaa !21
  br label %176

128:                                              ; preds = %.lr.ph105
  %129 = invoke noundef zeroext i8 @_ZN2rw6Stream6readU8Ev(ptr noundef nonnull align 8 dereferenceable(8) %3)
          to label %130 unwind label %.loopexit98

130:                                              ; preds = %128
  %131 = shl nsw i32 %.081104, 1
  %132 = sext i32 %131 to i64
  %133 = getelementptr inbounds i8, ptr %.0107, i64 %132
  store i8 %129, ptr %133, align 1, !tbaa !21
  %134 = invoke noundef zeroext i8 @_ZN2rw6Stream6readU8Ev(ptr noundef nonnull align 8 dereferenceable(8) %3)
          to label %135 unwind label %.loopexit98

135:                                              ; preds = %130
  %136 = or disjoint i32 %131, 1
  %137 = sext i32 %136 to i64
  %138 = getelementptr inbounds i8, ptr %.0107, i64 %137
  store i8 %134, ptr %138, align 1, !tbaa !21
  br label %176

139:                                              ; preds = %.lr.ph105
  %140 = invoke noundef zeroext i8 @_ZN2rw6Stream6readU8Ev(ptr noundef nonnull align 8 dereferenceable(8) %3)
          to label %141 unwind label %.loopexit98

141:                                              ; preds = %139
  %142 = mul nsw i32 %.081104, 3
  %143 = add nsw i32 %142, 2
  %144 = sext i32 %143 to i64
  %145 = getelementptr inbounds i8, ptr %.0107, i64 %144
  store i8 %140, ptr %145, align 1, !tbaa !21
  %146 = invoke noundef zeroext i8 @_ZN2rw6Stream6readU8Ev(ptr noundef nonnull align 8 dereferenceable(8) %3)
          to label %147 unwind label %.loopexit98

147:                                              ; preds = %141
  %148 = add nsw i32 %142, 1
  %149 = sext i32 %148 to i64
  %150 = getelementptr inbounds i8, ptr %.0107, i64 %149
  store i8 %146, ptr %150, align 1, !tbaa !21
  %151 = invoke noundef zeroext i8 @_ZN2rw6Stream6readU8Ev(ptr noundef nonnull align 8 dereferenceable(8) %3)
          to label %152 unwind label %.loopexit98

152:                                              ; preds = %147
  %153 = sext i32 %142 to i64
  %154 = getelementptr inbounds i8, ptr %.0107, i64 %153
  store i8 %151, ptr %154, align 1, !tbaa !21
  br label %176

155:                                              ; preds = %.lr.ph105
  %156 = invoke noundef zeroext i8 @_ZN2rw6Stream6readU8Ev(ptr noundef nonnull align 8 dereferenceable(8) %3)
          to label %157 unwind label %.loopexit98

157:                                              ; preds = %155
  %158 = shl nsw i32 %.081104, 2
  %159 = or disjoint i32 %158, 2
  %160 = sext i32 %159 to i64
  %161 = getelementptr inbounds i8, ptr %.0107, i64 %160
  store i8 %156, ptr %161, align 1, !tbaa !21
  %162 = invoke noundef zeroext i8 @_ZN2rw6Stream6readU8Ev(ptr noundef nonnull align 8 dereferenceable(8) %3)
          to label %163 unwind label %.loopexit98

163:                                              ; preds = %157
  %164 = or disjoint i32 %158, 1
  %165 = sext i32 %164 to i64
  %166 = getelementptr inbounds i8, ptr %.0107, i64 %165
  store i8 %162, ptr %166, align 1, !tbaa !21
  %167 = invoke noundef zeroext i8 @_ZN2rw6Stream6readU8Ev(ptr noundef nonnull align 8 dereferenceable(8) %3)
          to label %168 unwind label %.loopexit98

168:                                              ; preds = %163
  %169 = sext i32 %158 to i64
  %170 = getelementptr inbounds i8, ptr %.0107, i64 %169
  store i8 %167, ptr %170, align 1, !tbaa !21
  %171 = invoke noundef zeroext i8 @_ZN2rw6Stream6readU8Ev(ptr noundef nonnull align 8 dereferenceable(8) %3)
          to label %172 unwind label %.loopexit98

172:                                              ; preds = %168
  %173 = or disjoint i32 %158, 3
  %174 = sext i32 %173 to i64
  %175 = getelementptr inbounds i8, ptr %.0107, i64 %174
  %spec.store.select = select i1 %.not93.fr123, i8 %171, i8 -1
  store i8 %spec.store.select, ptr %175, align 1
  br label %176

176:                                              ; preds = %172, %115, %125, %135, %152
  %.182 = phi i32 [ %.081104, %152 ], [ %.081104, %135 ], [ %.081104, %125 ], [ %120, %115 ], [ %.081104, %172 ]
  %177 = add nsw i32 %.182, 1
  %178 = load i32, ptr %90, align 4, !tbaa !26
  %179 = icmp slt i32 %177, %178
  br i1 %179, label %.lr.ph105, label %._crit_edge, !llvm.loop !32

._crit_edge:                                      ; preds = %176, %.preheader
  %180 = load i32, ptr %97, align 4, !tbaa !30
  invoke void @_ZN2rw12StreamMemory4seekEii(ptr noundef nonnull align 8 dereferenceable(28) %3, i32 noundef %95, i32 noundef 1)
          to label %181 unwind label %.loopexit.split-lp.loopexit

181:                                              ; preds = %._crit_edge
  %182 = sext i32 %180 to i64
  %183 = sub nsw i64 0, %182
  %184 = getelementptr inbounds i8, ptr %.0107, i64 %183
  %185 = add nuw nsw i32 %.087106, 1
  %186 = load i32, ptr %96, align 8, !tbaa !28
  %187 = icmp slt i32 %185, %186
  br i1 %187, label %.preheader, label %._crit_edge108, !llvm.loop !33

._crit_edge108:                                   ; preds = %181, %89
  invoke void @_ZN2rw12StreamMemory5closeEv(ptr noundef nonnull align 8 dereferenceable(28) %3)
          to label %188 unwind label %.loopexit.split-lp.loopexit.split-lp

188:                                              ; preds = %._crit_edge108
  %189 = load ptr, ptr getelementptr inbounds (i8, ptr @_ZN2rw6Engine8memfuncsE, i64 16), align 8, !tbaa !34
  invoke void %189(ptr noundef nonnull %6)
          to label %192 unwind label %.loopexit.split-lp.loopexit.split-lp

.loopexit:                                        ; preds = %.lr.ph105, %27, %29, %16
  invoke void @_ZN2rw12StreamMemory5closeEv(ptr noundef nonnull align 8 dereferenceable(28) %3)
          to label %190 unwind label %.loopexit.split-lp.loopexit.split-lp

190:                                              ; preds = %.loopexit
  %191 = load ptr, ptr getelementptr inbounds (i8, ptr @_ZN2rw6Engine8memfuncsE, i64 16), align 8, !tbaa !34
  invoke void %191(ptr noundef nonnull %6)
          to label %192 unwind label %.loopexit.split-lp.loopexit.split-lp

192:                                              ; preds = %190, %188
  %.079 = phi ptr [ %52, %188 ], [ null, %190 ]
  call void @llvm.lifetime.end.p0(i64 56, ptr nonnull %5) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #6
  br label %193

.loopexit.split-lp:                               ; preds = %.split, %.split.us, %.loopexit98, %.loopexit.split-lp.loopexit.split-lp, %.loopexit.split-lp.loopexit
  %.pn = phi { ptr, i32 } [ %lpad.loopexit, %.loopexit98 ], [ %lpad.loopexit99, %.loopexit.split-lp.loopexit ], [ %lpad.loopexit.split-lp100, %.loopexit.split-lp.loopexit.split-lp ], [ %86, %.split ], [ %73, %.split.us ]
  call void @llvm.lifetime.end.p0(i64 56, ptr nonnull %5) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #6
  br label %194

193:                                              ; preds = %7, %192
  %.1 = phi ptr [ %.079, %192 ], [ null, %7 ]
  call void @_ZN2rw6StreamD2Ev(ptr noundef nonnull align 8 dereferenceable(28) %3) #6
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %3) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #6
  ret ptr %.1

194:                                              ; preds = %.loopexit.split-lp, %9
  %.pn.pn = phi { ptr, i32 } [ %.pn, %.loopexit.split-lp ], [ %10, %9 ]
  call void @_ZN2rw6StreamD2Ev(ptr noundef nonnull align 8 dereferenceable(28) %3) #6
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %3) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #6
  resume { ptr, i32 } %.pn.pn
}

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN2rw12StreamMemoryC2Ev(ptr noundef nonnull align 8 dereferenceable(28)) unnamed_addr #2 align 2

declare noundef ptr @_ZN2rw15getFileContentsEPKcPj(ptr noundef, ptr noundef) local_unnamed_addr #3

declare i32 @__gxx_personality_v0(...)

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

declare noundef i32 @_ZN2rw12StreamMemory5read8EPvj(ptr noundef nonnull align 8 dereferenceable(28), ptr noundef, i32 noundef) unnamed_addr #3

declare void @_ZN2rw12StreamMemory4seekEii(ptr noundef nonnull align 8 dereferenceable(28), i32 noundef, i32 noundef) unnamed_addr #3

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

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

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

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

declare void @_ZN2rw12StreamMemory5closeEv(ptr noundef nonnull align 8 dereferenceable(28)) unnamed_addr #3

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN2rw6StreamD2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #4 align 2

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

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

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { inlinehint mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { mustprogress 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 #5 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #6 = { 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 0}
!10 = !{!"_ZTSN2rw9DIBheaderE", !6, i64 0, !6, i64 4, !6, i64 8, !11, i64 12, !11, i64 14, !6, i64 16, !6, i64 20, !6, i64 24, !6, i64 28, !6, i64 32, !6, i64 36, !6, i64 40, !6, i64 44, !6, i64 48, !6, i64 52}
!11 = !{!"short", !7, i64 0}
!12 = !{!10, !6, i64 16}
!13 = !{!10, !6, i64 32}
!14 = !{!10, !6, i64 40}
!15 = !{!10, !6, i64 4}
!16 = !{!10, !6, i64 8}
!17 = !{!10, !11, i64 14}
!18 = !{!19, !20, i64 32}
!19 = !{!"_ZTSN2rw5ImageE", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12, !6, i64 16, !6, i64 20, !20, i64 24, !20, i64 32}
!20 = !{!"any pointer", !7, i64 0}
!21 = !{!7, !7, i64 0}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}
!24 = !{!25, !6, i64 12}
!25 = !{!"_ZTSN2rw9BMPheaderE", !11, i64 0, !6, i64 4, !7, i64 8, !6, i64 12}
!26 = !{!19, !6, i64 4}
!27 = !{!19, !6, i64 16}
!28 = !{!19, !6, i64 8}
!29 = !{!19, !20, i64 24}
!30 = !{!19, !6, i64 20}
!31 = !{!19, !6, i64 12}
!32 = distinct !{!32, !23}
!33 = distinct !{!33, !23}
!34 = !{!35, !20, i64 16}
!35 = !{!"_ZTSN2rw15MemoryFunctionsE", !20, i64 0, !20, i64 8, !20, i64 16, !20, i64 24, !20, i64 32}


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