; LLVM IR from aap/librw :: src/tga.ll (ZN2rw8writeTGAEPNS_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"

%"struct.rw::TGAHeader" = type { i8, i8, i8, i16, i16, i8, i16, i16, i16, i16, i8, i8 }
%"class.rw::StreamFile" = type { %"class.rw::Stream", ptr }
%"class.rw::Stream" = type { ptr }
%"struct.rw::Error" = type { i32, i32 }
%"struct.rw::Image" = type { i32, i32, i32, i32, i32, i32, ptr, ptr }

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

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

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

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

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) #2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN2rw8writeTGAEPNS_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 %"struct.rw::TGAHeader", align 2
  %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 ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca i32, align 4
  %17 = 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 20, 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)
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = invoke noundef ptr @_ZN2rw10StreamFile4openEPKcS2_(ptr noundef nonnull align 8 dereferenceable(16) %6, ptr noundef %18, ptr noundef @.str.6)
          to label %20 unwind label %36

20:                                               ; preds = %2
  %21 = icmp ne ptr %19, null
  br i1 %21, label %44, label %22

22:                                               ; preds = %20
  br label %23

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

31:                                               ; preds = %23
  %32 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %28, ptr noundef @.str.8, ptr noundef %30) #5
  invoke void @_ZN2rw8setErrorEPNS_5ErrorE(ptr noundef %9)
          to label %33 unwind label %40

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

34:                                               ; preds = %33
  br label %35

35:                                               ; preds = %34
  store i32 1, ptr %10, align 4
  br label %286

36:                                               ; preds = %106, %2
  %37 = landingpad { ptr, i32 }
          cleanup
  %38 = extractvalue { ptr, i32 } %37, 0
  store ptr %38, ptr %7, align 8
  %39 = extractvalue { ptr, i32 } %37, 1
  store i32 %39, ptr %8, align 4
  br label %295

40:                                               ; preds = %31, %23
  %41 = landingpad { ptr, i32 }
          cleanup
  %42 = extractvalue { ptr, i32 } %41, 0
  store ptr %42, ptr %7, align 8
  %43 = extractvalue { ptr, i32 } %41, 1
  store i32 %43, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  br label %295

44:                                               ; preds = %20
  %45 = getelementptr inbounds %"struct.rw::TGAHeader", ptr %5, i32 0, i32 0
  store i8 0, ptr %45, align 2, !tbaa !13
  %46 = load ptr, ptr %3, align 8, !tbaa !5
  %47 = getelementptr inbounds %"struct.rw::Image", ptr %46, i32 0, i32 7
  %48 = load ptr, ptr %47, align 8, !tbaa !16
  %49 = icmp ne ptr %48, null
  %50 = zext i1 %49 to i64
  %51 = select i1 %49, i32 1, i32 2
  %52 = trunc i32 %51 to i8
  %53 = getelementptr inbounds %"struct.rw::TGAHeader", ptr %5, i32 0, i32 2
  store i8 %52, ptr %53, align 2, !tbaa !18
  %54 = load ptr, ptr %3, align 8, !tbaa !5
  %55 = getelementptr inbounds %"struct.rw::Image", ptr %54, i32 0, i32 7
  %56 = load ptr, ptr %55, align 8, !tbaa !16
  %57 = icmp ne ptr %56, null
  %58 = zext i1 %57 to i8
  %59 = getelementptr inbounds %"struct.rw::TGAHeader", ptr %5, i32 0, i32 1
  store i8 %58, ptr %59, align 1, !tbaa !19
  %60 = getelementptr inbounds %"struct.rw::TGAHeader", ptr %5, i32 0, i32 3
  store i16 0, ptr %60, align 2, !tbaa !20
  %61 = load ptr, ptr %3, align 8, !tbaa !5
  %62 = getelementptr inbounds %"struct.rw::Image", ptr %61, i32 0, i32 3
  %63 = load i32, ptr %62, align 4, !tbaa !21
  %64 = icmp eq i32 %63, 4
  br i1 %64, label %65, label %66

65:                                               ; preds = %44
  br label %73

66:                                               ; preds = %44
  %67 = load ptr, ptr %3, align 8, !tbaa !5
  %68 = getelementptr inbounds %"struct.rw::Image", ptr %67, i32 0, i32 3
  %69 = load i32, ptr %68, align 4, !tbaa !21
  %70 = icmp eq i32 %69, 8
  %71 = zext i1 %70 to i64
  %72 = select i1 %70, i32 256, i32 0
  br label %73

