; LLVM IR from casensiom/fast-image-processing :: src (bmp)

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

@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [3 x i8], align 1

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

declare noalias ptr @fopen(ptr noundef, ptr noundef) #1

declare i32 @fclose(ptr noundef) #1

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @save_image_ex(ptr noundef %0, ptr noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4) #3 {
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca [13 x i32], align 16
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  %19 = alloca i32, align 4
  %20 = alloca i32, align 4
  %21 = alloca i32, align 4
  %22 = alloca i32, align 4
  %23 = alloca i32, align 4
  %24 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store i32 %2, ptr %8, align 4, !tbaa !9
  store i32 %3, ptr %9, align 4, !tbaa !9
  store i32 %4, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 52, ptr %11) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #4
  %25 = load i32, ptr %8, align 4, !tbaa !9
  store i32 %25, ptr %21, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #4
  %26 = load i32, ptr %9, align 4, !tbaa !9
  store i32 %26, ptr %22, align 4, !tbaa !9
  %27 = load i32, ptr %21, align 4, !tbaa !9
  %28 = mul nsw i32 %27, 3
  %29 = srem i32 %28, 4
  %30 = sub nsw i32 4, %29
  store i32 %30, ptr %13, align 4, !tbaa !9
  %31 = load i32, ptr %13, align 4, !tbaa !9
  %32 = icmp eq i32 %31, 4
  br i1 %32, label %33, label %34

33:                                               ; preds = %5
  store i32 0, ptr %13, align 4, !tbaa !9
  br label %34

34:                                               ; preds = %33, %5
  %35 = load i32, ptr %21, align 4, !tbaa !9
  %36 = mul nsw i32 %35, 3
  %37 = load i32, ptr %13, align 4, !tbaa !9
  %38 = add nsw i32 %36, %37
  %39 = load i32, ptr %22, align 4, !tbaa !9
  %40 = mul nsw i32 %38, %39
  store i32 %40, ptr %14, align 4, !tbaa !9
  %41 = load i32, ptr %14, align 4, !tbaa !9
  %42 = add nsw i32 %41, 54
  %43 = getelementptr inbounds [13 x i32], ptr %11, i64 0, i64 0
  store i32 %42, ptr %43, align 16, !tbaa !9
  %44 = getelementptr inbounds [13 x i32], ptr %11, i64 0, i64 1
  store i32 0, ptr %44, align 4, !tbaa !9
  %45 = getelementptr inbounds [13 x i32], ptr %11, i64 0, i64 2
  store i32 54, ptr %45, align 8, !tbaa !9
  %46 = getelementptr inbounds [13 x i32], ptr %11, i64 0, i64 3
  store i32 40, ptr %46, align 4, !tbaa !9
  %47 = load i32, ptr %21, align 4, !tbaa !9
  %48 = getelementptr inbounds [13 x i32], ptr %11, i64 0, i64 4
  store i32 %47, ptr %48, align 16, !tbaa !9
  %49 = load i32, ptr %22, align 4, !tbaa !9
  %50 = getelementptr inbounds [13 x i32], ptr %11, i64 0, i64 5
  store i32 %49, ptr %50, align 4, !tbaa !9
  %51 = getelementptr inbounds [13 x i32], ptr %11, i64 0, i64 7
  store i32 0, ptr %51, align 4, !tbaa !9
  %52 = load i32, ptr %14, align 4, !tbaa !9
  %53 = getelementptr inbounds [13 x i32], ptr %11, i64 0, i64 8
  store i32 %52, ptr %53, align 16, !tbaa !9
  %54 = getelementptr inbounds [13 x i32], ptr %11, i64 0, i64 9
  store i32 0, ptr %54, align 4, !tbaa !9
  %55 = getelementptr inbounds [13 x i32], ptr %11, i64 0, i64 10
  store i32 0, ptr %55, align 8, !tbaa !9
  %56 = getelementptr inbounds [13 x i32], ptr %11, i64 0, i64 11
  store i32 0, ptr %56, align 4, !tbaa !9
  %57 = getelementptr inbounds [13 x i32], ptr %11, i64 0, i64 12
  store i32 0, ptr %57, align 16, !tbaa !9
  %58 = load ptr, ptr %6, align 8, !tbaa !5
  %59 = call noalias ptr @fopen(ptr noundef %58, ptr noundef @.str.2)
  store ptr %59, ptr %12, align 8, !tbaa !5
  %60 = load ptr, ptr %12, align 8, !tbaa !5
  %61 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %60, ptr noundef @.str.3) #4
  store i32 0, ptr %17, align 4, !tbaa !9
  br label %62

62:                                               ; preds = %97, %34
  %63 = load i32, ptr %17, align 4, !tbaa !9
  %64 = icmp sle i32 %63, 5
  br i1 %64, label %65, label %100

65:                                               ; preds = %62
  %66 = load ptr, ptr %12, align 8, !tbaa !5
  %67 = load i32, ptr %17, align 4, !tbaa !9
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds [13 x i32], ptr %11, i64 0, i64 %68
  %70 = load i32, ptr %69, align 4, !tbaa !9
  %71 = and i32 %70, 255
  %72 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %66, ptr noundef @.str.4, i32 noundef %71) #4
  %73 = load ptr, ptr %12, align 8, !tbaa !5
  %74 = load i32, ptr %17, align 4, !tbaa !9
  %75 = sext i32 %74 to i64
  %76 = getelementptr inbounds [13 x i32], ptr %11, i64 0, i64 %75
  %77 = load i32, ptr %76, align 4, !tbaa !9
  %78 = and i32 %77, 65280
  %79 = lshr i32 %78, 8
  %80 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %73, ptr noundef @.str.4, i32 noundef %79) #4
  %81 = load ptr, ptr %12, align 8, !tbaa !5
  %82 = load i32, ptr %17, align 4, !tbaa !9
  %83 = sext i32 %82 to i64
  %84 = getelementptr inbounds [13 x i32], ptr %11, i64 0, i64 %83
  %85 = load i32, ptr %84, align 4, !tbaa !9
  %86 = and i32 %85, 16711680
  %87 = lshr i32 %86, 16
  %88 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %81, ptr noundef @.str.4, i32 noundef %87) #4
  %89 = load ptr, ptr %12, align 8, !tbaa !5
  %90 = load i32, ptr %17, align 4, !tbaa !9
  %91 = sext i32 %90 to i64
  %92 = getelementptr inbounds [13 x i32], ptr %11, i64 0, i64 %91
  %93 = load i32, ptr %92, align 4, !tbaa !9
  %94 = and i32 %93, -16777216
  %95 = lshr i32 %94, 24
  %96 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %89, ptr noundef @.str.4, i32 noundef %95) #4
  br label %97

97:                                               ; preds = %65
  %98 = load i32, ptr %17, align 4, !tbaa !9
  %99 = add nsw i32 %98, 1
  store i32 %99, ptr %17, align 4, !tbaa !9
  br label %62, !llvm.loop !11

100:                                              ; preds = %62
  %101 = load ptr, ptr %12, align 8, !tbaa !5
  %102 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %101, ptr noundef @.str.4, i32 noundef 1) #4
  %103 = load ptr, ptr %12, align 8, !tbaa !5
  %104 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %103, ptr noundef @.str.4, i32 noundef 0) #4
  %105 = load ptr, ptr %12, align 8, !tbaa !5
  %106 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %105, ptr noundef @.str.4, i32 noundef 24) #4
  %107 = load ptr, ptr %12, align 8, !tbaa !5
  %108 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %107, ptr noundef @.str.4, i32 noundef 0) #4
  store i32 7, ptr %17, align 4, !tbaa !9
  br label %109

109:                                              ; preds = %144, %100
  %110 = load i32, ptr %17, align 4, !tbaa !9
  %111 = icmp sle i32 %110, 12
  br i1 %111, label %112, label %147

