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

; 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 }
%struct.spng_plte = type { i32, [256 x %struct.spng_plte_entry] }
%struct.spng_plte_entry = type { i8, i8, i8, i8 }

@stderr = external global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [56 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [63 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [42 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [31 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 ptr @spng_ctx_new(i32 noundef) #1

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

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

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

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

declare ptr @spng_strerror(i32 noundef) #1

declare void @spng_ctx_free(ptr noundef) #1

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

; Function Attrs: mustprogress uwtable
define dso_local void @px_read_png(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4) #4 {
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca %struct.spng_ihdr, align 4
  %16 = alloca i8, align 1
  %17 = alloca i32, align 4
  %18 = alloca i64, align 8
  %19 = alloca ptr, align 8
  %20 = alloca %struct.spng_plte, align 4
  %21 = alloca i64, align 8
  %22 = alloca i64, align 8
  %23 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !5
  store ptr %3, ptr %9, align 8, !tbaa !5
  store ptr %4, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #7
  store i32 0, ptr %12, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #7
  store ptr null, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #7
  store ptr null, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %15) #7
  call void @llvm.lifetime.start.p0(i64 1, ptr %16) #7
  store i8 0, ptr %16, align 1, !tbaa !11
  %24 = load ptr, ptr %6, align 8, !tbaa !5
  %25 = call noalias ptr @fopen(ptr noundef %24, ptr noundef @.str.4)
  store ptr %25, ptr %11, align 8, !tbaa !5
  %26 = load ptr, ptr %11, align 8, !tbaa !5
  %27 = icmp eq ptr %26, null
  br i1 %27, label %28, label %37

28:                                               ; preds = %5
  br label %29

29:                                               ; preds = %28
  %30 = load ptr, ptr @stderr, align 8, !tbaa !5
  %31 = load ptr, ptr %6, align 8, !tbaa !5
  %32 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %30, ptr noundef @.str.5, ptr noundef %31) #7
  %33 = load ptr, ptr @stderr, align 8, !tbaa !5
  %34 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %33, ptr noundef @.str.2) #7
  br label %35

35:                                               ; preds = %29
  br label %36

36:                                               ; preds = %35
  store i32 1, ptr %17, align 4
  br label %253

37:                                               ; preds = %5
  br label %38

38:                                               ; preds = %37
  %39 = call ptr @spng_ctx_new(i32 noundef 0)
  store ptr %39, ptr %13, align 8, !tbaa !5
  %40 = load ptr, ptr %13, align 8, !tbaa !5
  %41 = icmp eq ptr %40, null
  br i1 %41, label %42, label %50

42:                                               ; preds = %38
  br label %43

43:                                               ; preds = %42
  %44 = load ptr, ptr @stderr, align 8, !tbaa !5
  %45 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %44, ptr noundef @.str.6) #7
  %46 = load ptr, ptr @stderr, align 8, !tbaa !5
  %47 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %46, ptr noundef @.str.2) #7
  br label %48

48:                                               ; preds = %43
  br label %49

49:                                               ; preds = %48
  store i8 1, ptr %16, align 1, !tbaa !11
  br label %251

50:                                               ; preds = %38
  %51 = load ptr, ptr %13, align 8, !tbaa !5
  %52 = call i32 @spng_set_crc_action(ptr noundef %51, i32 noundef 2, i32 noundef 2)
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #7
  store i64 67108864, ptr %18, align 8, !tbaa !13
  %53 = load ptr, ptr %13, align 8, !tbaa !5
  %54 = load i64, ptr %18, align 8, !tbaa !13
  %55 = load i64, ptr %18, align 8, !tbaa !13
  %56 = call i32 @spng_set_chunk_limits(ptr noundef %53, i64 noundef %54, i64 noundef %55)
  %57 = load ptr, ptr %13, align 8, !tbaa !5
  %58 = load ptr, ptr %11, align 8, !tbaa !5
  %59 = call i32 @spng_set_png_file(ptr noundef %57, ptr noundef %58)
  %60 = load ptr, ptr %13, align 8, !tbaa !5
  %61 = call i32 @spng_get_ihdr(ptr noundef %60, ptr noundef %15)
  store i32 %61, ptr %12, align 4, !tbaa !9
  %62 = load i32, ptr %12, align 4, !tbaa !9
  %63 = icmp ne i32 %62, 0
  br i1 %63, label %64, label %74

64:                                               ; preds = %50
  br label %65

65:                                               ; preds = %64
  %66 = load ptr, ptr @stderr, align 8, !tbaa !5
  %67 = load i32, ptr %12, align 4, !tbaa !9
  %68 = call ptr @spng_strerror(i32 noundef %67)
  %69 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %66, ptr noundef @.str.7, ptr noundef %68) #7
  %70 = load ptr, ptr @stderr, align 8, !tbaa !5
  %71 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %70, ptr noundef @.str.2) #7
  br label %72

72:                                               ; preds = %65
  br label %73

73:                                               ; preds = %72
  store i8 1, ptr %16, align 1, !tbaa !11
  store i32 4, ptr %17, align 4
  br label %247

74:                                               ; preds = %50
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #7
  %75 = getelementptr inbounds %struct.spng_ihdr, ptr %15, i32 0, i32 3
  %76 = load i8, ptr %75, align 1, !tbaa !15
  %77 = zext i8 %76 to i32
  %78 = call noundef ptr @_ZL14color_type_str15spng_color_type(i32 noundef %77)
  store ptr %78, ptr %19, align 8, !tbaa !5
  br label %79

79:                                               ; preds = %74
  %80 = load ptr, ptr @stderr, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.spng_ihdr, ptr %15, i32 0, i32 0
  %82 = load i32, ptr %81, align 4, !tbaa !17
  %83 = getelementptr inbounds %struct.spng_ihdr, ptr %15, i32 0, i32 1
  %84 = load i32, ptr %83, align 4, !tbaa !18
  %85 = getelementptr inbounds %struct.spng_ihdr, ptr %15, i32 0, i32 2
  %86 = load i8, ptr %85, align 4, !tbaa !19
  %87 = zext i8 %86 to i32
  %88 = getelementptr inbounds %struct.spng_ihdr, ptr %15, i32 0, i32 3
  %89 = load i8, ptr %88, align 1, !tbaa !15
  %90 = zext i8 %89 to i32
  %91 = load ptr, ptr %19, align 8, !tbaa !5
  %92 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %80, ptr noundef @.str.8, i32 noundef %82, i32 noundef %84, i32 noundef %87, i32 noundef %90, ptr noundef %91) #7
  %93 = load ptr, ptr @stderr, align 8, !tbaa !5
  %94 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %93, ptr noundef @.str.2) #7
  br label %95

95:                                               ; preds = %79
  br label %96

96:                                               ; preds = %95
  br label %97

97:                                               ; preds = %96
  %98 = load ptr, ptr @stderr, align 8, !tbaa !5
  %99 = getelementptr inbounds %struct.spng_ihdr, ptr %15, i32 0, i32 4
  %100 = load i8, ptr %99, align 2, !tbaa !20
  %101 = zext i8 %100 to i32
  %102 = getelementptr inbounds %struct.spng_ihdr, ptr %15, i32 0, i32 5
  %103 = load i8, ptr %102, align 1, !tbaa !21
  %104 = zext i8 %103 to i32
  %105 = getelementptr inbounds %struct.spng_ihdr, ptr %15, i32 0, i32 6
  %106 = load i8, ptr %105, align 4, !tbaa !22
  %107 = zext i8 %106 to i32
  %108 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %98, ptr noundef @.str.9, i32 noundef %101, i32 noundef %104, i32 noundef %107) #7
  %109 = load ptr, ptr @stderr, align 8, !tbaa !5
  %110 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %109, ptr noundef @.str.2) #7
  br label %111

111:                                              ; preds = %97
  br label %112

112:                                              ; preds = %111
  %113 = getelementptr inbounds %struct.spng_ihdr, ptr %15, i32 0, i32 1
  %114 = load i32, ptr %113, align 4, !tbaa !18
  %115 = load ptr, ptr %7, align 8, !tbaa !5
  store i32 %114, ptr %115, align 4, !tbaa !9
  %116 = getelementptr inbounds %struct.spng_ihdr, ptr %15, i32 0, i32 0
  %117 = load i32, ptr %116, align 4, !tbaa !17
  %118 = load ptr, ptr %8, align 8, !tbaa !5
  store i32 %117, ptr %118, align 4, !tbaa !9
  %119 = getelementptr inbounds %struct.spng_ihdr, ptr %15, i32 0, i32 3
  %120 = load i8, ptr %119, align 1, !tbaa !15
  %121 = zext i8 %120 to i32
  %122 = icmp eq i32 %121, 0
  br i1 %122, label %123, label %125

123:                                              ; preds = %112
  %124 = load ptr, ptr %9, align 8, !tbaa !5
  store i32 1, ptr %124, align 4, !tbaa !9
  br label %150

125:                                              ; preds = %112
  %126 = getelementptr inbounds %struct.spng_ihdr, ptr %15, i32 0, i32 3
  %127 = load i8, ptr %126, align 1, !tbaa !15
  %128 = zext i8 %127 to i32
  %129 = icmp eq i32 %128, 2
  br i1 %129, label %130, label %132

130:                                              ; preds = %125
  %131 = load ptr, ptr %9, align 8, !tbaa !5
  store i32 3, ptr %131, align 4, !tbaa !9
  br label %149

132:                                              ; preds = %125
  %133 = getelementptr inbounds %struct.spng_ihdr, ptr %15, i32 0, i32 3
  %134 = load i8, ptr %133, align 1, !tbaa !15
  %135 = zext i8 %134 to i32
  %136 = icmp eq i32 %135, 6
  br i1 %136, label %137, label %139

137:                                              ; preds = %132
  %138 = load ptr, ptr %9, align 8, !tbaa !5
  store i32 4, ptr %138, align 4, !tbaa !9
  br label %148

139:                                              ; preds = %132
  br label %140

140:                                              ; preds = %139
  %141 = load ptr, ptr @stderr, align 8, !tbaa !5
  %142 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %141, ptr noundef @.str.10) #7
  %143 = load ptr, ptr @stderr, align 8, !tbaa !5
  %144 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %143, ptr noundef @.str.2) #7
  br label %145

145:                                              ; preds = %140
  br label %146

146:                                              ; preds = %145
  %147 = load ptr, ptr %9, align 8, !tbaa !5
  store i32 0, ptr %147, align 4, !tbaa !9
  br label %148

148:                                              ; preds = %146, %137
  br label %149

149:                                              ; preds = %148, %130
  br label %150

150:                                              ; preds = %149, %123
  call void @llvm.lifetime.start.p0(i64 1028, ptr %20) #7
  call void @llvm.memset.p0.i64(ptr align 4 %20, i8 0, i64 1028, i1 false)
  %151 = load ptr, ptr %13, align 8, !tbaa !5
  %152 = call i32 @spng_get_plte(ptr noundef %151, ptr noundef %20)
  store i32 %152, ptr %12, align 4, !tbaa !9
  %153 = load i32, ptr %12, align 4, !tbaa !9
  %154 = icmp ne i32 %153, 0
  br i1 %154, label %155, label %168

155:                                              ; preds = %150
  %156 = load i32, ptr %12, align 4, !tbaa !9
  %157 = icmp ne i32 %156, 73
  br i1 %157, label %158, label %168

158:                                              ; preds = %155
  br label %159

159:                                              ; preds = %158
  %160 = load ptr, ptr @stderr, align 8, !tbaa !5
  %161 = load i32, ptr %12, align 4, !tbaa !9
  %162 = call ptr @spng_strerror(i32 noundef %161)
  %163 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %160, ptr noundef @.str.11, ptr noundef %162) #7
  %164 = load ptr, ptr @stderr, align 8, !tbaa !5
  %165 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %164, ptr noundef @.str.2) #7
  br label %166

166:                                              ; preds = %159
  br label %167

167:                                              ; preds = %166
  store i8 1, ptr %16, align 1, !tbaa !11
  store i32 4, ptr %17, align 4
  br label %246

168:                                              ; preds = %155, %150
  %169 = load i32, ptr %12, align 4, !tbaa !9
  %170 = icmp ne i32 %169, 0
  br i1 %170, label %181, label %171

171:                                              ; preds = %168
  br label %172

172:                                              ; preds = %171
  %173 = load ptr, ptr @stderr, align 8, !tbaa !5
  %174 = getelementptr inbounds %struct.spng_plte, ptr %20, i32 0, i32 0
  %175 = load i32, ptr %174, align 4, !tbaa !23
  %176 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %173, ptr noundef @.str.12, i32 noundef %175) #7
  %177 = load ptr, ptr @stderr, align 8, !tbaa !5
  %178 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %177, ptr noundef @.str.2) #7
  br label %179

179:                                              ; preds = %172
  br label %180

180:                                              ; preds = %179
  br label %181

181:                                              ; preds = %180, %168
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %22) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %23) #7
  store i32 256, ptr %23, align 4, !tbaa !9
  %182 = getelementptr inbounds %struct.spng_ihdr, ptr %15, i32 0, i32 3
  %183 = load i8, ptr %182, align 1, !tbaa !15
  %184 = zext i8 %183 to i32
  %185 = icmp eq i32 %184, 3
  br i1 %185, label %186, label %187

186:                                              ; preds = %181
  store i32 4, ptr %23, align 4, !tbaa !9
  br label %187

187:                                              ; preds = %186, %181
  %188 = load ptr, ptr %13, align 8, !tbaa !5
  %189 = load i32, ptr %23, align 4, !tbaa !9
  %190 = call i32 @spng_decoded_image_size(ptr noundef %188, i32 noundef %189, ptr noundef %21)
  store i32 %190, ptr %12, align 4, !tbaa !9
  %191 = load i32, ptr %12, align 4, !tbaa !9
  %192 = icmp ne i32 %191, 0
  br i1 %192, label %193, label %194

193:                                              ; preds = %187
  store i8 1, ptr %16, align 1, !tbaa !11
  store i32 4, ptr %17, align 4
  br label %245

194:                                              ; preds = %187
  %195 = load i64, ptr %21, align 8, !tbaa !13
  %196 = call noalias ptr @malloc(i64 noundef %195) #8
  store ptr %196, ptr %14, align 8, !tbaa !5
  %197 = load ptr, ptr %14, align 8, !tbaa !5
  %198 = load ptr, ptr %10, align 8, !tbaa !5
  store ptr %197, ptr %198, align 8, !tbaa !5
  %199 = load ptr, ptr %14, align 8, !tbaa !5
  %200 = icmp eq ptr %199, null
  br i1 %200, label %201, label %202

201:                                              ; preds = %194
  store i8 1, ptr %16, align 1, !tbaa !11
  store i32 4, ptr %17, align 4
  br label %245

202:                                              ; preds = %194
  %203 = load ptr, ptr %9, align 8, !tbaa !5
  %204 = load i32, ptr %203, align 4, !tbaa !9
  %205 = icmp eq i32 %204, 4
  br i1 %205, label %206, label %211

206:                                              ; preds = %202
  %207 = load ptr, ptr %13, align 8, !tbaa !5
  %208 = load ptr, ptr %14, align 8, !tbaa !5
  %209 = load i64, ptr %21, align 8, !tbaa !13
  %210 = call i32 @spng_decode_image(ptr noundef %207, ptr noundef %208, i64 noundef %209, i32 noundef 1, i32 noundef 0)
  store i32 %210, ptr %12, align 4, !tbaa !9
  br label %231

211:                                              ; preds = %202
  %212 = load ptr, ptr %9, align 8, !tbaa !5
  %213 = load i32, ptr %212, align 4, !tbaa !9
  %214 = icmp eq i32 %213, 1
  br i1 %214, label %215, label %220

215:                                              ; preds = %211
  %216 = load ptr, ptr %13, align 8, !tbaa !5
  %217 = load ptr, ptr %14, align 8, !tbaa !5
  %218 = load i64, ptr %21, align 8, !tbaa !13
  %219 = call i32 @spng_decode_image(ptr noundef %216, ptr noundef %217, i64 noundef %218, i32 noundef 64, i32 noundef 0)
  store i32 %219, ptr %12, align 4, !tbaa !9
  br label %230

220:                                              ; preds = %211
  %221 = load ptr, ptr %9, align 8, !tbaa !5
  %222 = load i32, ptr %221, align 4, !tbaa !9
  %223 = icmp eq i32 %222, 3
  br i1 %223, label %224, label %229

224:                                              ; preds = %220
  %225 = load ptr, ptr %13, align 8, !tbaa !5
  %226 = load ptr, ptr %14, align 8, !tbaa !5
  %227 = load i64, ptr %21, align 8, !tbaa !13
  %228 = call i32 @spng_decode_image(ptr noundef %225, ptr noundef %226, i64 noundef %227, i32 noundef 4, i32 noundef 0)
  store i32 %228, ptr %12, align 4, !tbaa !9
  br label %229

229:                                              ; preds = %224, %220
  br label %230

230:                                              ; preds = %229, %215
  br label %231

231:                                              ; preds = %230, %206
  %232 = load i32, ptr %12, align 4, !tbaa !9
  %233 = icmp ne i32 %232, 0
  br i1 %233, label %234, label %244

234:                                              ; preds = %231
  br label %235

235:                                              ; preds = %234
  %236 = load ptr, ptr @stderr, align 8, !tbaa !5
  %237 = load i32, ptr %12, align 4, !tbaa !9
  %238 = call ptr @spng_strerror(i32 noundef %237)
  %239 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %236, ptr noundef @.str.13, ptr noundef %238) #7
  %240 = load ptr, ptr @stderr, align 8, !tbaa !5
  %241 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %240, ptr noundef @.str.2) #7
  br label %242

242:                                              ; preds = %235
  br label %243

243:                                              ; preds = %242
  store i8 1, ptr %16, align 1, !tbaa !11
  store i32 4, ptr %17, align 4
  br label %245

244:                                              ; preds = %231
  store i32 0, ptr %17, align 4
  br label %245

245:                                              ; preds = %244, %243, %201, %193
  call void @llvm.lifetime.end.p0(i64 4, ptr %23) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #7
  br label %246

246:                                              ; preds = %245, %167
  call void @llvm.lifetime.end.p0(i64 1028, ptr %20) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #7
  br label %247

247:                                              ; preds = %246, %73
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #7
  %248 = load i32, ptr %17, align 4
  switch i32 %248, label %256 [
    i32 0, label %249
    i32 4, label %251
  ]

249:                                              ; preds = %247
  br label %250

250:                                              ; preds = %249
  br label %251

251:                                              ; preds = %250, %247, %49
  %252 = load ptr, ptr %13, align 8, !tbaa !5
  call void @spng_ctx_free(ptr noundef %252)
  store i32 0, ptr %17, align 4
  br label %253

253:                                              ; preds = %251, %36
  call void @llvm.lifetime.end.p0(i64 1, ptr %16) #7
  call void @llvm.lifetime.end.p0(i64 16, ptr %15) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #7
  %254 = load i32, ptr %17, align 4
  switch i32 %254, label %256 [
    i32 0, label %255
    i32 1, label %255
  ]

255:                                              ; preds = %253, %253
  ret void

256:                                              ; preds = %253, %247
  unreachable
}

declare i32 @spng_set_crc_action(ptr noundef, i32 noundef, i32 noundef) #1

declare i32 @spng_set_chunk_limits(ptr noundef, i64 noundef, i64 noundef) #1

declare i32 @spng_get_ihdr(ptr noundef, ptr noundef) #1

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef ptr @_ZL14color_type_str15spng_color_type(i32 noundef) #5

declare i32 @spng_get_plte(ptr noundef, ptr noundef) #1

declare i32 @spng_decoded_image_size(ptr noundef, i32 noundef, ptr noundef) #1

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #6

declare i32 @spng_decode_image(ptr noundef, ptr noundef, i64 noundef, i32 noundef, i32 noundef) #1

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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { 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 #5 = { 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 allocsize(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 #7 = { nounwind }
attributes #8 = { nounwind allocsize(0) }

!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 = !{!16, !7, i64 9}
!16 = !{!"_ZTS9spng_ihdr", !10, i64 0, !10, i64 4, !7, i64 8, !7, i64 9, !7, i64 10, !7, i64 11, !7, i64 12}
!17 = !{!16, !10, i64 0}
!18 = !{!16, !10, i64 4}
!19 = !{!16, !7, i64 8}
!20 = !{!16, !7, i64 10}
!21 = !{!16, !7, i64 11}
!22 = !{!16, !7, i64 12}
!23 = !{!24, !10, i64 0}
!24 = !{!"_ZTS9spng_plte", !10, i64 0, !7, i64 4}


; 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 }
%struct.spng_plte = type { i32, [256 x %struct.spng_plte_entry] }
%struct.spng_plte_entry = type { i8, i8, i8, i8 }

@stderr = external local_unnamed_addr global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [56 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [63 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [42 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [31 x i8], align 1

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

declare ptr @spng_ctx_new(i32 noundef) local_unnamed_addr #1

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

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

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

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

declare ptr @spng_strerror(i32 noundef) local_unnamed_addr #1

declare void @spng_ctx_free(ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

; Function Attrs: mustprogress uwtable
define dso_local void @px_read_png(ptr noundef %0, ptr nocapture noundef writeonly %1, ptr nocapture noundef writeonly %2, ptr nocapture noundef %3, ptr nocapture noundef writeonly %4) local_unnamed_addr #4 {
  %6 = alloca %struct.spng_ihdr, align 4
  %7 = alloca %struct.spng_plte, align 4
  %8 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %6) #7
  %9 = tail call noalias ptr @fopen(ptr noundef %0, ptr noundef nonnull @.str.4)
  %10 = icmp eq ptr %9, null
  br i1 %10, label %11, label %16

11:                                               ; preds = %5
  %12 = load ptr, ptr @stderr, align 8, !tbaa !5
  %13 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %12, ptr noundef nonnull @.str.5, ptr noundef %0) #8
  %14 = load ptr, ptr @stderr, align 8, !tbaa !5
  %15 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %14, ptr noundef nonnull @.str.2) #8
  br label %111

16:                                               ; preds = %5
  %17 = tail call ptr @spng_ctx_new(i32 noundef 0)
  %18 = icmp eq ptr %17, null
  br i1 %18, label %19, label %24

19:                                               ; preds = %16
  %20 = load ptr, ptr @stderr, align 8, !tbaa !5
  %21 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %20, ptr noundef nonnull @.str.6) #8
  %22 = load ptr, ptr @stderr, align 8, !tbaa !5
  %23 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %22, ptr noundef nonnull @.str.2) #8
  br label %110

24:                                               ; preds = %16
  %25 = tail call i32 @spng_set_crc_action(ptr noundef nonnull %17, i32 noundef 2, i32 noundef 2)
  %26 = tail call i32 @spng_set_chunk_limits(ptr noundef nonnull %17, i64 noundef 67108864, i64 noundef 67108864)
  %27 = tail call i32 @spng_set_png_file(ptr noundef nonnull %17, ptr noundef nonnull %9)
  %28 = call i32 @spng_get_ihdr(ptr noundef nonnull %17, ptr noundef nonnull %6)
  %.not = icmp eq i32 %28, 0
  br i1 %.not, label %35, label %29

29:                                               ; preds = %24
  %30 = load ptr, ptr @stderr, align 8, !tbaa !5
  %31 = call ptr @spng_strerror(i32 noundef %28)
  %32 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %30, ptr noundef nonnull @.str.7, ptr noundef %31) #8
  %33 = load ptr, ptr @stderr, align 8, !tbaa !5
  %34 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %33, ptr noundef nonnull @.str.2) #8
  br label %110

35:                                               ; preds = %24
  %36 = getelementptr inbounds i8, ptr %6, i64 9
  %37 = load i8, ptr %36, align 1, !tbaa !9
  %38 = zext i8 %37 to i32
  %39 = call noundef ptr @_ZL14color_type_str15spng_color_type(i32 noundef %38)
  %40 = load ptr, ptr @stderr, align 8, !tbaa !5
  %41 = load i32, ptr %6, align 4, !tbaa !12
  %42 = getelementptr inbounds i8, ptr %6, i64 4
  %43 = load i32, ptr %42, align 4, !tbaa !13
  %44 = getelementptr inbounds i8, ptr %6, i64 8
  %45 = load i8, ptr %44, align 4, !tbaa !14
  %46 = zext i8 %45 to i32
  %47 = load i8, ptr %36, align 1, !tbaa !9
  %48 = zext i8 %47 to i32
  %49 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %40, ptr noundef nonnull @.str.8, i32 noundef %41, i32 noundef %43, i32 noundef %46, i32 noundef %48, ptr noundef %39) #8
  %50 = load ptr, ptr @stderr, align 8, !tbaa !5
  %51 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %50, ptr noundef nonnull @.str.2) #8
  %52 = load ptr, ptr @stderr, align 8, !tbaa !5
  %53 = getelementptr inbounds i8, ptr %6, i64 10
  %54 = load i8, ptr %53, align 2, !tbaa !15
  %55 = zext i8 %54 to i32
  %56 = getelementptr inbounds i8, ptr %6, i64 11
  %57 = load i8, ptr %56, align 1, !tbaa !16
  %58 = zext i8 %57 to i32
  %59 = getelementptr inbounds i8, ptr %6, i64 12
  %60 = load i8, ptr %59, align 4, !tbaa !17
  %61 = zext i8 %60 to i32
  %62 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %52, ptr noundef nonnull @.str.9, i32 noundef %55, i32 noundef %58, i32 noundef %61) #8
  %63 = load ptr, ptr @stderr, align 8, !tbaa !5
  %64 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %63, ptr noundef nonnull @.str.2) #8
  %65 = load i32, ptr %42, align 4, !tbaa !13
  store i32 %65, ptr %1, align 4, !tbaa !18
  %66 = load i32, ptr %6, align 4, !tbaa !12
  store i32 %66, ptr %2, align 4, !tbaa !18
  %67 = load i8, ptr %36, align 1, !tbaa !9
  switch i8 %67, label %70 [
    i8 0, label %75
    i8 2, label %68
    i8 6, label %69
  ]

68:                                               ; preds = %35
  br label %75

69:                                               ; preds = %35
  br label %75

70:                                               ; preds = %35
  %71 = load ptr, ptr @stderr, align 8, !tbaa !5
  %72 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %71, ptr noundef nonnull @.str.10) #8
  %73 = load ptr, ptr @stderr, align 8, !tbaa !5
  %74 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %73, ptr noundef nonnull @.str.2) #8
  br label %75

75:                                               ; preds = %35, %68, %70, %69
  %.sink = phi i32 [ 3, %68 ], [ 0, %70 ], [ 4, %69 ], [ 1, %35 ]
  store i32 %.sink, ptr %3, align 4, !tbaa !18
  call void @llvm.lifetime.start.p0(i64 1028, ptr nonnull %7) #7
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 4 dereferenceable(1028) %7, i8 0, i64 1028, i1 false)
  %76 = call i32 @spng_get_plte(ptr noundef nonnull %17, ptr noundef nonnull %7)
  switch i32 %76, label %77 [
    i32 0, label %83
    i32 73, label %89
  ]

77:                                               ; preds = %75
  %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.11, ptr noundef %79) #8
  %81 = load ptr, ptr @stderr, align 8, !tbaa !5
  %82 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %81, ptr noundef nonnull @.str.2) #8
  br label %109

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

89:                                               ; preds = %75, %83
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %8) #7
  %90 = load i8, ptr %36, align 1, !tbaa !9
  %91 = icmp eq i8 %90, 3
  %spec.store.select = select i1 %91, i32 4, i32 256
  %92 = call i32 @spng_decoded_image_size(ptr noundef nonnull %17, i32 noundef %spec.store.select, ptr noundef nonnull %8)
  %.not51 = icmp eq i32 %92, 0
  br i1 %.not51, label %93, label %.thread

93:                                               ; preds = %89
  %94 = load i64, ptr %8, align 8, !tbaa !21
  %95 = call noalias ptr @malloc(i64 noundef %94) #9
  store ptr %95, ptr %4, align 8, !tbaa !5
  %96 = icmp eq ptr %95, null
  br i1 %96, label %.thread, label %97

97:                                               ; preds = %93
  %98 = load i32, ptr %3, align 4, !tbaa !18
  switch i32 %98, label %.thread [
    i32 4, label %101
    i32 1, label %99
    i32 3, label %100
  ]

99:                                               ; preds = %97
  br label %101

100:                                              ; preds = %97
  br label %101

101:                                              ; preds = %97, %99, %100
  %.sink55 = phi i32 [ 64, %99 ], [ 4, %100 ], [ 1, %97 ]
  %102 = call i32 @spng_decode_image(ptr noundef nonnull %17, ptr noundef nonnull %95, i64 noundef %94, i32 noundef %.sink55, i32 noundef 0)
  %.not52 = icmp eq i32 %102, 0
  br i1 %.not52, label %.thread, label %103

103:                                              ; preds = %101
  %104 = load ptr, ptr @stderr, align 8, !tbaa !5
  %105 = call ptr @spng_strerror(i32 noundef %102)
  %106 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %104, ptr noundef nonnull @.str.13, ptr noundef %105) #8
  %107 = load ptr, ptr @stderr, align 8, !tbaa !5
  %108 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %107, ptr noundef nonnull @.str.2) #8
  br label %.thread

.thread:                                          ; preds = %97, %101, %93, %89, %103
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #7
  br label %109

109:                                              ; preds = %.thread, %77
  call void @llvm.lifetime.end.p0(i64 1028, ptr nonnull %7) #7
  br label %110

110:                                              ; preds = %29, %109, %19
  call void @spng_ctx_free(ptr noundef %17)
  br label %111

111:                                              ; preds = %110, %11
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %6) #7
  ret void
}

declare i32 @spng_set_crc_action(ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

declare i32 @spng_set_chunk_limits(ptr noundef, i64 noundef, i64 noundef) local_unnamed_addr #1

declare i32 @spng_get_ihdr(ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef ptr @_ZL14color_type_str15spng_color_type(i32 noundef) local_unnamed_addr #5

declare i32 @spng_get_plte(ptr noundef, ptr noundef) local_unnamed_addr #1

declare i32 @spng_decoded_image_size(ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #6

declare i32 @spng_decode_image(ptr noundef, ptr noundef, i64 noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

attributes #0 = { mustprogress 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 = { 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 #3 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { 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 #5 = { 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 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) 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 #7 = { nounwind }
attributes #8 = { cold nounwind }
attributes #9 = { nounwind allocsize(0) }

!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, !7, i64 9}
!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, !11, i64 4}
!14 = !{!10, !7, i64 8}
!15 = !{!10, !7, i64 10}
!16 = !{!10, !7, i64 11}
!17 = !{!10, !7, i64 12}
!18 = !{!11, !11, i64 0}
!19 = !{!20, !11, i64 0}
!20 = !{!"_ZTS9spng_plte", !11, i64 0, !7, i64 4}
!21 = !{!22, !22, i64 0}
!22 = !{!"long", !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass