; LLVM IR from OAID/AutoKernel :: autokernel_plugin/tests/common/tengine_operations.ll (Z10save_image5imagePKc)

; 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.image = type { i32, i32, i32, ptr }

@stderr = external global ptr, align 8
@.str.107 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.108 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.109 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.110 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.111 = external hidden unnamed_addr constant [26 x i8], align 1

; Function Attrs: nounwind
declare void @free(ptr noundef) #0

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

; 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
declare dso_local i32 @stbi_write_bmp(ptr noundef, i32 noundef, i32 noundef, i32 noundef, ptr noundef) #2

; Function Attrs: mustprogress uwtable
declare dso_local i32 @stbi_write_tga(ptr noundef, i32 noundef, i32 noundef, i32 noundef, ptr noundef) #2

; Function Attrs: mustprogress uwtable
declare dso_local i32 @stbi_write_png(ptr noundef, i32 noundef, i32 noundef, i32 noundef, ptr noundef, i32 noundef) #2

; Function Attrs: mustprogress uwtable
declare dso_local i32 @stbi_write_jpg(ptr noundef, i32 noundef, i32 noundef, i32 noundef, ptr noundef, i32 noundef) #2

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

; Function Attrs: nounwind allocsize(0,1)
declare noalias ptr @calloc(i64 noundef, i64 noundef) #3

; Function Attrs: mustprogress uwtable
define dso_local void @_Z10save_image5imagePKc(ptr noundef byval(%struct.image) align 8 %0, ptr noundef %1) #2 {
  %3 = alloca ptr, align 8
  %4 = alloca [256 x i8], align 16
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  store ptr %1, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 256, ptr %4) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  %12 = getelementptr inbounds %struct.image, ptr %0, i32 0, i32 0
  %13 = load i32, ptr %12, align 8, !tbaa !9
  %14 = getelementptr inbounds %struct.image, ptr %0, i32 0, i32 1
  %15 = load i32, ptr %14, align 4, !tbaa !12
  %16 = mul nsw i32 %13, %15
  %17 = getelementptr inbounds %struct.image, ptr %0, i32 0, i32 2
  %18 = load i32, ptr %17, align 8, !tbaa !13
  %19 = mul nsw i32 %16, %18
  %20 = sext i32 %19 to i64
  %21 = call noalias ptr @calloc(i64 noundef %20, i64 noundef 1) #6
  store ptr %21, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  store i32 0, ptr %7, align 4, !tbaa !14
  br label %22

22:                                               ; preds = %65, %2
  %23 = load i32, ptr %7, align 4, !tbaa !14
  %24 = getelementptr inbounds %struct.image, ptr %0, i32 0, i32 2
  %25 = load i32, ptr %24, align 8, !tbaa !13
  %26 = icmp slt i32 %23, %25
  br i1 %26, label %27, label %68

27:                                               ; preds = %22
  store i32 0, ptr %6, align 4, !tbaa !14
  br label %28

28:                                               ; preds = %61, %27
  %29 = load i32, ptr %6, align 4, !tbaa !14
  %30 = getelementptr inbounds %struct.image, ptr %0, i32 0, i32 0
  %31 = load i32, ptr %30, align 8, !tbaa !9
  %32 = getelementptr inbounds %struct.image, ptr %0, i32 0, i32 1
  %33 = load i32, ptr %32, align 4, !tbaa !12
  %34 = mul nsw i32 %31, %33
  %35 = icmp slt i32 %29, %34
  br i1 %35, label %36, label %64

36:                                               ; preds = %28
  %37 = getelementptr inbounds %struct.image, ptr %0, i32 0, i32 3
  %38 = load ptr, ptr %37, align 8, !tbaa !15
  %39 = load i32, ptr %6, align 4, !tbaa !14
  %40 = load i32, ptr %7, align 4, !tbaa !14
  %41 = getelementptr inbounds %struct.image, ptr %0, i32 0, i32 0
  %42 = load i32, ptr %41, align 8, !tbaa !9
  %43 = mul nsw i32 %40, %42
  %44 = getelementptr inbounds %struct.image, ptr %0, i32 0, i32 1
  %45 = load i32, ptr %44, align 4, !tbaa !12
  %46 = mul nsw i32 %43, %45
  %47 = add nsw i32 %39, %46
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds float, ptr %38, i64 %48
  %50 = load float, ptr %49, align 4, !tbaa !16
  %51 = fptoui float %50 to i8
  %52 = load ptr, ptr %5, align 8, !tbaa !5
  %53 = load i32, ptr %6, align 4, !tbaa !14
  %54 = getelementptr inbounds %struct.image, ptr %0, i32 0, i32 2
  %55 = load i32, ptr %54, align 8, !tbaa !13
  %56 = mul nsw i32 %53, %55
  %57 = load i32, ptr %7, align 4, !tbaa !14
  %58 = add nsw i32 %56, %57
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds i8, ptr %52, i64 %59
  store i8 %51, ptr %60, align 1, !tbaa !18
  br label %61

61:                                               ; preds = %36
  %62 = load i32, ptr %6, align 4, !tbaa !14
  %63 = add nsw i32 %62, 1
  store i32 %63, ptr %6, align 4, !tbaa !14
  br label %28, !llvm.loop !19

64:                                               ; preds = %28
  br label %65

65:                                               ; preds = %64
  %66 = load i32, ptr %7, align 4, !tbaa !14
  %67 = add nsw i32 %66, 1
  store i32 %67, ptr %7, align 4, !tbaa !14
  br label %22, !llvm.loop !21

68:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  store i32 0, ptr %8, align 4, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  store i32 0, ptr %9, align 4, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  %69 = load ptr, ptr %3, align 8, !tbaa !5
  %70 = call i64 @strlen(ptr noundef %69) #7
  %71 = trunc i64 %70 to i32
  store i32 %71, ptr %10, align 4, !tbaa !14
  %72 = load ptr, ptr %3, align 8, !tbaa !5
  %73 = load i32, ptr %10, align 4, !tbaa !14
  %74 = sub nsw i32 %73, 2
  %75 = sext i32 %74 to i64
  %76 = getelementptr inbounds i8, ptr %72, i64 %75
  %77 = load i8, ptr %76, align 1, !tbaa !18
  %78 = sext i8 %77 to i32
  %79 = icmp eq i32 %78, 106
  br i1 %79, label %80, label %98

80:                                               ; preds = %68
  %81 = load ptr, ptr %3, align 8, !tbaa !5
  %82 = load i32, ptr %10, align 4, !tbaa !14
  %83 = sub nsw i32 %82, 1
  %84 = sext i32 %83 to i64
  %85 = getelementptr inbounds i8, ptr %81, i64 %84
  %86 = load i8, ptr %85, align 1, !tbaa !18
  %87 = sext i8 %86 to i32
  %88 = icmp eq i32 %87, 112
  br i1 %88, label %89, label %98

89:                                               ; preds = %80
  %90 = load ptr, ptr %3, align 8, !tbaa !5
  %91 = load i32, ptr %10, align 4, !tbaa !14
  %92 = sext i32 %91 to i64
  %93 = getelementptr inbounds i8, ptr %90, i64 %92
  %94 = load i8, ptr %93, align 1, !tbaa !18
  %95 = sext i8 %94 to i32
  %96 = icmp eq i32 %95, 103
  br i1 %96, label %97, label %98

97:                                               ; preds = %89
  store i32 0, ptr %9, align 4, !tbaa !14
  br label %98

98:                                               ; preds = %97, %89, %80, %68
  %99 = load ptr, ptr %3, align 8, !tbaa !5
  %100 = load i32, ptr %10, align 4, !tbaa !14
  %101 = sub nsw i32 %100, 2
  %102 = sext i32 %101 to i64
  %103 = getelementptr inbounds i8, ptr %99, i64 %102
  %104 = load i8, ptr %103, align 1, !tbaa !18
  %105 = sext i8 %104 to i32
  %106 = icmp eq i32 %105, 112
  br i1 %106, label %107, label %125

107:                                              ; preds = %98
  %108 = load ptr, ptr %3, align 8, !tbaa !5
  %109 = load i32, ptr %10, align 4, !tbaa !14
  %110 = sub nsw i32 %109, 1
  %111 = sext i32 %110 to i64
  %112 = getelementptr inbounds i8, ptr %108, i64 %111
  %113 = load i8, ptr %112, align 1, !tbaa !18
  %114 = sext i8 %113 to i32
  %115 = icmp eq i32 %114, 110
  br i1 %115, label %116, label %125

116:                                              ; preds = %107
  %117 = load ptr, ptr %3, align 8, !tbaa !5
  %118 = load i32, ptr %10, align 4, !tbaa !14
  %119 = sext i32 %118 to i64
  %120 = getelementptr inbounds i8, ptr %117, i64 %119
  %121 = load i8, ptr %120, align 1, !tbaa !18
  %122 = sext i8 %121 to i32
  %123 = icmp eq i32 %122, 103
  br i1 %123, label %124, label %125

124:                                              ; preds = %116
  store i32 1, ptr %9, align 4, !tbaa !14
  br label %125

125:                                              ; preds = %124, %116, %107, %98
  %126 = load ptr, ptr %3, align 8, !tbaa !5
  %127 = load i32, ptr %10, align 4, !tbaa !14
  %128 = sub nsw i32 %127, 2
  %129 = sext i32 %128 to i64
  %130 = getelementptr inbounds i8, ptr %126, i64 %129
  %131 = load i8, ptr %130, align 1, !tbaa !18
  %132 = sext i8 %131 to i32
  %133 = icmp eq i32 %132, 116
  br i1 %133, label %134, label %152

134:                                              ; preds = %125
  %135 = load ptr, ptr %3, align 8, !tbaa !5
  %136 = load i32, ptr %10, align 4, !tbaa !14
  %137 = sub nsw i32 %136, 1
  %138 = sext i32 %137 to i64
  %139 = getelementptr inbounds i8, ptr %135, i64 %138
  %140 = load i8, ptr %139, align 1, !tbaa !18
  %141 = sext i8 %140 to i32
  %142 = icmp eq i32 %141, 103
  br i1 %142, label %143, label %152

143:                                              ; preds = %134
  %144 = load ptr, ptr %3, align 8, !tbaa !5
  %145 = load i32, ptr %10, align 4, !tbaa !14
  %146 = sext i32 %145 to i64
  %147 = getelementptr inbounds i8, ptr %144, i64 %146
  %148 = load i8, ptr %147, align 1, !tbaa !18
  %149 = sext i8 %148 to i32
  %150 = icmp eq i32 %149, 97
  br i1 %150, label %151, label %152

151:                                              ; preds = %143
  store i32 2, ptr %9, align 4, !tbaa !14
  br label %152

152:                                              ; preds = %151, %143, %134, %125
  %153 = load ptr, ptr %3, align 8, !tbaa !5
  %154 = load i32, ptr %10, align 4, !tbaa !14
  %155 = sub nsw i32 %154, 2
  %156 = sext i32 %155 to i64
  %157 = getelementptr inbounds i8, ptr %153, i64 %156
  %158 = load i8, ptr %157, align 1, !tbaa !18
  %159 = sext i8 %158 to i32
  %160 = icmp eq i32 %159, 98
  br i1 %160, label %161, label %179

161:                                              ; preds = %152
  %162 = load ptr, ptr %3, align 8, !tbaa !5
  %163 = load i32, ptr %10, align 4, !tbaa !14
  %164 = sub nsw i32 %163, 1
  %165 = sext i32 %164 to i64
  %166 = getelementptr inbounds i8, ptr %162, i64 %165
  %167 = load i8, ptr %166, align 1, !tbaa !18
  %168 = sext i8 %167 to i32
  %169 = icmp eq i32 %168, 109
  br i1 %169, label %170, label %179

170:                                              ; preds = %161
  %171 = load ptr, ptr %3, align 8, !tbaa !5
  %172 = load i32, ptr %10, align 4, !tbaa !14
  %173 = sext i32 %172 to i64
  %174 = getelementptr inbounds i8, ptr %171, i64 %173
  %175 = load i8, ptr %174, align 1, !tbaa !18
  %176 = sext i8 %175 to i32
  %177 = icmp eq i32 %176, 112
  br i1 %177, label %178, label %179

178:                                              ; preds = %170
  store i32 3, ptr %9, align 4, !tbaa !14
  br label %179

179:                                              ; preds = %178, %170, %161, %152
  %180 = load i32, ptr %9, align 4, !tbaa !14
  switch i32 %180, label %238 [
    i32 0, label %181
    i32 1, label %194
    i32 2, label %212
    i32 3, label %225
  ]

181:                                              ; preds = %179
  %182 = getelementptr inbounds [256 x i8], ptr %4, i64 0, i64 0
  %183 = load ptr, ptr %3, align 8, !tbaa !5
  %184 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef %182, ptr noundef @.str.107, ptr noundef %183) #5
  %185 = getelementptr inbounds [256 x i8], ptr %4, i64 0, i64 0
  %186 = getelementptr inbounds %struct.image, ptr %0, i32 0, i32 0
  %187 = load i32, ptr %186, align 8, !tbaa !9
  %188 = getelementptr inbounds %struct.image, ptr %0, i32 0, i32 1
  %189 = load i32, ptr %188, align 4, !tbaa !12
  %190 = getelementptr inbounds %struct.image, ptr %0, i32 0, i32 2
  %191 = load i32, ptr %190, align 8, !tbaa !13
  %192 = load ptr, ptr %5, align 8, !tbaa !5
  %193 = call i32 @stbi_write_jpg(ptr noundef %185, i32 noundef %187, i32 noundef %189, i32 noundef %191, ptr noundef %192, i32 noundef 80)
  store i32 %193, ptr %8, align 4, !tbaa !14
  br label %239

194:                                              ; preds = %179
  %195 = getelementptr inbounds [256 x i8], ptr %4, i64 0, i64 0
  %196 = load ptr, ptr %3, align 8, !tbaa !5
  %197 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef %195, ptr noundef @.str.108, ptr noundef %196) #5
  %198 = getelementptr inbounds [256 x i8], ptr %4, i64 0, i64 0
  %199 = getelementptr inbounds %struct.image, ptr %0, i32 0, i32 0
  %200 = load i32, ptr %199, align 8, !tbaa !9
  %201 = getelementptr inbounds %struct.image, ptr %0, i32 0, i32 1
  %202 = load i32, ptr %201, align 4, !tbaa !12
  %203 = getelementptr inbounds %struct.image, ptr %0, i32 0, i32 2
  %204 = load i32, ptr %203, align 8, !tbaa !13
  %205 = load ptr, ptr %5, align 8, !tbaa !5
  %206 = getelementptr inbounds %struct.image, ptr %0, i32 0, i32 0
  %207 = load i32, ptr %206, align 8, !tbaa !9
  %208 = getelementptr inbounds %struct.image, ptr %0, i32 0, i32 2
  %209 = load i32, ptr %208, align 8, !tbaa !13
  %210 = mul nsw i32 %207, %209
  %211 = call i32 @stbi_write_png(ptr noundef %198, i32 noundef %200, i32 noundef %202, i32 noundef %204, ptr noundef %205, i32 noundef %210)
  store i32 %211, ptr %8, align 4, !tbaa !14
  br label %239

212:                                              ; preds = %179
  %213 = getelementptr inbounds [256 x i8], ptr %4, i64 0, i64 0
  %214 = load ptr, ptr %3, align 8, !tbaa !5
  %215 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef %213, ptr noundef @.str.109, ptr noundef %214) #5
  %216 = getelementptr inbounds [256 x i8], ptr %4, i64 0, i64 0
  %217 = getelementptr inbounds %struct.image, ptr %0, i32 0, i32 0
  %218 = load i32, ptr %217, align 8, !tbaa !9
  %219 = getelementptr inbounds %struct.image, ptr %0, i32 0, i32 1
  %220 = load i32, ptr %219, align 4, !tbaa !12
  %221 = getelementptr inbounds %struct.image, ptr %0, i32 0, i32 2
  %222 = load i32, ptr %221, align 8, !tbaa !13
  %223 = load ptr, ptr %5, align 8, !tbaa !5
  %224 = call i32 @stbi_write_tga(ptr noundef %216, i32 noundef %218, i32 noundef %220, i32 noundef %222, ptr noundef %223)
  store i32 %224, ptr %8, align 4, !tbaa !14
  br label %239

225:                                              ; preds = %179
  %226 = getelementptr inbounds [256 x i8], ptr %4, i64 0, i64 0
  %227 = load ptr, ptr %3, align 8, !tbaa !5
  %228 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef %226, ptr noundef @.str.110, ptr noundef %227) #5
  %229 = getelementptr inbounds [256 x i8], ptr %4, i64 0, i64 0
  %230 = getelementptr inbounds %struct.image, ptr %0, i32 0, i32 0
  %231 = load i32, ptr %230, align 8, !tbaa !9
  %232 = getelementptr inbounds %struct.image, ptr %0, i32 0, i32 1
  %233 = load i32, ptr %232, align 4, !tbaa !12
  %234 = getelementptr inbounds %struct.image, ptr %0, i32 0, i32 2
  %235 = load i32, ptr %234, align 8, !tbaa !13
  %236 = load ptr, ptr %5, align 8, !tbaa !5
  %237 = call i32 @stbi_write_bmp(ptr noundef %229, i32 noundef %231, i32 noundef %233, i32 noundef %235, ptr noundef %236)
  store i32 %237, ptr %8, align 4, !tbaa !14
  br label %239

238:                                              ; preds = %179
  store i32 1, ptr %11, align 4
  br label %248

239:                                              ; preds = %225, %212, %194, %181
  %240 = load ptr, ptr %5, align 8, !tbaa !5
  call void @free(ptr noundef %240) #5
  %241 = load i32, ptr %8, align 4, !tbaa !14
  %242 = icmp ne i32 %241, 0
  br i1 %242, label %247, label %243

243:                                              ; preds = %239
  %244 = load ptr, ptr @stderr, align 8, !tbaa !5
  %245 = getelementptr inbounds [256 x i8], ptr %4, i64 0, i64 0
  %246 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %244, ptr noundef @.str.111, ptr noundef %245) #5
  br label %247

247:                                              ; preds = %243, %239
  store i32 0, ptr %11, align 4
  br label %248

248:                                              ; preds = %247, %238
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 256, ptr %4) #5
  %249 = load i32, ptr %11, align 4
  switch i32 %249, label %251 [
    i32 0, label %250
    i32 1, label %250
  ]

250:                                              ; preds = %248, %248
  ret void

251:                                              ; preds = %248
  unreachable
}

; Function Attrs: nounwind willreturn memory(read)
declare i64 @strlen(ptr noundef) #4

; Function Attrs: nounwind
declare i32 @sprintf(ptr noundef, ptr noundef, ...) #0

attributes #0 = { 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { nounwind allocsize(0,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 #4 = { nounwind willreturn memory(read) "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 }
attributes #6 = { nounwind allocsize(0,1) }
attributes #7 = { nounwind willreturn memory(read) }

!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 = !{!"_ZTS5image", !11, i64 0, !11, i64 4, !11, i64 8, !6, i64 16}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !11, i64 4}
!13 = !{!10, !11, i64 8}
!14 = !{!11, !11, i64 0}
!15 = !{!10, !6, i64 16}
!16 = !{!17, !17, i64 0}
!17 = !{!"float", !7, i64 0}
!18 = !{!7, !7, i64 0}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = distinct !{!21, !20}


; 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.image = type { i32, i32, i32, ptr }

@stderr = external local_unnamed_addr global ptr, align 8
@.str.107 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.108 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.109 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.110 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.111 = external hidden unnamed_addr constant [26 x i8], align 1

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #0

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

; 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
declare dso_local i32 @stbi_write_bmp(ptr noundef, i32 noundef, i32 noundef, i32 noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
declare dso_local i32 @stbi_write_tga(ptr noundef, i32 noundef, i32 noundef, i32 noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
declare dso_local i32 @stbi_write_png(ptr noundef, i32 noundef, i32 noundef, i32 noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
declare dso_local i32 @stbi_write_jpg(ptr noundef, i32 noundef, i32 noundef, i32 noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

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

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @calloc(i64 noundef, i64 noundef) local_unnamed_addr #4

; Function Attrs: mustprogress uwtable
define dso_local void @_Z10save_image5imagePKc(ptr nocapture noundef readonly byval(%struct.image) align 8 %0, ptr noundef %1) local_unnamed_addr #2 {
  %3 = alloca [256 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 256, ptr nonnull %3) #6
  %4 = load i32, ptr %0, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 4
  %6 = load i32, ptr %5, align 4, !tbaa !11
  %7 = mul i32 %6, %4
  %8 = getelementptr inbounds i8, ptr %0, i64 8
  %9 = load i32, ptr %8, align 8, !tbaa !12
  %10 = mul nsw i32 %7, %9
  %11 = sext i32 %10 to i64
  %12 = tail call noalias ptr @calloc(i64 noundef %11, i64 noundef 1) #7
  %13 = icmp sgt i32 %9, 0
  br i1 %13, label %.preheader.lr.ph, label %._crit_edge79

.preheader.lr.ph:                                 ; preds = %2
  %14 = icmp sgt i32 %7, 0
  %15 = getelementptr inbounds i8, ptr %0, i64 16
  %16 = load ptr, ptr %15, align 8
  br i1 %14, label %.preheader.us.preheader, label %._crit_edge79

.preheader.us.preheader:                          ; preds = %.preheader.lr.ph
  %17 = zext nneg i32 %9 to i64
  %wide.trip.count85 = zext nneg i32 %9 to i64
  %wide.trip.count = zext nneg i32 %7 to i64
  %18 = getelementptr i8, ptr %12, i64 %wide.trip.count85
  %19 = getelementptr i8, ptr %18, i64 %wide.trip.count
  %scevgep = getelementptr i8, ptr %19, i64 -1
  %20 = shl nuw nsw i64 %wide.trip.count, 2
  %scevgep90 = getelementptr i8, ptr %16, i64 %20
  %min.iters.check = icmp ugt i32 %7, 7
  %ident.check.not = icmp eq i32 %9, 1
  %or.cond = and i1 %min.iters.check, %ident.check.not
  %n.vec = and i64 %wide.trip.count, 2147483640
  %cmp.n = icmp eq i64 %n.vec, %wide.trip.count
  %xtraiter = and i64 %wide.trip.count, 3
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br label %.preheader.us

.preheader.us:                                    ; preds = %.preheader.us.preheader, %._crit_edge.us
  %indvars.iv82 = phi i64 [ 0, %.preheader.us.preheader ], [ %indvars.iv.next83, %._crit_edge.us ]
  %21 = trunc nuw nsw i64 %indvars.iv82 to i32
  %factor.op.mul.reass.us = mul i32 %7, %21
  %22 = sext i32 %factor.op.mul.reass.us to i64
  %invariant.gep = getelementptr float, ptr %16, i64 %22
  %invariant.gep87 = getelementptr inbounds i8, ptr %12, i64 %indvars.iv82
  br i1 %or.cond, label %vector.memcheck, label %scalar.ph.preheader

vector.memcheck:                                  ; preds = %.preheader.us
  %23 = trunc i64 %indvars.iv82 to i32
  %24 = mul i32 %7, %23
  %25 = sext i32 %24 to i64
  %26 = shl nsw i64 %25, 2
  %scevgep91 = getelementptr i8, ptr %scevgep90, i64 %26
  %scevgep89 = getelementptr i8, ptr %16, i64 %26
  %bound0 = icmp ult ptr %12, %scevgep91
  %bound1 = icmp ult ptr %scevgep89, %scevgep
  %found.conflict = and i1 %bound0, %bound1
  br i1 %found.conflict, label %scalar.ph.preheader, label %vector.body

vector.body:                                      ; preds = %vector.memcheck, %vector.body
  %index = phi i64 [ %index.next, %vector.body ], [ 0, %vector.memcheck ]
  %27 = getelementptr float, ptr %invariant.gep, i64 %index
  %28 = getelementptr i8, ptr %27, i64 16
  %wide.load = load <4 x float>, ptr %27, align 4, !tbaa !13, !alias.scope !15
  %wide.load92 = load <4 x float>, ptr %28, align 4, !tbaa !13, !alias.scope !15
  %29 = fptoui <4 x float> %wide.load to <4 x i8>
  %30 = fptoui <4 x float> %wide.load92 to <4 x i8>
  %31 = getelementptr inbounds i8, ptr %invariant.gep87, i64 %index
  %32 = getelementptr inbounds i8, ptr %31, i64 4
  store <4 x i8> %29, ptr %31, align 1, !tbaa !18, !alias.scope !19, !noalias !15
  store <4 x i8> %30, ptr %32, align 1, !tbaa !18, !alias.scope !19, !noalias !15
  %index.next = add nuw i64 %index, 8
  %33 = icmp eq i64 %index.next, %n.vec
  br i1 %33, label %middle.block, label %vector.body, !llvm.loop !21

middle.block:                                     ; preds = %vector.body
  br i1 %cmp.n, label %._crit_edge.us, label %scalar.ph.preheader

scalar.ph.preheader:                              ; preds = %middle.block, %vector.memcheck, %.preheader.us
  %indvars.iv.ph = phi i64 [ 0, %vector.memcheck ], [ 0, %.preheader.us ], [ %n.vec, %middle.block ]
  br i1 %lcmp.mod.not, label %scalar.ph.prol.loopexit, label %scalar.ph.prol

scalar.ph.prol:                                   ; preds = %scalar.ph.preheader, %scalar.ph.prol
  %indvars.iv.prol = phi i64 [ %indvars.iv.next.prol, %scalar.ph.prol ], [ %indvars.iv.ph, %scalar.ph.preheader ]
  %prol.iter = phi i64 [ %prol.iter.next, %scalar.ph.prol ], [ 0, %scalar.ph.preheader ]
  %gep.prol = getelementptr float, ptr %invariant.gep, i64 %indvars.iv.prol
  %34 = load float, ptr %gep.prol, align 4, !tbaa !13
  %35 = fptoui float %34 to i8
  %36 = mul nuw nsw i64 %indvars.iv.prol, %17
  %gep88.prol = getelementptr inbounds i8, ptr %invariant.gep87, i64 %36
  store i8 %35, ptr %gep88.prol, align 1, !tbaa !18
  %indvars.iv.next.prol = add nuw nsw i64 %indvars.iv.prol, 1
  %prol.iter.next = add i64 %prol.iter, 1
  %prol.iter.cmp.not = icmp eq i64 %prol.iter.next, %xtraiter
  br i1 %prol.iter.cmp.not, label %scalar.ph.prol.loopexit, label %scalar.ph.prol, !llvm.loop !25

scalar.ph.prol.loopexit:                          ; preds = %scalar.ph.prol, %scalar.ph.preheader
  %indvars.iv.unr = phi i64 [ %indvars.iv.ph, %scalar.ph.preheader ], [ %indvars.iv.next.prol, %scalar.ph.prol ]
  %37 = sub nsw i64 %indvars.iv.ph, %wide.trip.count
  %38 = icmp ugt i64 %37, -4
  br i1 %38, label %._crit_edge.us, label %scalar.ph

scalar.ph:                                        ; preds = %scalar.ph.prol.loopexit, %scalar.ph
  %indvars.iv = phi i64 [ %indvars.iv.next.3, %scalar.ph ], [ %indvars.iv.unr, %scalar.ph.prol.loopexit ]
  %gep = getelementptr float, ptr %invariant.gep, i64 %indvars.iv
  %39 = load float, ptr %gep, align 4, !tbaa !13
  %40 = fptoui float %39 to i8
  %41 = mul nuw nsw i64 %indvars.iv, %17
  %gep88 = getelementptr inbounds i8, ptr %invariant.gep87, i64 %41
  store i8 %40, ptr %gep88, align 1, !tbaa !18
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %gep.1 = getelementptr float, ptr %invariant.gep, i64 %indvars.iv.next
  %42 = load float, ptr %gep.1, align 4, !tbaa !13
  %43 = fptoui float %42 to i8
  %44 = mul nuw nsw i64 %indvars.iv.next, %17
  %gep88.1 = getelementptr inbounds i8, ptr %invariant.gep87, i64 %44
  store i8 %43, ptr %gep88.1, align 1, !tbaa !18
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %gep.2 = getelementptr float, ptr %invariant.gep, i64 %indvars.iv.next.1
  %45 = load float, ptr %gep.2, align 4, !tbaa !13
  %46 = fptoui float %45 to i8
  %47 = mul nuw nsw i64 %indvars.iv.next.1, %17
  %gep88.2 = getelementptr inbounds i8, ptr %invariant.gep87, i64 %47
  store i8 %46, ptr %gep88.2, align 1, !tbaa !18
  %indvars.iv.next.2 = add nuw nsw i64 %indvars.iv, 3
  %gep.3 = getelementptr float, ptr %invariant.gep, i64 %indvars.iv.next.2
  %48 = load float, ptr %gep.3, align 4, !tbaa !13
  %49 = fptoui float %48 to i8
  %50 = mul nuw nsw i64 %indvars.iv.next.2, %17
  %gep88.3 = getelementptr inbounds i8, ptr %invariant.gep87, i64 %50
  store i8 %49, ptr %gep88.3, align 1, !tbaa !18
  %indvars.iv.next.3 = add nuw nsw i64 %indvars.iv, 4
  %exitcond.not.3 = icmp eq i64 %indvars.iv.next.3, %wide.trip.count
  br i1 %exitcond.not.3, label %._crit_edge.us, label %scalar.ph, !llvm.loop !27

._crit_edge.us:                                   ; preds = %scalar.ph.prol.loopexit, %scalar.ph, %middle.block
  %indvars.iv.next83 = add nuw nsw i64 %indvars.iv82, 1
  %exitcond86.not = icmp eq i64 %indvars.iv.next83, %wide.trip.count85
  br i1 %exitcond86.not, label %._crit_edge79, label %.preheader.us, !llvm.loop !28

._crit_edge79:                                    ; preds = %._crit_edge.us, %.preheader.lr.ph, %2
  %51 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %1) #8
  %52 = shl i64 %51, 32
  %sext = add i64 %52, -8589934592
  %53 = ashr exact i64 %sext, 32
  %54 = getelementptr inbounds i8, ptr %1, i64 %53
  %55 = load i8, ptr %54, align 1, !tbaa !18
  switch i8 %55, label %.thread62 [
    i8 112, label %56
    i8 116, label %66
    i8 98, label %76
  ]

56:                                               ; preds = %._crit_edge79
  %sext49 = add i64 %52, -4294967296
  %57 = ashr exact i64 %sext49, 32
  %58 = getelementptr inbounds i8, ptr %1, i64 %57
  %59 = load i8, ptr %58, align 1, !tbaa !18
  %60 = icmp eq i8 %59, 110
  br i1 %60, label %61, label %.thread62

61:                                               ; preds = %56
  %62 = ashr exact i64 %52, 32
  %63 = getelementptr inbounds i8, ptr %1, i64 %62
  %64 = load i8, ptr %63, align 1, !tbaa !18
  %65 = icmp eq i8 %64, 103
  br i1 %65, label %88, label %.thread62

66:                                               ; preds = %._crit_edge79
  %sext51 = add i64 %52, -4294967296
  %67 = ashr exact i64 %sext51, 32
  %68 = getelementptr inbounds i8, ptr %1, i64 %67
  %69 = load i8, ptr %68, align 1, !tbaa !18
  %70 = icmp eq i8 %69, 103
  br i1 %70, label %71, label %.thread62

71:                                               ; preds = %66
  %72 = ashr exact i64 %52, 32
  %73 = getelementptr inbounds i8, ptr %1, i64 %72
  %74 = load i8, ptr %73, align 1, !tbaa !18
  %75 = icmp eq i8 %74, 97
  br i1 %75, label %92, label %.thread62

76:                                               ; preds = %._crit_edge79
  %sext53 = add i64 %52, -4294967296
  %77 = ashr exact i64 %sext53, 32
  %78 = getelementptr inbounds i8, ptr %1, i64 %77
  %79 = load i8, ptr %78, align 1, !tbaa !18
  %80 = icmp eq i8 %79, 109
  br i1 %80, label %81, label %.thread62

81:                                               ; preds = %76
  %82 = ashr exact i64 %52, 32
  %83 = getelementptr inbounds i8, ptr %1, i64 %82
  %84 = load i8, ptr %83, align 1, !tbaa !18
  %85 = icmp eq i8 %84, 112
  br i1 %85, label %95, label %.thread62

.thread62:                                        ; preds = %._crit_edge79, %56, %61, %66, %71, %81, %76
  %86 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) %3, ptr noundef nonnull dereferenceable(1) @.str.107, ptr noundef nonnull %1) #6
  %87 = call i32 @stbi_write_jpg(ptr noundef nonnull %3, i32 noundef %4, i32 noundef %6, i32 noundef %9, ptr noundef %12, i32 noundef 80)
  br label %98

88:                                               ; preds = %61
  %89 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) %3, ptr noundef nonnull dereferenceable(1) @.str.108, ptr noundef nonnull %1) #6
  %90 = mul nsw i32 %9, %4
  %91 = call i32 @stbi_write_png(ptr noundef nonnull %3, i32 noundef %4, i32 noundef %6, i32 noundef %9, ptr noundef %12, i32 noundef %90)
  br label %98

92:                                               ; preds = %71
  %93 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) %3, ptr noundef nonnull dereferenceable(1) @.str.109, ptr noundef nonnull %1) #6
  %94 = call i32 @stbi_write_tga(ptr noundef nonnull %3, i32 noundef %4, i32 noundef %6, i32 noundef %9, ptr noundef %12)
  br label %98

95:                                               ; preds = %81
  %96 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) %3, ptr noundef nonnull dereferenceable(1) @.str.110, ptr noundef nonnull %1) #6
  %97 = call i32 @stbi_write_bmp(ptr noundef nonnull %3, i32 noundef %4, i32 noundef %6, i32 noundef %9, ptr noundef %12)
  br label %98

98:                                               ; preds = %95, %92, %88, %.thread62
  %.045 = phi i32 [ %97, %95 ], [ %94, %92 ], [ %91, %88 ], [ %87, %.thread62 ]
  call void @free(ptr noundef %12) #6
  %.not = icmp eq i32 %.045, 0
  br i1 %.not, label %99, label %102

99:                                               ; preds = %98
  %100 = load ptr, ptr @stderr, align 8, !tbaa !29
  %101 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %100, ptr noundef nonnull @.str.111, ptr noundef nonnull %3) #9
  br label %102

102:                                              ; preds = %98, %99
  call void @llvm.lifetime.end.p0(i64 256, ptr nonnull %3) #6
  ret void
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #5

; Function Attrs: nofree nounwind
declare noundef i32 @sprintf(ptr noalias nocapture noundef writeonly, ptr nocapture noundef readonly, ...) local_unnamed_addr #3

attributes #0 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 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 = { 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 #4 = { mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { mustprogress nofree nounwind willreturn memory(argmem: read) "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #6 = { nounwind }
attributes #7 = { nounwind allocsize(0,1) }
attributes #8 = { nounwind willreturn memory(read) }
attributes #9 = { 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 = !{!"_ZTS5image", !7, i64 0, !7, i64 4, !7, i64 8, !10, i64 16}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !7, i64 4}
!12 = !{!6, !7, i64 8}
!13 = !{!14, !14, i64 0}
!14 = !{!"float", !8, i64 0}
!15 = !{!16}
!16 = distinct !{!16, !17}
!17 = distinct !{!17, !"LVerDomain"}
!18 = !{!8, !8, i64 0}
!19 = !{!20}
!20 = distinct !{!20, !17}
!21 = distinct !{!21, !22, !23, !24}
!22 = !{!"llvm.loop.mustprogress"}
!23 = !{!"llvm.loop.isvectorized", i32 1}
!24 = !{!"llvm.loop.unroll.runtime.disable"}
!25 = distinct !{!25, !26}
!26 = !{!"llvm.loop.unroll.disable"}
!27 = distinct !{!27, !22, !23}
!28 = distinct !{!28, !22}
!29 = !{!10, !10, i64 0}


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