; LLVM IR from mkazhdan/DMG :: Util/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_struct_def = type { [1 x %struct.__jmp_buf_tag], ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i8, i8, i64, i64, i64, %struct.z_stream_s, ptr, i64, i32, i32, i32, i32, i32, i64, i64, i64, i64, i64, i64, i64, i64, ptr, ptr, ptr, ptr, ptr, ptr, %struct.png_row_info_struct, i64, i64, ptr, i16, i16, [5 x i8], i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i16, i8, float, %struct.png_color_16_struct, %struct.png_color_16_struct, ptr, i64, i64, i32, float, float, 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, i64, i64, i64, i64, i64, i64, i32, i32, i64, i64, ptr, ptr, ptr, ptr, ptr, i8, i8, ptr, ptr, ptr, ptr, ptr, ptr, i64, ptr, ptr, i32, ptr, i8, i16, i16, i16, i64, i64, i8, i8, i64, i64, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i8, i64, i64, %struct.png_unknown_chunk_t, i64, i64 }
%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_row_info_struct = type { i64, i64, i8, i8, i8, i8 }
%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 }

@png_IDAT = external global [5 x i8], align 1
@.str.122 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.123 = external hidden unnamed_addr constant [20 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 noundef, ptr noundef, i64 noundef) #1

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

declare void @png_chunk_error(ptr noundef, ptr noundef) #2

declare void @png_free(ptr noundef, ptr noundef) #2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

declare ptr @png_malloc(ptr noundef, i64 noundef) #2

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

14:                                               ; preds = %3
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.png_struct_def, ptr %15, i32 0, i32 43
  %17 = getelementptr inbounds [5 x i8], ptr %16, i64 0, i64 0
  %18 = call i32 @memcmp(ptr noundef %17, ptr noundef @png_IDAT, i64 noundef 4) #6
  %19 = icmp ne i32 %18, 0
  br i1 %19, label %20, label %25

20:                                               ; preds = %14
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.png_struct_def, ptr %21, i32 0, i32 12
  %23 = load i64, ptr %22, align 8, !tbaa !11
  %24 = or i64 %23, 8
  store i64 %24, ptr %22, align 8, !tbaa !11
  br label %25

25:                                               ; preds = %20, %14
  br label %26

26:                                               ; preds = %25, %3
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.png_struct_def, ptr %28, i32 0, i32 43
  %30 = getelementptr inbounds [5 x i8], ptr %29, i64 0, i64 0
  call void @png_check_chunk_name(ptr noundef %27, ptr noundef %30)
  %31 = load ptr, ptr %4, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.png_struct_def, ptr %31, i32 0, i32 43
  %33 = getelementptr inbounds [5 x i8], ptr %32, i64 0, i64 0
  %34 = load i8, ptr %33, align 4, !tbaa !21
  %35 = zext i8 %34 to i32
  %36 = and i32 %35, 32
  %37 = icmp ne i32 %36, 0
  br i1 %37, label %53, label %38

38:                                               ; preds = %26
  %39 = load ptr, ptr %4, align 8, !tbaa !5
  %40 = load ptr, ptr %4, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.png_struct_def, ptr %40, i32 0, i32 43
  %42 = getelementptr inbounds [5 x i8], ptr %41, i64 0, i64 0
  %43 = call i32 @png_handle_as_unknown(ptr noundef %39, ptr noundef %42)
  %44 = icmp ne i32 %43, 3
  br i1 %44, label %45, label %52

45:                                               ; preds = %38
  %46 = load ptr, ptr %4, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.png_struct_def, ptr %46, i32 0, i32 111
  %48 = load ptr, ptr %47, align 8, !tbaa !22
  %49 = icmp eq ptr %48, null
  br i1 %49, label %50, label %52

50:                                               ; preds = %45
  %51 = load ptr, ptr %4, align 8, !tbaa !5
  call void @png_chunk_error(ptr noundef %51, ptr noundef @.str.122)
  br label %52

52:                                               ; preds = %50, %45, %38
  br label %53

