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

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

%"class.rw::StreamFile" = type { %"class.rw::Stream", ptr }
%"class.rw::Stream" = type { ptr }
%"struct.rw::Error" = type { i32, i32 }
%"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 }

@.str = external hidden unnamed_addr constant [3 x i8], align 1
@stderr = external global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [55 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [4 x i8], align 1

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

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

declare i32 @__gxx_personality_v0(...)

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

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

23:                                               ; preds = %2
  %24 = icmp ne ptr %22, null
  br i1 %24, label %47, label %25

25:                                               ; preds = %23
  br label %26

26:                                               ; preds = %25
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  %27 = getelementptr inbounds %"struct.rw::Error", ptr %9, i32 0, i32 0
  store i32 0, ptr %27, align 4, !tbaa !9
  %28 = getelementptr inbounds %"struct.rw::Error", ptr %9, i32 0, i32 1
  store i32 -2147483645, ptr %28, align 4, !tbaa !12
  %29 = load ptr, ptr @stderr, align 8, !tbaa !5
  %30 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %29, ptr noundef @.str.1, ptr noundef @.str.2, i32 noundef 203) #5
  %31 = load ptr, ptr @stderr, align 8, !tbaa !5
  %32 = load ptr, ptr %4, align 8, !tbaa !5
  %33 = invoke noundef ptr (i32, ...) @_ZN2rw9dbgsprintEjz(i32 noundef -2147483645, ptr noundef %32)
          to label %34 unwind label %43

34:                                               ; preds = %26
  %35 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %31, ptr noundef @.str.3, ptr noundef %33) #5
  invoke void @_ZN2rw8setErrorEPNS_5ErrorE(ptr noundef %9)
          to label %36 unwind label %43

36:                                               ; preds = %34
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  br label %37

37:                                               ; preds = %36
  br label %38

38:                                               ; preds = %37
  store i32 1, ptr %10, align 4
  br label %333

39:                                               ; preds = %2
  %40 = landingpad { ptr, i32 }
          cleanup
  %41 = extractvalue { ptr, i32 } %40, 0
  store ptr %41, ptr %7, align 8
  %42 = extractvalue { ptr, i32 } %40, 1
  store i32 %42, ptr %8, align 4
  br label %343

43:                                               ; preds = %34, %26
  %44 = landingpad { ptr, i32 }
          cleanup
  %45 = extractvalue { ptr, i32 } %44, 0
  store ptr %45, ptr %7, align 8
  %46 = extractvalue { ptr, i32 } %44, 1
  store i32 %46, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  br label %343

47:                                               ; preds = %23
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  %48 = load ptr, ptr %3, align 8, !tbaa !5
  %49 = getelementptr inbounds %"struct.rw::Image", ptr %48, i32 0, i32 3
  %50 = load i32, ptr %49, align 4, !tbaa !13
  %51 = icmp sgt i32 %50, 8
  br i1 %51, label %52, label %53

52:                                               ; preds = %47
  br label %60

53:                                               ; preds = %47
  %54 = load ptr, ptr %3, align 8, !tbaa !5
  %55 = getelementptr inbounds %"struct.rw::Image", ptr %54, i32 0, i32 3
  %56 = load i32, ptr %55, align 4, !tbaa !13
  %57 = icmp eq i32 %56, 4
  %58 = zext i1 %57 to i64
  %59 = select i1 %57, i32 16, i32 256
  br label %60

60:                                               ; preds = %53, %52
  %61 = phi i32 [ 0, %52 ], [ %59, %53 ]
  store i32 %61, ptr %11, align 4, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  %62 = load ptr, ptr %3, align 8, !tbaa !5
  %63 = getelementptr inbounds %"struct.rw::Image", ptr %62, i32 0, i32 1
  %64 = load i32, ptr %63, align 4, !tbaa !16
  %65 = load ptr, ptr %3, align 8, !tbaa !5
  %66 = getelementptr inbounds %"struct.rw::Image", ptr %65, i32 0, i32 3
  %67 = load i32, ptr %66, align 4, !tbaa !13
  %68 = mul nsw i32 %64, %67
  %69 = sdiv i32 %68, 8
  store i32 %69, ptr %12, align 4, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  %70 = load ptr, ptr %3, align 8, !tbaa !5
  %71 = getelementptr inbounds %"struct.rw::Image", ptr %70, i32 0, i32 3
  %72 = load i32, ptr %71, align 4, !tbaa !13
  %73 = icmp eq i32 %72, 32
  br i1 %73, label %74, label %75

74:                                               ; preds = %60
  br label %79

75:                                               ; preds = %60
  %76 = load ptr, ptr %3, align 8, !tbaa !5
  %77 = getelementptr inbounds %"struct.rw::Image", ptr %76, i32 0, i32 3
  %78 = load i32, ptr %77, align 4, !tbaa !13
  br label %79

79:                                               ; preds = %75, %74
  %80 = phi i32 [ 24, %74 ], [ %78, %75 ]
  store i32 %80, ptr %13, align 4, !tbaa !15
  %81 = load i32, ptr %12, align 4, !tbaa !15
  %82 = add nsw i32 %81, 3
  %83 = and i32 %82, -4
  store i32 %83, ptr %12, align 4, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 16, ptr %14) #5
  %84 = getelementptr inbounds %"struct.rw::BMPheader", ptr %14, i32 0, i32 0
  store i16 19778, ptr %84, align 4, !tbaa !17
  %85 = load i32, ptr %11, align 4, !tbaa !15
  %86 = mul nsw i32 4, %85
  %87 = add nsw i32 54, %86
  %88 = load ptr, ptr %3, align 8, !tbaa !5
  %89 = getelementptr inbounds %"struct.rw::Image", ptr %88, i32 0, i32 2
  %90 = load i32, ptr %89, align 8, !tbaa !20
  %91 = load i32, ptr %12, align 4, !tbaa !15
  %92 = mul nsw i32 %90, %91
  %93 = add nsw i32 %87, %92
  %94 = getelementptr inbounds %"struct.rw::BMPheader", ptr %14, i32 0, i32 1
  store i32 %93, ptr %94, align 4, !tbaa !21
  %95 = getelementptr inbounds %"struct.rw::BMPheader", ptr %14, i32 0, i32 2
  %96 = getelementptr inbounds [2 x i16], ptr %95, i64 0, i64 0
  store i16 0, ptr %96, align 4, !tbaa !22
  %97 = getelementptr inbounds %"struct.rw::BMPheader", ptr %14, i32 0, i32 2
  %98 = getelementptr inbounds [2 x i16], ptr %97, i64 0, i64 1
  store i16 0, ptr %98, align 2, !tbaa !22
  %99 = load i32, ptr %11, align 4, !tbaa !15
  %100 = mul nsw i32 4, %99
  %101 = add nsw i32 54, %100
  %102 = getelementptr inbounds %"struct.rw::BMPheader", ptr %14, i32 0, i32 3
  store i32 %101, ptr %102, align 4, !tbaa !23
  invoke void @_ZN2rw9BMPheader5writeEPNS_6StreamE(ptr noundef nonnull align 4 dereferenceable(16) %14, ptr noundef %6)
          to label %103 unwind label %132

103:                                              ; preds = %79
  call void @llvm.lifetime.start.p0(i64 56, ptr %15) #5
  %104 = getelementptr inbounds %"struct.rw::DIBheader", ptr %15, i32 0, i32 0
  store i32 40, ptr %104, align 4, !tbaa !24
  %105 = load ptr, ptr %3, align 8, !tbaa !5
  %106 = getelementptr inbounds %"struct.rw::Image", ptr %105, i32 0, i32 1
  %107 = load i32, ptr %106, align 4, !tbaa !16
  %108 = getelementptr inbounds %"struct.rw::DIBheader", ptr %15, i32 0, i32 1
  store i32 %107, ptr %108, align 4, !tbaa !26
  %109 = load ptr, ptr %3, align 8, !tbaa !5
  %110 = getelementptr inbounds %"struct.rw::Image", ptr %109, i32 0, i32 2
  %111 = load i32, ptr %110, align 8, !tbaa !20
  %112 = getelementptr inbounds %"struct.rw::DIBheader", ptr %15, i32 0, i32 2
  store i32 %111, ptr %112, align 4, !tbaa !27
  %113 = getelementptr inbounds %"struct.rw::DIBheader", ptr %15, i32 0, i32 3
  store i16 1, ptr %113, align 4, !tbaa !28
  %114 = load i32, ptr %13, align 4, !tbaa !15
  %115 = trunc i32 %114 to i16
  %116 = getelementptr inbounds %"struct.rw::DIBheader", ptr %15, i32 0, i32 4
  store i16 %115, ptr %116, align 2, !tbaa !29
  %117 = getelementptr inbounds %"struct.rw::DIBheader", ptr %15, i32 0, i32 5
  store i32 0, ptr %117, align 4, !tbaa !30
  %118 = getelementptr inbounds %"struct.rw::DIBheader", ptr %15, i32 0, i32 6
  store i32 0, ptr %118, align 4, !tbaa !31
  %119 = getelementptr inbounds %"struct.rw::DIBheader", ptr %15, i32 0, i32 7
  store i32 2835, ptr %119, align 4, !tbaa !32
  %120 = getelementptr inbounds %"struct.rw::DIBheader", ptr %15, i32 0, i32 8
  store i32 2835, ptr %120, align 4, !tbaa !33
  %121 = getelementptr inbounds %"struct.rw::DIBheader", ptr %15, i32 0, i32 9
  store i32 0, ptr %121, align 4, !tbaa !34
  %122 = getelementptr inbounds %"struct.rw::DIBheader", ptr %15, i32 0, i32 10
  store i32 0, ptr %122, align 4, !tbaa !35
  %123 = getelementptr inbounds %"struct.rw::DIBheader", ptr %15, i32 0, i32 0
  %124 = load i32, ptr %123, align 4, !tbaa !24
  %125 = invoke noundef i32 @_ZN2rw10StreamFile6write8EPKvj(ptr noundef nonnull align 8 dereferenceable(16) %6, ptr noundef %15, i32 noundef %124)
          to label %126 unwind label %136

126:                                              ; preds = %103
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #5
  store i32 0, ptr %16, align 4, !tbaa !15
  br label %127

127:                                              ; preds = %176, %126
  %128 = load i32, ptr %16, align 4, !tbaa !15
  %129 = load i32, ptr %11, align 4, !tbaa !15
  %130 = icmp slt i32 %128, %129
  br i1 %130, label %140, label %131

131:                                              ; preds = %127
  store i32 4, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #5
  br label %183

132:                                              ; preds = %79
  %133 = landingpad { ptr, i32 }
          cleanup
  %134 = extractvalue { ptr, i32 } %133, 0
  store ptr %134, ptr %7, align 8
  %135 = extractvalue { ptr, i32 } %133, 1
  store i32 %135, ptr %8, align 4
  br label %342

136:                                              ; preds = %103
  %137 = landingpad { ptr, i32 }
          cleanup
  %138 = extractvalue { ptr, i32 } %137, 0
  store ptr %138, ptr %7, align 8
  %139 = extractvalue { ptr, i32 } %137, 1
  store i32 %139, ptr %8, align 4
  br label %341

140:                                              ; preds = %127
  %141 = load ptr, ptr %3, align 8, !tbaa !5
  %142 = getelementptr inbounds %"struct.rw::Image", ptr %141, i32 0, i32 7
  %143 = load ptr, ptr %142, align 8, !tbaa !36
  %144 = load i32, ptr %16, align 4, !tbaa !15
  %145 = mul nsw i32 %144, 4
  %146 = add nsw i32 %145, 2
  %147 = sext i32 %146 to i64
  %148 = getelementptr inbounds i8, ptr %143, i64 %147
  %149 = load i8, ptr %148, align 1, !tbaa !37
  %150 = invoke noundef i32 @_ZN2rw6Stream7writeU8Eh(ptr noundef nonnull align 8 dereferenceable(8) %6, i8 noundef zeroext %149)
          to label %151 unwind label %179

151:                                              ; preds = %140
  %152 = load ptr, ptr %3, align 8, !tbaa !5
  %153 = getelementptr inbounds %"struct.rw::Image", ptr %152, i32 0, i32 7
  %154 = load ptr, ptr %153, align 8, !tbaa !36
  %155 = load i32, ptr %16, align 4, !tbaa !15
  %156 = mul nsw i32 %155, 4
  %157 = add nsw i32 %156, 1
  %158 = sext i32 %157 to i64
  %159 = getelementptr inbounds i8, ptr %154, i64 %158
  %160 = load i8, ptr %159, align 1, !tbaa !37
  %161 = invoke noundef i32 @_ZN2rw6Stream7writeU8Eh(ptr noundef nonnull align 8 dereferenceable(8) %6, i8 noundef zeroext %160)
          to label %162 unwind label %179