73:                                               ; preds = %66, %65
  %74 = phi i32 [ 16, %65 ], [ %72, %66 ]
  %75 = trunc i32 %74 to i16
  %76 = getelementptr inbounds %"struct.rw::TGAHeader", ptr %5, i32 0, i32 4
  store i16 %75, ptr %76, align 2, !tbaa !22
  %77 = load ptr, ptr %3, align 8, !tbaa !5
  %78 = getelementptr inbounds %"struct.rw::Image", ptr %77, i32 0, i32 7
  %79 = load ptr, ptr %78, align 8, !tbaa !16
  %80 = icmp ne ptr %79, null
  %81 = zext i1 %80 to i64
  %82 = select i1 %80, i32 32, i32 0
  %83 = trunc i32 %82 to i8
  %84 = getelementptr inbounds %"struct.rw::TGAHeader", ptr %5, i32 0, i32 5
  store i8 %83, ptr %84, align 2, !tbaa !23
  %85 = getelementptr inbounds %"struct.rw::TGAHeader", ptr %5, i32 0, i32 6
  store i16 0, ptr %85, align 2, !tbaa !24
  %86 = getelementptr inbounds %"struct.rw::TGAHeader", ptr %5, i32 0, i32 7
  store i16 0, ptr %86, align 2, !tbaa !25
  %87 = load ptr, ptr %3, align 8, !tbaa !5
  %88 = getelementptr inbounds %"struct.rw::Image", ptr %87, i32 0, i32 1
  %89 = load i32, ptr %88, align 4, !tbaa !26
  %90 = trunc i32 %89 to i16
  %91 = getelementptr inbounds %"struct.rw::TGAHeader", ptr %5, i32 0, i32 8
  store i16 %90, ptr %91, align 2, !tbaa !27
  %92 = load ptr, ptr %3, align 8, !tbaa !5
  %93 = getelementptr inbounds %"struct.rw::Image", ptr %92, i32 0, i32 2
  %94 = load i32, ptr %93, align 8, !tbaa !28
  %95 = trunc i32 %94 to i16
  %96 = getelementptr inbounds %"struct.rw::TGAHeader", ptr %5, i32 0, i32 9
  store i16 %95, ptr %96, align 2, !tbaa !29
  %97 = load ptr, ptr %3, align 8, !tbaa !5
  %98 = getelementptr inbounds %"struct.rw::Image", ptr %97, i32 0, i32 3
  %99 = load i32, ptr %98, align 4, !tbaa !21
  %100 = icmp eq i32 %99, 4
  br i1 %100, label %101, label %102

101:                                              ; preds = %73
  br label %106

102:                                              ; preds = %73
  %103 = load ptr, ptr %3, align 8, !tbaa !5
  %104 = getelementptr inbounds %"struct.rw::Image", ptr %103, i32 0, i32 3
  %105 = load i32, ptr %104, align 4, !tbaa !21
  br label %106

106:                                              ; preds = %102, %101
  %107 = phi i32 [ 8, %101 ], [ %105, %102 ]
  %108 = trunc i32 %107 to i8
  %109 = getelementptr inbounds %"struct.rw::TGAHeader", ptr %5, i32 0, i32 10
  store i8 %108, ptr %109, align 2, !tbaa !30
  %110 = load ptr, ptr %3, align 8, !tbaa !5
  %111 = getelementptr inbounds %"struct.rw::Image", ptr %110, i32 0, i32 3
  %112 = load i32, ptr %111, align 4, !tbaa !21
  %113 = icmp eq i32 %112, 32
  %114 = zext i1 %113 to i64
  %115 = select i1 %113, i32 8, i32 0
  %116 = or i32 32, %115
  %117 = trunc i32 %116 to i8
  %118 = getelementptr inbounds %"struct.rw::TGAHeader", ptr %5, i32 0, i32 11
  store i8 %117, ptr %118, align 1, !tbaa !31
  invoke void @_ZN2rw9TGAHeader5writeEPNS_6StreamE(ptr noundef nonnull align 2 dereferenceable(20) %5, ptr noundef %6)
          to label %119 unwind label %36

119:                                              ; preds = %106
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  %120 = getelementptr inbounds %"struct.rw::TGAHeader", ptr %5, i32 0, i32 1
  %121 = load i8, ptr %120, align 1, !tbaa !19
  %122 = icmp ne i8 %121, 0
  br i1 %122, label %123, label %127

123:                                              ; preds = %119
  %124 = load ptr, ptr %3, align 8, !tbaa !5
  %125 = getelementptr inbounds %"struct.rw::Image", ptr %124, i32 0, i32 7
  %126 = load ptr, ptr %125, align 8, !tbaa !16
  br label %128

127:                                              ; preds = %119
  br label %128

128:                                              ; preds = %127, %123
  %129 = phi ptr [ %126, %123 ], [ null, %127 ]
  store ptr %129, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  %130 = load ptr, ptr %11, align 8, !tbaa !5
  store ptr %130, ptr %12, align 8, !tbaa !5
  %131 = load ptr, ptr %11, align 8, !tbaa !5
  %132 = icmp ne ptr %131, null
  br i1 %132, label %133, label %182

133:                                              ; preds = %128
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  store i32 0, ptr %13, align 4, !tbaa !32
  br label %134

134:                                              ; preds = %174, %133
  %135 = load i32, ptr %13, align 4, !tbaa !32
  %136 = getelementptr inbounds %"struct.rw::TGAHeader", ptr %5, i32 0, i32 4
  %137 = load i16, ptr %136, align 2, !tbaa !22
  %138 = sext i16 %137 to i32
  %139 = icmp slt i32 %135, %138
  br i1 %139, label %141, label %140

140:                                              ; preds = %134
  store i32 4, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  br label %181

141:                                              ; preds = %134
  %142 = load ptr, ptr %12, align 8, !tbaa !5
  %143 = load i32, ptr %13, align 4, !tbaa !32
  %144 = sext i32 %143 to i64
  %145 = getelementptr inbounds [4 x i8], ptr %142, i64 %144
  %146 = getelementptr inbounds [4 x i8], ptr %145, i64 0, i64 2
  %147 = load i8, ptr %146, align 1, !tbaa !33
  %148 = invoke noundef i32 @_ZN2rw6Stream7writeU8Eh(ptr noundef nonnull align 8 dereferenceable(8) %6, i8 noundef zeroext %147)
          to label %149 unwind label %177

149:                                              ; preds = %141
  %150 = load ptr, ptr %12, align 8, !tbaa !5
  %151 = load i32, ptr %13, align 4, !tbaa !32
  %152 = sext i32 %151 to i64
  %153 = getelementptr inbounds [4 x i8], ptr %150, i64 %152
  %154 = getelementptr inbounds [4 x i8], ptr %153, i64 0, i64 1
  %155 = load i8, ptr %154, align 1, !tbaa !33
  %156 = invoke noundef i32 @_ZN2rw6Stream7writeU8Eh(ptr noundef nonnull align 8 dereferenceable(8) %6, i8 noundef zeroext %155)
          to label %157 unwind label %177

157:                                              ; preds = %149
  %158 = load ptr, ptr %12, align 8, !tbaa !5
  %159 = load i32, ptr %13, align 4, !tbaa !32
  %160 = sext i32 %159 to i64
  %161 = getelementptr inbounds [4 x i8], ptr %158, i64 %160
  %162 = getelementptr inbounds [4 x i8], ptr %161, i64 0, i64 0
  %163 = load i8, ptr %162, align 1, !tbaa !33
  %164 = invoke noundef i32 @_ZN2rw6Stream7writeU8Eh(ptr noundef nonnull align 8 dereferenceable(8) %6, i8 noundef zeroext %163)
          to label %165 unwind label %177

165:                                              ; preds = %157
  %166 = load ptr, ptr %12, align 8, !tbaa !5
  %167 = load i32, ptr %13, align 4, !tbaa !32
  %168 = sext i32 %167 to i64
  %169 = getelementptr inbounds [4 x i8], ptr %166, i64 %168
  %170 = getelementptr inbounds [4 x i8], ptr %169, i64 0, i64 3
  %171 = load i8, ptr %170, align 1, !tbaa !33
  %172 = invoke noundef i32 @_ZN2rw6Stream7writeU8Eh(ptr noundef nonnull align 8 dereferenceable(8) %6, i8 noundef zeroext %171)
          to label %173 unwind label %177

173:                                              ; preds = %165
  br label %174

174:                                              ; preds = %173
  %175 = load i32, ptr %13, align 4, !tbaa !32
  %176 = add nsw i32 %175, 1
  store i32 %176, ptr %13, align 4, !tbaa !32
  br label %134, !llvm.loop !34

177:                                              ; preds = %165, %157, %149, %141
  %178 = landingpad { ptr, i32 }
          cleanup
  %179 = extractvalue { ptr, i32 } %178, 0
  store ptr %179, ptr %7, align 8
  %180 = extractvalue { ptr, i32 } %178, 1
  store i32 %180, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  br label %294

181:                                              ; preds = %140
  br label %182

182:                                              ; preds = %181, %128
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #5
  %183 = load ptr, ptr %3, align 8, !tbaa !5
  %184 = getelementptr inbounds %"struct.rw::Image", ptr %183, i32 0, i32 6
  %185 = load ptr, ptr %184, align 8, !tbaa !36
  store ptr %185, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #5
  store i32 0, ptr %16, align 4, !tbaa !32
  br label %186

186:                                              ; preds = %281, %182
  %187 = load i32, ptr %16, align 4, !tbaa !32
  %188 = load ptr, ptr %3, align 8, !tbaa !5
  %189 = getelementptr inbounds %"struct.rw::Image", ptr %188, i32 0, i32 2
  %190 = load i32, ptr %189, align 8, !tbaa !28
  %191 = icmp slt i32 %187, %190
  br i1 %191, label %193, label %192

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

193:                                              ; preds = %186
  %194 = load ptr, ptr %14, align 8, !tbaa !5
  store ptr %194, ptr %15, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #5
  store i32 0, ptr %17, align 4, !tbaa !32
  br label %195

195:                                              ; preds = %271, %193
  %196 = load i32, ptr %17, align 4, !tbaa !32
  %197 = load ptr, ptr %3, align 8, !tbaa !5
  %198 = getelementptr inbounds %"struct.rw::Image", ptr %197, i32 0, i32 1
  %199 = load i32, ptr %198, align 4, !tbaa !26
  %200 = icmp slt i32 %196, %199
  br i1 %200, label %202, label %201

201:                                              ; preds = %195
  store i32 10, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #5
  br label %274

202:                                              ; preds = %195
  %203 = load ptr, ptr %3, align 8, !tbaa !5
  %204 = getelementptr inbounds %"struct.rw::Image", ptr %203, i32 0, i32 3
  %205 = load i32, ptr %204, align 4, !tbaa !21
  switch i32 %205, label %264 [
    i32 4, label %206
    i32 8, label %206
    i32 16, label %216
    i32 24, label %227
    i32 32, label %243
  ]

206:                                              ; preds = %202, %202
  %207 = load ptr, ptr %15, align 8, !tbaa !5
  %208 = getelementptr inbounds i8, ptr %207, i64 0
  %209 = load i8, ptr %208, align 1, !tbaa !33
  %210 = invoke noundef i32 @_ZN2rw6Stream7writeU8Eh(ptr noundef nonnull align 8 dereferenceable(8) %6, i8 noundef zeroext %209)
          to label %211 unwind label %212

211:                                              ; preds = %206
  br label %264

212:                                              ; preds = %258, %253, %248, %243, %237, %232, %227, %221, %216, %206
  %213 = landingpad { ptr, i32 }
          cleanup
  %214 = extractvalue { ptr, i32 } %213, 0
  store ptr %214, ptr %7, align 8
  %215 = extractvalue { ptr, i32 } %213, 1
  store i32 %215, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #5
  br label %293

216:                                              ; preds = %202
  %217 = load ptr, ptr %15, align 8, !tbaa !5
  %218 = getelementptr inbounds i8, ptr %217, i64 0
  %219 = load i8, ptr %218, align 1, !tbaa !33
  %220 = invoke noundef i32 @_ZN2rw6Stream7writeU8Eh(ptr noundef nonnull align 8 dereferenceable(8) %6, i8 noundef zeroext %219)
          to label %221 unwind label %212

221:                                              ; preds = %216
  %222 = load ptr, ptr %15, align 8, !tbaa !5
  %223 = getelementptr inbounds i8, ptr %222, i64 1
  %224 = load i8, ptr %223, align 1, !tbaa !33
  %225 = invoke noundef i32 @_ZN2rw6Stream7writeU8Eh(ptr noundef nonnull align 8 dereferenceable(8) %6, i8 noundef zeroext %224)
          to label %226 unwind label %212

226:                                              ; preds = %221
  br label %264

227:                                              ; preds = %202
  %228 = load ptr, ptr %15, align 8, !tbaa !5
  %229 = getelementptr inbounds i8, ptr %228, i64 2
  %230 = load i8, ptr %229, align 1, !tbaa !33
  %231 = invoke noundef i32 @_ZN2rw6Stream7writeU8Eh(ptr noundef nonnull align 8 dereferenceable(8) %6, i8 noundef zeroext %230)
          to label %232 unwind label %212

232:                                              ; preds = %227
  %233 = load ptr, ptr %15, align 8, !tbaa !5
  %234 = getelementptr inbounds i8, ptr %233, i64 1
  %235 = load i8, ptr %234, align 1, !tbaa !33
  %236 = invoke noundef i32 @_ZN2rw6Stream7writeU8Eh(ptr noundef nonnull align 8 dereferenceable(8) %6, i8 noundef zeroext %235)
          to label %237 unwind label %212

237:                                              ; preds = %232
  %238 = load ptr, ptr %15, align 8, !tbaa !5
  %239 = getelementptr inbounds i8, ptr %238, i64 0
  %240 = load i8, ptr %239, align 1, !tbaa !33
  %241 = invoke noundef i32 @_ZN2rw6Stream7writeU8Eh(ptr noundef nonnull align 8 dereferenceable(8) %6, i8 noundef zeroext %240)
          to label %242 unwind label %212

242:                                              ; preds = %237
  br label %264

243:                                              ; preds = %202
  %244 = load ptr, ptr %15, align 8, !tbaa !5
  %245 = getelementptr inbounds i8, ptr %244, i64 2
  %246 = load i8, ptr %245, align 1, !tbaa !33
  %247 = invoke noundef i32 @_ZN2rw6Stream7writeU8Eh(ptr noundef nonnull align 8 dereferenceable(8) %6, i8 noundef zeroext %246)
          to label %248 unwind label %212

248:                                              ; preds = %243
  %249 = load ptr, ptr %15, align 8, !tbaa !5
  %250 = getelementptr inbounds i8, ptr %249, i64 1
  %251 = load i8, ptr %250, align 1, !tbaa !33
  %252 = invoke noundef i32 @_ZN2rw6Stream7writeU8Eh(ptr noundef nonnull align 8 dereferenceable(8) %6, i8 noundef zeroext %251)
          to label %253 unwind label %212

253:                                              ; preds = %248
  %254 = load ptr, ptr %15, align 8, !tbaa !5
  %255 = getelementptr inbounds i8, ptr %254, i64 0
  %256 = load i8, ptr %255, align 1, !tbaa !33
  %257 = invoke noundef i32 @_ZN2rw6Stream7writeU8Eh(ptr noundef nonnull align 8 dereferenceable(8) %6, i8 noundef zeroext %256)
          to label %258 unwind label %212

