; LLVM IR from EyalAr/lwip :: src/lib/png (pngrutil)

; 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_color_16_struct = type { i8, i16, i16, i16, i16 }
%struct.png_struct_def = type { [1 x %struct.__jmp_buf_tag], ptr, ptr, i64, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i8, i8, i32, i32, i32, i32, %struct.z_stream_s, i32, i32, i32, i32, i64, i32, i32, i32, ptr, ptr, i64, i32, i32, ptr, i16, i32, i16, 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, 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, i8, [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_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 }
%struct.png_info_def = type { i32, i32, i32, i64, ptr, i16, i16, i8, i8, i8, i8, i8, i8, i8, i8, [8 x i8], %struct.png_colorspace, ptr, ptr, i32, i32, i32, ptr, %struct.png_time_struct, %struct.png_color_8_struct, ptr, %struct.png_color_16_struct, %struct.png_color_16_struct, i32, i32, i8, i32, i32, i8, ptr, ptr, i32, i32, ptr, ptr, i8, i8, i32, ptr, i32, ptr, i32, i8, ptr, ptr, ptr }
%struct.png_time_struct = type { i16, i8, i8, i8, i8, i8 }
%struct.png_color_struct = type { i8, i8, i8 }

@.str.4 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [14 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

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

; Function Attrs: nounwind uwtable
declare dso_local void @png_crc_read(ptr noalias noundef, ptr noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @png_crc_finish(ptr noalias noundef, i32 noundef) #1

; Function Attrs: noreturn
declare void @png_chunk_error(ptr noundef, ptr noundef) #2

declare void @png_chunk_benign_error(ptr noundef, ptr noundef) #3

; Function Attrs: nounwind uwtable
define dso_local void @png_handle_bKGD(ptr noalias noundef %0, ptr noalias noundef %1, i32 noundef %2) #1 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca [6 x i8], align 1
  %9 = alloca %struct.png_color_16_struct, align 2
  %10 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i32 %2, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.start.p0(i64 6, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 10, ptr %9) #4
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.png_struct_def, ptr %11, i32 0, i32 13
  %13 = load i32, ptr %12, align 4, !tbaa !11
  %14 = and i32 %13, 1
  %15 = icmp eq i32 %14, 0
  br i1 %15, label %16, label %18

16:                                               ; preds = %3
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  call void @png_chunk_error(ptr noundef %17, ptr noundef @.str.6) #5
  unreachable

18:                                               ; preds = %3
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.png_struct_def, ptr %19, i32 0, i32 13
  %21 = load i32, ptr %20, align 4, !tbaa !11
  %22 = and i32 %21, 4
  %23 = icmp ne i32 %22, 0
  br i1 %23, label %36, label %24

24:                                               ; preds = %18
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.png_struct_def, ptr %25, i32 0, i32 40
  %27 = load i8, ptr %26, align 1, !tbaa !22
  %28 = zext i8 %27 to i32
  %29 = icmp eq i32 %28, 3
  br i1 %29, label %30, label %41

30:                                               ; preds = %24
  %31 = load ptr, ptr %4, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.png_struct_def, ptr %31, i32 0, i32 13
  %33 = load i32, ptr %32, align 4, !tbaa !11
  %34 = and i32 %33, 2
  %35 = icmp eq i32 %34, 0
  br i1 %35, label %36, label %41

36:                                               ; preds = %30, %18
  %37 = load ptr, ptr %4, align 8, !tbaa !5
  %38 = load i32, ptr %6, align 4, !tbaa !9
  %39 = call i32 @png_crc_finish(ptr noundef %37, i32 noundef %38)
  %40 = load ptr, ptr %4, align 8, !tbaa !5
  call void @png_chunk_benign_error(ptr noundef %40, ptr noundef @.str.4)
  store i32 1, ptr %10, align 4
  br label %227

41:                                               ; preds = %30, %24
  %42 = load ptr, ptr %5, align 8, !tbaa !5
  %43 = icmp ne ptr %42, null
  br i1 %43, label %44, label %55

44:                                               ; preds = %41
  %45 = load ptr, ptr %5, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.png_info_def, ptr %45, i32 0, i32 2
  %47 = load i32, ptr %46, align 8, !tbaa !23
  %48 = and i32 %47, 32
  %49 = icmp ne i32 %48, 0
  br i1 %49, label %50, label %55

50:                                               ; preds = %44
  %51 = load ptr, ptr %4, align 8, !tbaa !5
  %52 = load i32, ptr %6, align 4, !tbaa !9
  %53 = call i32 @png_crc_finish(ptr noundef %51, i32 noundef %52)
  %54 = load ptr, ptr %4, align 8, !tbaa !5
  call void @png_chunk_benign_error(ptr noundef %54, ptr noundef @.str.7)
  store i32 1, ptr %10, align 4
  br label %227

55:                                               ; preds = %44, %41
  br label %56

56:                                               ; preds = %55
  br label %57

57:                                               ; preds = %56
  %58 = load ptr, ptr %4, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.png_struct_def, ptr %58, i32 0, i32 40
  %60 = load i8, ptr %59, align 1, !tbaa !22
  %61 = zext i8 %60 to i32
  %62 = icmp eq i32 %61, 3
  br i1 %62, label %63, label %64

63:                                               ; preds = %57
  store i32 1, ptr %7, align 4, !tbaa !9
  br label %74

64:                                               ; preds = %57
  %65 = load ptr, ptr %4, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.png_struct_def, ptr %65, i32 0, i32 40
  %67 = load i8, ptr %66, align 1, !tbaa !22
  %68 = zext i8 %67 to i32
  %69 = and i32 %68, 2
  %70 = icmp ne i32 %69, 0
  br i1 %70, label %71, label %72

71:                                               ; preds = %64
  store i32 6, ptr %7, align 4, !tbaa !9
  br label %73

72:                                               ; preds = %64
  store i32 2, ptr %7, align 4, !tbaa !9
  br label %73

73:                                               ; preds = %72, %71
  br label %74

74:                                               ; preds = %73, %63
  %75 = load i32, ptr %6, align 4, !tbaa !9
  %76 = load i32, ptr %7, align 4, !tbaa !9
  %77 = icmp ne i32 %75, %76
  br i1 %77, label %78, label %83

78:                                               ; preds = %74
  %79 = load ptr, ptr %4, align 8, !tbaa !5
  %80 = load i32, ptr %6, align 4, !tbaa !9
  %81 = call i32 @png_crc_finish(ptr noundef %79, i32 noundef %80)
  %82 = load ptr, ptr %4, align 8, !tbaa !5
  call void @png_chunk_benign_error(ptr noundef %82, ptr noundef @.str.5)
  store i32 1, ptr %10, align 4
  br label %227

83:                                               ; preds = %74
  %84 = load ptr, ptr %4, align 8, !tbaa !5
  %85 = getelementptr inbounds [6 x i8], ptr %8, i64 0, i64 0
  %86 = load i32, ptr %7, align 4, !tbaa !9
  call void @png_crc_read(ptr noundef %84, ptr noundef %85, i32 noundef %86)
  %87 = load ptr, ptr %4, align 8, !tbaa !5
  %88 = call i32 @png_crc_finish(ptr noundef %87, i32 noundef 0)
  %89 = icmp ne i32 %88, 0
  br i1 %89, label %90, label %91

90:                                               ; preds = %83
  store i32 1, ptr %10, align 4
  br label %227

91:                                               ; preds = %83
  %92 = load ptr, ptr %4, align 8, !tbaa !5
  %93 = getelementptr inbounds %struct.png_struct_def, ptr %92, i32 0, i32 40
  %94 = load i8, ptr %93, align 1, !tbaa !22
  %95 = zext i8 %94 to i32
  %96 = icmp eq i32 %95, 3
  br i1 %96, label %97, label %160

97:                                               ; preds = %91
  %98 = getelementptr inbounds [6 x i8], ptr %8, i64 0, i64 0
  %99 = load i8, ptr %98, align 1, !tbaa !26
  %100 = getelementptr inbounds %struct.png_color_16_struct, ptr %9, i32 0, i32 0
  store i8 %99, ptr %100, align 2, !tbaa !27
  %101 = load ptr, ptr %5, align 8, !tbaa !5
  %102 = icmp ne ptr %101, null
  br i1 %102, label %103, label %154

103:                                              ; preds = %97
  %104 = load ptr, ptr %5, align 8, !tbaa !5
  %105 = getelementptr inbounds %struct.png_info_def, ptr %104, i32 0, i32 5
  %106 = load i16, ptr %105, align 8, !tbaa !28
  %107 = zext i16 %106 to i32
  %108 = icmp ne i32 %107, 0
  br i1 %108, label %109, label %154

109:                                              ; preds = %103
  %110 = getelementptr inbounds [6 x i8], ptr %8, i64 0, i64 0
  %111 = load i8, ptr %110, align 1, !tbaa !26
  %112 = zext i8 %111 to i32
  %113 = load ptr, ptr %5, align 8, !tbaa !5
  %114 = getelementptr inbounds %struct.png_info_def, ptr %113, i32 0, i32 5
  %115 = load i16, ptr %114, align 8, !tbaa !28
  %116 = zext i16 %115 to i32
  %117 = icmp sge i32 %112, %116
  br i1 %117, label %118, label %120

118:                                              ; preds = %109
  %119 = load ptr, ptr %4, align 8, !tbaa !5
  call void @png_chunk_benign_error(ptr noundef %119, ptr noundef @.str.21)
  store i32 1, ptr %10, align 4
  br label %227

120:                                              ; preds = %109
  %121 = load ptr, ptr %4, align 8, !tbaa !5
  %122 = getelementptr inbounds %struct.png_struct_def, ptr %121, i32 0, i32 31
  %123 = load ptr, ptr %122, align 8, !tbaa !29
  %124 = getelementptr inbounds [6 x i8], ptr %8, i64 0, i64 0
  %125 = load i8, ptr %124, align 1, !tbaa !26
  %126 = zext i8 %125 to i64
  %127 = getelementptr inbounds %struct.png_color_struct, ptr %123, i64 %126
  %128 = getelementptr inbounds %struct.png_color_struct, ptr %127, i32 0, i32 0
  %129 = load i8, ptr %128, align 1, !tbaa !30
  %130 = zext i8 %129 to i16
  %131 = getelementptr inbounds %struct.png_color_16_struct, ptr %9, i32 0, i32 1
  store i16 %130, ptr %131, align 2, !tbaa !32
  %132 = load ptr, ptr %4, align 8, !tbaa !5
  %133 = getelementptr inbounds %struct.png_struct_def, ptr %132, i32 0, i32 31
  %134 = load ptr, ptr %133, align 8, !tbaa !29
  %135 = getelementptr inbounds [6 x i8], ptr %8, i64 0, i64 0
  %136 = load i8, ptr %135, align 1, !tbaa !26
  %137 = zext i8 %136 to i64
  %138 = getelementptr inbounds %struct.png_color_struct, ptr %134, i64 %137
  %139 = getelementptr inbounds %struct.png_color_struct, ptr %138, i32 0, i32 1
  %140 = load i8, ptr %139, align 1, !tbaa !33
  %141 = zext i8 %140 to i16
  %142 = getelementptr inbounds %struct.png_color_16_struct, ptr %9, i32 0, i32 2
  store i16 %141, ptr %142, align 2, !tbaa !34
  %143 = load ptr, ptr %4, align 8, !tbaa !5
  %144 = getelementptr inbounds %struct.png_struct_def, ptr %143, i32 0, i32 31
  %145 = load ptr, ptr %144, align 8, !tbaa !29
  %146 = getelementptr inbounds [6 x i8], ptr %8, i64 0, i64 0
  %147 = load i8, ptr %146, align 1, !tbaa !26
  %148 = zext i8 %147 to i64
  %149 = getelementptr inbounds %struct.png_color_struct, ptr %145, i64 %148
  %150 = getelementptr inbounds %struct.png_color_struct, ptr %149, i32 0, i32 2
  %151 = load i8, ptr %150, align 1, !tbaa !35
  %152 = zext i8 %151 to i16
  %153 = getelementptr inbounds %struct.png_color_16_struct, ptr %9, i32 0, i32 3
  store i16 %152, ptr %153, align 2, !tbaa !36
  br label %158

154:                                              ; preds = %103, %97
  %155 = getelementptr inbounds %struct.png_color_16_struct, ptr %9, i32 0, i32 3
  store i16 0, ptr %155, align 2, !tbaa !36
  %156 = getelementptr inbounds %struct.png_color_16_struct, ptr %9, i32 0, i32 2
  store i16 0, ptr %156, align 2, !tbaa !34
  %157 = getelementptr inbounds %struct.png_color_16_struct, ptr %9, i32 0, i32 1
  store i16 0, ptr %157, align 2, !tbaa !32
  br label %158

158:                                              ; preds = %154, %120
  %159 = getelementptr inbounds %struct.png_color_16_struct, ptr %9, i32 0, i32 4
  store i16 0, ptr %159, align 2, !tbaa !37
  br label %224

160:                                              ; preds = %91
  %161 = load ptr, ptr %4, align 8, !tbaa !5
  %162 = getelementptr inbounds %struct.png_struct_def, ptr %161, i32 0, i32 40
  %163 = load i8, ptr %162, align 1, !tbaa !22
  %164 = zext i8 %163 to i32
  %165 = and i32 %164, 2
  %166 = icmp eq i32 %165, 0
  br i1 %166, label %167, label %183

167:                                              ; preds = %160
  %168 = getelementptr inbounds %struct.png_color_16_struct, ptr %9, i32 0, i32 0
  store i8 0, ptr %168, align 2, !tbaa !27
  %169 = getelementptr inbounds [6 x i8], ptr %8, i64 0, i64 0
  %170 = load i8, ptr %169, align 1, !tbaa !26
  %171 = zext i8 %170 to i32
  %172 = shl i32 %171, 8
  %173 = getelementptr inbounds [6 x i8], ptr %8, i64 0, i64 0
  %174 = getelementptr inbounds i8, ptr %173, i64 1
  %175 = load i8, ptr %174, align 1, !tbaa !26
  %176 = zext i8 %175 to i32
  %177 = add i32 %172, %176
  %178 = trunc i32 %177 to i16
  %179 = getelementptr inbounds %struct.png_color_16_struct, ptr %9, i32 0, i32 4
  store i16 %178, ptr %179, align 2, !tbaa !37
  %180 = getelementptr inbounds %struct.png_color_16_struct, ptr %9, i32 0, i32 3
  store i16 %178, ptr %180, align 2, !tbaa !36
  %181 = getelementptr inbounds %struct.png_color_16_struct, ptr %9, i32 0, i32 2
  store i16 %178, ptr %181, align 2, !tbaa !34
  %182 = getelementptr inbounds %struct.png_color_16_struct, ptr %9, i32 0, i32 1
  store i16 %178, ptr %182, align 2, !tbaa !32
  br label %223

183:                                              ; preds = %160
  %184 = getelementptr inbounds %struct.png_color_16_struct, ptr %9, i32 0, i32 0
  store i8 0, ptr %184, align 2, !tbaa !27
  %185 = getelementptr inbounds [6 x i8], ptr %8, i64 0, i64 0
  %186 = load i8, ptr %185, align 1, !tbaa !26
  %187 = zext i8 %186 to i32
  %188 = shl i32 %187, 8
  %189 = getelementptr inbounds [6 x i8], ptr %8, i64 0, i64 0
  %190 = getelementptr inbounds i8, ptr %189, i64 1
  %191 = load i8, ptr %190, align 1, !tbaa !26
  %192 = zext i8 %191 to i32
  %193 = add i32 %188, %192
  %194 = trunc i32 %193 to i16
  %195 = getelementptr inbounds %struct.png_color_16_struct, ptr %9, i32 0, i32 1
  store i16 %194, ptr %195, align 2, !tbaa !32
  %196 = getelementptr inbounds [6 x i8], ptr %8, i64 0, i64 0
  %197 = getelementptr inbounds i8, ptr %196, i64 2
  %198 = load i8, ptr %197, align 1, !tbaa !26
  %199 = zext i8 %198 to i32
  %200 = shl i32 %199, 8
  %201 = getelementptr inbounds [6 x i8], ptr %8, i64 0, i64 0
  %202 = getelementptr inbounds i8, ptr %201, i64 2
  %203 = getelementptr inbounds i8, ptr %202, i64 1
  %204 = load i8, ptr %203, align 1, !tbaa !26
  %205 = zext i8 %204 to i32
  %206 = add i32 %200, %205
  %207 = trunc i32 %206 to i16
  %208 = getelementptr inbounds %struct.png_color_16_struct, ptr %9, i32 0, i32 2
  store i16 %207, ptr %208, align 2, !tbaa !34
  %209 = getelementptr inbounds [6 x i8], ptr %8, i64 0, i64 0
  %210 = getelementptr inbounds i8, ptr %209, i64 4
  %211 = load i8, ptr %210, align 1, !tbaa !26
  %212 = zext i8 %211 to i32
  %213 = shl i32 %212, 8
  %214 = getelementptr inbounds [6 x i8], ptr %8, i64 0, i64 0
  %215 = getelementptr inbounds i8, ptr %214, i64 4
  %216 = getelementptr inbounds i8, ptr %215, i64 1
  %217 = load i8, ptr %216, align 1, !tbaa !26
  %218 = zext i8 %217 to i32
  %219 = add i32 %213, %218
  %220 = trunc i32 %219 to i16
  %221 = getelementptr inbounds %struct.png_color_16_struct, ptr %9, i32 0, i32 3
  store i16 %220, ptr %221, align 2, !tbaa !36
  %222 = getelementptr inbounds %struct.png_color_16_struct, ptr %9, i32 0, i32 4
  store i16 0, ptr %222, align 2, !tbaa !37
  br label %223

223:                                              ; preds = %183, %167
  br label %224

224:                                              ; preds = %223, %158
  %225 = load ptr, ptr %4, align 8, !tbaa !5
  %226 = load ptr, ptr %5, align 8, !tbaa !5
  call void @png_set_bKGD(ptr noundef %225, ptr noundef %226, ptr noundef %9)
  store i32 0, ptr %10, align 4
  br label %227

227:                                              ; preds = %224, %118, %90, %78, %50, %36
  call void @llvm.lifetime.end.p0(i64 10, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 6, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  %228 = load i32, ptr %10, align 4
  switch i32 %228, label %230 [
    i32 0, label %229
    i32 1, label %229
  ]

229:                                              ; preds = %227, %227
  ret void

230:                                              ; preds = %227
  unreachable
}

declare void @png_set_bKGD(ptr noundef, ptr noundef, ptr noundef) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { 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 = { "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 284}
!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, !7, i64 280, !7, i64 281, !10, i64 284, !10, i64 288, !10, i64 292, !10, i64 296, !14, i64 304, !10, i64 416, !10, i64 420, !10, i64 424, !10, i64 428, !13, i64 432, !10, i64 440, !10, i64 444, !10, i64 448, !6, i64 456, !6, i64 464, !13, i64 472, !10, i64 480, !10, i64 484, !6, i64 488, !15, i64 496, !10, i64 500, !15, i64 504, !7, i64 506, !7, i64 507, !7, i64 508, !7, i64 509, !7, i64 510, !7, i64 511, !7, i64 512, !7, i64 513, !7, i64 514, !7, i64 515, !7, i64 516, !7, i64 517, !7, i64 518, !15, i64 520, !7, i64 522, !10, i64 524, !16, i64 528, !16, i64 538, !10, i64 548, !10, i64 552, !6, i64 560, !6, i64 568, !6, i64 576, !6, i64 584, !6, i64 592, !6, i64 600, !17, i64 608, !17, i64 613, !6, i64 624, !16, i64 632, !6, i64 648, !6, i64 656, !6, i64 664, !6, i64 672, !6, i64 680, !6, i64 688, !6, i64 696, !6, i64 704, !6, i64 712, !10, i64 720, !10, i64 724, !13, i64 728, !13, i64 736, !13, i64 744, !13, i64 752, !10, i64 760, !10, i64 764, !6, i64 768, !6, i64 776, !7, i64 784, !7, i64 785, !10, i64 816, !6, i64 824, !6, i64 832, !10, i64 840, !10, i64 844, !6, i64 848, !7, i64 856, !7, i64 857, !15, i64 858, !15, i64 860, !10, i64 864, !7, i64 868, !6, i64 872, !6, i64 880, !6, i64 888, !6, i64 896, !6, i64 904, !6, i64 912, !6, i64 920, !7, i64 928, !10, i64 932, !10, i64 936, !10, i64 940, !13, i64 944, !18, i64 952, !13, i64 984, !6, i64 992, !13, i64 1000, !10, i64 1008, !10, i64 1012, !6, i64 1016, !7, i64 1024, !19, i64 1056}
!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 511}
!23 = !{!24, !10, i64 8}
!24 = !{!"png_info_def", !10, i64 0, !10, i64 4, !10, i64 8, !13, i64 16, !6, i64 24, !15, i64 32, !15, i64 34, !7, i64 36, !7, i64 37, !7, i64 38, !7, i64 39, !7, i64 40, !7, i64 41, !7, i64 42, !7, i64 43, !7, i64 44, !19, i64 52, !6, i64 128, !6, i64 136, !10, i64 144, !10, i64 148, !10, i64 152, !6, i64 160, !25, i64 168, !17, i64 176, !6, i64 184, !16, i64 192, !16, i64 202, !10, i64 212, !10, i64 216, !7, i64 220, !10, i64 224, !10, i64 228, !7, i64 232, !6, i64 240, !6, i64 248, !10, i64 256, !10, i64 260, !6, i64 264, !6, i64 272, !7, i64 280, !7, i64 281, !10, i64 284, !6, i64 288, !10, i64 296, !6, i64 304, !10, i64 312, !7, i64 316, !6, i64 320, !6, i64 328, !6, i64 336}
!25 = !{!"png_time_struct", !15, i64 0, !7, i64 2, !7, i64 3, !7, i64 4, !7, i64 5, !7, i64 6}
!26 = !{!7, !7, i64 0}
!27 = !{!16, !7, i64 0}
!28 = !{!24, !15, i64 32}
!29 = !{!12, !6, i64 488}
!30 = !{!31, !7, i64 0}
!31 = !{!"png_color_struct", !7, i64 0, !7, i64 1, !7, i64 2}
!32 = !{!16, !15, i64 2}
!33 = !{!31, !7, i64 1}
!34 = !{!16, !15, i64 4}
!35 = !{!31, !7, i64 2}
!36 = !{!16, !15, i64 6}
!37 = !{!16, !15, i64 8}


; 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.png_color_16_struct = type { i8, i16, i16, i16, i16 }
%struct.png_color_struct = type { i8, i8, i8 }

@.str.4 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [14 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

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

; Function Attrs: nounwind uwtable
declare dso_local void @png_crc_read(ptr noalias noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @png_crc_finish(ptr noalias noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: noreturn
declare void @png_chunk_error(ptr noundef, ptr noundef) local_unnamed_addr #2

declare void @png_chunk_benign_error(ptr noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
define dso_local void @png_handle_bKGD(ptr noalias noundef %0, ptr noalias noundef %1, i32 noundef %2) local_unnamed_addr #1 {
  %4 = alloca [6 x i8], align 1
  %5 = alloca %struct.png_color_16_struct, align 2
  call void @llvm.lifetime.start.p0(i64 6, ptr nonnull %4) #4
  call void @llvm.lifetime.start.p0(i64 10, ptr nonnull %5) #4
  %6 = getelementptr inbounds i8, ptr %0, i64 284
  %7 = load i32, ptr %6, align 4, !tbaa !5
  %8 = and i32 %7, 1
  %9 = icmp eq i32 %8, 0
  %.sink50.sroa.gep = getelementptr inbounds i8, ptr %5, i64 2
  %.sink50.sroa.gep54 = getelementptr inbounds i8, ptr %5, i64 8
  %.sink50.sroa.gep55 = getelementptr inbounds i8, ptr %5, i64 8
  %.sink50.sroa.gep56 = getelementptr inbounds i8, ptr %5, i64 8
  %.sink53.sroa.gep = getelementptr inbounds i8, ptr %5, i64 4
  %.sink53.sroa.gep57 = getelementptr inbounds i8, ptr %5, i64 6
  %.sink53.sroa.gep58 = getelementptr inbounds i8, ptr %5, i64 2
  %.sink53.sroa.gep59 = getelementptr inbounds i8, ptr %5, i64 6
  br i1 %9, label %10, label %11

10:                                               ; preds = %3
  tail call void @png_chunk_error(ptr noundef nonnull %0, ptr noundef nonnull @.str.6) #5
  unreachable

11:                                               ; preds = %3
  %12 = and i32 %7, 4
  %.not = icmp eq i32 %12, 0
  br i1 %.not, label %13, label %19

13:                                               ; preds = %11
  %14 = getelementptr inbounds i8, ptr %0, i64 511
  %15 = load i8, ptr %14, align 1, !tbaa !20
  %16 = icmp eq i8 %15, 3
  %17 = and i32 %7, 2
  %18 = icmp eq i32 %17, 0
  %or.cond = and i1 %18, %16
  br i1 %or.cond, label %19, label %21

19:                                               ; preds = %13, %11
  %20 = tail call i32 @png_crc_finish(ptr noundef nonnull %0, i32 noundef %2)
  tail call void @png_chunk_benign_error(ptr noundef nonnull %0, ptr noundef nonnull @.str.4) #4
  br label %96

21:                                               ; preds = %13
  %.not38 = icmp eq ptr %1, null
  br i1 %.not38, label %28, label %22

22:                                               ; preds = %21
  %23 = getelementptr inbounds i8, ptr %1, i64 8
  %24 = load i32, ptr %23, align 8, !tbaa !21
  %25 = and i32 %24, 32
  %.not39 = icmp eq i32 %25, 0
  br i1 %.not39, label %28, label %26

26:                                               ; preds = %22
  %27 = tail call i32 @png_crc_finish(ptr noundef nonnull %0, i32 noundef %2)
  tail call void @png_chunk_benign_error(ptr noundef nonnull %0, ptr noundef nonnull @.str.7) #4
  br label %96

28:                                               ; preds = %22, %21
  %29 = and i8 %15, 2
  %.not40 = icmp eq i8 %29, 0
  %. = select i1 %.not40, i32 2, i32 6
  %.0 = select i1 %16, i32 1, i32 %.
  %.not41 = icmp eq i32 %.0, %2
  br i1 %.not41, label %32, label %30

30:                                               ; preds = %28
  %31 = tail call i32 @png_crc_finish(ptr noundef nonnull %0, i32 noundef %2)
  tail call void @png_chunk_benign_error(ptr noundef nonnull %0, ptr noundef nonnull @.str.5) #4
  br label %96

32:                                               ; preds = %28
  call void @png_crc_read(ptr noundef nonnull %0, ptr noundef nonnull %4, i32 noundef %2)
  %33 = call i32 @png_crc_finish(ptr noundef nonnull %0, i32 noundef 0)
  %.not42 = icmp eq i32 %33, 0
  br i1 %.not42, label %34, label %96

34:                                               ; preds = %32
  %35 = load i8, ptr %14, align 1, !tbaa !20
  %36 = icmp eq i8 %35, 3
  br i1 %36, label %37, label %63

37:                                               ; preds = %34
  %38 = load i8, ptr %4, align 1, !tbaa !24
  store i8 %38, ptr %5, align 2, !tbaa !25
  br i1 %.not38, label %60, label %39

39:                                               ; preds = %37
  %40 = getelementptr inbounds i8, ptr %1, i64 32
  %41 = load i16, ptr %40, align 8, !tbaa !26
  %.not43 = icmp eq i16 %41, 0
  br i1 %.not43, label %60, label %42

42:                                               ; preds = %39
  %43 = zext i8 %38 to i16
  %.not44 = icmp ugt i16 %41, %43
  br i1 %.not44, label %45, label %44

44:                                               ; preds = %42
  call void @png_chunk_benign_error(ptr noundef nonnull %0, ptr noundef nonnull @.str.21) #4
  br label %96

45:                                               ; preds = %42
  %46 = getelementptr inbounds i8, ptr %0, i64 488
  %47 = load ptr, ptr %46, align 8, !tbaa !27
  %48 = zext i8 %38 to i64
  %49 = getelementptr inbounds %struct.png_color_struct, ptr %47, i64 %48
  %50 = load i8, ptr %49, align 1, !tbaa !28
  %51 = zext i8 %50 to i16
  %52 = getelementptr inbounds i8, ptr %5, i64 2
  store i16 %51, ptr %52, align 2, !tbaa !30
  %53 = getelementptr inbounds %struct.png_color_struct, ptr %47, i64 %48, i32 1
  %54 = load i8, ptr %53, align 1, !tbaa !31
  %55 = zext i8 %54 to i16
  %56 = getelementptr inbounds i8, ptr %5, i64 4
  store i16 %55, ptr %56, align 2, !tbaa !32
  %57 = getelementptr inbounds %struct.png_color_struct, ptr %47, i64 %48, i32 2
  %58 = load i8, ptr %57, align 1, !tbaa !33
  %59 = zext i8 %58 to i16
  br label %95

60:                                               ; preds = %39, %37
  %61 = getelementptr inbounds i8, ptr %5, i64 6
  store i16 0, ptr %61, align 2, !tbaa !34
  %62 = getelementptr inbounds i8, ptr %5, i64 4
  store i16 0, ptr %62, align 2, !tbaa !32
  br label %95

63:                                               ; preds = %34
  %64 = and i8 %35, 2
  %65 = icmp eq i8 %64, 0
  store i8 0, ptr %5, align 2, !tbaa !25
  %66 = load i8, ptr %4, align 1, !tbaa !24
  %67 = zext i8 %66 to i16
  %68 = shl nuw i16 %67, 8
  %69 = getelementptr inbounds i8, ptr %4, i64 1
  %70 = load i8, ptr %69, align 1, !tbaa !24
  %71 = zext i8 %70 to i16
  %72 = or disjoint i16 %68, %71
  br i1 %65, label %73, label %76

73:                                               ; preds = %63
  %74 = getelementptr inbounds i8, ptr %5, i64 8
  store i16 %72, ptr %74, align 2, !tbaa !35
  %75 = getelementptr inbounds i8, ptr %5, i64 6
  store i16 %72, ptr %75, align 2, !tbaa !34
  br label %95

76:                                               ; preds = %63
  %77 = getelementptr inbounds i8, ptr %5, i64 2
  store i16 %72, ptr %77, align 2, !tbaa !30
  %78 = getelementptr inbounds i8, ptr %4, i64 2
  %79 = load i8, ptr %78, align 1, !tbaa !24
  %80 = zext i8 %79 to i16
  %81 = shl nuw i16 %80, 8
  %82 = getelementptr inbounds i8, ptr %4, i64 3
  %83 = load i8, ptr %82, align 1, !tbaa !24
  %84 = zext i8 %83 to i16
  %85 = or disjoint i16 %81, %84
  %86 = getelementptr inbounds i8, ptr %5, i64 4
  store i16 %85, ptr %86, align 2, !tbaa !32
  %87 = getelementptr inbounds i8, ptr %4, i64 4
  %88 = load i8, ptr %87, align 1, !tbaa !24
  %89 = zext i8 %88 to i16
  %90 = shl nuw i16 %89, 8
  %91 = getelementptr inbounds i8, ptr %4, i64 5
  %92 = load i8, ptr %91, align 1, !tbaa !24
  %93 = zext i8 %92 to i16
  %94 = or disjoint i16 %90, %93
  br label %95

95:                                               ; preds = %45, %60, %73, %76
  %.sink53.sroa.phi = phi ptr [ %.sink53.sroa.gep, %73 ], [ %.sink53.sroa.gep57, %76 ], [ %.sink53.sroa.gep58, %60 ], [ %.sink53.sroa.gep59, %45 ]
  %.sink51 = phi i16 [ %72, %73 ], [ %94, %76 ], [ 0, %60 ], [ %59, %45 ]
  %.sink50.sroa.phi = phi ptr [ %.sink50.sroa.gep, %73 ], [ %.sink50.sroa.gep54, %76 ], [ %.sink50.sroa.gep55, %60 ], [ %.sink50.sroa.gep56, %45 ]
  %.sink48 = phi i16 [ %72, %73 ], [ 0, %76 ], [ 0, %60 ], [ 0, %45 ]
  store i16 %.sink51, ptr %.sink53.sroa.phi, align 2, !tbaa !36
  store i16 %.sink48, ptr %.sink50.sroa.phi, align 2, !tbaa !36
  call void @png_set_bKGD(ptr noundef nonnull %0, ptr noundef %1, ptr noundef nonnull %5) #4
  br label %96

96:                                               ; preds = %32, %95, %44, %30, %26, %19
  call void @llvm.lifetime.end.p0(i64 10, ptr nonnull %5) #4
  call void @llvm.lifetime.end.p0(i64 6, ptr nonnull %4) #4
  ret void
}

declare void @png_set_bKGD(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #3

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { 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 = { "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 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 284}
!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, !7, i64 280, !7, i64 281, !11, i64 284, !11, i64 288, !11, i64 292, !11, i64 296, !12, i64 304, !11, i64 416, !11, i64 420, !11, i64 424, !11, i64 428, !10, i64 432, !11, i64 440, !11, i64 444, !11, i64 448, !9, i64 456, !9, i64 464, !10, i64 472, !11, i64 480, !11, i64 484, !9, i64 488, !13, i64 496, !11, i64 500, !13, i64 504, !7, i64 506, !7, i64 507, !7, i64 508, !7, i64 509, !7, i64 510, !7, i64 511, !7, i64 512, !7, i64 513, !7, i64 514, !7, i64 515, !7, i64 516, !7, i64 517, !7, i64 518, !13, i64 520, !7, i64 522, !11, i64 524, !14, i64 528, !14, i64 538, !11, i64 548, !11, i64 552, !9, i64 560, !9, i64 568, !9, i64 576, !9, i64 584, !9, i64 592, !9, i64 600, !15, i64 608, !15, i64 613, !9, i64 624, !14, i64 632, !9, i64 648, !9, i64 656, !9, i64 664, !9, i64 672, !9, i64 680, !9, i64 688, !9, i64 696, !9, i64 704, !9, i64 712, !11, i64 720, !11, i64 724, !10, i64 728, !10, i64 736, !10, i64 744, !10, i64 752, !11, i64 760, !11, i64 764, !9, i64 768, !9, i64 776, !7, i64 784, !7, i64 785, !11, i64 816, !9, i64 824, !9, i64 832, !11, i64 840, !11, i64 844, !9, i64 848, !7, i64 856, !7, i64 857, !13, i64 858, !13, i64 860, !11, i64 864, !7, i64 868, !9, i64 872, !9, i64 880, !9, i64 888, !9, i64 896, !9, i64 904, !9, i64 912, !9, i64 920, !7, i64 928, !11, i64 932, !11, i64 936, !11, i64 940, !10, i64 944, !16, i64 952, !10, i64 984, !9, i64 992, !10, i64 1000, !11, i64 1008, !11, i64 1012, !9, i64 1016, !7, i64 1024, !17, i64 1056}
!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 511}
!21 = !{!22, !11, i64 8}
!22 = !{!"png_info_def", !11, i64 0, !11, i64 4, !11, i64 8, !10, i64 16, !9, i64 24, !13, i64 32, !13, i64 34, !7, i64 36, !7, i64 37, !7, i64 38, !7, i64 39, !7, i64 40, !7, i64 41, !7, i64 42, !7, i64 43, !7, i64 44, !17, i64 52, !9, i64 128, !9, i64 136, !11, i64 144, !11, i64 148, !11, i64 152, !9, i64 160, !23, i64 168, !15, i64 176, !9, i64 184, !14, i64 192, !14, i64 202, !11, i64 212, !11, i64 216, !7, i64 220, !11, i64 224, !11, i64 228, !7, i64 232, !9, i64 240, !9, i64 248, !11, i64 256, !11, i64 260, !9, i64 264, !9, i64 272, !7, i64 280, !7, i64 281, !11, i64 284, !9, i64 288, !11, i64 296, !9, i64 304, !11, i64 312, !7, i64 316, !9, i64 320, !9, i64 328, !9, i64 336}
!23 = !{!"png_time_struct", !13, i64 0, !7, i64 2, !7, i64 3, !7, i64 4, !7, i64 5, !7, i64 6}
!24 = !{!7, !7, i64 0}
!25 = !{!14, !7, i64 0}
!26 = !{!22, !13, i64 32}
!27 = !{!6, !9, i64 488}
!28 = !{!29, !7, i64 0}
!29 = !{!"png_color_struct", !7, i64 0, !7, i64 1, !7, i64 2}
!30 = !{!14, !13, i64 2}
!31 = !{!29, !7, i64 1}
!32 = !{!14, !13, i64 4}
!33 = !{!29, !7, i64 2}
!34 = !{!14, !13, i64 6}
!35 = !{!14, !13, i64 8}
!36 = !{!13, !13, i64 0}


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