162:                                              ; preds = %151
  %163 = load ptr, ptr %3, align 8, !tbaa !5
  %164 = getelementptr inbounds %"struct.rw::Image", ptr %163, i32 0, i32 7
  %165 = load ptr, ptr %164, align 8, !tbaa !36
  %166 = load i32, ptr %16, align 4, !tbaa !15
  %167 = mul nsw i32 %166, 4
  %168 = add nsw i32 %167, 0
  %169 = sext i32 %168 to i64
  %170 = getelementptr inbounds i8, ptr %165, i64 %169
  %171 = load i8, ptr %170, align 1, !tbaa !37
  %172 = invoke noundef i32 @_ZN2rw6Stream7writeU8Eh(ptr noundef nonnull align 8 dereferenceable(8) %6, i8 noundef zeroext %171)
          to label %173 unwind label %179

173:                                              ; preds = %162
  %174 = invoke noundef i32 @_ZN2rw6Stream7writeU8Eh(ptr noundef nonnull align 8 dereferenceable(8) %6, i8 noundef zeroext -1)
          to label %175 unwind label %179

175:                                              ; preds = %173
  br label %176

176:                                              ; preds = %175
  %177 = load i32, ptr %16, align 4, !tbaa !15
  %178 = add nsw i32 %177, 1
  store i32 %178, ptr %16, align 4, !tbaa !15
  br label %127, !llvm.loop !38

179:                                              ; preds = %173, %162, %151, %140
  %180 = landingpad { ptr, i32 }
          cleanup
  %181 = extractvalue { ptr, i32 } %180, 0
  store ptr %181, ptr %7, align 8
  %182 = extractvalue { ptr, i32 } %180, 1
  store i32 %182, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #5
  br label %341

183:                                              ; preds = %131
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #5
  %184 = load ptr, ptr %3, align 8, !tbaa !5
  %185 = getelementptr inbounds %"struct.rw::Image", ptr %184, i32 0, i32 6
  %186 = load ptr, ptr %185, align 8, !tbaa !40
  %187 = load ptr, ptr %3, align 8, !tbaa !5
  %188 = getelementptr inbounds %"struct.rw::Image", ptr %187, i32 0, i32 2
  %189 = load i32, ptr %188, align 8, !tbaa !20
  %190 = sub nsw i32 %189, 1
  %191 = load ptr, ptr %3, align 8, !tbaa !5
  %192 = getelementptr inbounds %"struct.rw::Image", ptr %191, i32 0, i32 5
  %193 = load i32, ptr %192, align 4, !tbaa !41
  %194 = mul nsw i32 %190, %193
  %195 = sext i32 %194 to i64
  %196 = getelementptr inbounds i8, ptr %186, i64 %195
  store ptr %196, ptr %17, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #5
  store i32 0, ptr %19, align 4, !tbaa !15
  br label %197

197:                                              ; preds = %327, %183
  %198 = load i32, ptr %19, align 4, !tbaa !15
  %199 = load ptr, ptr %3, align 8, !tbaa !5
  %200 = getelementptr inbounds %"struct.rw::Image", ptr %199, i32 0, i32 2
  %201 = load i32, ptr %200, align 8, !tbaa !20
  %202 = icmp slt i32 %198, %201
  br i1 %202, label %204, label %203

203:                                              ; preds = %197
  store i32 7, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #5
  br label %331

204:                                              ; preds = %197
  %205 = load ptr, ptr %17, align 8, !tbaa !5
  store ptr %205, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #5
  store i32 0, ptr %20, align 4, !tbaa !15
  br label %206

206:                                              ; preds = %297, %204
  %207 = load i32, ptr %20, align 4, !tbaa !15
  %208 = load ptr, ptr %3, align 8, !tbaa !5
  %209 = getelementptr inbounds %"struct.rw::Image", ptr %208, i32 0, i32 1
  %210 = load i32, ptr %209, align 4, !tbaa !16
  %211 = icmp slt i32 %207, %210
  br i1 %211, label %213, label %212

212:                                              ; preds = %206
  store i32 10, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #5
  br label %300

213:                                              ; preds = %206
  %214 = load ptr, ptr %3, align 8, !tbaa !5
  %215 = getelementptr inbounds %"struct.rw::Image", ptr %214, i32 0, i32 3
  %216 = load i32, ptr %215, align 4, !tbaa !13
  switch i32 %216, label %296 [
    i32 4, label %217
    i32 8, label %241
    i32 16, label %247
    i32 24, label %260
    i32 32, label %278
  ]

217:                                              ; preds = %213
  %218 = load ptr, ptr %5, align 8, !tbaa !5
  %219 = getelementptr inbounds i8, ptr %218, i64 0
  %220 = load i8, ptr %219, align 1, !tbaa !37
  %221 = zext i8 %220 to i32
  %222 = and i32 %221, 15
  %223 = shl i32 %222, 4
  %224 = load ptr, ptr %5, align 8, !tbaa !5
  %225 = getelementptr inbounds i8, ptr %224, i64 1
  %226 = load i8, ptr %225, align 1, !tbaa !37
  %227 = zext i8 %226 to i32
  %228 = and i32 %227, 15
  %229 = or i32 %223, %228
  %230 = trunc i32 %229 to i8
  %231 = invoke noundef i32 @_ZN2rw6Stream7writeU8Eh(ptr noundef nonnull align 8 dereferenceable(8) %6, i8 noundef zeroext %230)
          to label %232 unwind label %237

232:                                              ; preds = %217
  %233 = load ptr, ptr %5, align 8, !tbaa !5
  %234 = getelementptr inbounds i8, ptr %233, i64 2
  store ptr %234, ptr %5, align 8, !tbaa !5
  %235 = load i32, ptr %20, align 4, !tbaa !15
  %236 = add nsw i32 %235, 1
  store i32 %236, ptr %20, align 4, !tbaa !15
  br label %296

237:                                              ; preds = %288, %283, %278, %270, %265, %260, %252, %247, %241, %217
  %238 = landingpad { ptr, i32 }
          cleanup
  %239 = extractvalue { ptr, i32 } %238, 0
  store ptr %239, ptr %7, align 8
  %240 = extractvalue { ptr, i32 } %238, 1
  store i32 %240, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #5
  br label %330