258:                                              ; preds = %253
  %259 = load ptr, ptr %15, align 8, !tbaa !5
  %260 = getelementptr inbounds i8, ptr %259, i64 3
  %261 = load i8, ptr %260, align 1, !tbaa !33
  %262 = invoke noundef i32 @_ZN2rw6Stream7writeU8Eh(ptr noundef nonnull align 8 dereferenceable(8) %6, i8 noundef zeroext %261)
          to label %263 unwind label %212

263:                                              ; preds = %258
  br label %264

264:                                              ; preds = %263, %242, %226, %211, %202
  %265 = load ptr, ptr %3, align 8, !tbaa !5
  %266 = getelementptr inbounds %"struct.rw::Image", ptr %265, i32 0, i32 4
  %267 = load i32, ptr %266, align 8, !tbaa !37
  %268 = load ptr, ptr %15, align 8, !tbaa !5
  %269 = sext i32 %267 to i64
  %270 = getelementptr inbounds i8, ptr %268, i64 %269
  store ptr %270, ptr %15, align 8, !tbaa !5
  br label %271

271:                                              ; preds = %264
  %272 = load i32, ptr %17, align 4, !tbaa !32
  %273 = add nsw i32 %272, 1
  store i32 %273, ptr %17, align 4, !tbaa !32
  br label %195, !llvm.loop !38

274:                                              ; preds = %201
  %275 = load ptr, ptr %3, align 8, !tbaa !5
  %276 = getelementptr inbounds %"struct.rw::Image", ptr %275, i32 0, i32 5
  %277 = load i32, ptr %276, align 4, !tbaa !39
  %278 = load ptr, ptr %14, align 8, !tbaa !5
  %279 = sext i32 %277 to i64
  %280 = getelementptr inbounds i8, ptr %278, i64 %279
  store ptr %280, ptr %14, align 8, !tbaa !5
  br label %281

281:                                              ; preds = %274
  %282 = load i32, ptr %16, align 4, !tbaa !32
  %283 = add nsw i32 %282, 1
  store i32 %283, ptr %16, align 4, !tbaa !32
  br label %186, !llvm.loop !40

284:                                              ; preds = %192
  invoke void @_ZN2rw10StreamFile5closeEv(ptr noundef nonnull align 8 dereferenceable(16) %6)
          to label %285 unwind label %289

285:                                              ; preds = %284
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  store i32 0, ptr %10, align 4
  br label %286

286:                                              ; preds = %285, %35
  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 20, ptr %5) #5
  %287 = load i32, ptr %10, align 4
  switch i32 %287, label %301 [
    i32 0, label %288
    i32 1, label %288
  ]

288:                                              ; preds = %286, %286
  ret void

289:                                              ; preds = %284
  %290 = landingpad { ptr, i32 }
          cleanup
  %291 = extractvalue { ptr, i32 } %290, 0
  store ptr %291, ptr %7, align 8
  %292 = extractvalue { ptr, i32 } %290, 1
  store i32 %292, ptr %8, align 4
  br label %293

293:                                              ; preds = %289, %212
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #5
  br label %294

294:                                              ; preds = %293, %177
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  br label %295

295:                                              ; preds = %294, %40, %36
  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 20, ptr %5) #5
  br label %296

296:                                              ; preds = %295
  %297 = load ptr, ptr %7, align 8
  %298 = load i32, ptr %8, align 4
  %299 = insertvalue { ptr, i32 } poison, ptr %297, 0
  %300 = insertvalue { ptr, i32 } %299, i32 %298, 1
  resume { ptr, i32 } %300

301:                                              ; preds = %286
  unreachable
}

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

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

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

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

declare void @_ZN2rw8setErrorEPNS_5ErrorE(ptr noundef) #1

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN2rw6StreamD2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #3 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 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #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, !7, i64 0}
!14 = !{!"_ZTSN2rw9TGAHeaderE", !7, i64 0, !7, i64 1, !7, i64 2, !15, i64 4, !15, i64 6, !7, i64 8, !15, i64 10, !15, i64 12, !15, i64 14, !15, i64 16, !7, i64 18, !7, i64 19}
!15 = !{!"short", !7, i64 0}
!16 = !{!17, !6, i64 32}
!17 = !{!"_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}
!18 = !{!14, !7, i64 2}
!19 = !{!14, !7, i64 1}
!20 = !{!14, !15, i64 4}
!21 = !{!17, !11, i64 12}
!22 = !{!14, !15, i64 6}
!23 = !{!14, !7, i64 8}
!24 = !{!14, !15, i64 10}
!25 = !{!14, !15, i64 12}
!26 = !{!17, !11, i64 4}
!27 = !{!14, !15, i64 14}
!28 = !{!17, !11, i64 8}
!29 = !{!14, !15, i64 16}
!30 = !{!14, !7, i64 18}
!31 = !{!14, !7, i64 19}
!32 = !{!11, !11, i64 0}
!33 = !{!7, !7, i64 0}
!34 = distinct !{!34, !35}
!35 = !{!"llvm.loop.mustprogress"}
!36 = !{!17, !6, i64 24}
!37 = !{!17, !11, i64 16}
!38 = distinct !{!38, !35}
!39 = !{!17, !11, i64 20}
!40 = distinct !{!40, !35}


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

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

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

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

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

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) #2

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

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

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

14:                                               ; preds = %8
  %15 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %12, ptr noundef nonnull @.str.8, ptr noundef %13) #7
  invoke void @_ZN2rw8setErrorEPNS_5ErrorE(ptr noundef nonnull %5)
          to label %16 unwind label %19

16:                                               ; preds = %14
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #6
  br label %137

17:                                               ; preds = %21, %2
  %18 = landingpad { ptr, i32 }
          cleanup
  br label %140

19:                                               ; preds = %14, %8
  %20 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #6
  br label %140

21:                                               ; preds = %7
  store i8 0, ptr %3, align 2, !tbaa !13
  %22 = getelementptr inbounds i8, ptr %0, i64 32
  %23 = load ptr, ptr %22, align 8, !tbaa !16
  %.not60 = icmp eq ptr %23, null
  %24 = select i1 %.not60, i8 2, i8 1
  %25 = getelementptr inbounds i8, ptr %3, i64 2
  store i8 %24, ptr %25, align 2, !tbaa !18
  %26 = icmp ne ptr %23, null
  %27 = zext i1 %26 to i8
  %28 = getelementptr inbounds i8, ptr %3, i64 1
  store i8 %27, ptr %28, align 1, !tbaa !19
  %29 = getelementptr inbounds i8, ptr %3, i64 4
  store i16 0, ptr %29, align 2, !tbaa !20
  %30 = getelementptr inbounds i8, ptr %0, i64 12
  %31 = load i32, ptr %30, align 4, !tbaa !21
  %32 = icmp eq i32 %31, 4
  %33 = icmp eq i32 %31, 8
  %34 = select i1 %33, i16 256, i16 0
  %35 = select i1 %32, i16 16, i16 %34
  %36 = getelementptr inbounds i8, ptr %3, i64 6
  store i16 %35, ptr %36, align 2, !tbaa !22
  %37 = select i1 %.not60, i8 0, i8 32
  %38 = getelementptr inbounds i8, ptr %3, i64 8
  store i8 %37, ptr %38, align 2, !tbaa !23
  %39 = getelementptr inbounds i8, ptr %3, i64 10
  store i16 0, ptr %39, align 2, !tbaa !24
  %40 = getelementptr inbounds i8, ptr %3, i64 12
  store i16 0, ptr %40, align 2, !tbaa !25
  %41 = getelementptr inbounds i8, ptr %0, i64 4
  %42 = getelementptr inbounds i8, ptr %3, i64 14
  %43 = getelementptr inbounds i8, ptr %0, i64 8
  %44 = load <2 x i32>, ptr %41, align 4, !tbaa !26
  %45 = trunc <2 x i32> %44 to <2 x i16>
  store <2 x i16> %45, ptr %42, align 2, !tbaa !27
  %46 = trunc i32 %31 to i8
  %47 = select i1 %32, i8 8, i8 %46
  %48 = getelementptr inbounds i8, ptr %3, i64 18
  store i8 %47, ptr %48, align 2, !tbaa !28
  %49 = icmp eq i32 %31, 32
  %50 = select i1 %49, i8 40, i8 32
  %51 = getelementptr inbounds i8, ptr %3, i64 19
  store i8 %50, ptr %51, align 1, !tbaa !29
  invoke void @_ZN2rw9TGAHeader5writeEPNS_6StreamE(ptr noundef nonnull align 2 dereferenceable(20) %3, ptr noundef nonnull %4)
          to label %52 unwind label %17

52:                                               ; preds = %21
  %53 = load i8, ptr %28, align 1, !tbaa !19
  %.not62 = icmp eq i8 %53, 0
  br i1 %.not62, label %.thread, label %54

54:                                               ; preds = %52
  %55 = load ptr, ptr %22, align 8, !tbaa !16
  %.not63 = icmp ne ptr %55, null
  %56 = load i16, ptr %36, align 2
  %57 = icmp sgt i16 %56, 0
  %or.cond = select i1 %.not63, i1 %57, i1 false
  br i1 %or.cond, label %.lr.ph, label %.thread

.lr.ph:                                           ; preds = %54, %73
  %indvars.iv = phi i64 [ %indvars.iv.next, %73 ], [ 0, %54 ]
  %58 = getelementptr inbounds [4 x i8], ptr %55, i64 %indvars.iv
  %59 = getelementptr inbounds i8, ptr %58, i64 2
  %60 = load i8, ptr %59, align 1, !tbaa !30
  %61 = invoke noundef i32 @_ZN2rw6Stream7writeU8Eh(ptr noundef nonnull align 8 dereferenceable(8) %4, i8 noundef zeroext %60)
          to label %62 unwind label %77

62:                                               ; preds = %.lr.ph
  %63 = getelementptr inbounds i8, ptr %58, i64 1
  %64 = load i8, ptr %63, align 1, !tbaa !30
  %65 = invoke noundef i32 @_ZN2rw6Stream7writeU8Eh(ptr noundef nonnull align 8 dereferenceable(8) %4, i8 noundef zeroext %64)
          to label %66 unwind label %77

66:                                               ; preds = %62
  %67 = load i8, ptr %58, align 1, !tbaa !30
  %68 = invoke noundef i32 @_ZN2rw6Stream7writeU8Eh(ptr noundef nonnull align 8 dereferenceable(8) %4, i8 noundef zeroext %67)
          to label %69 unwind label %77

69:                                               ; preds = %66
  %70 = getelementptr inbounds i8, ptr %58, i64 3
  %71 = load i8, ptr %70, align 1, !tbaa !30
  %72 = invoke noundef i32 @_ZN2rw6Stream7writeU8Eh(ptr noundef nonnull align 8 dereferenceable(8) %4, i8 noundef zeroext %71)
          to label %73 unwind label %77

73:                                               ; preds = %69
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %74 = load i16, ptr %36, align 2, !tbaa !22
  %75 = sext i16 %74 to i64
  %76 = icmp slt i64 %indvars.iv.next, %75
  br i1 %76, label %.lr.ph, label %.thread, !llvm.loop !31

77:                                               ; preds = %69, %66, %62, %.lr.ph
  %78 = landingpad { ptr, i32 }
          cleanup
  br label %140

.thread:                                          ; preds = %73, %52, %54
  %79 = load i32, ptr %43, align 8, !tbaa !33
  %80 = icmp sgt i32 %79, 0
  br i1 %80, label %.preheader.lr.ph, label %._crit_edge76

.preheader.lr.ph:                                 ; preds = %.thread
  %81 = getelementptr inbounds i8, ptr %0, i64 16
  %82 = getelementptr inbounds i8, ptr %0, i64 20
  %83 = load i32, ptr %41, align 4, !tbaa !34
  %84 = icmp sgt i32 %83, 0
  br i1 %84, label %.preheader.preheader, label %._crit_edge76

.preheader.preheader:                             ; preds = %.preheader.lr.ph
  %85 = getelementptr inbounds i8, ptr %0, i64 24
  %86 = load ptr, ptr %85, align 8, !tbaa !35
  br label %.preheader

.preheader:                                       ; preds = %.preheader.preheader, %._crit_edge
  %87 = phi i32 [ %90, %._crit_edge ], [ %79, %.preheader.preheader ]
  %88 = phi i32 [ %91, %._crit_edge ], [ %83, %.preheader.preheader ]
  %.04975 = phi i32 [ %95, %._crit_edge ], [ 0, %.preheader.preheader ]
  %.05174 = phi ptr [ %94, %._crit_edge ], [ %86, %.preheader.preheader ]
  %89 = icmp sgt i32 %88, 0
  br i1 %89, label %.lr.ph73, label %._crit_edge

._crit_edge76:                                    ; preds = %._crit_edge, %.preheader.lr.ph, %.thread
  invoke void @_ZN2rw10StreamFile5closeEv(ptr noundef nonnull align 8 dereferenceable(16) %4)
          to label %137 unwind label %138

._crit_edge.loopexit:                             ; preds = %130
  %.pre = load i32, ptr %43, align 8, !tbaa !33
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %.preheader
  %90 = phi i32 [ %.pre, %._crit_edge.loopexit ], [ %87, %.preheader ]
  %91 = phi i32 [ %135, %._crit_edge.loopexit ], [ %88, %.preheader ]
  %92 = load i32, ptr %82, align 4, !tbaa !36
  %93 = sext i32 %92 to i64
  %94 = getelementptr inbounds i8, ptr %.05174, i64 %93
  %95 = add nuw nsw i32 %.04975, 1
  %96 = icmp slt i32 %95, %90
  br i1 %96, label %.preheader, label %._crit_edge76, !llvm.loop !37

.lr.ph73:                                         ; preds = %.preheader, %130
  %.072 = phi i32 [ %134, %130 ], [ 0, %.preheader ]
  %.05071 = phi ptr [ %133, %130 ], [ %.05174, %.preheader ]
  %97 = load i32, ptr %30, align 4, !tbaa !21
  %98 = add i32 %97, -4
  %99 = call i32 @llvm.fshl.i32(i32 %98, i32 %98, i32 30)
  switch i32 %99, label %130 [
    i32 0, label %.invoke
    i32 1, label %.invoke
    i32 3, label %102
    i32 5, label %107
    i32 7, label %115
  ]

100:                                              ; preds = %.invoke, %123, %119, %115, %111, %107, %102
  %101 = landingpad { ptr, i32 }
          cleanup
  br label %140

102:                                              ; preds = %.lr.ph73
  %103 = load i8, ptr %.05071, align 1, !tbaa !30
  %104 = invoke noundef i32 @_ZN2rw6Stream7writeU8Eh(ptr noundef nonnull align 8 dereferenceable(8) %4, i8 noundef zeroext %103)
          to label %105 unwind label %100

105:                                              ; preds = %102
  %106 = getelementptr inbounds i8, ptr %.05071, i64 1
  br label %.invoke

107:                                              ; preds = %.lr.ph73
  %108 = getelementptr inbounds i8, ptr %.05071, i64 2
  %109 = load i8, ptr %108, align 1, !tbaa !30
  %110 = invoke noundef i32 @_ZN2rw6Stream7writeU8Eh(ptr noundef nonnull align 8 dereferenceable(8) %4, i8 noundef zeroext %109)
          to label %111 unwind label %100

111:                                              ; preds = %107
  %112 = getelementptr inbounds i8, ptr %.05071, i64 1
  %113 = load i8, ptr %112, align 1, !tbaa !30
  %114 = invoke noundef i32 @_ZN2rw6Stream7writeU8Eh(ptr noundef nonnull align 8 dereferenceable(8) %4, i8 noundef zeroext %113)
          to label %.invoke unwind label %100

115:                                              ; preds = %.lr.ph73
  %116 = getelementptr inbounds i8, ptr %.05071, i64 2
  %117 = load i8, ptr %116, align 1, !tbaa !30
  %118 = invoke noundef i32 @_ZN2rw6Stream7writeU8Eh(ptr noundef nonnull align 8 dereferenceable(8) %4, i8 noundef zeroext %117)
          to label %119 unwind label %100

119:                                              ; preds = %115
  %120 = getelementptr inbounds i8, ptr %.05071, i64 1
  %121 = load i8, ptr %120, align 1, !tbaa !30
  %122 = invoke noundef i32 @_ZN2rw6Stream7writeU8Eh(ptr noundef nonnull align 8 dereferenceable(8) %4, i8 noundef zeroext %121)
          to label %123 unwind label %100

123:                                              ; preds = %119
  %124 = load i8, ptr %.05071, align 1, !tbaa !30
  %125 = invoke noundef i32 @_ZN2rw6Stream7writeU8Eh(ptr noundef nonnull align 8 dereferenceable(8) %4, i8 noundef zeroext %124)
          to label %126 unwind label %100

126:                                              ; preds = %123
  %127 = getelementptr inbounds i8, ptr %.05071, i64 3
  br label %.invoke

.invoke:                                          ; preds = %111, %.lr.ph73, %.lr.ph73, %105, %126
  %.05071.sink = phi ptr [ %106, %105 ], [ %127, %126 ], [ %.05071, %.lr.ph73 ], [ %.05071, %.lr.ph73 ], [ %.05071, %111 ]
  %128 = load i8, ptr %.05071.sink, align 1, !tbaa !30
  %129 = invoke noundef i32 @_ZN2rw6Stream7writeU8Eh(ptr noundef nonnull align 8 dereferenceable(8) %4, i8 noundef zeroext %128)
          to label %130 unwind label %100

130:                                              ; preds = %.invoke, %.lr.ph73
  %131 = load i32, ptr %81, align 8, !tbaa !39
  %132 = sext i32 %131 to i64
  %133 = getelementptr inbounds i8, ptr %.05071, i64 %132
  %134 = add nuw nsw i32 %.072, 1
  %135 = load i32, ptr %41, align 4, !tbaa !34
  %136 = icmp slt i32 %134, %135
  br i1 %136, label %.lr.ph73, label %._crit_edge.loopexit, !llvm.loop !40

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

138:                                              ; preds = %._crit_edge76
  %139 = landingpad { ptr, i32 }
          cleanup
  br label %140

140:                                              ; preds = %77, %138, %100, %19, %17
  %.pn65.pn = phi { ptr, i32 } [ %18, %17 ], [ %20, %19 ], [ %78, %77 ], [ %101, %100 ], [ %139, %138 ]
  call void @_ZN2rw6StreamD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %4) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #6
  call void @llvm.lifetime.end.p0(i64 20, ptr nonnull %3) #6
  resume { ptr, i32 } %.pn65.pn
}

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

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

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

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

declare void @_ZN2rw8setErrorEPNS_5ErrorE(ptr noundef) local_unnamed_addr #1

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN2rw6StreamD2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #3 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 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #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, !8, i64 0}
!14 = !{!"_ZTSN2rw9TGAHeaderE", !8, i64 0, !8, i64 1, !8, i64 2, !15, i64 4, !15, i64 6, !8, i64 8, !15, i64 10, !15, i64 12, !15, i64 14, !15, i64 16, !8, i64 18, !8, i64 19}
!15 = !{!"short", !8, i64 0}
!16 = !{!17, !12, i64 32}
!17 = !{!"_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}
!18 = !{!14, !8, i64 2}
!19 = !{!14, !8, i64 1}
!20 = !{!14, !15, i64 4}
!21 = !{!17, !7, i64 12}
!22 = !{!14, !15, i64 6}
!23 = !{!14, !8, i64 8}
!24 = !{!14, !15, i64 10}
!25 = !{!14, !15, i64 12}
!26 = !{!7, !7, i64 0}
!27 = !{!15, !15, i64 0}
!28 = !{!14, !8, i64 18}
!29 = !{!14, !8, i64 19}
!30 = !{!8, !8, i64 0}
!31 = distinct !{!31, !32}
!32 = !{!"llvm.loop.mustprogress"}
!33 = !{!17, !7, i64 8}
!34 = !{!17, !7, i64 4}
!35 = !{!17, !12, i64 24}
!36 = !{!17, !7, i64 20}
!37 = distinct !{!37, !32, !38}
!38 = !{!"llvm.loop.unswitch.partial.disable"}
!39 = !{!17, !7, i64 16}
!40 = distinct !{!40, !32}


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