112:                                              ; preds = %109
  %113 = load ptr, ptr %12, align 8, !tbaa !5
  %114 = load i32, ptr %17, align 4, !tbaa !9
  %115 = sext i32 %114 to i64
  %116 = getelementptr inbounds [13 x i32], ptr %11, i64 0, i64 %115
  %117 = load i32, ptr %116, align 4, !tbaa !9
  %118 = and i32 %117, 255
  %119 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %113, ptr noundef @.str.4, i32 noundef %118) #4
  %120 = load ptr, ptr %12, align 8, !tbaa !5
  %121 = load i32, ptr %17, align 4, !tbaa !9
  %122 = sext i32 %121 to i64
  %123 = getelementptr inbounds [13 x i32], ptr %11, i64 0, i64 %122
  %124 = load i32, ptr %123, align 4, !tbaa !9
  %125 = and i32 %124, 65280
  %126 = lshr i32 %125, 8
  %127 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %120, ptr noundef @.str.4, i32 noundef %126) #4
  %128 = load ptr, ptr %12, align 8, !tbaa !5
  %129 = load i32, ptr %17, align 4, !tbaa !9
  %130 = sext i32 %129 to i64
  %131 = getelementptr inbounds [13 x i32], ptr %11, i64 0, i64 %130
  %132 = load i32, ptr %131, align 4, !tbaa !9
  %133 = and i32 %132, 16711680
  %134 = lshr i32 %133, 16
  %135 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %128, ptr noundef @.str.4, i32 noundef %134) #4
  %136 = load ptr, ptr %12, align 8, !tbaa !5
  %137 = load i32, ptr %17, align 4, !tbaa !9
  %138 = sext i32 %137 to i64
  %139 = getelementptr inbounds [13 x i32], ptr %11, i64 0, i64 %138
  %140 = load i32, ptr %139, align 4, !tbaa !9
  %141 = and i32 %140, -16777216
  %142 = lshr i32 %141, 24
  %143 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %136, ptr noundef @.str.4, i32 noundef %142) #4
  br label %144

144:                                              ; preds = %112
  %145 = load i32, ptr %17, align 4, !tbaa !9
  %146 = add nsw i32 %145, 1
  store i32 %146, ptr %17, align 4, !tbaa !9
  br label %109, !llvm.loop !13

147:                                              ; preds = %109
  store i32 0, ptr %16, align 4, !tbaa !9
  br label %148

148:                                              ; preds = %276, %147
  %149 = load i32, ptr %16, align 4, !tbaa !9
  %150 = load i32, ptr %22, align 4, !tbaa !9
  %151 = icmp slt i32 %149, %150
  br i1 %151, label %152, label %279

152:                                              ; preds = %148
  store i32 0, ptr %15, align 4, !tbaa !9
  br label %153

153:                                              ; preds = %257, %152
  %154 = load i32, ptr %15, align 4, !tbaa !9
  %155 = load i32, ptr %21, align 4, !tbaa !9
  %156 = icmp slt i32 %154, %155
  br i1 %156, label %157, label %260

157:                                              ; preds = %153
  %158 = load i32, ptr %10, align 4, !tbaa !9
  %159 = icmp eq i32 %158, 1
  br i1 %159, label %160, label %191

160:                                              ; preds = %157
  %161 = load ptr, ptr %7, align 8, !tbaa !5
  %162 = load i32, ptr %15, align 4, !tbaa !9
  %163 = load i32, ptr %16, align 4, !tbaa !9
  %164 = load i32, ptr %21, align 4, !tbaa !9
  %165 = mul nsw i32 %163, %164
  %166 = add nsw i32 %162, %165
  %167 = sext i32 %166 to i64
  %168 = getelementptr inbounds i8, ptr %161, i64 %167
  %169 = load i8, ptr %168, align 1, !tbaa !14
  %170 = zext i8 %169 to i32
  store i32 %170, ptr %18, align 4, !tbaa !9
  %171 = load ptr, ptr %7, align 8, !tbaa !5
  %172 = load i32, ptr %15, align 4, !tbaa !9
  %173 = load i32, ptr %16, align 4, !tbaa !9
  %174 = load i32, ptr %21, align 4, !tbaa !9
  %175 = mul nsw i32 %173, %174
  %176 = add nsw i32 %172, %175
  %177 = sext i32 %176 to i64
  %178 = getelementptr inbounds i8, ptr %171, i64 %177
  %179 = load i8, ptr %178, align 1, !tbaa !14
  %180 = zext i8 %179 to i32
  store i32 %180, ptr %19, align 4, !tbaa !9
  %181 = load ptr, ptr %7, align 8, !tbaa !5
  %182 = load i32, ptr %15, align 4, !tbaa !9
  %183 = load i32, ptr %16, align 4, !tbaa !9
  %184 = load i32, ptr %21, align 4, !tbaa !9
  %185 = mul nsw i32 %183, %184
  %186 = add nsw i32 %182, %185
  %187 = sext i32 %186 to i64
  %188 = getelementptr inbounds i8, ptr %181, i64 %187
  %189 = load i8, ptr %188, align 1, !tbaa !14
  %190 = zext i8 %189 to i32
  store i32 %190, ptr %20, align 4, !tbaa !9
  br label %247

191:                                              ; preds = %157
  call void @llvm.lifetime.start.p0(i64 4, ptr %23) #4
  store i32 3, ptr %23, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %24) #4
  store i32 0, ptr %24, align 4, !tbaa !9
  %192 = load i32, ptr %10, align 4, !tbaa !9
  %193 = icmp eq i32 %192, 4
  br i1 %193, label %194, label %195

194:                                              ; preds = %191
  store i32 4, ptr %23, align 4, !tbaa !9
  store i32 1, ptr %24, align 4, !tbaa !9
  br label %195

195:                                              ; preds = %194, %191
  %196 = load ptr, ptr %7, align 8, !tbaa !5
  %197 = load i32, ptr %15, align 4, !tbaa !9
  %198 = load i32, ptr %23, align 4, !tbaa !9
  %199 = mul nsw i32 %197, %198
  %200 = load i32, ptr %16, align 4, !tbaa !9
  %201 = load i32, ptr %21, align 4, !tbaa !9
  %202 = mul nsw i32 %200, %201
  %203 = load i32, ptr %23, align 4, !tbaa !9
  %204 = mul nsw i32 %202, %203
  %205 = add nsw i32 %199, %204
  %206 = load i32, ptr %24, align 4, !tbaa !9
  %207 = add nsw i32 %205, %206
  %208 = add nsw i32 %207, 0
  %209 = sext i32 %208 to i64
  %210 = getelementptr inbounds i8, ptr %196, i64 %209
  %211 = load i8, ptr %210, align 1, !tbaa !14
  %212 = zext i8 %211 to i32
  store i32 %212, ptr %18, align 4, !tbaa !9
  %213 = load ptr, ptr %7, align 8, !tbaa !5
  %214 = load i32, ptr %15, align 4, !tbaa !9
  %215 = load i32, ptr %23, align 4, !tbaa !9
  %216 = mul nsw i32 %214, %215
  %217 = load i32, ptr %16, align 4, !tbaa !9
  %218 = load i32, ptr %21, align 4, !tbaa !9
  %219 = mul nsw i32 %217, %218
  %220 = load i32, ptr %23, align 4, !tbaa !9
  %221 = mul nsw i32 %219, %220
  %222 = add nsw i32 %216, %221
  %223 = load i32, ptr %24, align 4, !tbaa !9
  %224 = add nsw i32 %222, %223
  %225 = add nsw i32 %224, 1
  %226 = sext i32 %225 to i64
  %227 = getelementptr inbounds i8, ptr %213, i64 %226
  %228 = load i8, ptr %227, align 1, !tbaa !14
  %229 = zext i8 %228 to i32
  store i32 %229, ptr %19, align 4, !tbaa !9
  %230 = load ptr, ptr %7, align 8, !tbaa !5
  %231 = load i32, ptr %15, align 4, !tbaa !9
  %232 = load i32, ptr %23, align 4, !tbaa !9
  %233 = mul nsw i32 %231, %232
  %234 = load i32, ptr %16, align 4, !tbaa !9
  %235 = load i32, ptr %21, align 4, !tbaa !9
  %236 = mul nsw i32 %234, %235
  %237 = load i32, ptr %23, align 4, !tbaa !9
  %238 = mul nsw i32 %236, %237
  %239 = add nsw i32 %233, %238
  %240 = load i32, ptr %24, align 4, !tbaa !9
  %241 = add nsw i32 %239, %240
  %242 = add nsw i32 %241, 2
  %243 = sext i32 %242 to i64
  %244 = getelementptr inbounds i8, ptr %230, i64 %243
  %245 = load i8, ptr %244, align 1, !tbaa !14
  %246 = zext i8 %245 to i32
  store i32 %246, ptr %20, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %24) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %23) #4
  br label %247

247:                                              ; preds = %195, %160
  %248 = load ptr, ptr %12, align 8, !tbaa !5
  %249 = load i32, ptr %20, align 4, !tbaa !9
  %250 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %248, ptr noundef @.str.4, i32 noundef %249) #4
  %251 = load ptr, ptr %12, align 8, !tbaa !5
  %252 = load i32, ptr %19, align 4, !tbaa !9
  %253 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %251, ptr noundef @.str.4, i32 noundef %252) #4
  %254 = load ptr, ptr %12, align 8, !tbaa !5
  %255 = load i32, ptr %18, align 4, !tbaa !9
  %256 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %254, ptr noundef @.str.4, i32 noundef %255) #4
  br label %257

257:                                              ; preds = %247
  %258 = load i32, ptr %15, align 4, !tbaa !9
  %259 = add nsw i32 %258, 1
  store i32 %259, ptr %15, align 4, !tbaa !9
  br label %153, !llvm.loop !15

260:                                              ; preds = %153
  %261 = load i32, ptr %13, align 4, !tbaa !9
  %262 = icmp ne i32 %261, 0
  br i1 %262, label %263, label %275

263:                                              ; preds = %260
  store i32 1, ptr %17, align 4, !tbaa !9
  br label %264

264:                                              ; preds = %271, %263
  %265 = load i32, ptr %17, align 4, !tbaa !9
  %266 = load i32, ptr %13, align 4, !tbaa !9
  %267 = icmp sle i32 %265, %266
  br i1 %267, label %268, label %274

268:                                              ; preds = %264
  %269 = load ptr, ptr %12, align 8, !tbaa !5
  %270 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %269, ptr noundef @.str.4, i32 noundef 0) #4
  br label %271

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

274:                                              ; preds = %264
  br label %275

275:                                              ; preds = %274, %260
  br label %276

276:                                              ; preds = %275
  %277 = load i32, ptr %16, align 4, !tbaa !9
  %278 = add nsw i32 %277, 1
  store i32 %278, ptr %16, align 4, !tbaa !9
  br label %148, !llvm.loop !17

279:                                              ; preds = %148
  %280 = load ptr, ptr %12, align 8, !tbaa !5
  %281 = call i32 @fclose(ptr noundef %280)
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 52, ptr %11) #4
  ret i32 0
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #3 = { 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 }

!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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = !{!7, !7, i64 0}
!15 = distinct !{!15, !12}
!16 = distinct !{!16, !12}
!17 = distinct !{!17, !12}


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

@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: nofree nounwind
declare noalias noundef ptr @fopen(ptr nocapture noundef readonly, ptr nocapture noundef readonly) local_unnamed_addr #0

; Function Attrs: nofree nounwind
declare noundef i32 @fclose(ptr nocapture noundef) local_unnamed_addr #0

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

; Function Attrs: nofree nounwind uwtable
define dso_local noundef i32 @save_image_ex(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1, i32 noundef %2, i32 noundef %3, i32 noundef %4) local_unnamed_addr #1 {
.preheader100:
  %5 = mul nsw i32 %2, 3
  %6 = srem i32 %5, 4
  %7 = sub nsw i32 4, %6
  %8 = icmp eq i32 %6, 0
  %spec.store.select = select i1 %8, i32 0, i32 %7
  %9 = add nsw i32 %spec.store.select, %5
  %10 = mul nsw i32 %9, %3
  %11 = add nsw i32 %10, 54
  %12 = tail call noalias ptr @fopen(ptr noundef %0, ptr noundef nonnull @.str.2)
  %13 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %12, ptr noundef nonnull @.str.3) #2
  %14 = and i32 %11, 255
  %15 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %12, ptr noundef nonnull @.str.4, i32 noundef %14) #2
  %16 = lshr i32 %11, 8
  %17 = and i32 %16, 255
  %18 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %12, ptr noundef nonnull @.str.4, i32 noundef %17) #2
  %19 = lshr i32 %11, 16
  %20 = and i32 %19, 255
  %21 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %12, ptr noundef nonnull @.str.4, i32 noundef %20) #2
  %22 = lshr i32 %11, 24
  %23 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %12, ptr noundef nonnull @.str.4, i32 noundef %22) #2
  %24 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %12, ptr noundef nonnull @.str.4, i32 noundef 0) #2
  %25 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %12, ptr noundef nonnull @.str.4, i32 noundef 0) #2
  %26 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %12, ptr noundef nonnull @.str.4, i32 noundef 0) #2
  %27 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %12, ptr noundef nonnull @.str.4, i32 noundef 0) #2
  %28 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %12, ptr noundef nonnull @.str.4, i32 noundef 54) #2
  %29 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %12, ptr noundef nonnull @.str.4, i32 noundef 0) #2
  %30 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %12, ptr noundef nonnull @.str.4, i32 noundef 0) #2
  %31 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %12, ptr noundef nonnull @.str.4, i32 noundef 0) #2
  %32 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %12, ptr noundef nonnull @.str.4, i32 noundef 40) #2
  %33 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %12, ptr noundef nonnull @.str.4, i32 noundef 0) #2
  %34 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %12, ptr noundef nonnull @.str.4, i32 noundef 0) #2
  %35 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %12, ptr noundef nonnull @.str.4, i32 noundef 0) #2
  %36 = and i32 %2, 255
  %37 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %12, ptr noundef nonnull @.str.4, i32 noundef %36) #2
  %38 = lshr i32 %2, 8
  %39 = and i32 %38, 255
  %40 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %12, ptr noundef nonnull @.str.4, i32 noundef %39) #2
  %41 = lshr i32 %2, 16
  %42 = and i32 %41, 255
  %43 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %12, ptr noundef nonnull @.str.4, i32 noundef %42) #2
  %44 = lshr i32 %2, 24
  %45 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %12, ptr noundef nonnull @.str.4, i32 noundef %44) #2
  %46 = and i32 %3, 255
  %47 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %12, ptr noundef nonnull @.str.4, i32 noundef %46) #2
  %48 = lshr i32 %3, 8
  %49 = and i32 %48, 255
  %50 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %12, ptr noundef nonnull @.str.4, i32 noundef %49) #2
  %51 = lshr i32 %3, 16
  %52 = and i32 %51, 255
  %53 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %12, ptr noundef nonnull @.str.4, i32 noundef %52) #2
  %54 = lshr i32 %3, 24
  %55 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %12, ptr noundef nonnull @.str.4, i32 noundef %54) #2
  %56 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %12, ptr noundef nonnull @.str.4, i32 noundef 1) #2
  %57 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %12, ptr noundef nonnull @.str.4, i32 noundef 0) #2
  %58 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %12, ptr noundef nonnull @.str.4, i32 noundef 24) #2
  %59 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %12, ptr noundef nonnull @.str.4, i32 noundef 0) #2
  %60 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %12, ptr noundef nonnull @.str.4, i32 noundef 0) #2
  %61 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %12, ptr noundef nonnull @.str.4, i32 noundef 0) #2
  %62 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %12, ptr noundef nonnull @.str.4, i32 noundef 0) #2
  %63 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %12, ptr noundef nonnull @.str.4, i32 noundef 0) #2
  %64 = and i32 %10, 255
  %65 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %12, ptr noundef nonnull @.str.4, i32 noundef %64) #2
  %66 = lshr i32 %10, 8
  %67 = and i32 %66, 255
  %68 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %12, ptr noundef nonnull @.str.4, i32 noundef %67) #2
  %69 = lshr i32 %10, 16
  %70 = and i32 %69, 255
  %71 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %12, ptr noundef nonnull @.str.4, i32 noundef %70) #2
  %72 = lshr i32 %10, 24
  %73 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %12, ptr noundef nonnull @.str.4, i32 noundef %72) #2
  %74 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %12, ptr noundef nonnull @.str.4, i32 noundef 0) #2
  %75 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %12, ptr noundef nonnull @.str.4, i32 noundef 0) #2
  %76 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %12, ptr noundef nonnull @.str.4, i32 noundef 0) #2
  %77 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %12, ptr noundef nonnull @.str.4, i32 noundef 0) #2
  %78 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %12, ptr noundef nonnull @.str.4, i32 noundef 0) #2
  %79 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %12, ptr noundef nonnull @.str.4, i32 noundef 0) #2
  %80 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %12, ptr noundef nonnull @.str.4, i32 noundef 0) #2
  %81 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %12, ptr noundef nonnull @.str.4, i32 noundef 0) #2
  %82 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %12, ptr noundef nonnull @.str.4, i32 noundef 0) #2
  %83 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %12, ptr noundef nonnull @.str.4, i32 noundef 0) #2
  %84 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %12, ptr noundef nonnull @.str.4, i32 noundef 0) #2
  %85 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %12, ptr noundef nonnull @.str.4, i32 noundef 0) #2
  %86 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %12, ptr noundef nonnull @.str.4, i32 noundef 0) #2
  %87 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %12, ptr noundef nonnull @.str.4, i32 noundef 0) #2
  %88 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %12, ptr noundef nonnull @.str.4, i32 noundef 0) #2
  %89 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %12, ptr noundef nonnull @.str.4, i32 noundef 0) #2
  %90 = icmp sgt i32 %3, 0
  br i1 %90, label %.preheader99.lr.ph, label %._crit_edge108

.preheader99.lr.ph:                               ; preds = %.preheader100
  %91 = icmp sgt i32 %2, 0
  %.not98104 = icmp eq i32 %spec.store.select, 0
  br i1 %91, label %.preheader99.us.preheader, label %.preheader99.lr.ph.split

.preheader99.us.preheader:                        ; preds = %.preheader99.lr.ph
  %92 = zext nneg i32 %2 to i64
  %wide.trip.count126 = zext nneg i32 %3 to i64
  br label %.preheader99.us

.preheader99.us:                                  ; preds = %.preheader99.us.preheader, %.loopexit.us
  %indvars.iv123 = phi i64 [ 0, %.preheader99.us.preheader ], [ %indvars.iv.next124, %.loopexit.us ]
  %93 = mul nuw nsw i64 %indvars.iv123, %92
  %invariant.gep = getelementptr inbounds i8, ptr %1, i64 %93
  br label %96

.lr.ph106.us:                                     ; preds = %._crit_edge.us, %.lr.ph106.us
  %.2105.us = phi i32 [ %95, %.lr.ph106.us ], [ 1, %._crit_edge.us ]
  %94 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %12, ptr noundef nonnull @.str.4, i32 noundef 0) #2
  %95 = add nuw nsw i32 %.2105.us, 1
  %exitcond122.not = icmp eq i32 %.2105.us, %spec.store.select
  br i1 %exitcond122.not, label %.loopexit.us, label %.lr.ph106.us, !llvm.loop !5

.loopexit.us:                                     ; preds = %.lr.ph106.us, %._crit_edge.us
  %indvars.iv.next124 = add nuw nsw i64 %indvars.iv123, 1
  %exitcond127.not = icmp eq i64 %indvars.iv.next124, %wide.trip.count126
  br i1 %exitcond127.not, label %._crit_edge108, label %.preheader99.us, !llvm.loop !7

96:                                               ; preds = %.preheader99.us, %115
  %indvars.iv = phi i64 [ 0, %.preheader99.us ], [ %indvars.iv.next, %115 ]
  switch i32 %4, label %101 [
    i32 1, label %98
    i32 4, label %97
  ]

97:                                               ; preds = %96
  br label %101

98:                                               ; preds = %96
  %gep = getelementptr inbounds i8, ptr %invariant.gep, i64 %indvars.iv
  %99 = load i8, ptr %gep, align 1, !tbaa !8
  %100 = zext i8 %99 to i32
  br label %115

101:                                              ; preds = %97, %96
  %.089.us = phi i64 [ 4, %97 ], [ 3, %96 ]
  %.0.us = phi i64 [ 1, %97 ], [ 0, %96 ]
  %102 = add nuw nsw i64 %indvars.iv, %93
  %103 = mul i64 %.089.us, %102
  %104 = add i64 %103, %.0.us
  %sext = shl i64 %104, 32
  %105 = ashr exact i64 %sext, 32
  %106 = getelementptr inbounds i8, ptr %1, i64 %105
  %107 = load i8, ptr %106, align 1, !tbaa !8
  %108 = zext i8 %107 to i32
  %109 = getelementptr i8, ptr %106, i64 1
  %110 = load i8, ptr %109, align 1, !tbaa !8
  %111 = zext i8 %110 to i32
  %112 = getelementptr i8, ptr %106, i64 2
  %113 = load i8, ptr %112, align 1, !tbaa !8
  %114 = zext i8 %113 to i32
  br label %115

115:                                              ; preds = %101, %98
  %.093.us = phi i32 [ %100, %98 ], [ %108, %101 ]
  %.092.us = phi i32 [ %100, %98 ], [ %111, %101 ]
  %.091.us = phi i32 [ %100, %98 ], [ %114, %101 ]
  %116 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %12, ptr noundef nonnull @.str.4, i32 noundef %.091.us) #2
  %117 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %12, ptr noundef nonnull @.str.4, i32 noundef %.092.us) #2
  %118 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %12, ptr noundef nonnull @.str.4, i32 noundef %.093.us) #2
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond121.not = icmp eq i64 %indvars.iv.next, %92
  br i1 %exitcond121.not, label %._crit_edge.us, label %96, !llvm.loop !11

._crit_edge.us:                                   ; preds = %115
  br i1 %.not98104, label %.loopexit.us, label %.lr.ph106.us

.preheader99.lr.ph.split:                         ; preds = %.preheader99.lr.ph
  %.not = icmp eq i32 %spec.store.select, 0
  br i1 %.not, label %._crit_edge108, label %.preheader99

.preheader99:                                     ; preds = %.preheader99.lr.ph.split, %..loopexit_crit_edge
  %.095107 = phi i32 [ %122, %..loopexit_crit_edge ], [ 0, %.preheader99.lr.ph.split ]
  br label %119

119:                                              ; preds = %.preheader99, %119
  %.2105 = phi i32 [ 1, %.preheader99 ], [ %121, %119 ]
  %120 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %12, ptr noundef nonnull @.str.4, i32 noundef 0) #2
  %121 = add nuw nsw i32 %.2105, 1
  %exitcond.not = icmp eq i32 %.2105, %spec.store.select
  br i1 %exitcond.not, label %..loopexit_crit_edge, label %119, !llvm.loop !5

..loopexit_crit_edge:                             ; preds = %119
  %122 = add nuw nsw i32 %.095107, 1
  %exitcond119.not = icmp eq i32 %122, %3
  br i1 %exitcond119.not, label %._crit_edge108, label %.preheader99, !llvm.loop !7

._crit_edge108:                                   ; preds = %..loopexit_crit_edge, %.loopexit.us, %.preheader99.lr.ph.split, %.preheader100
  %123 = tail call i32 @fclose(ptr noundef %12)
  ret i32 0
}

attributes #0 = { 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 #1 = { nofree 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 #2 = { 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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = distinct !{!7, !6}
!8 = !{!9, !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = distinct !{!11, !6}


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