241:                                              ; preds = %213
  %242 = load ptr, ptr %5, align 8, !tbaa !5
  %243 = getelementptr inbounds i8, ptr %242, i32 1
  store ptr %243, ptr %5, align 8, !tbaa !5
  %244 = load i8, ptr %242, align 1, !tbaa !37
  %245 = invoke noundef i32 @_ZN2rw6Stream7writeU8Eh(ptr noundef nonnull align 8 dereferenceable(8) %6, i8 noundef zeroext %244)
          to label %246 unwind label %237

246:                                              ; preds = %241
  br label %296

247:                                              ; preds = %213
  %248 = load ptr, ptr %5, align 8, !tbaa !5
  %249 = getelementptr inbounds i8, ptr %248, i64 0
  %250 = load i8, ptr %249, align 1, !tbaa !37
  %251 = invoke noundef i32 @_ZN2rw6Stream7writeU8Eh(ptr noundef nonnull align 8 dereferenceable(8) %6, i8 noundef zeroext %250)
          to label %252 unwind label %237

252:                                              ; preds = %247
  %253 = load ptr, ptr %5, align 8, !tbaa !5
  %254 = getelementptr inbounds i8, ptr %253, i64 1
  %255 = load i8, ptr %254, align 1, !tbaa !37
  %256 = invoke noundef i32 @_ZN2rw6Stream7writeU8Eh(ptr noundef nonnull align 8 dereferenceable(8) %6, i8 noundef zeroext %255)
          to label %257 unwind label %237

257:                                              ; preds = %252
  %258 = load ptr, ptr %5, align 8, !tbaa !5
  %259 = getelementptr inbounds i8, ptr %258, i64 2
  store ptr %259, ptr %5, align 8, !tbaa !5
  br label %296

260:                                              ; preds = %213
  %261 = load ptr, ptr %5, align 8, !tbaa !5
  %262 = getelementptr inbounds i8, ptr %261, i64 2
  %263 = load i8, ptr %262, align 1, !tbaa !37
  %264 = invoke noundef i32 @_ZN2rw6Stream7writeU8Eh(ptr noundef nonnull align 8 dereferenceable(8) %6, i8 noundef zeroext %263)
          to label %265 unwind label %237

265:                                              ; preds = %260
  %266 = load ptr, ptr %5, align 8, !tbaa !5
  %267 = getelementptr inbounds i8, ptr %266, i64 1
  %268 = load i8, ptr %267, align 1, !tbaa !37
  %269 = invoke noundef i32 @_ZN2rw6Stream7writeU8Eh(ptr noundef nonnull align 8 dereferenceable(8) %6, i8 noundef zeroext %268)
          to label %270 unwind label %237

270:                                              ; preds = %265
  %271 = load ptr, ptr %5, align 8, !tbaa !5
  %272 = getelementptr inbounds i8, ptr %271, i64 0
  %273 = load i8, ptr %272, align 1, !tbaa !37
  %274 = invoke noundef i32 @_ZN2rw6Stream7writeU8Eh(ptr noundef nonnull align 8 dereferenceable(8) %6, i8 noundef zeroext %273)
          to label %275 unwind label %237

275:                                              ; preds = %270
  %276 = load ptr, ptr %5, align 8, !tbaa !5
  %277 = getelementptr inbounds i8, ptr %276, i64 3
  store ptr %277, ptr %5, align 8, !tbaa !5
  br label %296

278:                                              ; preds = %213
  %279 = load ptr, ptr %5, align 8, !tbaa !5
  %280 = getelementptr inbounds i8, ptr %279, i64 2
  %281 = load i8, ptr %280, align 1, !tbaa !37
  %282 = invoke noundef i32 @_ZN2rw6Stream7writeU8Eh(ptr noundef nonnull align 8 dereferenceable(8) %6, i8 noundef zeroext %281)
          to label %283 unwind label %237

283:                                              ; preds = %278
  %284 = load ptr, ptr %5, align 8, !tbaa !5
  %285 = getelementptr inbounds i8, ptr %284, i64 1
  %286 = load i8, ptr %285, align 1, !tbaa !37
  %287 = invoke noundef i32 @_ZN2rw6Stream7writeU8Eh(ptr noundef nonnull align 8 dereferenceable(8) %6, i8 noundef zeroext %286)
          to label %288 unwind label %237

288:                                              ; preds = %283
  %289 = load ptr, ptr %5, align 8, !tbaa !5
  %290 = getelementptr inbounds i8, ptr %289, i64 0
  %291 = load i8, ptr %290, align 1, !tbaa !37
  %292 = invoke noundef i32 @_ZN2rw6Stream7writeU8Eh(ptr noundef nonnull align 8 dereferenceable(8) %6, i8 noundef zeroext %291)
          to label %293 unwind label %237

293:                                              ; preds = %288
  %294 = load ptr, ptr %5, align 8, !tbaa !5
  %295 = getelementptr inbounds i8, ptr %294, i64 4
  store ptr %295, ptr %5, align 8, !tbaa !5
  br label %296

296:                                              ; preds = %293, %275, %257, %246, %232, %213
  br label %297

297:                                              ; preds = %296
  %298 = load i32, ptr %20, align 4, !tbaa !15
  %299 = add nsw i32 %298, 1
  store i32 %299, ptr %20, align 4, !tbaa !15
  br label %206, !llvm.loop !42

300:                                              ; preds = %212
  %301 = load ptr, ptr %5, align 8, !tbaa !5
  %302 = load ptr, ptr %17, align 8, !tbaa !5
  %303 = ptrtoint ptr %301 to i64
  %304 = ptrtoint ptr %302 to i64
  %305 = sub i64 %303, %304
  %306 = srem i64 %305, 4
  %307 = trunc i64 %306 to i32
  store i32 %307, ptr %18, align 4, !tbaa !15
  br label %308

308:                                              ; preds = %314, %300
  %309 = load i32, ptr %18, align 4, !tbaa !15
  %310 = add nsw i32 %309, -1
  store i32 %310, ptr %18, align 4, !tbaa !15
  %311 = icmp ne i32 %309, 0
  br i1 %311, label %312, label %319

312:                                              ; preds = %308
  %313 = invoke noundef i32 @_ZN2rw6Stream7writeU8Eh(ptr noundef nonnull align 8 dereferenceable(8) %6, i8 noundef zeroext 0)
          to label %314 unwind label %315

314:                                              ; preds = %312
  br label %308, !llvm.loop !43

315:                                              ; preds = %312
  %316 = landingpad { ptr, i32 }
          cleanup
  %317 = extractvalue { ptr, i32 } %316, 0
  store ptr %317, ptr %7, align 8
  %318 = extractvalue { ptr, i32 } %316, 1
  store i32 %318, ptr %8, align 4
  br label %330

319:                                              ; preds = %308
  %320 = load ptr, ptr %3, align 8, !tbaa !5
  %321 = getelementptr inbounds %"struct.rw::Image", ptr %320, i32 0, i32 5
  %322 = load i32, ptr %321, align 4, !tbaa !41
  %323 = load ptr, ptr %17, align 8, !tbaa !5
  %324 = sext i32 %322 to i64
  %325 = sub i64 0, %324
  %326 = getelementptr inbounds i8, ptr %323, i64 %325
  store ptr %326, ptr %17, align 8, !tbaa !5
  br label %327

327:                                              ; preds = %319
  %328 = load i32, ptr %19, align 4, !tbaa !15
  %329 = add nsw i32 %328, 1
  store i32 %329, ptr %19, align 4, !tbaa !15
  br label %197, !llvm.loop !44

330:                                              ; preds = %315, %237
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #5
  br label %340

331:                                              ; preds = %203
  invoke void @_ZN2rw10StreamFile5closeEv(ptr noundef nonnull align 8 dereferenceable(16) %6)
          to label %332 unwind label %336

332:                                              ; preds = %331
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #5
  call void @llvm.lifetime.end.p0(i64 56, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  store i32 0, ptr %10, align 4
  br label %333

333:                                              ; preds = %332, %38
  call void @_ZN2rw6StreamD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %6) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  %334 = load i32, ptr %10, align 4
  switch i32 %334, label %349 [
    i32 0, label %335
    i32 1, label %335
  ]

335:                                              ; preds = %333, %333
  ret void

336:                                              ; preds = %331
  %337 = landingpad { ptr, i32 }
          cleanup
  %338 = extractvalue { ptr, i32 } %337, 0
  store ptr %338, ptr %7, align 8
  %339 = extractvalue { ptr, i32 } %337, 1
  store i32 %339, ptr %8, align 4
  br label %340

340:                                              ; preds = %336, %330
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #5
  br label %341

341:                                              ; preds = %340, %179, %136
  call void @llvm.lifetime.end.p0(i64 56, ptr %15) #5
  br label %342

342:                                              ; preds = %341, %132
  call void @llvm.lifetime.end.p0(i64 16, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  br label %343

343:                                              ; preds = %342, %43, %39
  call void @_ZN2rw6StreamD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %6) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  br label %344

344:                                              ; preds = %343
  %345 = load ptr, ptr %7, align 8
  %346 = load i32, ptr %8, align 4
  %347 = insertvalue { ptr, i32 } poison, ptr %345, 0
  %348 = insertvalue { ptr, i32 } %347, i32 %346, 1
  resume { ptr, i32 } %348

349:                                              ; preds = %333
  unreachable
}

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

declare noundef ptr @_ZN2rw10StreamFile4openEPKcS2_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef, ptr noundef) #3

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

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

declare void @_ZN2rw8setErrorEPNS_5ErrorE(ptr noundef) #3

declare noundef i32 @_ZN2rw10StreamFile6write8EPKvj(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef, i32 noundef) unnamed_addr #3

declare noundef i32 @_ZN2rw6Stream7writeU8Eh(ptr noundef nonnull align 8 dereferenceable(8), i8 noundef zeroext) #3

declare void @_ZN2rw10StreamFile5closeEv(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #3

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN2rw6StreamD2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #2 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 = { 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 = { 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 #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, !11, i64 0}
!10 = !{!"_ZTSN2rw5ErrorE", !11, i64 0, !11, i64 4}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !11, i64 4}
!13 = !{!14, !11, i64 12}
!14 = !{!"_ZTSN2rw5ImageE", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !6, i64 24, !6, i64 32}
!15 = !{!11, !11, i64 0}
!16 = !{!14, !11, i64 4}
!17 = !{!18, !19, i64 0}
!18 = !{!"_ZTSN2rw9BMPheaderE", !19, i64 0, !11, i64 4, !7, i64 8, !11, i64 12}
!19 = !{!"short", !7, i64 0}
!20 = !{!14, !11, i64 8}
!21 = !{!18, !11, i64 4}
!22 = !{!19, !19, i64 0}
!23 = !{!18, !11, i64 12}
!24 = !{!25, !11, i64 0}
!25 = !{!"_ZTSN2rw9DIBheaderE", !11, i64 0, !11, i64 4, !11, i64 8, !19, i64 12, !19, i64 14, !11, i64 16, !11, i64 20, !11, i64 24, !11, i64 28, !11, i64 32, !11, i64 36, !11, i64 40, !11, i64 44, !11, i64 48, !11, i64 52}
!26 = !{!25, !11, i64 4}
!27 = !{!25, !11, i64 8}
!28 = !{!25, !19, i64 12}
!29 = !{!25, !19, i64 14}
!30 = !{!25, !11, i64 16}
!31 = !{!25, !11, i64 20}
!32 = !{!25, !11, i64 24}
!33 = !{!25, !11, i64 28}
!34 = !{!25, !11, i64 32}
!35 = !{!25, !11, i64 36}
!36 = !{!14, !6, i64 32}
!37 = !{!7, !7, i64 0}
!38 = distinct !{!38, !39}
!39 = !{!"llvm.loop.mustprogress"}
!40 = !{!14, !6, i64 24}
!41 = !{!14, !11, i64 20}
!42 = distinct !{!42, !39}
!43 = distinct !{!43, !39}
!44 = distinct !{!44, !39}


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

%"class.rw::StreamFile" = type { %"class.rw::Stream", ptr }
%"class.rw::Stream" = type { ptr }
%"struct.rw::Error" = type { i32, i32 }
%"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 }

@.str = external hidden unnamed_addr constant [3 x i8], align 1
@stderr = external local_unnamed_addr global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [55 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [4 x i8], align 1

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

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

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN2rw8writeBMPEPNS_5ImageEPKc(ptr nocapture noundef readonly %0, ptr noundef %1) local_unnamed_addr #0 personality ptr @__gxx_personality_v0 {
  %3 = alloca %"class.rw::StreamFile", align 8
  %4 = alloca %"struct.rw::Error", align 4
  %5 = alloca %"struct.rw::BMPheader", align 4
  %6 = alloca %"struct.rw::DIBheader", align 4
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %3) #6
  call void @_ZN2rw10StreamFileC2Ev(ptr noundef nonnull align 8 dereferenceable(16) %3)
  %7 = invoke noundef ptr @_ZN2rw10StreamFile4openEPKcS2_(ptr noundef nonnull align 8 dereferenceable(16) %3, ptr noundef %1, ptr noundef nonnull @.str)
          to label %8 unwind label %18

8:                                                ; preds = %2
  %.not = icmp eq ptr %7, null
  br i1 %.not, label %9, label %22

9:                                                ; preds = %8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #6
  store i32 0, ptr %4, align 4, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %4, i64 4
  store i32 -2147483645, ptr %10, align 4, !tbaa !10
  %11 = load ptr, ptr @stderr, align 8, !tbaa !11
  %12 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %11, ptr noundef nonnull @.str.1, ptr noundef nonnull @.str.2, i32 noundef 203) #7
  %13 = load ptr, ptr @stderr, align 8, !tbaa !11
  %14 = invoke noundef ptr (i32, ...) @_ZN2rw9dbgsprintEjz(i32 noundef -2147483645, ptr noundef %1)
          to label %15 unwind label %20

15:                                               ; preds = %9
  %16 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %13, ptr noundef nonnull @.str.3, ptr noundef %14) #7
  invoke void @_ZN2rw8setErrorEPNS_5ErrorE(ptr noundef nonnull %4)
          to label %17 unwind label %20

17:                                               ; preds = %15
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #6
  br label %176

18:                                               ; preds = %2
  %19 = landingpad { ptr, i32 }
          cleanup
  br label %181

20:                                               ; preds = %15, %9
  %21 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #6
  br label %181

22:                                               ; preds = %8
  %23 = getelementptr inbounds i8, ptr %0, i64 12
  %24 = load i32, ptr %23, align 4, !tbaa !13
  %25 = icmp sgt i32 %24, 8
  %26 = icmp eq i32 %24, 4
  %27 = select i1 %26, i32 16, i32 256
  %28 = shl nuw nsw i32 %27, 2
  %29 = getelementptr inbounds i8, ptr %0, i64 4
  %30 = load i32, ptr %29, align 4, !tbaa !15
  %31 = mul nsw i32 %30, %24
  %32 = sdiv i32 %31, 8
  %33 = add nsw i32 %32, 3
  %34 = and i32 %33, -4
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %5) #6
  store i16 19778, ptr %5, align 4, !tbaa !16
  %35 = or disjoint i32 %28, 54
  %36 = select i1 %25, i32 54, i32 %35
  %37 = getelementptr inbounds i8, ptr %0, i64 8
  %38 = load i32, ptr %37, align 8, !tbaa !19
  %39 = mul nsw i32 %34, %38
  %40 = add nsw i32 %39, %36
  %41 = getelementptr inbounds i8, ptr %5, i64 4
  store i32 %40, ptr %41, align 4, !tbaa !20
  %42 = getelementptr inbounds i8, ptr %5, i64 8
  store i16 0, ptr %42, align 4, !tbaa !21
  %43 = getelementptr inbounds i8, ptr %5, i64 10
  store i16 0, ptr %43, align 2, !tbaa !21
  %44 = getelementptr inbounds i8, ptr %5, i64 12
  store i32 %36, ptr %44, align 4, !tbaa !22
  invoke void @_ZN2rw9BMPheader5writeEPNS_6StreamE(ptr noundef nonnull align 4 dereferenceable(16) %5, ptr noundef nonnull %3)
          to label %45 unwind label %68

45:                                               ; preds = %22
  %46 = icmp eq i32 %24, 32
  %47 = trunc i32 %24 to i16
  call void @llvm.lifetime.start.p0(i64 56, ptr nonnull %6) #6
  store i32 40, ptr %6, align 4, !tbaa !23
  %48 = getelementptr inbounds i8, ptr %6, i64 4
  %49 = load <2 x i32>, ptr %29, align 4, !tbaa !25
  store <2 x i32> %49, ptr %48, align 4, !tbaa !25
  %50 = getelementptr inbounds i8, ptr %6, i64 12
  store i16 1, ptr %50, align 4, !tbaa !26
  %51 = select i1 %46, i16 24, i16 %47
  %52 = getelementptr inbounds i8, ptr %6, i64 14
  store i16 %51, ptr %52, align 2, !tbaa !27
  %53 = getelementptr inbounds i8, ptr %6, i64 16
  store <4 x i32> <i32 0, i32 0, i32 2835, i32 2835>, ptr %53, align 4, !tbaa !25
  %54 = getelementptr inbounds i8, ptr %6, i64 32
  store i32 0, ptr %54, align 4, !tbaa !28
  %55 = getelementptr inbounds i8, ptr %6, i64 36
  store i32 0, ptr %55, align 4, !tbaa !29
  %56 = invoke noundef i32 @_ZN2rw10StreamFile6write8EPKvj(ptr noundef nonnull align 8 dereferenceable(16) %3, ptr noundef nonnull %6, i32 noundef 40)
          to label %.preheader80 unwind label %70

.preheader80:                                     ; preds = %45
  br i1 %25, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader80
  %57 = getelementptr inbounds i8, ptr %0, i64 32
  %wide.trip.count = zext nneg i32 %27 to i64
  br label %72

._crit_edge:                                      ; preds = %92, %.preheader80
  %58 = load i32, ptr %37, align 8, !tbaa !19
  %59 = getelementptr inbounds i8, ptr %0, i64 20
  %60 = icmp sgt i32 %58, 0
  br i1 %60, label %.preheader.preheader, label %._crit_edge89

.preheader.preheader:                             ; preds = %._crit_edge
  %61 = getelementptr inbounds i8, ptr %0, i64 24
  %62 = load ptr, ptr %61, align 8, !tbaa !30
  %63 = add nsw i32 %58, -1
  %64 = load i32, ptr %59, align 4, !tbaa !31
  %65 = mul nsw i32 %63, %64
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds i8, ptr %62, i64 %66
  br label %.preheader

68:                                               ; preds = %22
  %69 = landingpad { ptr, i32 }
          cleanup
  br label %180

70:                                               ; preds = %45
  %71 = landingpad { ptr, i32 }
          cleanup
  br label %179

72:                                               ; preds = %.lr.ph, %92
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %92 ]
  %73 = load ptr, ptr %57, align 8, !tbaa !32
  %74 = shl nsw i64 %indvars.iv, 2
  %75 = or disjoint i64 %74, 2
  %76 = getelementptr inbounds i8, ptr %73, i64 %75
  %77 = load i8, ptr %76, align 1, !tbaa !33
  %78 = invoke noundef i32 @_ZN2rw6Stream7writeU8Eh(ptr noundef nonnull align 8 dereferenceable(8) %3, i8 noundef zeroext %77)
          to label %79 unwind label %93

79:                                               ; preds = %72
  %80 = load ptr, ptr %57, align 8, !tbaa !32
  %81 = or disjoint i64 %74, 1
  %82 = getelementptr inbounds i8, ptr %80, i64 %81
  %83 = load i8, ptr %82, align 1, !tbaa !33
  %84 = invoke noundef i32 @_ZN2rw6Stream7writeU8Eh(ptr noundef nonnull align 8 dereferenceable(8) %3, i8 noundef zeroext %83)
          to label %85 unwind label %93

85:                                               ; preds = %79
  %86 = load ptr, ptr %57, align 8, !tbaa !32
  %87 = getelementptr inbounds i8, ptr %86, i64 %74
  %88 = load i8, ptr %87, align 1, !tbaa !33
  %89 = invoke noundef i32 @_ZN2rw6Stream7writeU8Eh(ptr noundef nonnull align 8 dereferenceable(8) %3, i8 noundef zeroext %88)
          to label %90 unwind label %93

90:                                               ; preds = %85
  %91 = invoke noundef i32 @_ZN2rw6Stream7writeU8Eh(ptr noundef nonnull align 8 dereferenceable(8) %3, i8 noundef zeroext -1)
          to label %92 unwind label %93

92:                                               ; preds = %90
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %72, !llvm.loop !34

93:                                               ; preds = %90, %85, %79, %72
  %94 = landingpad { ptr, i32 }
          cleanup
  br label %179

.preheader:                                       ; preds = %.preheader.preheader, %167
  %.05888 = phi i32 [ %172, %167 ], [ 0, %.preheader.preheader ]
  %.06087 = phi ptr [ %171, %167 ], [ %67, %.preheader.preheader ]
  %95 = load i32, ptr %29, align 4, !tbaa !15
  %96 = icmp sgt i32 %95, 0
  br i1 %96, label %.lr.ph85, label %._crit_edge86

._crit_edge89:                                    ; preds = %167, %._crit_edge
  invoke void @_ZN2rw10StreamFile5closeEv(ptr noundef nonnull align 8 dereferenceable(16) %3)
          to label %175 unwind label %177

._crit_edge86:                                    ; preds = %157, %.preheader
  %.062.lcssa = phi ptr [ %.06087, %.preheader ], [ %.163, %157 ]
  %97 = ptrtoint ptr %.062.lcssa to i64
  %98 = ptrtoint ptr %.06087 to i64
  %99 = sub i64 %97, %98
  %100 = srem i64 %99, 4
  %101 = trunc nsw i64 %100 to i32
  br label %161

.lr.ph85:                                         ; preds = %.preheader, %157
  %.084 = phi i32 [ %158, %157 ], [ 0, %.preheader ]
  %.06283 = phi ptr [ %.163, %157 ], [ %.06087, %.preheader ]
  %102 = load i32, ptr %23, align 4, !tbaa !13
  %103 = add i32 %102, -4
  %104 = call i32 @llvm.fshl.i32(i32 %103, i32 %103, i32 30)
  switch i32 %104, label %157 [
    i32 0, label %105
    i32 1, label %118
    i32 3, label %122
    i32 5, label %131
    i32 7, label %144
  ]

105:                                              ; preds = %.lr.ph85
  %106 = load i8, ptr %.06283, align 1, !tbaa !33
  %107 = shl i8 %106, 4
  %108 = getelementptr inbounds i8, ptr %.06283, i64 1
  %109 = load i8, ptr %108, align 1, !tbaa !33
  %110 = and i8 %109, 15
  %111 = or disjoint i8 %110, %107
  %112 = invoke noundef i32 @_ZN2rw6Stream7writeU8Eh(ptr noundef nonnull align 8 dereferenceable(8) %3, i8 noundef zeroext %111)
          to label %113 unwind label %116

113:                                              ; preds = %105
  %114 = getelementptr inbounds i8, ptr %.06283, i64 2
  %115 = add nsw i32 %.084, 1
  br label %157

116:                                              ; preds = %152, %148, %144, %139, %135, %131, %125, %122, %118, %105
  %117 = landingpad { ptr, i32 }
          cleanup
  br label %179

118:                                              ; preds = %.lr.ph85
  %119 = getelementptr inbounds i8, ptr %.06283, i64 1
  %120 = load i8, ptr %.06283, align 1, !tbaa !33
  %121 = invoke noundef i32 @_ZN2rw6Stream7writeU8Eh(ptr noundef nonnull align 8 dereferenceable(8) %3, i8 noundef zeroext %120)
          to label %157 unwind label %116

122:                                              ; preds = %.lr.ph85
  %123 = load i8, ptr %.06283, align 1, !tbaa !33
  %124 = invoke noundef i32 @_ZN2rw6Stream7writeU8Eh(ptr noundef nonnull align 8 dereferenceable(8) %3, i8 noundef zeroext %123)
          to label %125 unwind label %116

125:                                              ; preds = %122
  %126 = getelementptr inbounds i8, ptr %.06283, i64 1
  %127 = load i8, ptr %126, align 1, !tbaa !33
  %128 = invoke noundef i32 @_ZN2rw6Stream7writeU8Eh(ptr noundef nonnull align 8 dereferenceable(8) %3, i8 noundef zeroext %127)
          to label %129 unwind label %116

129:                                              ; preds = %125
  %130 = getelementptr inbounds i8, ptr %.06283, i64 2
  br label %157

131:                                              ; preds = %.lr.ph85
  %132 = getelementptr inbounds i8, ptr %.06283, i64 2
  %133 = load i8, ptr %132, align 1, !tbaa !33
  %134 = invoke noundef i32 @_ZN2rw6Stream7writeU8Eh(ptr noundef nonnull align 8 dereferenceable(8) %3, i8 noundef zeroext %133)
          to label %135 unwind label %116

135:                                              ; preds = %131
  %136 = getelementptr inbounds i8, ptr %.06283, i64 1
  %137 = load i8, ptr %136, align 1, !tbaa !33
  %138 = invoke noundef i32 @_ZN2rw6Stream7writeU8Eh(ptr noundef nonnull align 8 dereferenceable(8) %3, i8 noundef zeroext %137)
          to label %139 unwind label %116

139:                                              ; preds = %135
  %140 = load i8, ptr %.06283, align 1, !tbaa !33
  %141 = invoke noundef i32 @_ZN2rw6Stream7writeU8Eh(ptr noundef nonnull align 8 dereferenceable(8) %3, i8 noundef zeroext %140)
          to label %142 unwind label %116

142:                                              ; preds = %139
  %143 = getelementptr inbounds i8, ptr %.06283, i64 3
  br label %157

144:                                              ; preds = %.lr.ph85
  %145 = getelementptr inbounds i8, ptr %.06283, i64 2
  %146 = load i8, ptr %145, align 1, !tbaa !33
  %147 = invoke noundef i32 @_ZN2rw6Stream7writeU8Eh(ptr noundef nonnull align 8 dereferenceable(8) %3, i8 noundef zeroext %146)
          to label %148 unwind label %116

148:                                              ; preds = %144
  %149 = getelementptr inbounds i8, ptr %.06283, i64 1
  %150 = load i8, ptr %149, align 1, !tbaa !33
  %151 = invoke noundef i32 @_ZN2rw6Stream7writeU8Eh(ptr noundef nonnull align 8 dereferenceable(8) %3, i8 noundef zeroext %150)
          to label %152 unwind label %116

152:                                              ; preds = %148
  %153 = load i8, ptr %.06283, align 1, !tbaa !33
  %154 = invoke noundef i32 @_ZN2rw6Stream7writeU8Eh(ptr noundef nonnull align 8 dereferenceable(8) %3, i8 noundef zeroext %153)
          to label %155 unwind label %116

155:                                              ; preds = %152
  %156 = getelementptr inbounds i8, ptr %.06283, i64 4
  br label %157

157:                                              ; preds = %.lr.ph85, %113, %129, %142, %155, %118
  %.163 = phi ptr [ %.06283, %.lr.ph85 ], [ %156, %155 ], [ %143, %142 ], [ %130, %129 ], [ %119, %118 ], [ %114, %113 ]
  %.1 = phi i32 [ %.084, %.lr.ph85 ], [ %.084, %155 ], [ %.084, %142 ], [ %.084, %129 ], [ %.084, %118 ], [ %115, %113 ]
  %158 = add nsw i32 %.1, 1
  %159 = load i32, ptr %29, align 4, !tbaa !15
  %160 = icmp slt i32 %158, %159
  br i1 %160, label %.lr.ph85, label %._crit_edge86, !llvm.loop !36

161:                                              ; preds = %162, %._crit_edge86
  %.059 = phi i32 [ %101, %._crit_edge86 ], [ %163, %162 ]
  %.not73 = icmp eq i32 %.059, 0
  br i1 %.not73, label %167, label %162

162:                                              ; preds = %161
  %163 = add nsw i32 %.059, -1
  %164 = invoke noundef i32 @_ZN2rw6Stream7writeU8Eh(ptr noundef nonnull align 8 dereferenceable(8) %3, i8 noundef zeroext 0)
          to label %161 unwind label %165, !llvm.loop !37

165:                                              ; preds = %162
  %166 = landingpad { ptr, i32 }
          cleanup
  br label %179

167:                                              ; preds = %161
  %168 = load i32, ptr %59, align 4, !tbaa !31
  %169 = sext i32 %168 to i64
  %170 = sub nsw i64 0, %169
  %171 = getelementptr inbounds i8, ptr %.06087, i64 %170
  %172 = add nuw nsw i32 %.05888, 1
  %173 = load i32, ptr %37, align 8, !tbaa !19
  %174 = icmp slt i32 %172, %173
  br i1 %174, label %.preheader, label %._crit_edge89, !llvm.loop !38

175:                                              ; preds = %._crit_edge89
  call void @llvm.lifetime.end.p0(i64 56, ptr nonnull %6) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %5) #6
  br label %176

176:                                              ; preds = %175, %17
  call void @_ZN2rw6StreamD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %3) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %3) #6
  ret void

177:                                              ; preds = %._crit_edge89
  %178 = landingpad { ptr, i32 }
          cleanup
  br label %179

179:                                              ; preds = %177, %165, %116, %93, %70
  %.pn76 = phi { ptr, i32 } [ %94, %93 ], [ %71, %70 ], [ %178, %177 ], [ %117, %116 ], [ %166, %165 ]
  call void @llvm.lifetime.end.p0(i64 56, ptr nonnull %6) #6
  br label %180

180:                                              ; preds = %179, %68
  %.pn76.pn = phi { ptr, i32 } [ %.pn76, %179 ], [ %69, %68 ]
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %5) #6
  br label %181

181:                                              ; preds = %180, %20, %18
  %.pn76.pn.pn = phi { ptr, i32 } [ %.pn76.pn, %180 ], [ %21, %20 ], [ %19, %18 ]
  call void @_ZN2rw6StreamD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %3) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %3) #6
  resume { ptr, i32 } %.pn76.pn.pn
}

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

declare noundef ptr @_ZN2rw10StreamFile4openEPKcS2_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef, ptr noundef) local_unnamed_addr #3

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

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

declare void @_ZN2rw8setErrorEPNS_5ErrorE(ptr noundef) local_unnamed_addr #3

declare noundef i32 @_ZN2rw10StreamFile6write8EPKvj(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef, i32 noundef) unnamed_addr #3

declare noundef i32 @_ZN2rw6Stream7writeU8Eh(ptr noundef nonnull align 8 dereferenceable(8), i8 noundef zeroext) local_unnamed_addr #3

declare void @_ZN2rw10StreamFile5closeEv(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #3

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.fshl.i32(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 = { 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 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #6 = { nounwind }
attributes #7 = { cold nounwind }

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

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


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SCCPPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass