; LLVM IR from zchrissirhcz/pixel :: legacy/px_png_libspng.ll (Z19px_write_png_customPKciiiPhRKSt6vectorIiSaIiEE)

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z19px_write_png_customPKciiiPhRKSt6vectorIiSaIiEE(ptr noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, ptr noundef %4, ptr noundef nonnull align 8 dereferenceable(24) %5) #0 {
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i8, align 1
  %14 = alloca i32, align 4
  %15 = alloca i64, align 8
  %16 = alloca ptr, align 8
  %17 = alloca i64, align 8
  %18 = alloca i32, align 4
  %19 = alloca ptr, align 8
  %20 = alloca ptr, align 8
  %21 = alloca %struct.spng_ihdr, align 4
  %22 = alloca i32, align 4
  %23 = alloca i32, align 4
  %24 = alloca i8, align 1
  %25 = alloca i64, align 8
  %26 = alloca i32, align 4
  %27 = alloca i32, align 4
  %28 = alloca i32, align 4
  %29 = alloca i32, align 4
  %30 = alloca i32, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store i32 %1, ptr %8, align 4, !tbaa !9
  store i32 %2, ptr %9, align 4, !tbaa !9
  store i32 %3, ptr %10, align 4, !tbaa !9
  store ptr %4, ptr %11, align 8, !tbaa !5
  store ptr %5, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %13) #6
  store i8 0, ptr %13, align 1, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #6
  store i32 1, ptr %14, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #6
  %31 = load i32, ptr %8, align 4, !tbaa !9
  %32 = load i32, ptr %9, align 4, !tbaa !9
  %33 = mul nsw i32 %31, %32
  %34 = load i32, ptr %10, align 4, !tbaa !9
  %35 = mul nsw i32 1, %34
  %36 = mul nsw i32 %33, %35
  %37 = sext i32 %36 to i64
  store i64 %37, ptr %15, align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #6
  %38 = load ptr, ptr %11, align 8, !tbaa !5
  store ptr %38, ptr %16, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #6
  store i32 0, ptr %18, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #6
  store volatile ptr null, ptr %19, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #6
  %39 = call ptr @spng_ctx_new(i32 noundef 2)
  store ptr %39, ptr %20, align 8, !tbaa !5
  %40 = load i8, ptr %13, align 1, !tbaa !11, !range !15, !noundef !16
  %41 = trunc i8 %40 to i1
  br i1 %41, label %42, label %43

42:                                               ; preds = %6
  br label %53

43:                                               ; preds = %6
  %44 = load ptr, ptr %7, align 8, !tbaa !5
  %45 = call noalias ptr @fopen(ptr noundef %44, ptr noundef @.str)
  store volatile ptr %45, ptr %19, align 8, !tbaa !5
  %46 = load volatile ptr, ptr %19, align 8, !tbaa !5
  %47 = icmp ne ptr %46, null
  br i1 %47, label %48, label %52

48:                                               ; preds = %43
  %49 = load ptr, ptr %20, align 8, !tbaa !5
  %50 = load volatile ptr, ptr %19, align 8, !tbaa !5
  %51 = call i32 @spng_set_png_file(ptr noundef %49, ptr noundef %50)
  br label %52

52:                                               ; preds = %48, %43
  br label %53

53:                                               ; preds = %52, %42
  %54 = load ptr, ptr %20, align 8, !tbaa !5
  %55 = call i32 @spng_set_option(ptr noundef %54, i32 noundef 12, i32 noundef 1)
  call void @llvm.lifetime.start.p0(i64 16, ptr %21) #6
  %56 = load i32, ptr %8, align 4, !tbaa !9
  %57 = getelementptr inbounds %struct.spng_ihdr, ptr %21, i32 0, i32 1
  store i32 %56, ptr %57, align 4, !tbaa !17
  %58 = load i32, ptr %9, align 4, !tbaa !9
  %59 = getelementptr inbounds %struct.spng_ihdr, ptr %21, i32 0, i32 0
  store i32 %58, ptr %59, align 4, !tbaa !19
  %60 = getelementptr inbounds %struct.spng_ihdr, ptr %21, i32 0, i32 2
  store i8 8, ptr %60, align 4, !tbaa !20
  %61 = load i32, ptr %10, align 4, !tbaa !9
  %62 = icmp eq i32 %61, 1
  br i1 %62, label %63, label %64

63:                                               ; preds = %53
  br label %69

64:                                               ; preds = %53
  %65 = load i32, ptr %10, align 4, !tbaa !9
  %66 = icmp eq i32 %65, 3
  %67 = zext i1 %66 to i64
  %68 = select i1 %66, i32 2, i32 6
  br label %69

69:                                               ; preds = %64, %63
  %70 = phi i32 [ 0, %63 ], [ %68, %64 ]
  %71 = trunc i32 %70 to i8
  %72 = getelementptr inbounds %struct.spng_ihdr, ptr %21, i32 0, i32 3
  store i8 %71, ptr %72, align 1, !tbaa !21
  %73 = getelementptr inbounds %struct.spng_ihdr, ptr %21, i32 0, i32 4
  store i8 0, ptr %73, align 2, !tbaa !22
  %74 = getelementptr inbounds %struct.spng_ihdr, ptr %21, i32 0, i32 5
  store i8 0, ptr %74, align 1, !tbaa !23
  %75 = getelementptr inbounds %struct.spng_ihdr, ptr %21, i32 0, i32 6
  store i8 0, ptr %75, align 4, !tbaa !24
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #6
  store i32 -1, ptr %22, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %23) #6
  store i32 3, ptr %23, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 1, ptr %24) #6
  store i8 0, ptr %24, align 1, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %25) #6
  store i64 0, ptr %25, align 8, !tbaa !13
  br label %76

76:                                               ; preds = %127, %69
  %77 = load i64, ptr %25, align 8, !tbaa !13
  %78 = load ptr, ptr %12, align 8, !tbaa !5
  %79 = call noundef i64 @_ZNKSt6vectorIiSaIiEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %78) #6
  %80 = icmp ult i64 %77, %79
  br i1 %80, label %82, label %81

81:                                               ; preds = %76
  call void @llvm.lifetime.end.p0(i64 8, ptr %25) #6
  br label %130

82:                                               ; preds = %76
  %83 = load ptr, ptr %12, align 8, !tbaa !5
  %84 = load i64, ptr %25, align 8, !tbaa !13
  %85 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %83, i64 noundef %84) #6
  %86 = load i32, ptr %85, align 4, !tbaa !9
  %87 = icmp eq i32 %86, 16
  br i1 %87, label %88, label %97

88:                                               ; preds = %82
  store i32 0, ptr %23, align 4, !tbaa !9
  %89 = load ptr, ptr %12, align 8, !tbaa !5
  %90 = load i64, ptr %25, align 8, !tbaa !13
  %91 = add i64 %90, 1
  %92 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %89, i64 noundef %91) #6
  %93 = load i32, ptr %92, align 4, !tbaa !9
  store i32 %93, ptr %22, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %26) #6
  store i32 0, ptr %26, align 4, !tbaa !9
  %94 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %22, ptr noundef nonnull align 4 dereferenceable(4) %26)
  call void @llvm.lifetime.start.p0(i64 4, ptr %27) #6
  store i32 9, ptr %27, align 4, !tbaa !9
  %95 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %94, ptr noundef nonnull align 4 dereferenceable(4) %27)
  %96 = load i32, ptr %95, align 4, !tbaa !9
  store i32 %96, ptr %22, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %27) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %26) #6
  br label %97

97:                                               ; preds = %88, %82
  %98 = load ptr, ptr %12, align 8, !tbaa !5
  %99 = load i64, ptr %25, align 8, !tbaa !13
  %100 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %98, i64 noundef %99) #6
  %101 = load i32, ptr %100, align 4, !tbaa !9
  %102 = icmp eq i32 %101, 17
  br i1 %102, label %103, label %112

103:                                              ; preds = %97
  %104 = load ptr, ptr %12, align 8, !tbaa !5
  %105 = load i64, ptr %25, align 8, !tbaa !13
  %106 = add i64 %105, 1
  %107 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %104, i64 noundef %106) #6
  %108 = load i32, ptr %107, align 4, !tbaa !9
  store i32 %108, ptr %23, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %28) #6
  store i32 0, ptr %28, align 4, !tbaa !9
  %109 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %23, ptr noundef nonnull align 4 dereferenceable(4) %28)
  call void @llvm.lifetime.start.p0(i64 4, ptr %29) #6
  store i32 4, ptr %29, align 4, !tbaa !9
  %110 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %109, ptr noundef nonnull align 4 dereferenceable(4) %29)
  %111 = load i32, ptr %110, align 4, !tbaa !9
  store i32 %111, ptr %23, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %29) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %28) #6
  br label %112

112:                                              ; preds = %103, %97
  %113 = load ptr, ptr %12, align 8, !tbaa !5
  %114 = load i64, ptr %25, align 8, !tbaa !13
  %115 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %113, i64 noundef %114) #6
  %116 = load i32, ptr %115, align 4, !tbaa !9
  %117 = icmp eq i32 %116, 18
  br i1 %117, label %118, label %126

118:                                              ; preds = %112
  %119 = load ptr, ptr %12, align 8, !tbaa !5
  %120 = load i64, ptr %25, align 8, !tbaa !13
  %121 = add i64 %120, 1
  %122 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %119, i64 noundef %121) #6
  %123 = load i32, ptr %122, align 4, !tbaa !9
  %124 = icmp ne i32 %123, 0
  %125 = zext i1 %124 to i8
  store i8 %125, ptr %24, align 1, !tbaa !11
  br label %126

126:                                              ; preds = %118, %112
  br label %127

127:                                              ; preds = %126
  %128 = load i64, ptr %25, align 8, !tbaa !13
  %129 = add i64 %128, 2
  store i64 %129, ptr %25, align 8, !tbaa !13
  br label %76, !llvm.loop !25

130:                                              ; preds = %81
  %131 = load i8, ptr %13, align 1, !tbaa !11, !range !15, !noundef !16
  %132 = trunc i8 %131 to i1
  br i1 %132, label %136, label %133

133:                                              ; preds = %130
  %134 = load volatile ptr, ptr %19, align 8, !tbaa !5
  %135 = icmp ne ptr %134, null
  br i1 %135, label %136, label %185

136:                                              ; preds = %133, %130
  %137 = load i32, ptr %22, align 4, !tbaa !9
  %138 = icmp sge i32 %137, 0
  br i1 %138, label %139, label %143

139:                                              ; preds = %136
  %140 = load ptr, ptr %20, align 8, !tbaa !5
  %141 = load i32, ptr %22, align 4, !tbaa !9
  %142 = call i32 @spng_set_option(ptr noundef %140, i32 noundef 2, i32 noundef %141)
  br label %148

143:                                              ; preds = %136
  %144 = load ptr, ptr %20, align 8, !tbaa !5
  %145 = call i32 @spng_set_option(ptr noundef %144, i32 noundef 10, i32 noundef 16)
  %146 = load ptr, ptr %20, align 8, !tbaa !5
  %147 = call i32 @spng_set_option(ptr noundef %146, i32 noundef 2, i32 noundef 1)
  br label %148

148:                                              ; preds = %143, %139
  %149 = load ptr, ptr %20, align 8, !tbaa !5
  %150 = load i32, ptr %23, align 4, !tbaa !9
  %151 = call i32 @spng_set_option(ptr noundef %149, i32 noundef 5, i32 noundef %150)
  %152 = load ptr, ptr %20, align 8, !tbaa !5
  %153 = call i32 @spng_set_ihdr(ptr noundef %152, ptr noundef %21)
  store i32 %153, ptr %18, align 4, !tbaa !9
  %154 = load i32, ptr %18, align 4, !tbaa !9
  %155 = icmp ne i32 %154, 0
  br i1 %155, label %156, label %166

156:                                              ; preds = %148
  br label %157

157:                                              ; preds = %156
  %158 = load ptr, ptr @stderr, align 8, !tbaa !5
  %159 = load i32, ptr %18, align 4, !tbaa !9
  %160 = call ptr @spng_strerror(i32 noundef %159)
  %161 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %158, ptr noundef @.str.1, ptr noundef %160) #6
  %162 = load ptr, ptr @stderr, align 8, !tbaa !5
  %163 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %162, ptr noundef @.str.2) #6
  br label %164

164:                                              ; preds = %157
  br label %165

165:                                              ; preds = %164
  br label %166

166:                                              ; preds = %165, %148
  call void @llvm.lifetime.start.p0(i64 4, ptr %30) #6
  store i32 256, ptr %30, align 4, !tbaa !27
  %167 = load ptr, ptr %20, align 8, !tbaa !5
  %168 = load ptr, ptr %16, align 8, !tbaa !5
  %169 = load i64, ptr %15, align 8, !tbaa !13
  %170 = load i32, ptr %30, align 4, !tbaa !27
  %171 = call i32 @spng_encode_image(ptr noundef %167, ptr noundef %168, i64 noundef %169, i32 noundef %170, i32 noundef 2)
  store i32 %171, ptr %18, align 4, !tbaa !9
  %172 = load i32, ptr %18, align 4, !tbaa !9
  %173 = icmp ne i32 %172, 0
  br i1 %173, label %174, label %184

174:                                              ; preds = %166
  br label %175

175:                                              ; preds = %174
  %176 = load ptr, ptr @stderr, align 8, !tbaa !5
  %177 = load i32, ptr %18, align 4, !tbaa !9
  %178 = call ptr @spng_strerror(i32 noundef %177)
  %179 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %176, ptr noundef @.str.3, ptr noundef %178) #6
  %180 = load ptr, ptr @stderr, align 8, !tbaa !5
  %181 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %180, ptr noundef @.str.2) #6
  br label %182

182:                                              ; preds = %175
  br label %183

183:                                              ; preds = %182
  br label %184

184:                                              ; preds = %183, %166
  call void @llvm.lifetime.end.p0(i64 4, ptr %30) #6
  br label %185

185:                                              ; preds = %184, %133
  %186 = load ptr, ptr %20, align 8, !tbaa !5
  call void @spng_ctx_free(ptr noundef %186)
  %187 = load volatile ptr, ptr %19, align 8, !tbaa !5
  %188 = call i32 @fflush(ptr noundef %187)
  %189 = load volatile ptr, ptr %19, align 8, !tbaa !5
  %190 = icmp ne ptr %189, null
  br i1 %190, label %191, label %194

191:                                              ; preds = %185
  %192 = load volatile ptr, ptr %19, align 8, !tbaa !5
  %193 = call i32 @fclose(ptr noundef %192)
  br label %194

194:                                              ; preds = %191, %185
  call void @llvm.lifetime.end.p0(i64 1, ptr %24) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %23) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr %21) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #6
  call void @llvm.lifetime.end.p0(i64 1, ptr %13) #6
  ret i32 0
}

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

declare ptr @spng_ctx_new(i32 noundef) #2

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

declare i32 @spng_set_png_file(ptr noundef, ptr noundef) #2

declare i32 @spng_set_option(ptr noundef, i32 noundef, i32 noundef) #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorIiSaIiEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #3 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #4

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #4

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

declare i32 @spng_set_ihdr(ptr noundef, ptr noundef) #2

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

declare ptr @spng_strerror(i32 noundef) #2

declare i32 @spng_encode_image(ptr noundef, ptr noundef, i64 noundef, i32 noundef, i32 noundef) #2

declare void @spng_ctx_free(ptr noundef) #2

declare i32 @fflush(ptr noundef) #2

declare i32 @fclose(ptr noundef) #2

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

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"long", !7, i64 0}
!15 = !{i8 0, i8 2}
!16 = !{}
!17 = !{!18, !10, i64 4}
!18 = !{!"_ZTS9spng_ihdr", !10, i64 0, !10, i64 4, !7, i64 8, !7, i64 9, !7, i64 10, !7, i64 11, !7, i64 12}
!19 = !{!18, !10, i64 0}
!20 = !{!18, !7, i64 8}
!21 = !{!18, !7, i64 9}
!22 = !{!18, !7, i64 10}
!23 = !{!18, !7, i64 11}
!24 = !{!18, !7, i64 12}
!25 = distinct !{!25, !26}
!26 = !{!"llvm.loop.mustprogress"}
!27 = !{!28, !28, i64 0}
!28 = !{!"_ZTS11spng_format", !7, i64 0}


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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z19px_write_png_customPKciiiPhRKSt6vectorIiSaIiEE(ptr nocapture noundef readonly %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, ptr noundef %4, ptr noundef nonnull align 8 dereferenceable(24) %5) local_unnamed_addr #0 {
  %7 = alloca ptr, align 8
  %8 = alloca %struct.spng_ihdr, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = mul nsw i32 %2, %1
  %16 = mul nsw i32 %15, %3
  %17 = sext i32 %16 to i64
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7)
  store volatile ptr null, ptr %7, align 8, !tbaa !5
  %18 = tail call ptr @spng_ctx_new(i32 noundef 2)
  %19 = tail call noalias ptr @fopen(ptr noundef %0, ptr noundef nonnull @.str)
  store volatile ptr %19, ptr %7, align 8, !tbaa !5
  %.0..0..0..0.17 = load volatile ptr, ptr %7, align 8, !tbaa !5
  %.not = icmp eq ptr %.0..0..0..0.17, null
  br i1 %.not, label %22, label %20

20:                                               ; preds = %6
  %.0..0..0..0.18 = load volatile ptr, ptr %7, align 8, !tbaa !5
  %21 = tail call i32 @spng_set_png_file(ptr noundef %18, ptr noundef %.0..0..0..0.18)
  br label %22

22:                                               ; preds = %6, %20
  %23 = tail call i32 @spng_set_option(ptr noundef %18, i32 noundef 12, i32 noundef 1)
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %8) #6
  %24 = getelementptr inbounds i8, ptr %8, i64 4
  store i32 %1, ptr %24, align 4, !tbaa !9
  store i32 %2, ptr %8, align 4, !tbaa !12
  %25 = getelementptr inbounds i8, ptr %8, i64 8
  store i8 8, ptr %25, align 4, !tbaa !13
  %26 = icmp eq i32 %3, 1
  %27 = icmp eq i32 %3, 3
  %28 = select i1 %27, i8 2, i8 6
  %29 = select i1 %26, i8 0, i8 %28
  %30 = getelementptr inbounds i8, ptr %8, i64 9
  store i8 %29, ptr %30, align 1, !tbaa !14
  %31 = getelementptr inbounds i8, ptr %8, i64 10
  store i8 0, ptr %31, align 2, !tbaa !15
  %32 = getelementptr inbounds i8, ptr %8, i64 11
  store i8 0, ptr %32, align 1, !tbaa !16
  %33 = getelementptr inbounds i8, ptr %8, i64 12
  store i8 0, ptr %33, align 4, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %9) #6
  store i32 -1, ptr %9, align 4, !tbaa !18
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %10) #6
  store i32 3, ptr %10, align 4, !tbaa !18
  %34 = tail call noundef i64 @_ZNKSt6vectorIiSaIiEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %5) #6
  %.not56 = icmp eq i64 %34, 0
  br i1 %.not56, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %22, %63
  %.055 = phi i64 [ %64, %63 ], [ 0, %22 ]
  %35 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %5, i64 noundef %.055) #6
  %36 = load i32, ptr %35, align 4, !tbaa !18
  %37 = icmp eq i32 %36, 16
  br i1 %37, label %38, label %45

38:                                               ; preds = %.lr.ph
  store i32 0, ptr %10, align 4, !tbaa !18
  %39 = or disjoint i64 %.055, 1
  %40 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %5, i64 noundef %39) #6
  %41 = load i32, ptr %40, align 4, !tbaa !18
  store i32 %41, ptr %9, align 4, !tbaa !18
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %11) #6
  store i32 0, ptr %11, align 4, !tbaa !18
  %42 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %9, ptr noundef nonnull align 4 dereferenceable(4) %11)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %12) #6
  store i32 9, ptr %12, align 4, !tbaa !18
  %43 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %42, ptr noundef nonnull align 4 dereferenceable(4) %12)
  %44 = load i32, ptr %43, align 4, !tbaa !18
  store i32 %44, ptr %9, align 4, !tbaa !18
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %12) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %11) #6
  br label %45

45:                                               ; preds = %38, %.lr.ph
  %46 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %5, i64 noundef %.055) #6
  %47 = load i32, ptr %46, align 4, !tbaa !18
  %48 = icmp eq i32 %47, 17
  br i1 %48, label %49, label %56

49:                                               ; preds = %45
  %50 = or disjoint i64 %.055, 1
  %51 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %5, i64 noundef %50) #6
  %52 = load i32, ptr %51, align 4, !tbaa !18
  store i32 %52, ptr %10, align 4, !tbaa !18
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %13) #6
  store i32 0, ptr %13, align 4, !tbaa !18
  %53 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %10, ptr noundef nonnull align 4 dereferenceable(4) %13)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %14) #6
  store i32 4, ptr %14, align 4, !tbaa !18
  %54 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %53, ptr noundef nonnull align 4 dereferenceable(4) %14)
  %55 = load i32, ptr %54, align 4, !tbaa !18
  store i32 %55, ptr %10, align 4, !tbaa !18
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %14) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %13) #6
  br label %56

56:                                               ; preds = %49, %45
  %57 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %5, i64 noundef %.055) #6
  %58 = load i32, ptr %57, align 4, !tbaa !18
  %59 = icmp eq i32 %58, 18
  br i1 %59, label %60, label %63

60:                                               ; preds = %56
  %61 = or disjoint i64 %.055, 1
  %62 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %5, i64 noundef %61) #6
  br label %63

63:                                               ; preds = %56, %60
  %64 = add i64 %.055, 2
  %65 = call noundef i64 @_ZNKSt6vectorIiSaIiEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %5) #6
  %66 = icmp ult i64 %64, %65
  br i1 %66, label %.lr.ph, label %._crit_edge, !llvm.loop !19

._crit_edge:                                      ; preds = %63, %22
  %.0..0..0..0.19 = load volatile ptr, ptr %7, align 8, !tbaa !5
  %.not51 = icmp eq ptr %.0..0..0..0.19, null
  br i1 %.not51, label %91, label %67

67:                                               ; preds = %._crit_edge
  %68 = load i32, ptr %9, align 4, !tbaa !18
  %69 = icmp sgt i32 %68, -1
  br i1 %69, label %72, label %70

70:                                               ; preds = %67
  %71 = call i32 @spng_set_option(ptr noundef %18, i32 noundef 10, i32 noundef 16)
  br label %72

72:                                               ; preds = %67, %70
  %.sink = phi i32 [ 1, %70 ], [ %68, %67 ]
  %73 = call i32 @spng_set_option(ptr noundef %18, i32 noundef 2, i32 noundef %.sink)
  %74 = load i32, ptr %10, align 4, !tbaa !18
  %75 = call i32 @spng_set_option(ptr noundef %18, i32 noundef 5, i32 noundef %74)
  %76 = call i32 @spng_set_ihdr(ptr noundef %18, ptr noundef nonnull %8)
  %.not52 = icmp eq i32 %76, 0
  br i1 %.not52, label %83, label %77

77:                                               ; preds = %72
  %78 = load ptr, ptr @stderr, align 8, !tbaa !5
  %79 = call ptr @spng_strerror(i32 noundef %76)
  %80 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %78, ptr noundef nonnull @.str.1, ptr noundef %79) #7
  %81 = load ptr, ptr @stderr, align 8, !tbaa !5
  %82 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %81, ptr noundef nonnull @.str.2) #7
  br label %83

83:                                               ; preds = %77, %72
  %84 = call i32 @spng_encode_image(ptr noundef %18, ptr noundef %4, i64 noundef %17, i32 noundef 256, i32 noundef 2)
  %.not53 = icmp eq i32 %84, 0
  br i1 %.not53, label %91, label %85

85:                                               ; preds = %83
  %86 = load ptr, ptr @stderr, align 8, !tbaa !5
  %87 = call ptr @spng_strerror(i32 noundef %84)
  %88 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %86, ptr noundef nonnull @.str.3, ptr noundef %87) #7
  %89 = load ptr, ptr @stderr, align 8, !tbaa !5
  %90 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %89, ptr noundef nonnull @.str.2) #7
  br label %91

91:                                               ; preds = %83, %85, %._crit_edge
  call void @spng_ctx_free(ptr noundef %18)
  %.0..0..0..0.20 = load volatile ptr, ptr %7, align 8, !tbaa !5
  %92 = call i32 @fflush(ptr noundef %.0..0..0..0.20)
  %.0..0..0..0.21 = load volatile ptr, ptr %7, align 8, !tbaa !5
  %.not54 = icmp eq ptr %.0..0..0..0.21, null
  br i1 %.not54, label %95, label %93

93:                                               ; preds = %91
  %.0..0..0..0.22 = load volatile ptr, ptr %7, align 8, !tbaa !5
  %94 = call i32 @fclose(ptr noundef %.0..0..0..0.22)
  br label %95

95:                                               ; preds = %93, %91
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %10) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %9) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %8) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7)
  ret i32 0
}

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

declare ptr @spng_ctx_new(i32 noundef) local_unnamed_addr #2

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

declare i32 @spng_set_png_file(ptr noundef, ptr noundef) local_unnamed_addr #2

declare i32 @spng_set_option(ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorIiSaIiEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #4 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #4 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #5

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #5

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

declare i32 @spng_set_ihdr(ptr noundef, ptr noundef) local_unnamed_addr #2

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

declare ptr @spng_strerror(i32 noundef) local_unnamed_addr #2

declare i32 @spng_encode_image(ptr noundef, ptr noundef, i64 noundef, i32 noundef, i32 noundef) local_unnamed_addr #2

declare void @spng_ctx_free(ptr noundef) local_unnamed_addr #2

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

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

attributes #0 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "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 nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { inlinehint mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !11, i64 4}
!10 = !{!"_ZTS9spng_ihdr", !11, i64 0, !11, i64 4, !7, i64 8, !7, i64 9, !7, i64 10, !7, i64 11, !7, i64 12}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !11, i64 0}
!13 = !{!10, !7, i64 8}
!14 = !{!10, !7, i64 9}
!15 = !{!10, !7, i64 10}
!16 = !{!10, !7, i64 11}
!17 = !{!10, !7, i64 12}
!18 = !{!11, !11, i64 0}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass