; 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 }
%struct.png_info_struct = type { i64, i64, i64, i64, ptr, i16, i16, i8, i8, i8, i8, i8, i8, i8, i8, [8 x i8], float, i8, i32, i32, ptr, %struct.png_time_struct, %struct.png_color_8_struct, ptr, %struct.png_color_16_struct, %struct.png_color_16_struct, i64, i64, i8, i64, i64, i8, ptr, float, float, float, float, float, float, float, float, ptr, i64, i64, ptr, ptr, i8, i8, i64, ptr, i64, ptr, ptr, i64, i8, ptr, i64, i8, double, double, ptr, ptr, ptr, i64, i64, i64, i64, i64, i64, i64, i64, i64 }
%struct.png_time_struct = type { i16, i8, i8, i8, i8, i8 }

@.str.101 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.102 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.103 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.104 = external hidden unnamed_addr constant [42 x i8], align 1
@.str.105 = external hidden unnamed_addr constant [37 x i8], align 1
@.str.106 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.107 = external hidden unnamed_addr constant [38 x i8], align 1
@.str.108 = external hidden unnamed_addr constant [18 x i8], align 1

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

declare void @png_error(ptr noundef, ptr noundef) #1

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

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

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

declare void @png_warning(ptr noundef, ptr noundef) #1

declare ptr @png_malloc_warn(ptr noundef, i64 noundef) #1

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

; Function Attrs: nounwind uwtable
define dso_local void @png_handle_sCAL(ptr noundef %0, ptr noundef %1, i64 noundef %2) #2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca double, align 8
  %10 = alloca double, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i64, align 8
  %13 = 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) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.png_struct_def, ptr %14, i32 0, i32 12
  %16 = load i64, ptr %15, align 8, !tbaa !11
  %17 = and i64 %16, 1
  %18 = icmp ne i64 %17, 0
  br i1 %18, label %21, label %19

19:                                               ; preds = %3
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  call void @png_error(ptr noundef %20, ptr noundef @.str.101)
  br label %48

21:                                               ; preds = %3
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.png_struct_def, ptr %22, i32 0, i32 12
  %24 = load i64, ptr %23, align 8, !tbaa !11
  %25 = and i64 %24, 4
  %26 = icmp ne i64 %25, 0
  br i1 %26, label %27, label %32

27:                                               ; preds = %21
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  call void @png_warning(ptr noundef %28, ptr noundef @.str.102)
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  %30 = load i64, ptr %6, align 8, !tbaa !9
  %31 = call i32 @png_crc_finish(ptr noundef %29, i64 noundef %30)
  store i32 1, ptr %13, align 4
  br label %138

32:                                               ; preds = %21
  %33 = load ptr, ptr %5, align 8, !tbaa !5
  %34 = icmp ne ptr %33, null
  br i1 %34, label %35, label %46

35:                                               ; preds = %32
  %36 = load ptr, ptr %5, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.png_info_struct, ptr %36, i32 0, i32 2
  %38 = load i64, ptr %37, align 8, !tbaa !21
  %39 = and i64 %38, 16384
  %40 = icmp ne i64 %39, 0
  br i1 %40, label %41, label %46

41:                                               ; preds = %35
  %42 = load ptr, ptr %4, align 8, !tbaa !5
  call void @png_warning(ptr noundef %42, ptr noundef @.str.103)
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  %44 = load i64, ptr %6, align 8, !tbaa !9
  %45 = call i32 @png_crc_finish(ptr noundef %43, i64 noundef %44)
  store i32 1, ptr %13, align 4
  br label %138

46:                                               ; preds = %35, %32
  br label %47

47:                                               ; preds = %46
  br label %48

48:                                               ; preds = %47, %19
  %49 = load ptr, ptr %4, align 8, !tbaa !5
  %50 = load i64, ptr %6, align 8, !tbaa !9
  %51 = add i64 %50, 1
  %52 = call ptr @png_malloc_warn(ptr noundef %49, i64 noundef %51)
  store ptr %52, ptr %7, align 8, !tbaa !5
  %53 = load ptr, ptr %7, align 8, !tbaa !5
  %54 = icmp eq ptr %53, null
  br i1 %54, label %55, label %57

55:                                               ; preds = %48
  %56 = load ptr, ptr %4, align 8, !tbaa !5
  call void @png_warning(ptr noundef %56, ptr noundef @.str.104)
  store i32 1, ptr %13, align 4
  br label %138

57:                                               ; preds = %48
  %58 = load i64, ptr %6, align 8, !tbaa !9
  store i64 %58, ptr %12, align 8, !tbaa !9
  %59 = load ptr, ptr %4, align 8, !tbaa !5
  %60 = load ptr, ptr %7, align 8, !tbaa !5
  %61 = load i64, ptr %12, align 8, !tbaa !9
  call void @png_crc_read(ptr noundef %59, ptr noundef %60, i64 noundef %61)
  %62 = load ptr, ptr %4, align 8, !tbaa !5
  %63 = call i32 @png_crc_finish(ptr noundef %62, i64 noundef 0)
  %64 = icmp ne i32 %63, 0
  br i1 %64, label %65, label %68

65:                                               ; preds = %57
  %66 = load ptr, ptr %4, align 8, !tbaa !5
  %67 = load ptr, ptr %7, align 8, !tbaa !5
  call void @png_free(ptr noundef %66, ptr noundef %67)
  store i32 1, ptr %13, align 4
  br label %138

68:                                               ; preds = %57
  %69 = load ptr, ptr %7, align 8, !tbaa !5
  %70 = load i64, ptr %12, align 8, !tbaa !9
  %71 = getelementptr inbounds i8, ptr %69, i64 %70
  store i8 0, ptr %71, align 1, !tbaa !25
  %72 = load ptr, ptr %7, align 8, !tbaa !5
  %73 = getelementptr inbounds i8, ptr %72, i64 1
  store ptr %73, ptr %8, align 8, !tbaa !5
  %74 = load ptr, ptr %8, align 8, !tbaa !5
  %75 = call double @strtod(ptr noundef %74, ptr noundef %11) #4
  store double %75, ptr %9, align 8, !tbaa !26
  %76 = load ptr, ptr %11, align 8, !tbaa !5
  %77 = load i8, ptr %76, align 1, !tbaa !25
  %78 = icmp ne i8 %77, 0
  br i1 %78, label %79, label %81

79:                                               ; preds = %68
  %80 = load ptr, ptr %4, align 8, !tbaa !5
  call void @png_warning(ptr noundef %80, ptr noundef @.str.105)
  store i32 1, ptr %13, align 4
  br label %138

81:                                               ; preds = %68
  %82 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %82, ptr %8, align 8, !tbaa !5
  br label %83

83:                                               ; preds = %88, %81
  %84 = load ptr, ptr %8, align 8, !tbaa !5
  %85 = load i8, ptr %84, align 1, !tbaa !25
  %86 = icmp ne i8 %85, 0
  br i1 %86, label %87, label %91

87:                                               ; preds = %83
  br label %88

88:                                               ; preds = %87
  %89 = load ptr, ptr %8, align 8, !tbaa !5
  %90 = getelementptr inbounds i8, ptr %89, i32 1
  store ptr %90, ptr %8, align 8, !tbaa !5
  br label %83, !llvm.loop !27

91:                                               ; preds = %83
  %92 = load ptr, ptr %8, align 8, !tbaa !5
  %93 = getelementptr inbounds i8, ptr %92, i32 1
  store ptr %93, ptr %8, align 8, !tbaa !5
  %94 = load ptr, ptr %7, align 8, !tbaa !5
  %95 = load i64, ptr %12, align 8, !tbaa !9
  %96 = getelementptr inbounds i8, ptr %94, i64 %95
  %97 = load ptr, ptr %8, align 8, !tbaa !5
  %98 = icmp ult ptr %96, %97
  br i1 %98, label %99, label %103

99:                                               ; preds = %91
  %100 = load ptr, ptr %4, align 8, !tbaa !5
  call void @png_warning(ptr noundef %100, ptr noundef @.str.106)
  %101 = load ptr, ptr %4, align 8, !tbaa !5
  %102 = load ptr, ptr %7, align 8, !tbaa !5
  call void @png_free(ptr noundef %101, ptr noundef %102)
  store i32 1, ptr %13, align 4
  br label %138

103:                                              ; preds = %91
  %104 = load ptr, ptr %8, align 8, !tbaa !5
  %105 = call double @strtod(ptr noundef %104, ptr noundef %11) #4
  store double %105, ptr %10, align 8, !tbaa !26
  %106 = load ptr, ptr %11, align 8, !tbaa !5
  %107 = load i8, ptr %106, align 1, !tbaa !25
  %108 = icmp ne i8 %107, 0
  br i1 %108, label %109, label %111

109:                                              ; preds = %103
  %110 = load ptr, ptr %4, align 8, !tbaa !5
  call void @png_warning(ptr noundef %110, ptr noundef @.str.107)
  store i32 1, ptr %13, align 4
  br label %138

111:                                              ; preds = %103
  %112 = load ptr, ptr %7, align 8, !tbaa !5
  %113 = load i64, ptr %12, align 8, !tbaa !9
  %114 = getelementptr inbounds i8, ptr %112, i64 %113
  %115 = load ptr, ptr %8, align 8, !tbaa !5
  %116 = icmp ult ptr %114, %115
  br i1 %116, label %123, label %117

117:                                              ; preds = %111
  %118 = load double, ptr %9, align 8, !tbaa !26
  %119 = fcmp ole double %118, 0.000000e+00
  br i1 %119, label %123, label %120

120:                                              ; preds = %117
  %121 = load double, ptr %10, align 8, !tbaa !26
  %122 = fcmp ole double %121, 0.000000e+00
  br i1 %122, label %123, label %127

123:                                              ; preds = %120, %117, %111
  %124 = load ptr, ptr %4, align 8, !tbaa !5
  call void @png_warning(ptr noundef %124, ptr noundef @.str.108)
  %125 = load ptr, ptr %4, align 8, !tbaa !5
  %126 = load ptr, ptr %7, align 8, !tbaa !5
  call void @png_free(ptr noundef %125, ptr noundef %126)
  store i32 1, ptr %13, align 4
  br label %138

127:                                              ; preds = %120
  %128 = load ptr, ptr %4, align 8, !tbaa !5
  %129 = load ptr, ptr %5, align 8, !tbaa !5
  %130 = load ptr, ptr %7, align 8, !tbaa !5
  %131 = getelementptr inbounds i8, ptr %130, i64 0
  %132 = load i8, ptr %131, align 1, !tbaa !25
  %133 = sext i8 %132 to i32
  %134 = load double, ptr %9, align 8, !tbaa !26
  %135 = load double, ptr %10, align 8, !tbaa !26
  call void @png_set_sCAL(ptr noundef %128, ptr noundef %129, i32 noundef %133, double noundef %134, double noundef %135)
  %136 = load ptr, ptr %4, align 8, !tbaa !5
  %137 = load ptr, ptr %7, align 8, !tbaa !5
  call void @png_free(ptr noundef %136, ptr noundef %137)
  store i32 0, ptr %13, align 4
  br label %138

138:                                              ; preds = %127, %123, %109, %99, %79, %65, %55, %41, %27
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  %139 = load i32, ptr %13, align 4
  switch i32 %139, label %141 [
    i32 0, label %140
    i32 1, label %140
  ]

140:                                              ; preds = %138, %138
  ret void

141:                                              ; preds = %138
  unreachable
}

; Function Attrs: nounwind
declare double @strtod(ptr noundef, ptr noundef) #3

declare void @png_set_sCAL(ptr noundef, ptr noundef, i32 noundef, double noundef, double noundef) #1

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

!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 = !{!22, !10, i64 16}
!22 = !{!"png_info_struct", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !6, i64 32, !16, i64 40, !16, i64 42, !7, i64 44, !7, i64 45, !7, i64 46, !7, i64 47, !7, i64 48, !7, i64 49, !7, i64 50, !7, i64 51, !7, i64 52, !17, i64 60, !7, i64 64, !14, i64 68, !14, i64 72, !6, i64 80, !23, i64 88, !19, i64 96, !6, i64 104, !18, i64 112, !18, i64 122, !10, i64 136, !10, i64 144, !7, i64 152, !10, i64 160, !10, i64 168, !7, i64 176, !6, i64 184, !17, i64 192, !17, i64 196, !17, i64 200, !17, i64 204, !17, i64 208, !17, i64 212, !17, i64 216, !17, i64 220, !6, i64 224, !10, i64 232, !10, i64 240, !6, i64 248, !6, i64 256, !7, i64 264, !7, i64 265, !10, i64 272, !6, i64 280, !10, i64 288, !6, i64 296, !6, i64 304, !10, i64 312, !7, i64 320, !6, i64 328, !10, i64 336, !7, i64 344, !24, i64 352, !24, i64 360, !6, i64 368, !6, i64 376, !6, i64 384, !10, i64 392, !10, i64 400, !10, i64 408, !10, i64 416, !10, i64 424, !10, i64 432, !10, i64 440, !10, i64 448, !10, i64 456}
!23 = !{!"png_time_struct", !16, i64 0, !7, i64 2, !7, i64 3, !7, i64 4, !7, i64 5, !7, i64 6}
!24 = !{!"double", !7, i64 0}
!25 = !{!7, !7, i64 0}
!26 = !{!24, !24, i64 0}
!27 = distinct !{!27, !28}
!28 = !{!"llvm.loop.mustprogress"}


; 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.101 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.102 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.103 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.104 = external hidden unnamed_addr constant [42 x i8], align 1
@.str.105 = external hidden unnamed_addr constant [37 x i8], align 1
@.str.106 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.107 = external hidden unnamed_addr constant [38 x i8], align 1
@.str.108 = external hidden unnamed_addr constant [18 x i8], align 1

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

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

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

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

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

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

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

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

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

8:                                                ; preds = %3
  tail call void @png_error(ptr noundef nonnull %0, ptr noundef nonnull @.str.101) #4
  br label %20

9:                                                ; preds = %3
  %10 = and i64 %6, 4
  %.not61 = icmp eq i64 %10, 0
  br i1 %.not61, label %13, label %11

11:                                               ; preds = %9
  tail call void @png_warning(ptr noundef nonnull %0, ptr noundef nonnull @.str.102) #4
  %12 = tail call i32 @png_crc_finish(ptr noundef nonnull %0, i64 noundef %2)
  br label %52

13:                                               ; preds = %9
  %.not62 = icmp eq ptr %1, null
  br i1 %.not62, label %20, label %14

14:                                               ; preds = %13
  %15 = getelementptr inbounds i8, ptr %1, i64 16
  %16 = load i64, ptr %15, align 8, !tbaa !19
  %17 = and i64 %16, 16384
  %.not63 = icmp eq i64 %17, 0
  br i1 %.not63, label %20, label %18

18:                                               ; preds = %14
  tail call void @png_warning(ptr noundef nonnull %0, ptr noundef nonnull @.str.103) #4
  %19 = tail call i32 @png_crc_finish(ptr noundef nonnull %0, i64 noundef %2)
  br label %52

20:                                               ; preds = %14, %13, %8
  %21 = add i64 %2, 1
  %22 = tail call ptr @png_malloc_warn(ptr noundef nonnull %0, i64 noundef %21) #4
  %23 = icmp eq ptr %22, null
  br i1 %23, label %24, label %25

24:                                               ; preds = %20
  tail call void @png_warning(ptr noundef nonnull %0, ptr noundef nonnull @.str.104) #4
  br label %52

25:                                               ; preds = %20
  tail call void @png_crc_read(ptr noundef nonnull %0, ptr noundef nonnull %22, i64 noundef %2)
  %26 = tail call i32 @png_crc_finish(ptr noundef nonnull %0, i64 noundef 0)
  %.not64 = icmp eq i32 %26, 0
  br i1 %.not64, label %28, label %27

27:                                               ; preds = %25
  tail call void @png_free(ptr noundef nonnull %0, ptr noundef nonnull %22) #4
  br label %52

28:                                               ; preds = %25
  %29 = getelementptr inbounds i8, ptr %22, i64 %2
  store i8 0, ptr %29, align 1, !tbaa !23
  %30 = getelementptr inbounds i8, ptr %22, i64 1
  %31 = call double @strtod(ptr noundef nonnull %30, ptr noundef nonnull %4) #4
  %32 = load ptr, ptr %4, align 8, !tbaa !24
  %33 = load i8, ptr %32, align 1, !tbaa !23
  %.not65 = icmp eq i8 %33, 0
  br i1 %.not65, label %.preheader, label %34

34:                                               ; preds = %28
  tail call void @png_warning(ptr noundef nonnull %0, ptr noundef nonnull @.str.105) #4
  br label %52

.preheader:                                       ; preds = %28, %.preheader
  %.0 = phi ptr [ %36, %.preheader ], [ %22, %28 ]
  %35 = load i8, ptr %.0, align 1, !tbaa !23
  %.not66 = icmp eq i8 %35, 0
  %36 = getelementptr inbounds i8, ptr %.0, i64 1
  br i1 %.not66, label %37, label %.preheader, !llvm.loop !25

37:                                               ; preds = %.preheader
  %38 = icmp ult ptr %29, %36
  br i1 %38, label %39, label %40

39:                                               ; preds = %37
  tail call void @png_warning(ptr noundef %0, ptr noundef nonnull @.str.106) #4
  tail call void @png_free(ptr noundef %0, ptr noundef nonnull %22) #4
  br label %52

40:                                               ; preds = %37
  %41 = call double @strtod(ptr noundef nonnull %36, ptr noundef nonnull %4) #4
  %42 = load ptr, ptr %4, align 8, !tbaa !24
  %43 = load i8, ptr %42, align 1, !tbaa !23
  %.not67 = icmp eq i8 %43, 0
  br i1 %.not67, label %45, label %44

44:                                               ; preds = %40
  tail call void @png_warning(ptr noundef %0, ptr noundef nonnull @.str.107) #4
  br label %52

45:                                               ; preds = %40
  %46 = fcmp ole double %31, 0.000000e+00
  %47 = fcmp ole double %41, 0.000000e+00
  %or.cond3 = select i1 %46, i1 true, i1 %47
  br i1 %or.cond3, label %48, label %49

48:                                               ; preds = %45
  tail call void @png_warning(ptr noundef %0, ptr noundef nonnull @.str.108) #4
  tail call void @png_free(ptr noundef %0, ptr noundef nonnull %22) #4
  br label %52

49:                                               ; preds = %45
  %50 = load i8, ptr %22, align 1, !tbaa !23
  %51 = sext i8 %50 to i32
  tail call void @png_set_sCAL(ptr noundef %0, ptr noundef %1, i32 noundef %51, double noundef %31, double noundef %41) #4
  tail call void @png_free(ptr noundef %0, ptr noundef nonnull %22) #4
  br label %52

52:                                               ; preds = %49, %48, %44, %39, %34, %27, %24, %18, %11
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #4
  ret void
}

; Function Attrs: mustprogress nofree nounwind willreturn
declare double @strtod(ptr noundef readonly, ptr nocapture noundef) local_unnamed_addr #3

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

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

!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 = !{!20, !10, i64 16}
!20 = !{!"png_info_struct", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !9, i64 32, !14, i64 40, !14, i64 42, !7, i64 44, !7, i64 45, !7, i64 46, !7, i64 47, !7, i64 48, !7, i64 49, !7, i64 50, !7, i64 51, !7, i64 52, !15, i64 60, !7, i64 64, !12, i64 68, !12, i64 72, !9, i64 80, !21, i64 88, !17, i64 96, !9, i64 104, !16, i64 112, !16, i64 122, !10, i64 136, !10, i64 144, !7, i64 152, !10, i64 160, !10, i64 168, !7, i64 176, !9, i64 184, !15, i64 192, !15, i64 196, !15, i64 200, !15, i64 204, !15, i64 208, !15, i64 212, !15, i64 216, !15, i64 220, !9, i64 224, !10, i64 232, !10, i64 240, !9, i64 248, !9, i64 256, !7, i64 264, !7, i64 265, !10, i64 272, !9, i64 280, !10, i64 288, !9, i64 296, !9, i64 304, !10, i64 312, !7, i64 320, !9, i64 328, !10, i64 336, !7, i64 344, !22, i64 352, !22, i64 360, !9, i64 368, !9, i64 376, !9, i64 384, !10, i64 392, !10, i64 400, !10, i64 408, !10, i64 416, !10, i64 424, !10, i64 432, !10, i64 440, !10, i64 448, !10, i64 456}
!21 = !{!"png_time_struct", !14, i64 0, !7, i64 2, !7, i64 3, !7, i64 4, !7, i64 5, !7, i64 6}
!22 = !{!"double", !7, i64 0}
!23 = !{!7, !7, i64 0}
!24 = !{!9, !9, i64 0}
!25 = distinct !{!25, !26}
!26 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass