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

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%struct.png_struct_def = type { [1 x %struct.__jmp_buf_tag], ptr, ptr, i64, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i8, i8, i32, i32, i32, i32, %struct.z_stream_s, ptr, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i64, i32, i32, i32, ptr, ptr, ptr, ptr, i64, i32, i32, ptr, i16, i32, i16, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i16, i8, i32, %struct.png_color_16_struct, %struct.png_color_16_struct, ptr, i32, i32, i32, i32, ptr, ptr, ptr, ptr, ptr, ptr, %struct.png_color_8_struct, %struct.png_color_8_struct, ptr, %struct.png_color_16_struct, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i32, i32, i64, i64, i64, i64, i32, i32, ptr, ptr, i32, [29 x i8], i32, ptr, ptr, i32, i32, ptr, i8, i8, i16, i16, i32, i8, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i8, i32, i32, i32, i64, %struct.png_unknown_chunk_t, i64, ptr, i64, i32, i32, ptr, [4 x ptr], %struct.png_colorspace }
%struct.__jmp_buf_tag = type { [8 x i64], i32, %struct.__sigset_t }
%struct.__sigset_t = type { [16 x i64] }
%struct.z_stream_s = type { ptr, i32, i64, ptr, i32, i64, ptr, ptr, ptr, ptr, ptr, i32, i64, i64 }
%struct.png_color_8_struct = type { i8, i8, i8, i8, i8 }
%struct.png_color_16_struct = type { i8, i16, i16, i16, i16 }
%struct.png_unknown_chunk_t = type { [5 x i8], ptr, i64, i8 }
%struct.png_colorspace = type { i32, %struct.png_xy, %struct.png_XYZ, i16, i16 }
%struct.png_xy = type { i32, i32, i32, i32, i32, i32, i32, i32 }
%struct.png_XYZ = type { i32, i32, i32, i32, i32, i32, i32, i32, i32 }

@.str.7 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [18 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @png_push_save_buffer(ptr noalias noundef %0) #0 {
  %2 = alloca ptr, align 8
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %9 = load ptr, ptr %2, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.png_struct_def, ptr %9, i32 0, i32 102
  %11 = load i64, ptr %10, align 8, !tbaa !9
  %12 = icmp ne i64 %11, 0
  br i1 %12, label %13, label %48

13:                                               ; preds = %1
  %14 = load ptr, ptr %2, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.png_struct_def, ptr %14, i32 0, i32 96
  %16 = load ptr, ptr %15, align 8, !tbaa !21
  %17 = load ptr, ptr %2, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.png_struct_def, ptr %17, i32 0, i32 97
  %19 = load ptr, ptr %18, align 8, !tbaa !22
  %20 = icmp ne ptr %16, %19
  br i1 %20, label %21, label %47

21:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  %22 = load ptr, ptr %2, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.png_struct_def, ptr %22, i32 0, i32 102
  %24 = load i64, ptr %23, align 8, !tbaa !9
  store i64 %24, ptr %4, align 8, !tbaa !23
  store i64 0, ptr %3, align 8, !tbaa !23
  %25 = load ptr, ptr %2, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.png_struct_def, ptr %25, i32 0, i32 96
  %27 = load ptr, ptr %26, align 8, !tbaa !21
  store ptr %27, ptr %5, align 8, !tbaa !5
  %28 = load ptr, ptr %2, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.png_struct_def, ptr %28, i32 0, i32 97
  %30 = load ptr, ptr %29, align 8, !tbaa !22
  store ptr %30, ptr %6, align 8, !tbaa !5
  br label %31

31:                                               ; preds = %39, %21
  %32 = load i64, ptr %3, align 8, !tbaa !23
  %33 = load i64, ptr %4, align 8, !tbaa !23
  %34 = icmp ult i64 %32, %33
  br i1 %34, label %35, label %46

35:                                               ; preds = %31
  %36 = load ptr, ptr %5, align 8, !tbaa !5
  %37 = load i8, ptr %36, align 1, !tbaa !24
  %38 = load ptr, ptr %6, align 8, !tbaa !5
  store i8 %37, ptr %38, align 1, !tbaa !24
  br label %39

39:                                               ; preds = %35
  %40 = load i64, ptr %3, align 8, !tbaa !23
  %41 = add i64 %40, 1
  store i64 %41, ptr %3, align 8, !tbaa !23
  %42 = load ptr, ptr %5, align 8, !tbaa !5
  %43 = getelementptr inbounds i8, ptr %42, i32 1
  store ptr %43, ptr %5, align 8, !tbaa !5
  %44 = load ptr, ptr %6, align 8, !tbaa !5
  %45 = getelementptr inbounds i8, ptr %44, i32 1
  store ptr %45, ptr %6, align 8, !tbaa !5
  br label %31, !llvm.loop !25

46:                                               ; preds = %31
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #5
  br label %47

47:                                               ; preds = %46, %13
  br label %48

48:                                               ; preds = %47, %1
  %49 = load ptr, ptr %2, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.png_struct_def, ptr %49, i32 0, i32 102
  %51 = load i64, ptr %50, align 8, !tbaa !9
  %52 = load ptr, ptr %2, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.png_struct_def, ptr %52, i32 0, i32 105
  %54 = load i64, ptr %53, align 8, !tbaa !27
  %55 = add i64 %51, %54
  %56 = load ptr, ptr %2, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.png_struct_def, ptr %56, i32 0, i32 103
  %58 = load i64, ptr %57, align 8, !tbaa !28
  %59 = icmp ugt i64 %55, %58
  br i1 %59, label %60, label %122

60:                                               ; preds = %48
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %61 = load ptr, ptr %2, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.png_struct_def, ptr %61, i32 0, i32 102
  %63 = load i64, ptr %62, align 8, !tbaa !9
  %64 = load ptr, ptr %2, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.png_struct_def, ptr %64, i32 0, i32 105
  %66 = load i64, ptr %65, align 8, !tbaa !27
  %67 = add i64 %66, 256
  %68 = sub i64 -1, %67
  %69 = icmp ugt i64 %63, %68
  br i1 %69, label %70, label %72

70:                                               ; preds = %60
  %71 = load ptr, ptr %2, align 8, !tbaa !5
  call void @png_error(ptr noundef %71, ptr noundef @.str.7) #6
  unreachable

72:                                               ; preds = %60
  %73 = load ptr, ptr %2, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.png_struct_def, ptr %73, i32 0, i32 102
  %75 = load i64, ptr %74, align 8, !tbaa !9
  %76 = load ptr, ptr %2, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.png_struct_def, ptr %76, i32 0, i32 105
  %78 = load i64, ptr %77, align 8, !tbaa !27
  %79 = add i64 %75, %78
  %80 = add i64 %79, 256
  store i64 %80, ptr %7, align 8, !tbaa !23
  %81 = load ptr, ptr %2, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.png_struct_def, ptr %81, i32 0, i32 97
  %83 = load ptr, ptr %82, align 8, !tbaa !22
  store ptr %83, ptr %8, align 8, !tbaa !5
  %84 = load ptr, ptr %2, align 8, !tbaa !5
  %85 = load i64, ptr %7, align 8, !tbaa !23
  %86 = call noalias ptr @png_malloc_warn(ptr noundef %84, i64 noundef %85)
  %87 = load ptr, ptr %2, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.png_struct_def, ptr %87, i32 0, i32 97
  store ptr %86, ptr %88, align 8, !tbaa !22
  %89 = load ptr, ptr %2, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct.png_struct_def, ptr %89, i32 0, i32 97
  %91 = load ptr, ptr %90, align 8, !tbaa !22
  %92 = icmp eq ptr %91, null
  br i1 %92, label %93, label %97

93:                                               ; preds = %72
  %94 = load ptr, ptr %2, align 8, !tbaa !5
  %95 = load ptr, ptr %8, align 8, !tbaa !5
  call void @png_free(ptr noundef %94, ptr noundef %95)
  %96 = load ptr, ptr %2, align 8, !tbaa !5
  call void @png_error(ptr noundef %96, ptr noundef @.str.8) #6
  unreachable

97:                                               ; preds = %72
  %98 = load ptr, ptr %8, align 8, !tbaa !5
  %99 = icmp ne ptr %98, null
  br i1 %99, label %100, label %108

100:                                              ; preds = %97
  %101 = load ptr, ptr %2, align 8, !tbaa !5
  %102 = getelementptr inbounds %struct.png_struct_def, ptr %101, i32 0, i32 97
  %103 = load ptr, ptr %102, align 8, !tbaa !22
  %104 = load ptr, ptr %8, align 8, !tbaa !5
  %105 = load ptr, ptr %2, align 8, !tbaa !5
  %106 = getelementptr inbounds %struct.png_struct_def, ptr %105, i32 0, i32 102
  %107 = load i64, ptr %106, align 8, !tbaa !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %103, ptr align 1 %104, i64 %107, i1 false)
  br label %116

108:                                              ; preds = %97
  %109 = load ptr, ptr %2, align 8, !tbaa !5
  %110 = getelementptr inbounds %struct.png_struct_def, ptr %109, i32 0, i32 102
  %111 = load i64, ptr %110, align 8, !tbaa !9
  %112 = icmp ne i64 %111, 0
  br i1 %112, label %113, label %115

113:                                              ; preds = %108
  %114 = load ptr, ptr %2, align 8, !tbaa !5
  call void @png_error(ptr noundef %114, ptr noundef @.str.9) #6
  unreachable

115:                                              ; preds = %108
  br label %116

116:                                              ; preds = %115, %100
  %117 = load ptr, ptr %2, align 8, !tbaa !5
  %118 = load ptr, ptr %8, align 8, !tbaa !5
  call void @png_free(ptr noundef %117, ptr noundef %118)
  %119 = load i64, ptr %7, align 8, !tbaa !23
  %120 = load ptr, ptr %2, align 8, !tbaa !5
  %121 = getelementptr inbounds %struct.png_struct_def, ptr %120, i32 0, i32 103
  store i64 %119, ptr %121, align 8, !tbaa !28
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  br label %122

122:                                              ; preds = %116, %48
  %123 = load ptr, ptr %2, align 8, !tbaa !5
  %124 = getelementptr inbounds %struct.png_struct_def, ptr %123, i32 0, i32 105
  %125 = load i64, ptr %124, align 8, !tbaa !27
  %126 = icmp ne i64 %125, 0
  br i1 %126, label %127, label %150

127:                                              ; preds = %122
  %128 = load ptr, ptr %2, align 8, !tbaa !5
  %129 = getelementptr inbounds %struct.png_struct_def, ptr %128, i32 0, i32 97
  %130 = load ptr, ptr %129, align 8, !tbaa !22
  %131 = load ptr, ptr %2, align 8, !tbaa !5
  %132 = getelementptr inbounds %struct.png_struct_def, ptr %131, i32 0, i32 102
  %133 = load i64, ptr %132, align 8, !tbaa !9
  %134 = getelementptr inbounds i8, ptr %130, i64 %133
  %135 = load ptr, ptr %2, align 8, !tbaa !5
  %136 = getelementptr inbounds %struct.png_struct_def, ptr %135, i32 0, i32 98
  %137 = load ptr, ptr %136, align 8, !tbaa !29
  %138 = load ptr, ptr %2, align 8, !tbaa !5
  %139 = getelementptr inbounds %struct.png_struct_def, ptr %138, i32 0, i32 105
  %140 = load i64, ptr %139, align 8, !tbaa !27
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %134, ptr align 1 %137, i64 %140, i1 false)
  %141 = load ptr, ptr %2, align 8, !tbaa !5
  %142 = getelementptr inbounds %struct.png_struct_def, ptr %141, i32 0, i32 105
  %143 = load i64, ptr %142, align 8, !tbaa !27
  %144 = load ptr, ptr %2, align 8, !tbaa !5
  %145 = getelementptr inbounds %struct.png_struct_def, ptr %144, i32 0, i32 102
  %146 = load i64, ptr %145, align 8, !tbaa !9
  %147 = add i64 %146, %143
  store i64 %147, ptr %145, align 8, !tbaa !9
  %148 = load ptr, ptr %2, align 8, !tbaa !5
  %149 = getelementptr inbounds %struct.png_struct_def, ptr %148, i32 0, i32 105
  store i64 0, ptr %149, align 8, !tbaa !27
  br label %150

150:                                              ; preds = %127, %122
  %151 = load ptr, ptr %2, align 8, !tbaa !5
  %152 = getelementptr inbounds %struct.png_struct_def, ptr %151, i32 0, i32 97
  %153 = load ptr, ptr %152, align 8, !tbaa !22
  %154 = load ptr, ptr %2, align 8, !tbaa !5
  %155 = getelementptr inbounds %struct.png_struct_def, ptr %154, i32 0, i32 96
  store ptr %153, ptr %155, align 8, !tbaa !21
  %156 = load ptr, ptr %2, align 8, !tbaa !5
  %157 = getelementptr inbounds %struct.png_struct_def, ptr %156, i32 0, i32 104
  store i64 0, ptr %157, align 8, !tbaa !30
  ret void
}

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

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

; Function Attrs: noreturn
declare void @png_error(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 noalias ptr @png_malloc_warn(ptr noundef, i64 noundef) #4

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

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

!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, !11, i64 848}
!10 = !{!"png_struct_def", !7, i64 0, !6, i64 200, !6, i64 208, !11, 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, !12, i64 300, !12, i64 304, !12, i64 308, !12, i64 312, !13, i64 320, !6, 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, !6, i64 544, !6, i64 552, !6, i64 560, !6, i64 568, !11, i64 576, !12, i64 584, !12, i64 588, !6, i64 592, !14, i64 600, !12, i64 604, !14, 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, !14, i64 626, !7, i64 628, !12, i64 632, !15, i64 636, !15, i64 646, !6, i64 656, !12, i64 664, !12, i64 668, !12, i64 672, !12, i64 676, !6, i64 680, !6, i64 688, !6, i64 696, !6, i64 704, !6, i64 712, !6, i64 720, !16, i64 728, !16, i64 733, !6, i64 744, !15, 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, !12, i64 840, !12, i64 844, !11, i64 848, !11, i64 856, !11, i64 864, !11, i64 872, !12, i64 880, !12, i64 884, !6, i64 888, !6, i64 896, !12, i64 904, !7, i64 908, !12, i64 940, !6, i64 944, !6, i64 952, !12, i64 960, !12, i64 964, !6, i64 968, !7, i64 976, !7, i64 977, !14, i64 978, !14, i64 980, !12, 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, !12, i64 1052, !12, i64 1056, !12, i64 1060, !11, i64 1064, !17, i64 1072, !11, i64 1104, !6, i64 1112, !11, i64 1120, !12, i64 1128, !12, i64 1132, !6, i64 1136, !7, i64 1144, !18, i64 1176}
!11 = !{!"long", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!"z_stream_s", !6, i64 0, !12, i64 8, !11, i64 16, !6, i64 24, !12, i64 32, !11, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !12, i64 88, !11, i64 96, !11, i64 104}
!14 = !{!"short", !7, i64 0}
!15 = !{!"png_color_16_struct", !7, i64 0, !14, i64 2, !14, i64 4, !14, i64 6, !14, i64 8}
!16 = !{!"png_color_8_struct", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3, !7, i64 4}
!17 = !{!"png_unknown_chunk_t", !7, i64 0, !6, i64 8, !11, i64 16, !7, i64 24}
!18 = !{!"png_colorspace", !12, i64 0, !19, i64 4, !20, i64 36, !14, i64 72, !14, i64 74}
!19 = !{!"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}
!20 = !{!"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}
!21 = !{!10, !6, i64 808}
!22 = !{!10, !6, i64 816}
!23 = !{!11, !11, i64 0}
!24 = !{!7, !7, i64 0}
!25 = distinct !{!25, !26}
!26 = !{!"llvm.loop.mustprogress"}
!27 = !{!10, !11, i64 872}
!28 = !{!10, !11, i64 856}
!29 = !{!10, !6, i64 824}
!30 = !{!10, !11, i64 864}


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

@.str.7 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [18 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @png_push_save_buffer(ptr noalias noundef %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 848
  %3 = load i64, ptr %2, align 8, !tbaa !5
  %.not = icmp eq i64 %3, 0
  br i1 %.not, label %.loopexit, label %4

4:                                                ; preds = %1
  %5 = getelementptr inbounds i8, ptr %0, i64 808
  %6 = load ptr, ptr %5, align 8, !tbaa !20
  %7 = getelementptr inbounds i8, ptr %0, i64 816
  %8 = load ptr, ptr %7, align 8, !tbaa !21
  %.not58 = icmp eq ptr %6, %8
  br i1 %.not58, label %.loopexit, label %iter.check

iter.check:                                       ; preds = %4
  %9 = ptrtoint ptr %8 to i64
  %10 = ptrtoint ptr %6 to i64
  %min.iters.check = icmp ult i64 %3, 8
  %11 = sub i64 %9, %10
  %diff.check = icmp ult i64 %11, 32
  %or.cond = or i1 %min.iters.check, %diff.check
  br i1 %or.cond, label %.preheader.preheader, label %vector.main.loop.iter.check

vector.main.loop.iter.check:                      ; preds = %iter.check
  %min.iters.check65 = icmp ult i64 %3, 32
  br i1 %min.iters.check65, label %vec.epilog.ph, label %vector.ph

vector.ph:                                        ; preds = %vector.main.loop.iter.check
  %n.vec = and i64 %3, -32
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %next.gep = getelementptr i8, ptr %6, i64 %index
  %next.gep67 = getelementptr i8, ptr %8, i64 %index
  %12 = getelementptr i8, ptr %next.gep, i64 16
  %wide.load = load <16 x i8>, ptr %next.gep, align 1, !tbaa !22
  %wide.load69 = load <16 x i8>, ptr %12, align 1, !tbaa !22
  %13 = getelementptr i8, ptr %next.gep67, i64 16
  store <16 x i8> %wide.load, ptr %next.gep67, align 1, !tbaa !22
  store <16 x i8> %wide.load69, ptr %13, align 1, !tbaa !22
  %index.next = add nuw i64 %index, 32
  %14 = icmp eq i64 %index.next, %n.vec
  br i1 %14, label %middle.block, label %vector.body, !llvm.loop !23

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %3, %n.vec
  br i1 %cmp.n, label %.loopexit, label %vec.epilog.iter.check

vec.epilog.iter.check:                            ; preds = %middle.block
  %ind.end75 = getelementptr i8, ptr %8, i64 %n.vec
  %ind.end72 = getelementptr i8, ptr %6, i64 %n.vec
  %n.vec.remaining = and i64 %3, 24
  %min.epilog.iters.check = icmp eq i64 %n.vec.remaining, 0
  br i1 %min.epilog.iters.check, label %.preheader.preheader, label %vec.epilog.ph

vec.epilog.ph:                                    ; preds = %vector.main.loop.iter.check, %vec.epilog.iter.check
  %vec.epilog.resume.val = phi i64 [ %n.vec, %vec.epilog.iter.check ], [ 0, %vector.main.loop.iter.check ]
  %n.vec71 = and i64 %3, -8
  %ind.end = getelementptr i8, ptr %6, i64 %n.vec71
  %ind.end74 = getelementptr i8, ptr %8, i64 %n.vec71
  br label %vec.epilog.vector.body

vec.epilog.vector.body:                           ; preds = %vec.epilog.vector.body, %vec.epilog.ph
  %index77 = phi i64 [ %vec.epilog.resume.val, %vec.epilog.ph ], [ %index.next81, %vec.epilog.vector.body ]
  %next.gep78 = getelementptr i8, ptr %6, i64 %index77
  %next.gep79 = getelementptr i8, ptr %8, i64 %index77
  %wide.load80 = load <8 x i8>, ptr %next.gep78, align 1, !tbaa !22
  store <8 x i8> %wide.load80, ptr %next.gep79, align 1, !tbaa !22
  %index.next81 = add nuw i64 %index77, 8
  %15 = icmp eq i64 %index.next81, %n.vec71
  br i1 %15, label %vec.epilog.middle.block, label %vec.epilog.vector.body, !llvm.loop !27

vec.epilog.middle.block:                          ; preds = %vec.epilog.vector.body
  %cmp.n82 = icmp eq i64 %3, %n.vec71
  br i1 %cmp.n82, label %.loopexit, label %.preheader.preheader

.preheader.preheader:                             ; preds = %vec.epilog.middle.block, %iter.check, %vec.epilog.iter.check
  %.064.ph = phi i64 [ 0, %iter.check ], [ %n.vec, %vec.epilog.iter.check ], [ %n.vec71, %vec.epilog.middle.block ]
  %.04963.ph = phi ptr [ %6, %iter.check ], [ %ind.end72, %vec.epilog.iter.check ], [ %ind.end, %vec.epilog.middle.block ]
  %.05062.ph = phi ptr [ %8, %iter.check ], [ %ind.end75, %vec.epilog.iter.check ], [ %ind.end74, %vec.epilog.middle.block ]
  %xtraiter = and i64 %3, 7
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.preheader.prol.loopexit, label %.preheader.prol

.preheader.prol:                                  ; preds = %.preheader.preheader, %.preheader.prol
  %.064.prol = phi i64 [ %17, %.preheader.prol ], [ %.064.ph, %.preheader.preheader ]
  %.04963.prol = phi ptr [ %18, %.preheader.prol ], [ %.04963.ph, %.preheader.preheader ]
  %.05062.prol = phi ptr [ %19, %.preheader.prol ], [ %.05062.ph, %.preheader.preheader ]
  %prol.iter = phi i64 [ %prol.iter.next, %.preheader.prol ], [ 0, %.preheader.preheader ]
  %16 = load i8, ptr %.04963.prol, align 1, !tbaa !22
  store i8 %16, ptr %.05062.prol, align 1, !tbaa !22
  %17 = add nuw i64 %.064.prol, 1
  %18 = getelementptr inbounds i8, ptr %.04963.prol, i64 1
  %19 = getelementptr inbounds i8, ptr %.05062.prol, i64 1
  %prol.iter.next = add i64 %prol.iter, 1
  %prol.iter.cmp.not = icmp eq i64 %prol.iter.next, %xtraiter
  br i1 %prol.iter.cmp.not, label %.preheader.prol.loopexit, label %.preheader.prol, !llvm.loop !28

.preheader.prol.loopexit:                         ; preds = %.preheader.prol, %.preheader.preheader
  %.064.unr = phi i64 [ %.064.ph, %.preheader.preheader ], [ %17, %.preheader.prol ]
  %.04963.unr = phi ptr [ %.04963.ph, %.preheader.preheader ], [ %18, %.preheader.prol ]
  %.05062.unr = phi ptr [ %.05062.ph, %.preheader.preheader ], [ %19, %.preheader.prol ]
  %20 = sub i64 %.064.ph, %3
  %21 = icmp ugt i64 %20, -8
  br i1 %21, label %.loopexit, label %.preheader

.preheader:                                       ; preds = %.preheader.prol.loopexit, %.preheader
  %.064 = phi i64 [ %44, %.preheader ], [ %.064.unr, %.preheader.prol.loopexit ]
  %.04963 = phi ptr [ %45, %.preheader ], [ %.04963.unr, %.preheader.prol.loopexit ]
  %.05062 = phi ptr [ %46, %.preheader ], [ %.05062.unr, %.preheader.prol.loopexit ]
  %22 = load i8, ptr %.04963, align 1, !tbaa !22
  store i8 %22, ptr %.05062, align 1, !tbaa !22
  %23 = getelementptr inbounds i8, ptr %.04963, i64 1
  %24 = getelementptr inbounds i8, ptr %.05062, i64 1
  %25 = load i8, ptr %23, align 1, !tbaa !22
  store i8 %25, ptr %24, align 1, !tbaa !22
  %26 = getelementptr inbounds i8, ptr %.04963, i64 2
  %27 = getelementptr inbounds i8, ptr %.05062, i64 2
  %28 = load i8, ptr %26, align 1, !tbaa !22
  store i8 %28, ptr %27, align 1, !tbaa !22
  %29 = getelementptr inbounds i8, ptr %.04963, i64 3
  %30 = getelementptr inbounds i8, ptr %.05062, i64 3
  %31 = load i8, ptr %29, align 1, !tbaa !22
  store i8 %31, ptr %30, align 1, !tbaa !22
  %32 = getelementptr inbounds i8, ptr %.04963, i64 4
  %33 = getelementptr inbounds i8, ptr %.05062, i64 4
  %34 = load i8, ptr %32, align 1, !tbaa !22
  store i8 %34, ptr %33, align 1, !tbaa !22
  %35 = getelementptr inbounds i8, ptr %.04963, i64 5
  %36 = getelementptr inbounds i8, ptr %.05062, i64 5
  %37 = load i8, ptr %35, align 1, !tbaa !22
  store i8 %37, ptr %36, align 1, !tbaa !22
  %38 = getelementptr inbounds i8, ptr %.04963, i64 6
  %39 = getelementptr inbounds i8, ptr %.05062, i64 6
  %40 = load i8, ptr %38, align 1, !tbaa !22
  store i8 %40, ptr %39, align 1, !tbaa !22
  %41 = getelementptr inbounds i8, ptr %.04963, i64 7
  %42 = getelementptr inbounds i8, ptr %.05062, i64 7
  %43 = load i8, ptr %41, align 1, !tbaa !22
  store i8 %43, ptr %42, align 1, !tbaa !22
  %44 = add nuw i64 %.064, 8
  %45 = getelementptr inbounds i8, ptr %.04963, i64 8
  %46 = getelementptr inbounds i8, ptr %.05062, i64 8
  %exitcond.not.7 = icmp eq i64 %44, %3
  br i1 %exitcond.not.7, label %.loopexit, label %.preheader, !llvm.loop !30

.loopexit:                                        ; preds = %.preheader.prol.loopexit, %.preheader, %middle.block, %vec.epilog.middle.block, %4, %1
  %47 = getelementptr inbounds i8, ptr %0, i64 872
  %48 = load i64, ptr %47, align 8, !tbaa !31
  %49 = add i64 %48, %3
  %50 = getelementptr inbounds i8, ptr %0, i64 856
  %51 = load i64, ptr %50, align 8, !tbaa !32
  %52 = icmp ugt i64 %49, %51
  br i1 %52, label %53, label %70

53:                                               ; preds = %.loopexit
  %54 = sub i64 -257, %48
  %55 = icmp ugt i64 %3, %54
  br i1 %55, label %56, label %57

56:                                               ; preds = %53
  tail call void @png_error(ptr noundef nonnull %0, ptr noundef nonnull @.str.7) #4
  unreachable

57:                                               ; preds = %53
  %58 = add i64 %49, 256
  %59 = getelementptr inbounds i8, ptr %0, i64 816
  %60 = load ptr, ptr %59, align 8, !tbaa !21
  %61 = tail call noalias ptr @png_malloc_warn(ptr noundef nonnull %0, i64 noundef %58) #5
  store ptr %61, ptr %59, align 8, !tbaa !21
  %62 = icmp eq ptr %61, null
  br i1 %62, label %63, label %64

63:                                               ; preds = %57
  tail call void @png_free(ptr noundef nonnull %0, ptr noundef %60) #5
  tail call void @png_error(ptr noundef nonnull %0, ptr noundef nonnull @.str.8) #4
  unreachable

64:                                               ; preds = %57
  %.not59 = icmp eq ptr %60, null
  %65 = load i64, ptr %2, align 8, !tbaa !5
  br i1 %.not59, label %67, label %66

66:                                               ; preds = %64
  tail call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 1 %61, ptr nonnull align 1 %60, i64 %65, i1 false)
  br label %69

67:                                               ; preds = %64
  %.not60 = icmp eq i64 %65, 0
  br i1 %.not60, label %69, label %68

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

69:                                               ; preds = %67, %66
  tail call void @png_free(ptr noundef nonnull %0, ptr noundef %60) #5
  store i64 %58, ptr %50, align 8, !tbaa !32
  %.pr = load i64, ptr %47, align 8, !tbaa !31
  br label %70

70:                                               ; preds = %69, %.loopexit
  %71 = phi i64 [ %.pr, %69 ], [ %48, %.loopexit ]
  %.not61 = icmp eq i64 %71, 0
  br i1 %.not61, label %82, label %72

72:                                               ; preds = %70
  %73 = getelementptr inbounds i8, ptr %0, i64 816
  %74 = load ptr, ptr %73, align 8, !tbaa !21
  %75 = load i64, ptr %2, align 8, !tbaa !5
  %76 = getelementptr inbounds i8, ptr %74, i64 %75
  %77 = getelementptr inbounds i8, ptr %0, i64 824
  %78 = load ptr, ptr %77, align 8, !tbaa !33
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 1 %76, ptr align 1 %78, i64 %71, i1 false)
  %79 = load i64, ptr %47, align 8, !tbaa !31
  %80 = load i64, ptr %2, align 8, !tbaa !5
  %81 = add i64 %80, %79
  store i64 %81, ptr %2, align 8, !tbaa !5
  store i64 0, ptr %47, align 8, !tbaa !31
  br label %82

82:                                               ; preds = %72, %70
  %83 = getelementptr inbounds i8, ptr %0, i64 816
  %84 = load ptr, ptr %83, align 8, !tbaa !21
  %85 = getelementptr inbounds i8, ptr %0, i64 808
  store ptr %84, ptr %85, align 8, !tbaa !20
  %86 = getelementptr inbounds i8, ptr %0, i64 864
  store i64 0, ptr %86, align 8, !tbaa !34
  ret void
}

; Function Attrs: noreturn
declare void @png_error(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 noalias ptr @png_malloc_warn(ptr noundef, i64 noundef) local_unnamed_addr #3

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


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass