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

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

@.str.32 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.33 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.34 = external hidden unnamed_addr constant [1 x i8], align 1
@.str.35 = external hidden unnamed_addr constant [33 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 hidden void @png_write_chunk_header(ptr noalias noundef, i32 noundef, i32 noundef) #1

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

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

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

declare i32 @png_check_keyword(ptr noundef, ptr noundef, ptr noundef) #3

; Function Attrs: nounwind uwtable
declare hidden void @png_text_compress_init(ptr noundef, ptr noundef, i64 noundef) #1

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

; Function Attrs: nounwind uwtable
declare hidden void @png_write_compressed_data_out(ptr noalias noundef, ptr noundef) #1

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

; Function Attrs: nounwind uwtable
define dso_local void @png_write_iTXt(ptr noalias noundef %0, i32 noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5) #1 {
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i64, align 8
  %16 = alloca i64, align 8
  %17 = alloca [82 x i8], align 16
  %18 = alloca %struct.compression_state, align 8
  store ptr %0, ptr %7, align 8, !tbaa !5
  store i32 %1, ptr %8, align 4, !tbaa !9
  store ptr %2, ptr %9, align 8, !tbaa !5
  store ptr %3, ptr %10, align 8, !tbaa !5
  store ptr %4, ptr %11, align 8, !tbaa !5
  store ptr %5, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #5
  call void @llvm.lifetime.start.p0(i64 82, ptr %17) #5
  call void @llvm.lifetime.start.p0(i64 1048, ptr %18) #5
  %19 = load ptr, ptr %7, align 8, !tbaa !5
  %20 = load ptr, ptr %9, align 8, !tbaa !5
  %21 = getelementptr inbounds [82 x i8], ptr %17, i64 0, i64 0
  %22 = call i32 @png_check_keyword(ptr noundef %19, ptr noundef %20, ptr noundef %21)
  store i32 %22, ptr %13, align 4, !tbaa !9
  %23 = load i32, ptr %13, align 4, !tbaa !9
  %24 = icmp eq i32 %23, 0
  br i1 %24, label %25, label %27

25:                                               ; preds = %6
  %26 = load ptr, ptr %7, align 8, !tbaa !5
  call void @png_error(ptr noundef %26, ptr noundef @.str.32) #6
  unreachable

27:                                               ; preds = %6
  %28 = load i32, ptr %8, align 4, !tbaa !9
  switch i32 %28, label %39 [
    i32 1, label %29
    i32 -1, label %29
    i32 0, label %34
    i32 2, label %34
  ]

29:                                               ; preds = %27, %27
  %30 = load i32, ptr %13, align 4, !tbaa !9
  %31 = add i32 %30, 1
  store i32 %31, ptr %13, align 4, !tbaa !9
  %32 = zext i32 %31 to i64
  %33 = getelementptr inbounds [82 x i8], ptr %17, i64 0, i64 %32
  store i8 0, ptr %33, align 1, !tbaa !11
  store i32 0, ptr %8, align 4, !tbaa !9
  br label %41

34:                                               ; preds = %27, %27
  %35 = load i32, ptr %13, align 4, !tbaa !9
  %36 = add i32 %35, 1
  store i32 %36, ptr %13, align 4, !tbaa !9
  %37 = zext i32 %36 to i64
  %38 = getelementptr inbounds [82 x i8], ptr %17, i64 0, i64 %37
  store i8 1, ptr %38, align 1, !tbaa !11
  store i32 1, ptr %8, align 4, !tbaa !9
  br label %41

39:                                               ; preds = %27
  %40 = load ptr, ptr %7, align 8, !tbaa !5
  call void @png_error(ptr noundef %40, ptr noundef @.str.33) #6
  unreachable

41:                                               ; preds = %34, %29
  %42 = load i32, ptr %13, align 4, !tbaa !9
  %43 = add i32 %42, 1
  store i32 %43, ptr %13, align 4, !tbaa !9
  %44 = zext i32 %43 to i64
  %45 = getelementptr inbounds [82 x i8], ptr %17, i64 0, i64 %44
  store i8 0, ptr %45, align 1, !tbaa !11
  %46 = load i32, ptr %13, align 4, !tbaa !9
  %47 = add i32 %46, 1
  store i32 %47, ptr %13, align 4, !tbaa !9
  %48 = load ptr, ptr %10, align 8, !tbaa !5
  %49 = icmp eq ptr %48, null
  br i1 %49, label %50, label %51

50:                                               ; preds = %41
  store ptr @.str.34, ptr %10, align 8, !tbaa !5
  br label %51

51:                                               ; preds = %50, %41
  %52 = load ptr, ptr %10, align 8, !tbaa !5
  %53 = call i64 @strlen(ptr noundef %52) #7
  %54 = add i64 %53, 1
  store i64 %54, ptr %15, align 8, !tbaa !12
  %55 = load ptr, ptr %11, align 8, !tbaa !5
  %56 = icmp eq ptr %55, null
  br i1 %56, label %57, label %58

57:                                               ; preds = %51
  store ptr @.str.34, ptr %11, align 8, !tbaa !5
  br label %58

58:                                               ; preds = %57, %51
  %59 = load ptr, ptr %11, align 8, !tbaa !5
  %60 = call i64 @strlen(ptr noundef %59) #7
  %61 = add i64 %60, 1
  store i64 %61, ptr %16, align 8, !tbaa !12
  %62 = load ptr, ptr %12, align 8, !tbaa !5
  %63 = icmp eq ptr %62, null
  br i1 %63, label %64, label %65

64:                                               ; preds = %58
  store ptr @.str.34, ptr %12, align 8, !tbaa !5
  br label %65

65:                                               ; preds = %64, %58
  %66 = load i32, ptr %13, align 4, !tbaa !9
  store i32 %66, ptr %14, align 4, !tbaa !9
  %67 = load i64, ptr %15, align 8, !tbaa !12
  %68 = load i32, ptr %14, align 4, !tbaa !9
  %69 = sub i32 2147483647, %68
  %70 = zext i32 %69 to i64
  %71 = icmp ugt i64 %67, %70
  br i1 %71, label %72, label %73

72:                                               ; preds = %65
  store i32 2147483647, ptr %14, align 4, !tbaa !9
  br label %79

73:                                               ; preds = %65
  %74 = load i32, ptr %14, align 4, !tbaa !9
  %75 = zext i32 %74 to i64
  %76 = load i64, ptr %15, align 8, !tbaa !12
  %77 = add i64 %75, %76
  %78 = trunc i64 %77 to i32
  store i32 %78, ptr %14, align 4, !tbaa !9
  br label %79

79:                                               ; preds = %73, %72
  %80 = load i64, ptr %16, align 8, !tbaa !12
  %81 = load i32, ptr %14, align 4, !tbaa !9
  %82 = sub i32 2147483647, %81
  %83 = zext i32 %82 to i64
  %84 = icmp ugt i64 %80, %83
  br i1 %84, label %85, label %86

85:                                               ; preds = %79
  store i32 2147483647, ptr %14, align 4, !tbaa !9
  br label %92

86:                                               ; preds = %79
  %87 = load i32, ptr %14, align 4, !tbaa !9
  %88 = zext i32 %87 to i64
  %89 = load i64, ptr %16, align 8, !tbaa !12
  %90 = add i64 %88, %89
  %91 = trunc i64 %90 to i32
  store i32 %91, ptr %14, align 4, !tbaa !9
  br label %92

92:                                               ; preds = %86, %85
  %93 = load ptr, ptr %12, align 8, !tbaa !5
  %94 = load ptr, ptr %12, align 8, !tbaa !5
  %95 = call i64 @strlen(ptr noundef %94) #7
  call void @png_text_compress_init(ptr noundef %18, ptr noundef %93, i64 noundef %95)
  %96 = load i32, ptr %8, align 4, !tbaa !9
  %97 = icmp ne i32 %96, 0
  br i1 %97, label %98, label %110

98:                                               ; preds = %92
  %99 = load ptr, ptr %7, align 8, !tbaa !5
  %100 = load i32, ptr %14, align 4, !tbaa !9
  %101 = call i32 @png_text_compress(ptr noundef %99, i32 noundef 1767135348, ptr noundef %18, i32 noundef %100)
  %102 = icmp ne i32 %101, 0
  br i1 %102, label %103, label %109

103:                                              ; preds = %98
  %104 = load ptr, ptr %7, align 8, !tbaa !5
  %105 = load ptr, ptr %7, align 8, !tbaa !5
  %106 = getelementptr inbounds %struct.png_struct_def, ptr %105, i32 0, i32 19
  %107 = getelementptr inbounds %struct.z_stream_s, ptr %106, i32 0, i32 6
  %108 = load ptr, ptr %107, align 8, !tbaa !14
  call void @png_error(ptr noundef %104, ptr noundef %108) #6
  unreachable

109:                                              ; preds = %98
  br label %124

110:                                              ; preds = %92
  %111 = getelementptr inbounds %struct.compression_state, ptr %18, i32 0, i32 1
  %112 = load i64, ptr %111, align 8, !tbaa !24
  %113 = load i32, ptr %14, align 4, !tbaa !9
  %114 = sub i32 2147483647, %113
  %115 = zext i32 %114 to i64
  %116 = icmp ugt i64 %112, %115
  br i1 %116, label %117, label %119

117:                                              ; preds = %110
  %118 = load ptr, ptr %7, align 8, !tbaa !5
  call void @png_error(ptr noundef %118, ptr noundef @.str.35) #6
  unreachable

119:                                              ; preds = %110
  %120 = getelementptr inbounds %struct.compression_state, ptr %18, i32 0, i32 1
  %121 = load i64, ptr %120, align 8, !tbaa !24
  %122 = trunc i64 %121 to i32
  %123 = getelementptr inbounds %struct.compression_state, ptr %18, i32 0, i32 2
  store i32 %122, ptr %123, align 8, !tbaa !26
  br label %124

124:                                              ; preds = %119, %109
  %125 = load ptr, ptr %7, align 8, !tbaa !5
  %126 = getelementptr inbounds %struct.compression_state, ptr %18, i32 0, i32 2
  %127 = load i32, ptr %126, align 8, !tbaa !26
  %128 = load i32, ptr %14, align 4, !tbaa !9
  %129 = add i32 %127, %128
  call void @png_write_chunk_header(ptr noundef %125, i32 noundef 1767135348, i32 noundef %129)
  %130 = load ptr, ptr %7, align 8, !tbaa !5
  %131 = getelementptr inbounds [82 x i8], ptr %17, i64 0, i64 0
  %132 = load i32, ptr %13, align 4, !tbaa !9
  %133 = zext i32 %132 to i64
  call void @png_write_chunk_data(ptr noundef %130, ptr noundef %131, i64 noundef %133)
  %134 = load ptr, ptr %7, align 8, !tbaa !5
  %135 = load ptr, ptr %10, align 8, !tbaa !5
  %136 = load i64, ptr %15, align 8, !tbaa !12
  call void @png_write_chunk_data(ptr noundef %134, ptr noundef %135, i64 noundef %136)
  %137 = load ptr, ptr %7, align 8, !tbaa !5
  %138 = load ptr, ptr %11, align 8, !tbaa !5
  %139 = load i64, ptr %16, align 8, !tbaa !12
  call void @png_write_chunk_data(ptr noundef %137, ptr noundef %138, i64 noundef %139)
  %140 = load i32, ptr %8, align 4, !tbaa !9
  %141 = icmp ne i32 %140, 0
  br i1 %141, label %142, label %144

142:                                              ; preds = %124
  %143 = load ptr, ptr %7, align 8, !tbaa !5
  call void @png_write_compressed_data_out(ptr noundef %143, ptr noundef %18)
  br label %150

144:                                              ; preds = %124
  %145 = load ptr, ptr %7, align 8, !tbaa !5
  %146 = load ptr, ptr %12, align 8, !tbaa !5
  %147 = getelementptr inbounds %struct.compression_state, ptr %18, i32 0, i32 2
  %148 = load i32, ptr %147, align 8, !tbaa !26
  %149 = zext i32 %148 to i64
  call void @png_write_chunk_data(ptr noundef %145, ptr noundef %146, i64 noundef %149)
  br label %150

150:                                              ; preds = %144, %142
  %151 = load ptr, ptr %7, align 8, !tbaa !5
  call void @png_write_chunk_end(ptr noundef %151)
  call void @llvm.lifetime.end.p0(i64 1048, ptr %18) #5
  call void @llvm.lifetime.end.p0(i64 82, ptr %17) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  ret void
}

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


; 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.compression_state = type { ptr, i64, i32, [1024 x i8] }

@.str.32 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.33 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.34 = external hidden unnamed_addr constant [1 x i8], align 1
@.str.35 = external hidden unnamed_addr constant [33 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 hidden void @png_write_chunk_header(ptr noalias noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

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

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

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

declare i32 @png_check_keyword(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare hidden void @png_text_compress_init(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
declare hidden void @png_write_compressed_data_out(ptr noalias noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #4

; Function Attrs: nounwind uwtable
define dso_local void @png_write_iTXt(ptr noalias noundef %0, i32 noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5) local_unnamed_addr #1 {
  %7 = alloca [82 x i8], align 16
  %8 = alloca %struct.compression_state, align 8
  call void @llvm.lifetime.start.p0(i64 82, ptr nonnull %7) #5
  call void @llvm.lifetime.start.p0(i64 1048, ptr nonnull %8) #5
  %9 = call i32 @png_check_keyword(ptr noundef %0, ptr noundef %2, ptr noundef nonnull %7) #5
  %10 = icmp eq i32 %9, 0
  br i1 %10, label %11, label %12

11:                                               ; preds = %6
  call void @png_error(ptr noundef %0, ptr noundef nonnull @.str.32) #6
  unreachable

12:                                               ; preds = %6
  %switch.tableidx = add i32 %1, 1
  %13 = icmp ult i32 %switch.tableidx, 4
  br i1 %13, label %switch.lookup, label %14

14:                                               ; preds = %12
  call void @png_error(ptr noundef %0, ptr noundef nonnull @.str.33) #6
  unreachable

switch.lookup:                                    ; preds = %12
  %switch.shiftamt = shl nuw nsw i32 %switch.tableidx, 3
  %switch.downshift = lshr i32 16777472, %switch.shiftamt
  %switch.masked = trunc i32 %switch.downshift to i8
  %switch.idx.cast = trunc i32 %switch.tableidx to i1
  %15 = add i32 %9, 1
  %16 = zext i32 %15 to i64
  %17 = getelementptr inbounds [82 x i8], ptr %7, i64 0, i64 %16
  store i8 %switch.masked, ptr %17, align 1, !tbaa !5
  %18 = add i32 %9, 2
  %19 = zext i32 %18 to i64
  %20 = getelementptr inbounds [82 x i8], ptr %7, i64 0, i64 %19
  store i8 0, ptr %20, align 1, !tbaa !5
  %21 = add i32 %9, 3
  %22 = icmp eq ptr %3, null
  %spec.store.select = select i1 %22, ptr @.str.34, ptr %3
  %23 = call i64 @strlen(ptr noundef nonnull dereferenceable(1) %spec.store.select) #7
  %24 = add i64 %23, 1
  %25 = icmp eq ptr %4, null
  %spec.store.select2 = select i1 %25, ptr @.str.34, ptr %4
  %26 = call i64 @strlen(ptr noundef nonnull dereferenceable(1) %spec.store.select2) #7
  %27 = add i64 %26, 1
  %28 = icmp eq ptr %5, null
  %spec.store.select1 = select i1 %28, ptr @.str.34, ptr %5
  %29 = sub i32 2147483644, %9
  %30 = zext i32 %29 to i64
  %31 = icmp ugt i64 %24, %30
  %32 = trunc i64 %24 to i32
  %33 = add i32 %21, %32
  %.049 = select i1 %31, i32 2147483647, i32 %33
  %34 = sub i32 2147483647, %.049
  %35 = zext i32 %34 to i64
  %36 = icmp ugt i64 %27, %35
  %37 = trunc i64 %27 to i32
  %38 = add i32 %.049, %37
  %.1 = select i1 %36, i32 2147483647, i32 %38
  %39 = call i64 @strlen(ptr noundef nonnull dereferenceable(1) %spec.store.select1) #7
  call void @png_text_compress_init(ptr noundef nonnull %8, ptr noundef nonnull %spec.store.select1, i64 noundef %39)
  br i1 %switch.idx.cast, label %40, label %45

40:                                               ; preds = %switch.lookup
  %41 = call i32 @png_text_compress(ptr noundef %0, i32 noundef 1767135348, ptr noundef nonnull %8, i32 noundef %.1)
  %.not55 = icmp eq i32 %41, 0
  br i1 %.not55, label %._crit_edge, label %42

._crit_edge:                                      ; preds = %40
  %.phi.trans.insert = getelementptr inbounds i8, ptr %8, i64 16
  %.pre = load i32, ptr %.phi.trans.insert, align 8, !tbaa !8
  br label %55

42:                                               ; preds = %40
  %43 = getelementptr inbounds i8, ptr %0, i64 368
  %44 = load ptr, ptr %43, align 8, !tbaa !13
  call void @png_error(ptr noundef %0, ptr noundef %44) #6
  unreachable

45:                                               ; preds = %switch.lookup
  %46 = getelementptr inbounds i8, ptr %8, i64 8
  %47 = load i64, ptr %46, align 8, !tbaa !23
  %48 = sub i32 2147483647, %.1
  %49 = zext i32 %48 to i64
  %50 = icmp ugt i64 %47, %49
  br i1 %50, label %51, label %52

51:                                               ; preds = %45
  call void @png_error(ptr noundef %0, ptr noundef nonnull @.str.35) #6
  unreachable

52:                                               ; preds = %45
  %53 = trunc nuw i64 %47 to i32
  %54 = getelementptr inbounds i8, ptr %8, i64 16
  store i32 %53, ptr %54, align 8, !tbaa !8
  br label %55

55:                                               ; preds = %._crit_edge, %52
  %56 = phi i32 [ %.pre, %._crit_edge ], [ %53, %52 ]
  %57 = add i32 %56, %.1
  call void @png_write_chunk_header(ptr noundef %0, i32 noundef 1767135348, i32 noundef %57)
  %58 = zext i32 %21 to i64
  call void @png_write_chunk_data(ptr noundef %0, ptr noundef nonnull %7, i64 noundef %58)
  call void @png_write_chunk_data(ptr noundef %0, ptr noundef nonnull %spec.store.select, i64 noundef %24)
  call void @png_write_chunk_data(ptr noundef %0, ptr noundef nonnull %spec.store.select2, i64 noundef %27)
  br i1 %switch.idx.cast, label %59, label %60

59:                                               ; preds = %55
  call void @png_write_compressed_data_out(ptr noundef %0, ptr noundef nonnull %8)
  br label %64

60:                                               ; preds = %55
  %61 = getelementptr inbounds i8, ptr %8, i64 16
  %62 = load i32, ptr %61, align 8, !tbaa !8
  %63 = zext i32 %62 to i64
  call void @png_write_chunk_data(ptr noundef %0, ptr noundef nonnull %spec.store.select1, i64 noundef %63)
  br label %64

64:                                               ; preds = %60, %59
  call void @png_write_chunk_end(ptr noundef %0)
  call void @llvm.lifetime.end.p0(i64 1048, ptr nonnull %8) #5
  call void @llvm.lifetime.end.p0(i64 82, ptr nonnull %7) #5
  ret void
}

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


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