53:                                               ; preds = %52, %26
  %54 = load ptr, ptr %4, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.png_struct_def, ptr %54, i32 0, i32 13
  %56 = load i64, ptr %55, align 8, !tbaa !23
  %57 = and i64 %56, 32768
  %58 = icmp ne i64 %57, 0
  br i1 %58, label %64, label %59

59:                                               ; preds = %53
  %60 = load ptr, ptr %4, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.png_struct_def, ptr %60, i32 0, i32 111
  %62 = load ptr, ptr %61, align 8, !tbaa !22
  %63 = icmp ne ptr %62, null
  br i1 %63, label %64, label %157

64:                                               ; preds = %59, %53
  %65 = load ptr, ptr %4, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.png_struct_def, ptr %65, i32 0, i32 134
  %67 = getelementptr inbounds %struct.png_unknown_chunk_t, ptr %66, i32 0, i32 0
  %68 = getelementptr inbounds [5 x i8], ptr %67, i64 0, i64 0
  %69 = load ptr, ptr %4, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.png_struct_def, ptr %69, i32 0, i32 43
  %71 = getelementptr inbounds [5 x i8], ptr %70, i64 0, i64 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %68, ptr align 4 %71, i64 5, i1 false)
  %72 = load ptr, ptr %4, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.png_struct_def, ptr %72, i32 0, i32 134
  %74 = getelementptr inbounds %struct.png_unknown_chunk_t, ptr %73, i32 0, i32 0
  %75 = getelementptr inbounds [5 x i8], ptr %74, i64 0, i64 4
  store i8 0, ptr %75, align 4, !tbaa !21
  %76 = load i64, ptr %6, align 8, !tbaa !9
  %77 = load ptr, ptr %4, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.png_struct_def, ptr %77, i32 0, i32 134
  %79 = getelementptr inbounds %struct.png_unknown_chunk_t, ptr %78, i32 0, i32 2
  store i64 %76, ptr %79, align 8, !tbaa !24
  %80 = load i64, ptr %6, align 8, !tbaa !9
  %81 = icmp eq i64 %80, 0
  br i1 %81, label %82, label %86

82:                                               ; preds = %64
  %83 = load ptr, ptr %4, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.png_struct_def, ptr %83, i32 0, i32 134
  %85 = getelementptr inbounds %struct.png_unknown_chunk_t, ptr %84, i32 0, i32 1
  store ptr null, ptr %85, align 8, !tbaa !25
  br label %99

86:                                               ; preds = %64
  %87 = load ptr, ptr %4, align 8, !tbaa !5
  %88 = load i64, ptr %6, align 8, !tbaa !9
  %89 = call ptr @png_malloc(ptr noundef %87, i64 noundef %88)
  %90 = load ptr, ptr %4, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.png_struct_def, ptr %90, i32 0, i32 134
  %92 = getelementptr inbounds %struct.png_unknown_chunk_t, ptr %91, i32 0, i32 1
  store ptr %89, ptr %92, align 8, !tbaa !25
  %93 = load ptr, ptr %4, align 8, !tbaa !5
  %94 = load ptr, ptr %4, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct.png_struct_def, ptr %94, i32 0, i32 134
  %96 = getelementptr inbounds %struct.png_unknown_chunk_t, ptr %95, i32 0, i32 1
  %97 = load ptr, ptr %96, align 8, !tbaa !25
  %98 = load i64, ptr %6, align 8, !tbaa !9
  call void @png_crc_read(ptr noundef %93, ptr noundef %97, i64 noundef %98)
  br label %99

99:                                               ; preds = %86, %82
  %100 = load ptr, ptr %4, align 8, !tbaa !5
  %101 = getelementptr inbounds %struct.png_struct_def, ptr %100, i32 0, i32 111
  %102 = load ptr, ptr %101, align 8, !tbaa !22
  %103 = icmp ne ptr %102, null
  br i1 %103, label %104, label %143

104:                                              ; preds = %99
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  %105 = load ptr, ptr %4, align 8, !tbaa !5
  %106 = getelementptr inbounds %struct.png_struct_def, ptr %105, i32 0, i32 111
  %107 = load ptr, ptr %106, align 8, !tbaa !22
  %108 = load ptr, ptr %4, align 8, !tbaa !5
  %109 = load ptr, ptr %4, align 8, !tbaa !5
  %110 = getelementptr inbounds %struct.png_struct_def, ptr %109, i32 0, i32 134
  %111 = call i32 %107(ptr noundef %108, ptr noundef %110)
  store i32 %111, ptr %8, align 4, !tbaa !26
  %112 = load i32, ptr %8, align 4, !tbaa !26
  %113 = icmp slt i32 %112, 0
  br i1 %113, label %114, label %116

114:                                              ; preds = %104
  %115 = load ptr, ptr %4, align 8, !tbaa !5
  call void @png_chunk_error(ptr noundef %115, ptr noundef @.str.123)
  br label %116

116:                                              ; preds = %114, %104
  %117 = load i32, ptr %8, align 4, !tbaa !26
  %118 = icmp eq i32 %117, 0
  br i1 %118, label %119, label %142

119:                                              ; preds = %116
  %120 = load ptr, ptr %4, align 8, !tbaa !5
  %121 = getelementptr inbounds %struct.png_struct_def, ptr %120, i32 0, i32 43
  %122 = getelementptr inbounds [5 x i8], ptr %121, i64 0, i64 0
  %123 = load i8, ptr %122, align 4, !tbaa !21
  %124 = zext i8 %123 to i32
  %125 = and i32 %124, 32
  %126 = icmp ne i32 %125, 0
  br i1 %126, label %137, label %127

127:                                              ; preds = %119
  %128 = load ptr, ptr %4, align 8, !tbaa !5
  %129 = load ptr, ptr %4, align 8, !tbaa !5
  %130 = getelementptr inbounds %struct.png_struct_def, ptr %129, i32 0, i32 43
  %131 = getelementptr inbounds [5 x i8], ptr %130, i64 0, i64 0
  %132 = call i32 @png_handle_as_unknown(ptr noundef %128, ptr noundef %131)
  %133 = icmp ne i32 %132, 3
  br i1 %133, label %134, label %136

134:                                              ; preds = %127
  %135 = load ptr, ptr %4, align 8, !tbaa !5
  call void @png_chunk_error(ptr noundef %135, ptr noundef @.str.122)
  br label %136

136:                                              ; preds = %134, %127
  br label %137

137:                                              ; preds = %136, %119
  %138 = load ptr, ptr %4, align 8, !tbaa !5
  %139 = load ptr, ptr %5, align 8, !tbaa !5
  %140 = load ptr, ptr %4, align 8, !tbaa !5
  %141 = getelementptr inbounds %struct.png_struct_def, ptr %140, i32 0, i32 134
  call void @png_set_unknown_chunks(ptr noundef %138, ptr noundef %139, ptr noundef %141, i32 noundef 1)
  br label %142

142:                                              ; preds = %137, %116
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  br label %148

143:                                              ; preds = %99
  %144 = load ptr, ptr %4, align 8, !tbaa !5
  %145 = load ptr, ptr %5, align 8, !tbaa !5
  %146 = load ptr, ptr %4, align 8, !tbaa !5
  %147 = getelementptr inbounds %struct.png_struct_def, ptr %146, i32 0, i32 134
  call void @png_set_unknown_chunks(ptr noundef %144, ptr noundef %145, ptr noundef %147, i32 noundef 1)
  br label %148

148:                                              ; preds = %143, %142
  %149 = load ptr, ptr %4, align 8, !tbaa !5
  %150 = load ptr, ptr %4, align 8, !tbaa !5
  %151 = getelementptr inbounds %struct.png_struct_def, ptr %150, i32 0, i32 134
  %152 = getelementptr inbounds %struct.png_unknown_chunk_t, ptr %151, i32 0, i32 1
  %153 = load ptr, ptr %152, align 8, !tbaa !25
  call void @png_free(ptr noundef %149, ptr noundef %153)
  %154 = load ptr, ptr %4, align 8, !tbaa !5
  %155 = getelementptr inbounds %struct.png_struct_def, ptr %154, i32 0, i32 134
  %156 = getelementptr inbounds %struct.png_unknown_chunk_t, ptr %155, i32 0, i32 1
  store ptr null, ptr %156, align 8, !tbaa !25
  br label %159

157:                                              ; preds = %59
  %158 = load i64, ptr %6, align 8, !tbaa !9
  store i64 %158, ptr %7, align 8, !tbaa !9
  br label %159

159:                                              ; preds = %157, %148
  %160 = load ptr, ptr %4, align 8, !tbaa !5
  %161 = load i64, ptr %7, align 8, !tbaa !9
  %162 = call i32 @png_crc_finish(ptr noundef %160, i64 noundef %161)
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  ret void
}

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

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

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

declare void @png_set_unknown_chunks(ptr noundef, ptr noundef, ptr noundef, i32 noundef) #2

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 = { "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: readwrite) }
attributes #4 = { nounwind willreturn memory(read) "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { nounwind }
attributes #6 = { nounwind willreturn memory(read) }

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !10, i64 280}
!12 = !{!"png_struct_def", !7, i64 0, !6, i64 200, !6, i64 208, !6, i64 216, !6, i64 224, !6, i64 232, !6, i64 240, !6, i64 248, !6, i64 256, !6, i64 264, !7, i64 272, !7, i64 273, !10, i64 280, !10, i64 288, !10, i64 296, !13, i64 304, !6, i64 416, !10, i64 424, !14, i64 432, !14, i64 436, !14, i64 440, !14, i64 444, !14, i64 448, !10, i64 456, !10, i64 464, !10, i64 472, !10, i64 480, !10, i64 488, !10, i64 496, !10, i64 504, !10, i64 512, !6, i64 520, !6, i64 528, !6, i64 536, !6, i64 544, !6, i64 552, !6, i64 560, !15, i64 568, !10, i64 592, !10, i64 600, !6, i64 608, !16, i64 616, !16, i64 618, !7, i64 620, !7, i64 625, !7, i64 626, !7, i64 627, !7, i64 628, !7, i64 629, !7, i64 630, !7, i64 631, !7, i64 632, !7, i64 633, !7, i64 634, !7, i64 635, !7, i64 636, !16, i64 638, !7, i64 640, !17, i64 644, !18, i64 648, !18, i64 658, !6, i64 672, !10, i64 680, !10, i64 688, !14, i64 696, !17, i64 700, !17, i64 704, !6, i64 712, !6, i64 720, !6, i64 728, !6, i64 736, !6, i64 744, !6, i64 752, !19, i64 760, !19, i64 765, !6, i64 776, !18, i64 784, !6, i64 800, !6, i64 808, !6, i64 816, !6, i64 824, !6, i64 832, !6, i64 840, !6, i64 848, !6, i64 856, !6, i64 864, !10, i64 872, !10, i64 880, !10, i64 888, !10, i64 896, !10, i64 904, !10, i64 912, !14, i64 920, !14, i64 924, !10, i64 928, !10, i64 936, !6, i64 944, !6, i64 952, !6, i64 960, !6, i64 968, !6, i64 976, !7, i64 984, !7, i64 985, !6, i64 992, !6, i64 1000, !6, i64 1008, !6, i64 1016, !6, i64 1024, !6, i64 1032, !10, i64 1040, !6, i64 1048, !6, i64 1056, !14, i64 1064, !6, i64 1072, !7, i64 1080, !16, i64 1082, !16, i64 1084, !16, i64 1086, !10, i64 1088, !10, i64 1096, !7, i64 1104, !7, i64 1105, !10, i64 1112, !10, i64 1120, !6, i64 1128, !6, i64 1136, !6, i64 1144, !6, i64 1152, !6, i64 1160, !6, i64 1168, !6, i64 1176, !7, i64 1184, !10, i64 1192, !10, i64 1200, !20, i64 1208, !10, i64 1240, !10, i64 1248}
!13 = !{!"z_stream_s", !6, i64 0, !14, i64 8, !10, i64 16, !6, i64 24, !14, i64 32, !10, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !14, i64 88, !10, i64 96, !10, i64 104}
!14 = !{!"int", !7, i64 0}
!15 = !{!"png_row_info_struct", !10, i64 0, !10, i64 8, !7, i64 16, !7, i64 17, !7, i64 18, !7, i64 19}
!16 = !{!"short", !7, i64 0}
!17 = !{!"float", !7, i64 0}
!18 = !{!"png_color_16_struct", !7, i64 0, !16, i64 2, !16, i64 4, !16, i64 6, !16, i64 8}
!19 = !{!"png_color_8_struct", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3, !7, i64 4}
!20 = !{!"png_unknown_chunk_t", !7, i64 0, !6, i64 8, !10, i64 16, !7, i64 24}
!21 = !{!7, !7, i64 0}
!22 = !{!12, !6, i64 1056}
!23 = !{!12, !10, i64 288}
!24 = !{!12, !10, i64 1224}
!25 = !{!12, !6, i64 1216}
!26 = !{!14, !14, i64 0}


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

@png_IDAT = external global [5 x i8], align 1
@.str.122 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.123 = external hidden unnamed_addr constant [20 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @png_crc_read(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #0

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

declare void @png_chunk_error(ptr noundef, ptr noundef) local_unnamed_addr #1

declare void @png_free(ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

declare ptr @png_malloc(ptr noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @png_handle_unknown(ptr noundef %0, ptr noundef %1, i64 noundef %2) local_unnamed_addr #0 {
  %4 = getelementptr inbounds i8, ptr %0, i64 280
  %5 = load i64, ptr %4, align 8, !tbaa !5
  %6 = and i64 %5, 4
  %.not = icmp eq i64 %6, 0
  br i1 %.not, label %11, label %7

7:                                                ; preds = %3
  %8 = getelementptr inbounds i8, ptr %0, i64 620
  %bcmp = tail call i32 @bcmp(ptr noundef nonnull dereferenceable(4) %8, ptr noundef nonnull dereferenceable(4) @png_IDAT, i64 4)
  %.not49 = icmp eq i32 %bcmp, 0
  br i1 %.not49, label %11, label %9

9:                                                ; preds = %7
  %10 = or i64 %5, 8
  store i64 %10, ptr %4, align 8, !tbaa !5
  br label %11

11:                                               ; preds = %7, %9, %3
  %12 = getelementptr inbounds i8, ptr %0, i64 620
  tail call void @png_check_chunk_name(ptr noundef nonnull %0, ptr noundef nonnull %12)
  %13 = load i8, ptr %12, align 4, !tbaa !19
  %14 = and i8 %13, 32
  %.not50 = icmp eq i8 %14, 0
  br i1 %.not50, label %15, label %22

15:                                               ; preds = %11
  %16 = tail call i32 @png_handle_as_unknown(ptr noundef nonnull %0, ptr noundef nonnull %12) #4
  %.not51 = icmp eq i32 %16, 3
  br i1 %.not51, label %22, label %17

17:                                               ; preds = %15
  %18 = getelementptr inbounds i8, ptr %0, i64 1056
  %19 = load ptr, ptr %18, align 8, !tbaa !20
  %20 = icmp eq ptr %19, null
  br i1 %20, label %21, label %22

21:                                               ; preds = %17
  tail call void @png_chunk_error(ptr noundef nonnull %0, ptr noundef nonnull @.str.122) #4
  br label %22

22:                                               ; preds = %15, %17, %21, %11
  %23 = getelementptr inbounds i8, ptr %0, i64 288
  %24 = load i64, ptr %23, align 8, !tbaa !21
  %25 = and i64 %24, 32768
  %.not52 = icmp eq i64 %25, 0
  br i1 %.not52, label %26, label %29

26:                                               ; preds = %22
  %27 = getelementptr inbounds i8, ptr %0, i64 1056
  %28 = load ptr, ptr %27, align 8, !tbaa !20
  %.not53 = icmp eq ptr %28, null
  br i1 %.not53, label %58, label %29

29:                                               ; preds = %26, %22
  %30 = getelementptr inbounds i8, ptr %0, i64 1208
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(5) %30, ptr noundef nonnull align 4 dereferenceable(5) %12, i64 5, i1 false)
  %31 = getelementptr inbounds i8, ptr %0, i64 1212
  store i8 0, ptr %31, align 4, !tbaa !19
  %32 = getelementptr inbounds i8, ptr %0, i64 1224
  store i64 %2, ptr %32, align 8, !tbaa !22
  %33 = icmp eq i64 %2, 0
  br i1 %33, label %34, label %36

34:                                               ; preds = %29
  %35 = getelementptr inbounds i8, ptr %0, i64 1216
  store ptr null, ptr %35, align 8, !tbaa !23
  br label %39

36:                                               ; preds = %29
  %37 = tail call ptr @png_malloc(ptr noundef nonnull %0, i64 noundef %2) #4
  %38 = getelementptr inbounds i8, ptr %0, i64 1216
  store ptr %37, ptr %38, align 8, !tbaa !23
  tail call void @png_crc_read(ptr noundef nonnull %0, ptr noundef %37, i64 noundef %2)
  br label %39

39:                                               ; preds = %36, %34
  %40 = getelementptr inbounds i8, ptr %0, i64 1056
  %41 = load ptr, ptr %40, align 8, !tbaa !20
  %.not54 = icmp eq ptr %41, null
  br i1 %.not54, label %54, label %42

42:                                               ; preds = %39
  %43 = tail call i32 %41(ptr noundef nonnull %0, ptr noundef nonnull %30) #4
  %44 = icmp slt i32 %43, 0
  br i1 %44, label %.thread, label %45

.thread:                                          ; preds = %42
  tail call void @png_chunk_error(ptr noundef nonnull %0, ptr noundef nonnull @.str.123) #4
  br label %55

45:                                               ; preds = %42
  %46 = icmp eq i32 %43, 0
  br i1 %46, label %47, label %55

47:                                               ; preds = %45
  %48 = load i8, ptr %12, align 4, !tbaa !19
  %49 = and i8 %48, 32
  %.not55 = icmp eq i8 %49, 0
  br i1 %.not55, label %50, label %53

50:                                               ; preds = %47
  %51 = tail call i32 @png_handle_as_unknown(ptr noundef nonnull %0, ptr noundef nonnull %12) #4
  %.not56 = icmp eq i32 %51, 3
  br i1 %.not56, label %53, label %52

52:                                               ; preds = %50
  tail call void @png_chunk_error(ptr noundef nonnull %0, ptr noundef nonnull @.str.122) #4
  br label %53

53:                                               ; preds = %50, %52, %47
  tail call void @png_set_unknown_chunks(ptr noundef nonnull %0, ptr noundef %1, ptr noundef nonnull %30, i32 noundef 1) #4
  br label %55

54:                                               ; preds = %39
  tail call void @png_set_unknown_chunks(ptr noundef nonnull %0, ptr noundef %1, ptr noundef nonnull %30, i32 noundef 1) #4
  br label %55

55:                                               ; preds = %.thread, %45, %53, %54
  %56 = getelementptr inbounds i8, ptr %0, i64 1216
  %57 = load ptr, ptr %56, align 8, !tbaa !23
  tail call void @png_free(ptr noundef nonnull %0, ptr noundef %57) #4
  store ptr null, ptr %56, align 8, !tbaa !23
  br label %58

58:                                               ; preds = %26, %55
  %.0 = phi i64 [ 0, %55 ], [ %2, %26 ]
  %59 = tail call i32 @png_crc_finish(ptr noundef nonnull %0, i64 noundef %.0)
  ret void
}

; Function Attrs: nounwind uwtable
declare dso_local void @png_check_chunk_name(ptr noundef, ptr noundef) local_unnamed_addr #0

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

declare void @png_set_unknown_chunks(ptr noundef, ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nofree nounwind willreturn memory(argmem: read)
declare i32 @bcmp(ptr nocapture, ptr nocapture, i64) local_unnamed_addr #3

attributes #0 = { 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 #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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nofree nounwind willreturn memory(argmem: read) }
attributes #4 = { 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, !10, i64 280}
!6 = !{!"png_struct_def", !7, i64 0, !9, i64 200, !9, i64 208, !9, i64 216, !9, i64 224, !9, i64 232, !9, i64 240, !9, i64 248, !9, i64 256, !9, i64 264, !7, i64 272, !7, i64 273, !10, i64 280, !10, i64 288, !10, i64 296, !11, i64 304, !9, i64 416, !10, i64 424, !12, i64 432, !12, i64 436, !12, i64 440, !12, i64 444, !12, i64 448, !10, i64 456, !10, i64 464, !10, i64 472, !10, i64 480, !10, i64 488, !10, i64 496, !10, i64 504, !10, i64 512, !9, i64 520, !9, i64 528, !9, i64 536, !9, i64 544, !9, i64 552, !9, i64 560, !13, i64 568, !10, i64 592, !10, i64 600, !9, i64 608, !14, i64 616, !14, i64 618, !7, i64 620, !7, i64 625, !7, i64 626, !7, i64 627, !7, i64 628, !7, i64 629, !7, i64 630, !7, i64 631, !7, i64 632, !7, i64 633, !7, i64 634, !7, i64 635, !7, i64 636, !14, i64 638, !7, i64 640, !15, i64 644, !16, i64 648, !16, i64 658, !9, i64 672, !10, i64 680, !10, i64 688, !12, i64 696, !15, i64 700, !15, i64 704, !9, i64 712, !9, i64 720, !9, i64 728, !9, i64 736, !9, i64 744, !9, i64 752, !17, i64 760, !17, i64 765, !9, i64 776, !16, i64 784, !9, i64 800, !9, i64 808, !9, i64 816, !9, i64 824, !9, i64 832, !9, i64 840, !9, i64 848, !9, i64 856, !9, i64 864, !10, i64 872, !10, i64 880, !10, i64 888, !10, i64 896, !10, i64 904, !10, i64 912, !12, i64 920, !12, i64 924, !10, i64 928, !10, i64 936, !9, i64 944, !9, i64 952, !9, i64 960, !9, i64 968, !9, i64 976, !7, i64 984, !7, i64 985, !9, i64 992, !9, i64 1000, !9, i64 1008, !9, i64 1016, !9, i64 1024, !9, i64 1032, !10, i64 1040, !9, i64 1048, !9, i64 1056, !12, i64 1064, !9, i64 1072, !7, i64 1080, !14, i64 1082, !14, i64 1084, !14, i64 1086, !10, i64 1088, !10, i64 1096, !7, i64 1104, !7, i64 1105, !10, i64 1112, !10, i64 1120, !9, i64 1128, !9, i64 1136, !9, i64 1144, !9, i64 1152, !9, i64 1160, !9, i64 1168, !9, i64 1176, !7, i64 1184, !10, i64 1192, !10, i64 1200, !18, i64 1208, !10, i64 1240, !10, i64 1248}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!"any pointer", !7, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!"z_stream_s", !9, i64 0, !12, i64 8, !10, i64 16, !9, i64 24, !12, i64 32, !10, i64 40, !9, i64 48, !9, i64 56, !9, i64 64, !9, i64 72, !9, i64 80, !12, i64 88, !10, i64 96, !10, i64 104}
!12 = !{!"int", !7, i64 0}
!13 = !{!"png_row_info_struct", !10, i64 0, !10, i64 8, !7, i64 16, !7, i64 17, !7, i64 18, !7, i64 19}
!14 = !{!"short", !7, i64 0}
!15 = !{!"float", !7, i64 0}
!16 = !{!"png_color_16_struct", !7, i64 0, !14, i64 2, !14, i64 4, !14, i64 6, !14, 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, !9, i64 8, !10, i64 16, !7, i64 24}
!19 = !{!7, !7, i64 0}
!20 = !{!6, !9, i64 1056}
!21 = !{!6, !10, i64 288}
!22 = !{!6, !10, i64 1224}
!23 = !{!6, !9, i64 1216}


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