; LLVM IR from Try/Tempest :: Engine/thirdparty/libpng (pngwrite)

; 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.png_struct_def = type { [1 x %struct.__jmp_buf_tag], ptr, ptr, i64, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i8, i8, i32, i32, i32, i32, %struct.z_stream_s, ptr, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i64, i32, i32, i32, ptr, ptr, ptr, ptr, i64, i32, i32, ptr, i16, i32, i16, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i16, i8, i32, %struct.png_color_16_struct, %struct.png_color_16_struct, ptr, i32, i32, i32, i32, ptr, ptr, ptr, ptr, ptr, ptr, %struct.png_color_8_struct, %struct.png_color_8_struct, ptr, %struct.png_color_16_struct, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i32, i32, i64, i64, i64, i64, i32, i32, ptr, ptr, i32, [29 x i8], i32, ptr, ptr, i32, i32, ptr, i8, i8, i16, i16, i32, i8, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i8, i32, i32, i32, i64, %struct.png_unknown_chunk_t, i64, ptr, i64, i32, i32, ptr, [4 x ptr], %struct.png_colorspace }
%struct.__jmp_buf_tag = type { [8 x i64], i32, %struct.__sigset_t }
%struct.__sigset_t = type { [16 x i64] }
%struct.z_stream_s = type { ptr, i32, i64, ptr, i32, i64, ptr, ptr, ptr, ptr, ptr, i32, i64, i64 }
%struct.png_color_8_struct = type { i8, i8, i8, i8, i8 }
%struct.png_color_16_struct = type { i8, i16, i16, i16, i16 }
%struct.png_unknown_chunk_t = type { [5 x i8], ptr, i64, i8 }
%struct.png_colorspace = type { i32, %struct.png_xy, %struct.png_XYZ, i16, i16 }
%struct.png_xy = type { i32, i32, i32, i32, i32, i32, i32, i32 }
%struct.png_XYZ = type { i32, i32, i32, i32, i32, i32, i32, i32, i32 }

@.str.7 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [57 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [29 x i8], align 1

declare void @png_app_warning(ptr noundef, 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: noreturn
declare void @png_error(ptr noundef, ptr noundef) #2

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

; Function Attrs: nounwind uwtable
define dso_local void @png_set_filter(ptr noalias noundef %0, i32 noundef %1, i32 noundef %2) #3 {
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i64, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  store i32 %2, ptr %6, align 4, !tbaa !9
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  %10 = icmp eq ptr %9, null
  br i1 %10, label %11, label %12

11:                                               ; preds = %3
  br label %194

12:                                               ; preds = %3
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.png_struct_def, ptr %13, i32 0, i32 122
  %15 = load i32, ptr %14, align 8, !tbaa !11
  %16 = and i32 %15, 4
  %17 = icmp ne i32 %16, 0
  br i1 %17, label %18, label %22

18:                                               ; preds = %12
  %19 = load i32, ptr %5, align 4, !tbaa !9
  %20 = icmp eq i32 %19, 64
  br i1 %20, label %21, label %22

21:                                               ; preds = %18
  store i32 0, ptr %5, align 4, !tbaa !9
  br label %22

22:                                               ; preds = %21, %18, %12
  %23 = load i32, ptr %5, align 4, !tbaa !9
  %24 = icmp eq i32 %23, 0
  br i1 %24, label %25, label %192

25:                                               ; preds = %22
  %26 = load i32, ptr %6, align 4, !tbaa !9
  %27 = and i32 %26, 255
  switch i32 %27, label %45 [
    i32 5, label %28
    i32 6, label %28
    i32 7, label %28
    i32 0, label %30
    i32 1, label %33
    i32 2, label %36
    i32 3, label %39
    i32 4, label %42
  ]

28:                                               ; preds = %25, %25, %25
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  call void @png_app_error(ptr noundef %29, ptr noundef @.str.7)
  br label %30

30:                                               ; preds = %28, %25
  %31 = load ptr, ptr %4, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.png_struct_def, ptr %31, i32 0, i32 60
  store i8 8, ptr %32, align 2, !tbaa !22
  br label %50

33:                                               ; preds = %25
  %34 = load ptr, ptr %4, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.png_struct_def, ptr %34, i32 0, i32 60
  store i8 16, ptr %35, align 2, !tbaa !22
  br label %50

36:                                               ; preds = %25
  %37 = load ptr, ptr %4, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.png_struct_def, ptr %37, i32 0, i32 60
  store i8 32, ptr %38, align 2, !tbaa !22
  br label %50

39:                                               ; preds = %25
  %40 = load ptr, ptr %4, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.png_struct_def, ptr %40, i32 0, i32 60
  store i8 64, ptr %41, align 2, !tbaa !22
  br label %50

42:                                               ; preds = %25
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.png_struct_def, ptr %43, i32 0, i32 60
  store i8 -128, ptr %44, align 2, !tbaa !22
  br label %50

45:                                               ; preds = %25
  %46 = load i32, ptr %6, align 4, !tbaa !9
  %47 = trunc i32 %46 to i8
  %48 = load ptr, ptr %4, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.png_struct_def, ptr %48, i32 0, i32 60
  store i8 %47, ptr %49, align 2, !tbaa !22
  br label %50

50:                                               ; preds = %45, %42, %39, %36, %33, %30
  %51 = load ptr, ptr %4, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.png_struct_def, ptr %51, i32 0, i32 46
  %53 = load ptr, ptr %52, align 8, !tbaa !23
  %54 = icmp ne ptr %53, null
  br i1 %54, label %55, label %187

55:                                               ; preds = %50
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %56 = load ptr, ptr %4, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.png_struct_def, ptr %56, i32 0, i32 38
  %58 = load i32, ptr %57, align 4, !tbaa !24
  %59 = icmp eq i32 %58, 1
  br i1 %59, label %60, label %63

60:                                               ; preds = %55
  %61 = load i32, ptr %6, align 4, !tbaa !9
  %62 = and i32 %61, -225
  store i32 %62, ptr %6, align 4, !tbaa !9
  br label %63

63:                                               ; preds = %60, %55
  %64 = load ptr, ptr %4, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.png_struct_def, ptr %64, i32 0, i32 37
  %66 = load i32, ptr %65, align 8, !tbaa !25
  %67 = icmp eq i32 %66, 1
  br i1 %67, label %68, label %71

68:                                               ; preds = %63
  %69 = load i32, ptr %6, align 4, !tbaa !9
  %70 = and i32 %69, -209
  store i32 %70, ptr %6, align 4, !tbaa !9
  br label %71

71:                                               ; preds = %68, %63
  %72 = load i32, ptr %6, align 4, !tbaa !9
  %73 = and i32 %72, 224
  %74 = icmp ne i32 %73, 0
  br i1 %74, label %75, label %84

75:                                               ; preds = %71
  %76 = load ptr, ptr %4, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.png_struct_def, ptr %76, i32 0, i32 45
  %78 = load ptr, ptr %77, align 8, !tbaa !26
  %79 = icmp eq ptr %78, null
  br i1 %79, label %80, label %84

80:                                               ; preds = %75
  %81 = load ptr, ptr %4, align 8, !tbaa !5
  call void @png_app_warning(ptr noundef %81, ptr noundef @.str.8)
  %82 = load i32, ptr %6, align 4, !tbaa !9
  %83 = and i32 %82, -225
  store i32 %83, ptr %6, align 4, !tbaa !9
  br label %84

84:                                               ; preds = %80, %75, %71
  store i32 0, ptr %7, align 4, !tbaa !9
  %85 = load i32, ptr %6, align 4, !tbaa !9
  %86 = and i32 %85, 16
  %87 = icmp ne i32 %86, 0
  br i1 %87, label %88, label %91

88:                                               ; preds = %84
  %89 = load i32, ptr %7, align 4, !tbaa !9
  %90 = add nsw i32 %89, 1
  store i32 %90, ptr %7, align 4, !tbaa !9
  br label %91

91:                                               ; preds = %88, %84
  %92 = load i32, ptr %6, align 4, !tbaa !9
  %93 = and i32 %92, 32
  %94 = icmp ne i32 %93, 0
  br i1 %94, label %95, label %98

95:                                               ; preds = %91
  %96 = load i32, ptr %7, align 4, !tbaa !9
  %97 = add nsw i32 %96, 1
  store i32 %97, ptr %7, align 4, !tbaa !9
  br label %98

98:                                               ; preds = %95, %91
  %99 = load i32, ptr %6, align 4, !tbaa !9
  %100 = and i32 %99, 64
  %101 = icmp ne i32 %100, 0
  br i1 %101, label %102, label %105

102:                                              ; preds = %98
  %103 = load i32, ptr %7, align 4, !tbaa !9
  %104 = add nsw i32 %103, 1
  store i32 %104, ptr %7, align 4, !tbaa !9
  br label %105

105:                                              ; preds = %102, %98
  %106 = load i32, ptr %6, align 4, !tbaa !9
  %107 = and i32 %106, 128
  %108 = icmp ne i32 %107, 0
  br i1 %108, label %109, label %112

109:                                              ; preds = %105
  %110 = load i32, ptr %7, align 4, !tbaa !9
  %111 = add nsw i32 %110, 1
  store i32 %111, ptr %7, align 4, !tbaa !9
  br label %112

112:                                              ; preds = %109, %105
  %113 = load ptr, ptr %4, align 8, !tbaa !5
  %114 = getelementptr inbounds %struct.png_struct_def, ptr %113, i32 0, i32 66
  %115 = load i8, ptr %114, align 4, !tbaa !27
  %116 = zext i8 %115 to i32
  %117 = load ptr, ptr %4, align 8, !tbaa !5
  %118 = getelementptr inbounds %struct.png_struct_def, ptr %117, i32 0, i32 63
  %119 = load i8, ptr %118, align 1, !tbaa !28
  %120 = zext i8 %119 to i32
  %121 = mul nsw i32 %116, %120
  %122 = icmp sge i32 %121, 8
  br i1 %122, label %123, label %140

123:                                              ; preds = %112
  %124 = load ptr, ptr %4, align 8, !tbaa !5
  %125 = getelementptr inbounds %struct.png_struct_def, ptr %124, i32 0, i32 37
  %126 = load i32, ptr %125, align 8, !tbaa !25
  %127 = zext i32 %126 to i64
  %128 = load ptr, ptr %4, align 8, !tbaa !5
  %129 = getelementptr inbounds %struct.png_struct_def, ptr %128, i32 0, i32 66
  %130 = load i8, ptr %129, align 4, !tbaa !27
  %131 = zext i8 %130 to i32
  %132 = load ptr, ptr %4, align 8, !tbaa !5
  %133 = getelementptr inbounds %struct.png_struct_def, ptr %132, i32 0, i32 63
  %134 = load i8, ptr %133, align 1, !tbaa !28
  %135 = zext i8 %134 to i32
  %136 = mul nsw i32 %131, %135
  %137 = sext i32 %136 to i64
  %138 = lshr i64 %137, 3
  %139 = mul i64 %127, %138
  br label %158

140:                                              ; preds = %112
  %141 = load ptr, ptr %4, align 8, !tbaa !5
  %142 = getelementptr inbounds %struct.png_struct_def, ptr %141, i32 0, i32 37
  %143 = load i32, ptr %142, align 8, !tbaa !25
  %144 = zext i32 %143 to i64
  %145 = load ptr, ptr %4, align 8, !tbaa !5
  %146 = getelementptr inbounds %struct.png_struct_def, ptr %145, i32 0, i32 66
  %147 = load i8, ptr %146, align 4, !tbaa !27
  %148 = zext i8 %147 to i32
  %149 = load ptr, ptr %4, align 8, !tbaa !5
  %150 = getelementptr inbounds %struct.png_struct_def, ptr %149, i32 0, i32 63
  %151 = load i8, ptr %150, align 1, !tbaa !28
  %152 = zext i8 %151 to i32
  %153 = mul nsw i32 %148, %152
  %154 = sext i32 %153 to i64
  %155 = mul i64 %144, %154
  %156 = add i64 %155, 7
  %157 = lshr i64 %156, 3
  br label %158

158:                                              ; preds = %140, %123
  %159 = phi i64 [ %139, %123 ], [ %157, %140 ]
  %160 = add i64 %159, 1
  store i64 %160, ptr %8, align 8, !tbaa !29
  %161 = load ptr, ptr %4, align 8, !tbaa !5
  %162 = getelementptr inbounds %struct.png_struct_def, ptr %161, i32 0, i32 47
  %163 = load ptr, ptr %162, align 8, !tbaa !30
  %164 = icmp eq ptr %163, null
  br i1 %164, label %165, label %171

165:                                              ; preds = %158
  %166 = load ptr, ptr %4, align 8, !tbaa !5
  %167 = load i64, ptr %8, align 8, !tbaa !29
  %168 = call noalias ptr @png_malloc(ptr noundef %166, i64 noundef %167)
  %169 = load ptr, ptr %4, align 8, !tbaa !5
  %170 = getelementptr inbounds %struct.png_struct_def, ptr %169, i32 0, i32 47
  store ptr %168, ptr %170, align 8, !tbaa !30
  br label %171

171:                                              ; preds = %165, %158
  %172 = load i32, ptr %7, align 4, !tbaa !9
  %173 = icmp sgt i32 %172, 1
  br i1 %173, label %174, label %186

174:                                              ; preds = %171
  %175 = load ptr, ptr %4, align 8, !tbaa !5
  %176 = getelementptr inbounds %struct.png_struct_def, ptr %175, i32 0, i32 48
  %177 = load ptr, ptr %176, align 8, !tbaa !31
  %178 = icmp eq ptr %177, null
  br i1 %178, label %179, label %185

179:                                              ; preds = %174
  %180 = load ptr, ptr %4, align 8, !tbaa !5
  %181 = load i64, ptr %8, align 8, !tbaa !29
  %182 = call noalias ptr @png_malloc(ptr noundef %180, i64 noundef %181)
  %183 = load ptr, ptr %4, align 8, !tbaa !5
  %184 = getelementptr inbounds %struct.png_struct_def, ptr %183, i32 0, i32 48
  store ptr %182, ptr %184, align 8, !tbaa !31
  br label %185

185:                                              ; preds = %179, %174
  br label %186

186:                                              ; preds = %185, %171
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  br label %187

187:                                              ; preds = %186, %50
  %188 = load i32, ptr %6, align 4, !tbaa !9
  %189 = trunc i32 %188 to i8
  %190 = load ptr, ptr %4, align 8, !tbaa !5
  %191 = getelementptr inbounds %struct.png_struct_def, ptr %190, i32 0, i32 60
  store i8 %189, ptr %191, align 2, !tbaa !22
  br label %194

192:                                              ; preds = %22
  %193 = load ptr, ptr %4, align 8, !tbaa !5
  call void @png_error(ptr noundef %193, ptr noundef @.str.9) #5
  unreachable

194:                                              ; preds = %187, %11
  ret void
}

declare void @png_app_error(ptr noundef, ptr noundef) #0

declare noalias ptr @png_malloc(ptr noundef, i64 noundef) #0

attributes #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 = { noreturn "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nounwind }
attributes #5 = { noreturn }

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 984}
!12 = !{!"png_struct_def", !7, i64 0, !6, i64 200, !6, i64 208, !13, i64 216, !6, i64 224, !6, i64 232, !6, i64 240, !6, i64 248, !6, i64 256, !6, i64 264, !6, i64 272, !6, i64 280, !6, i64 288, !7, i64 296, !7, i64 297, !10, i64 300, !10, i64 304, !10, i64 308, !10, i64 312, !14, i64 320, !6, i64 432, !10, i64 440, !10, i64 444, !10, i64 448, !10, i64 452, !10, i64 456, !10, i64 460, !10, i64 464, !10, i64 468, !10, i64 472, !10, i64 476, !10, i64 480, !10, i64 484, !10, i64 488, !10, i64 492, !10, i64 496, !10, i64 500, !10, i64 504, !10, i64 508, !10, i64 512, !10, i64 516, !13, i64 520, !10, i64 528, !10, i64 532, !10, i64 536, !6, i64 544, !6, i64 552, !6, i64 560, !6, i64 568, !13, i64 576, !10, i64 584, !10, i64 588, !6, i64 592, !15, i64 600, !10, i64 604, !15, i64 608, !7, i64 610, !7, i64 611, !7, i64 612, !7, i64 613, !7, i64 614, !7, i64 615, !7, i64 616, !7, i64 617, !7, i64 618, !7, i64 619, !7, i64 620, !7, i64 621, !7, i64 622, !7, i64 623, !7, i64 624, !15, i64 626, !7, i64 628, !10, i64 632, !16, i64 636, !16, i64 646, !6, i64 656, !10, i64 664, !10, i64 668, !10, i64 672, !10, i64 676, !6, i64 680, !6, i64 688, !6, i64 696, !6, i64 704, !6, i64 712, !6, i64 720, !17, i64 728, !17, i64 733, !6, i64 744, !16, i64 752, !6, i64 768, !6, i64 776, !6, i64 784, !6, i64 792, !6, i64 800, !6, i64 808, !6, i64 816, !6, i64 824, !6, i64 832, !10, i64 840, !10, i64 844, !13, i64 848, !13, i64 856, !13, i64 864, !13, i64 872, !10, i64 880, !10, i64 884, !6, i64 888, !6, i64 896, !10, i64 904, !7, i64 908, !10, i64 940, !6, i64 944, !6, i64 952, !10, i64 960, !10, i64 964, !6, i64 968, !7, i64 976, !7, i64 977, !15, i64 978, !15, i64 980, !10, i64 984, !7, i64 988, !6, i64 992, !6, i64 1000, !6, i64 1008, !6, i64 1016, !6, i64 1024, !6, i64 1032, !6, i64 1040, !7, i64 1048, !10, i64 1052, !10, i64 1056, !10, i64 1060, !13, i64 1064, !18, i64 1072, !13, i64 1104, !6, i64 1112, !13, i64 1120, !10, i64 1128, !10, i64 1132, !6, i64 1136, !7, i64 1144, !19, i64 1176}
!13 = !{!"long", !7, i64 0}
!14 = !{!"z_stream_s", !6, i64 0, !10, i64 8, !13, i64 16, !6, i64 24, !10, i64 32, !13, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !10, i64 88, !13, i64 96, !13, i64 104}
!15 = !{!"short", !7, i64 0}
!16 = !{!"png_color_16_struct", !7, i64 0, !15, i64 2, !15, i64 4, !15, i64 6, !15, i64 8}
!17 = !{!"png_color_8_struct", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3, !7, i64 4}
!18 = !{!"png_unknown_chunk_t", !7, i64 0, !6, i64 8, !13, i64 16, !7, i64 24}
!19 = !{!"png_colorspace", !10, i64 0, !20, i64 4, !21, i64 36, !15, i64 72, !15, i64 74}
!20 = !{!"png_xy", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28}
!21 = !{!"png_XYZ", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !10, i64 32}
!22 = !{!12, !7, i64 614}
!23 = !{!12, !6, i64 552}
!24 = !{!12, !10, i64 508}
!25 = !{!12, !10, i64 504}
!26 = !{!12, !6, i64 544}
!27 = !{!12, !7, i64 620}
!28 = !{!12, !7, i64 617}
!29 = !{!13, !13, i64 0}
!30 = !{!12, !6, i64 560}
!31 = !{!12, !6, i64 568}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

@.str.7 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [57 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [29 x i8], align 1

declare void @png_app_warning(ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: noreturn
declare void @png_error(ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @png_set_filter(ptr noalias noundef %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #2 {
  %4 = icmp eq ptr %0, null
  br i1 %4, label %87, label %5

5:                                                ; preds = %3
  %6 = getelementptr inbounds i8, ptr %0, i64 984
  %7 = load i32, ptr %6, align 8, !tbaa !5
  %8 = and i32 %7, 4
  %9 = icmp ne i32 %8, 0
  %10 = icmp eq i32 %1, 64
  %or.cond = and i1 %10, %9
  %11 = icmp eq i32 %1, 0
  %12 = or i1 %11, %or.cond
  br i1 %12, label %13, label %86

13:                                               ; preds = %5
  %trunc = trunc i32 %2 to i8
  switch i8 %trunc, label %19 [
    i8 5, label %14
    i8 6, label %14
    i8 7, label %14
    i8 0, label %20
    i8 1, label %15
    i8 2, label %16
    i8 3, label %17
    i8 4, label %18
  ]

14:                                               ; preds = %13, %13, %13
  tail call void @png_app_error(ptr noundef nonnull %0, ptr noundef nonnull @.str.7) #3
  br label %20

15:                                               ; preds = %13
  br label %20

16:                                               ; preds = %13
  br label %20

17:                                               ; preds = %13
  br label %20

18:                                               ; preds = %13
  br label %20

19:                                               ; preds = %13
  br label %20

20:                                               ; preds = %13, %14, %19, %18, %17, %16, %15
  %trunc.sink = phi i8 [ %trunc, %19 ], [ -128, %18 ], [ 64, %17 ], [ 32, %16 ], [ 16, %15 ], [ 8, %14 ], [ 8, %13 ]
  %21 = getelementptr inbounds i8, ptr %0, i64 614
  store i8 %trunc.sink, ptr %21, align 2, !tbaa !20
  %22 = getelementptr inbounds i8, ptr %0, i64 552
  %23 = load ptr, ptr %22, align 8, !tbaa !21
  %.not = icmp eq ptr %23, null
  br i1 %.not, label %83, label %24

24:                                               ; preds = %20
  %25 = getelementptr inbounds i8, ptr %0, i64 508
  %26 = load i32, ptr %25, align 4, !tbaa !22
  %27 = icmp eq i32 %26, 1
  %28 = and i32 %2, -225
  %spec.select = select i1 %27, i32 %28, i32 %2
  %29 = getelementptr inbounds i8, ptr %0, i64 504
  %30 = load i32, ptr %29, align 8, !tbaa !23
  %31 = icmp eq i32 %30, 1
  %32 = and i32 %spec.select, -209
  %.151 = select i1 %31, i32 %32, i32 %spec.select
  %33 = and i32 %.151, 224
  %.not57 = icmp eq i32 %33, 0
  br i1 %.not57, label %40, label %34

34:                                               ; preds = %24
  %35 = getelementptr inbounds i8, ptr %0, i64 544
  %36 = load ptr, ptr %35, align 8, !tbaa !24
  %37 = icmp eq ptr %36, null
  br i1 %37, label %38, label %40

38:                                               ; preds = %34
  tail call void @png_app_warning(ptr noundef nonnull %0, ptr noundef nonnull @.str.8) #3
  %39 = and i32 %.151, -225
  br label %40

40:                                               ; preds = %38, %34, %24
  %.252 = phi i32 [ %39, %38 ], [ %.151, %34 ], [ %.151, %24 ]
  %41 = lshr i32 %.252, 4
  %.lobit = and i32 %41, 1
  %42 = lshr i32 %.252, 5
  %43 = and i32 %42, 1
  %.1 = add nuw nsw i32 %.lobit, %43
  %44 = lshr i32 %.252, 6
  %45 = and i32 %44, 1
  %.2 = add nuw nsw i32 %.1, %45
  %46 = lshr i32 %.252, 7
  %47 = and i32 %46, 1
  %.3 = add nuw nsw i32 %.2, %47
  %48 = getelementptr inbounds i8, ptr %0, i64 620
  %49 = load i8, ptr %48, align 4, !tbaa !25
  %50 = zext i8 %49 to i32
  %51 = getelementptr inbounds i8, ptr %0, i64 617
  %52 = load i8, ptr %51, align 1, !tbaa !26
  %53 = zext i8 %52 to i32
  %54 = mul nuw nsw i32 %53, %50
  %55 = icmp ugt i32 %54, 7
  %56 = load i32, ptr %29, align 8, !tbaa !23
  %57 = zext i32 %56 to i64
  br i1 %55, label %58, label %62

58:                                               ; preds = %40
  %59 = lshr i32 %54, 3
  %60 = zext nneg i32 %59 to i64
  %61 = mul nuw nsw i64 %57, %60
  br label %67

62:                                               ; preds = %40
  %63 = zext nneg i32 %54 to i64
  %64 = mul nuw nsw i64 %57, %63
  %65 = add nuw nsw i64 %64, 7
  %66 = lshr i64 %65, 3
  br label %67

67:                                               ; preds = %62, %58
  %68 = phi i64 [ %61, %58 ], [ %66, %62 ]
  %69 = add nuw nsw i64 %68, 1
  %70 = getelementptr inbounds i8, ptr %0, i64 560
  %71 = load ptr, ptr %70, align 8, !tbaa !27
  %72 = icmp eq ptr %71, null
  br i1 %72, label %73, label %75

73:                                               ; preds = %67
  %74 = tail call noalias ptr @png_malloc(ptr noundef nonnull %0, i64 noundef %69) #3
  store ptr %74, ptr %70, align 8, !tbaa !27
  br label %75

75:                                               ; preds = %73, %67
  %76 = icmp ugt i32 %.3, 1
  br i1 %76, label %77, label %83

77:                                               ; preds = %75
  %78 = getelementptr inbounds i8, ptr %0, i64 568
  %79 = load ptr, ptr %78, align 8, !tbaa !28
  %80 = icmp eq ptr %79, null
  br i1 %80, label %81, label %83

81:                                               ; preds = %77
  %82 = tail call noalias ptr @png_malloc(ptr noundef nonnull %0, i64 noundef %69) #3
  store ptr %82, ptr %78, align 8, !tbaa !28
  br label %83

83:                                               ; preds = %75, %81, %77, %20
  %.353 = phi i32 [ %2, %20 ], [ %.252, %77 ], [ %.252, %81 ], [ %.252, %75 ]
  %84 = trunc i32 %.353 to i8
  %85 = getelementptr inbounds i8, ptr %0, i64 614
  store i8 %84, ptr %85, align 2, !tbaa !20
  br label %87

86:                                               ; preds = %5
  tail call void @png_error(ptr noundef nonnull %0, ptr noundef nonnull @.str.9) #4
  unreachable

87:                                               ; preds = %3, %83
  ret void
}

declare void @png_app_error(ptr noundef, ptr noundef) local_unnamed_addr #0

declare noalias ptr @png_malloc(ptr noundef, i64 noundef) local_unnamed_addr #0

attributes #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 = { noreturn "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 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 }
attributes #4 = { noreturn 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, !11, i64 984}
!6 = !{!"png_struct_def", !7, i64 0, !9, i64 200, !9, i64 208, !10, i64 216, !9, i64 224, !9, i64 232, !9, i64 240, !9, i64 248, !9, i64 256, !9, i64 264, !9, i64 272, !9, i64 280, !9, i64 288, !7, i64 296, !7, i64 297, !11, i64 300, !11, i64 304, !11, i64 308, !11, i64 312, !12, i64 320, !9, i64 432, !11, i64 440, !11, i64 444, !11, i64 448, !11, i64 452, !11, i64 456, !11, i64 460, !11, i64 464, !11, i64 468, !11, i64 472, !11, i64 476, !11, i64 480, !11, i64 484, !11, i64 488, !11, i64 492, !11, i64 496, !11, i64 500, !11, i64 504, !11, i64 508, !11, i64 512, !11, i64 516, !10, i64 520, !11, i64 528, !11, i64 532, !11, i64 536, !9, i64 544, !9, i64 552, !9, i64 560, !9, i64 568, !10, i64 576, !11, i64 584, !11, i64 588, !9, i64 592, !13, i64 600, !11, i64 604, !13, i64 608, !7, i64 610, !7, i64 611, !7, i64 612, !7, i64 613, !7, i64 614, !7, i64 615, !7, i64 616, !7, i64 617, !7, i64 618, !7, i64 619, !7, i64 620, !7, i64 621, !7, i64 622, !7, i64 623, !7, i64 624, !13, i64 626, !7, i64 628, !11, i64 632, !14, i64 636, !14, i64 646, !9, i64 656, !11, i64 664, !11, i64 668, !11, i64 672, !11, i64 676, !9, i64 680, !9, i64 688, !9, i64 696, !9, i64 704, !9, i64 712, !9, i64 720, !15, i64 728, !15, i64 733, !9, i64 744, !14, i64 752, !9, i64 768, !9, i64 776, !9, i64 784, !9, i64 792, !9, i64 800, !9, i64 808, !9, i64 816, !9, i64 824, !9, i64 832, !11, i64 840, !11, i64 844, !10, i64 848, !10, i64 856, !10, i64 864, !10, i64 872, !11, i64 880, !11, i64 884, !9, i64 888, !9, i64 896, !11, i64 904, !7, i64 908, !11, i64 940, !9, i64 944, !9, i64 952, !11, i64 960, !11, i64 964, !9, i64 968, !7, i64 976, !7, i64 977, !13, i64 978, !13, i64 980, !11, i64 984, !7, i64 988, !9, i64 992, !9, i64 1000, !9, i64 1008, !9, i64 1016, !9, i64 1024, !9, i64 1032, !9, i64 1040, !7, i64 1048, !11, i64 1052, !11, i64 1056, !11, i64 1060, !10, i64 1064, !16, i64 1072, !10, i64 1104, !9, i64 1112, !10, i64 1120, !11, i64 1128, !11, i64 1132, !9, i64 1136, !7, i64 1144, !17, i64 1176}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!"any pointer", !7, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!"int", !7, i64 0}
!12 = !{!"z_stream_s", !9, i64 0, !11, i64 8, !10, i64 16, !9, i64 24, !11, i64 32, !10, i64 40, !9, i64 48, !9, i64 56, !9, i64 64, !9, i64 72, !9, i64 80, !11, i64 88, !10, i64 96, !10, i64 104}
!13 = !{!"short", !7, i64 0}
!14 = !{!"png_color_16_struct", !7, i64 0, !13, i64 2, !13, i64 4, !13, i64 6, !13, i64 8}
!15 = !{!"png_color_8_struct", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3, !7, i64 4}
!16 = !{!"png_unknown_chunk_t", !7, i64 0, !9, i64 8, !10, i64 16, !7, i64 24}
!17 = !{!"png_colorspace", !11, i64 0, !18, i64 4, !19, i64 36, !13, i64 72, !13, i64 74}
!18 = !{!"png_xy", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !11, i64 24, !11, i64 28}
!19 = !{!"png_XYZ", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !11, i64 24, !11, i64 28, !11, i64 32}
!20 = !{!6, !7, i64 614}
!21 = !{!6, !9, i64 552}
!22 = !{!6, !11, i64 508}
!23 = !{!6, !11, i64 504}
!24 = !{!6, !9, i64 544}
!25 = !{!6, !7, i64 620}
!26 = !{!6, !7, i64 617}
!27 = !{!6, !9, i64 560}
!28 = !{!6, !9, i64 568}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass