; LLVM IR from corentinartaud/graphics :: ThirdParty/FreeImage-3170/Source/LibPNG (pngwrite)

; 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, ptr, ptr, i64, i32, i32, ptr, i16, i32, i16, 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, i8, i8, ptr, ptr, ptr, ptr, ptr, i8, [29 x i8], i32, ptr, ptr, i32, i32, ptr, i8, i8, i16, i16, i32, i8, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i8, i32, i32, i32, i64, %struct.png_unknown_chunk_t, i64, ptr, i64, i32, i32, ptr, [4 x ptr], %struct.png_colorspace }
%struct.__jmp_buf_tag = type { [8 x i64], i32, %struct.__sigset_t }
%struct.__sigset_t = type { [16 x i64] }
%struct.z_stream_s = type { ptr, i32, i64, ptr, i32, i64, ptr, ptr, ptr, ptr, ptr, i32, i64, i64 }
%struct.png_color_8_struct = type { i8, i8, i8, i8, i8 }
%struct.png_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 }

; 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
define dso_local void @png_set_filter_heuristics(ptr noalias noundef %0, i32 noundef %1, i32 noundef %2, ptr noundef %3, ptr noundef %4) #1 {
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !9
  store i32 %2, ptr %8, align 4, !tbaa !9
  store ptr %3, ptr %9, align 8, !tbaa !5
  store ptr %4, ptr %10, align 8, !tbaa !5
  %12 = load ptr, ptr %6, align 8, !tbaa !5
  %13 = load i32, ptr %7, align 4, !tbaa !9
  %14 = load i32, ptr %8, align 4, !tbaa !9
  %15 = call i32 @png_init_filter_heuristics(ptr noundef %12, i32 noundef %13, i32 noundef %14)
  %16 = icmp eq i32 %15, 0
  br i1 %16, label %17, label %18

17:                                               ; preds = %5
  br label %122

18:                                               ; preds = %5
  %19 = load i32, ptr %7, align 4, !tbaa !9
  %20 = icmp eq i32 %19, 2
  br i1 %20, label %21, label %122

21:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  store i32 0, ptr %11, align 4, !tbaa !9
  br label %22

22:                                               ; preds = %75, %21
  %23 = load i32, ptr %11, align 4, !tbaa !9
  %24 = load i32, ptr %8, align 4, !tbaa !9
  %25 = icmp slt i32 %23, %24
  br i1 %25, label %26, label %78

26:                                               ; preds = %22
  %27 = load ptr, ptr %9, align 8, !tbaa !5
  %28 = load i32, ptr %11, align 4, !tbaa !9
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds double, ptr %27, i64 %29
  %31 = load double, ptr %30, align 8, !tbaa !11
  %32 = fcmp ole double %31, 0.000000e+00
  br i1 %32, label %33, label %46

33:                                               ; preds = %26
  %34 = load ptr, ptr %6, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.png_struct_def, ptr %34, i32 0, i32 114
  %36 = load ptr, ptr %35, align 8, !tbaa !13
  %37 = load i32, ptr %11, align 4, !tbaa !9
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds i16, ptr %36, i64 %38
  store i16 256, ptr %39, align 2, !tbaa !24
  %40 = load ptr, ptr %6, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.png_struct_def, ptr %40, i32 0, i32 115
  %42 = load ptr, ptr %41, align 8, !tbaa !25
  %43 = load i32, ptr %11, align 4, !tbaa !9
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds i16, ptr %42, i64 %44
  store i16 256, ptr %45, align 2, !tbaa !24
  br label %74

46:                                               ; preds = %26
  %47 = load ptr, ptr %9, align 8, !tbaa !5
  %48 = load i32, ptr %11, align 4, !tbaa !9
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds double, ptr %47, i64 %49
  %51 = load double, ptr %50, align 8, !tbaa !11
  %52 = call double @llvm.fmuladd.f64(double 2.560000e+02, double %51, double 5.000000e-01)
  %53 = fptoui double %52 to i16
  %54 = load ptr, ptr %6, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.png_struct_def, ptr %54, i32 0, i32 115
  %56 = load ptr, ptr %55, align 8, !tbaa !25
  %57 = load i32, ptr %11, align 4, !tbaa !9
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds i16, ptr %56, i64 %58
  store i16 %53, ptr %59, align 2, !tbaa !24
  %60 = load ptr, ptr %9, align 8, !tbaa !5
  %61 = load i32, ptr %11, align 4, !tbaa !9
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds double, ptr %60, i64 %62
  %64 = load double, ptr %63, align 8, !tbaa !11
  %65 = fdiv double 2.560000e+02, %64
  %66 = fadd double %65, 5.000000e-01
  %67 = fptoui double %66 to i16
  %68 = load ptr, ptr %6, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.png_struct_def, ptr %68, i32 0, i32 114
  %70 = load ptr, ptr %69, align 8, !tbaa !13
  %71 = load i32, ptr %11, align 4, !tbaa !9
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds i16, ptr %70, i64 %72
  store i16 %67, ptr %73, align 2, !tbaa !24
  br label %74

74:                                               ; preds = %46, %33
  br label %75

75:                                               ; preds = %74
  %76 = load i32, ptr %11, align 4, !tbaa !9
  %77 = add nsw i32 %76, 1
  store i32 %77, ptr %11, align 4, !tbaa !9
  br label %22, !llvm.loop !26

78:                                               ; preds = %22
  store i32 0, ptr %11, align 4, !tbaa !9
  br label %79

79:                                               ; preds = %118, %78
  %80 = load i32, ptr %11, align 4, !tbaa !9
  %81 = icmp slt i32 %80, 5
  br i1 %81, label %82, label %121

82:                                               ; preds = %79
  %83 = load ptr, ptr %10, align 8, !tbaa !5
  %84 = load i32, ptr %11, align 4, !tbaa !9
  %85 = sext i32 %84 to i64
  %86 = getelementptr inbounds double, ptr %83, i64 %85
  %87 = load double, ptr %86, align 8, !tbaa !11
  %88 = fcmp oge double %87, 1.000000e+00
  br i1 %88, label %89, label %117

89:                                               ; preds = %82
  %90 = load ptr, ptr %10, align 8, !tbaa !5
  %91 = load i32, ptr %11, align 4, !tbaa !9
  %92 = sext i32 %91 to i64
  %93 = getelementptr inbounds double, ptr %90, i64 %92
  %94 = load double, ptr %93, align 8, !tbaa !11
  %95 = fdiv double 8.000000e+00, %94
  %96 = fadd double %95, 5.000000e-01
  %97 = fptoui double %96 to i16
  %98 = load ptr, ptr %6, align 8, !tbaa !5
  %99 = getelementptr inbounds %struct.png_struct_def, ptr %98, i32 0, i32 117
  %100 = load ptr, ptr %99, align 8, !tbaa !28
  %101 = load i32, ptr %11, align 4, !tbaa !9
  %102 = sext i32 %101 to i64
  %103 = getelementptr inbounds i16, ptr %100, i64 %102
  store i16 %97, ptr %103, align 2, !tbaa !24
  %104 = load ptr, ptr %10, align 8, !tbaa !5
  %105 = load i32, ptr %11, align 4, !tbaa !9
  %106 = sext i32 %105 to i64
  %107 = getelementptr inbounds double, ptr %104, i64 %106
  %108 = load double, ptr %107, align 8, !tbaa !11
  %109 = call double @llvm.fmuladd.f64(double 8.000000e+00, double %108, double 5.000000e-01)
  %110 = fptoui double %109 to i16
  %111 = load ptr, ptr %6, align 8, !tbaa !5
  %112 = getelementptr inbounds %struct.png_struct_def, ptr %111, i32 0, i32 116
  %113 = load ptr, ptr %112, align 8, !tbaa !29
  %114 = load i32, ptr %11, align 4, !tbaa !9
  %115 = sext i32 %114 to i64
  %116 = getelementptr inbounds i16, ptr %113, i64 %115
  store i16 %110, ptr %116, align 2, !tbaa !24
  br label %117

117:                                              ; preds = %89, %82
  br label %118

118:                                              ; preds = %117
  %119 = load i32, ptr %11, align 4, !tbaa !9
  %120 = add nsw i32 %119, 1
  store i32 %120, ptr %11, align 4, !tbaa !9
  br label %79, !llvm.loop !30

121:                                              ; preds = %79
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  br label %122

122:                                              ; preds = %121, %18, %17
  ret void
}

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { 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 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = !{!14, !6, i64 936}
!14 = !{!"png_struct_def", !7, i64 0, !6, i64 200, !6, i64 208, !15, 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, !15, i64 520, !10, i64 528, !10, i64 532, !10, i64 536, !6, i64 544, !6, i64 552, !6, i64 560, !6, i64 568, !6, i64 576, !6, i64 584, !15, i64 592, !10, i64 600, !10, i64 604, !6, i64 608, !17, i64 616, !10, i64 620, !17, i64 624, !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, !7, i64 637, !7, i64 638, !7, i64 639, !17, i64 640, !7, i64 642, !10, i64 644, !18, i64 648, !18, i64 658, !6, i64 672, !10, i64 680, !10, i64 684, !10, i64 688, !10, i64 692, !6, i64 696, !6, i64 704, !6, i64 712, !6, i64 720, !6, i64 728, !6, i64 736, !19, i64 744, !19, i64 749, !6, i64 760, !18, i64 768, !6, i64 784, !6, i64 792, !6, i64 800, !6, i64 808, !6, i64 816, !6, i64 824, !6, i64 832, !6, i64 840, !6, i64 848, !10, i64 856, !10, i64 860, !15, i64 864, !15, i64 872, !15, i64 880, !15, i64 888, !10, i64 896, !10, i64 900, !6, i64 904, !6, i64 912, !7, i64 920, !7, i64 921, !6, i64 928, !6, i64 936, !6, i64 944, !6, i64 952, !6, i64 960, !7, i64 968, !7, i64 969, !10, i64 1000, !6, i64 1008, !6, i64 1016, !10, i64 1024, !10, i64 1028, !6, i64 1032, !7, i64 1040, !7, i64 1041, !17, i64 1042, !17, i64 1044, !10, i64 1048, !7, i64 1052, !6, i64 1056, !6, i64 1064, !6, i64 1072, !6, i64 1080, !6, i64 1088, !6, i64 1096, !6, i64 1104, !7, i64 1112, !10, i64 1116, !10, i64 1120, !10, i64 1124, !15, i64 1128, !20, i64 1136, !15, i64 1168, !6, i64 1176, !15, i64 1184, !10, i64 1192, !10, i64 1196, !6, i64 1200, !7, i64 1208, !21, i64 1240}
!15 = !{!"long", !7, i64 0}
!16 = !{!"z_stream_s", !6, i64 0, !10, i64 8, !15, i64 16, !6, i64 24, !10, i64 32, !15, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !10, i64 88, !15, i64 96, !15, 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, !15, 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 = !{!17, !17, i64 0}
!25 = !{!14, !6, i64 944}
!26 = distinct !{!26, !27}
!27 = !{!"llvm.loop.mustprogress"}
!28 = !{!14, !6, i64 960}
!29 = !{!14, !6, i64 952}
!30 = distinct !{!30, !27}


; 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"

; Function Attrs: nounwind uwtable
define dso_local void @png_set_filter_heuristics(ptr noalias noundef %0, i32 noundef %1, i32 noundef %2, ptr nocapture noundef readonly %3, ptr nocapture noundef readonly %4) local_unnamed_addr #0 {
  %6 = tail call i32 @png_init_filter_heuristics(ptr noundef %0, i32 noundef %1, i32 noundef %2)
  %7 = icmp ne i32 %6, 0
  %8 = icmp eq i32 %1, 2
  %or.cond = and i1 %8, %7
  br i1 %or.cond, label %.preheader35, label %.loopexit

.preheader35:                                     ; preds = %5
  %9 = icmp sgt i32 %2, 0
  br i1 %9, label %.lr.ph, label %.preheader

.lr.ph:                                           ; preds = %.preheader35
  %10 = getelementptr inbounds i8, ptr %0, i64 936
  %11 = getelementptr inbounds i8, ptr %0, i64 944
  %wide.trip.count = zext nneg i32 %2 to i64
  br label %16

.preheader:                                       ; preds = %31, %.preheader35
  %12 = getelementptr inbounds i8, ptr %0, i64 960
  %13 = getelementptr inbounds i8, ptr %0, i64 952
  %14 = load double, ptr %4, align 8, !tbaa !5
  %15 = fcmp ult double %14, 1.000000e+00
  br i1 %15, label %42, label %34

16:                                               ; preds = %.lr.ph, %31
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %31 ]
  %17 = getelementptr inbounds double, ptr %3, i64 %indvars.iv
  %18 = load double, ptr %17, align 8, !tbaa !5
  %19 = fcmp ugt double %18, 0.000000e+00
  br i1 %19, label %23, label %20

20:                                               ; preds = %16
  %21 = load ptr, ptr %10, align 8, !tbaa !9
  %22 = getelementptr inbounds i16, ptr %21, i64 %indvars.iv
  store i16 256, ptr %22, align 2, !tbaa !22
  br label %31

23:                                               ; preds = %16
  %24 = tail call double @llvm.fmuladd.f64(double %18, double 2.560000e+02, double 5.000000e-01)
  %25 = fptoui double %24 to i16
  %26 = load ptr, ptr %11, align 8, !tbaa !23
  %27 = getelementptr inbounds i16, ptr %26, i64 %indvars.iv
  store i16 %25, ptr %27, align 2, !tbaa !22
  %28 = fdiv double 2.560000e+02, %18
  %29 = fadd double %28, 5.000000e-01
  %30 = fptoui double %29 to i16
  br label %31

31:                                               ; preds = %20, %23
  %.sink45 = phi ptr [ %11, %20 ], [ %10, %23 ]
  %.sink = phi i16 [ 256, %20 ], [ %30, %23 ]
  %32 = load ptr, ptr %.sink45, align 8, !tbaa !24
  %33 = getelementptr inbounds i16, ptr %32, i64 %indvars.iv
  store i16 %.sink, ptr %33, align 2, !tbaa !22
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %.preheader, label %16, !llvm.loop !25

34:                                               ; preds = %.preheader
  %35 = fdiv double 8.000000e+00, %14
  %36 = fadd double %35, 5.000000e-01
  %37 = fptoui double %36 to i16
  %38 = load ptr, ptr %12, align 8, !tbaa !27
  store i16 %37, ptr %38, align 2, !tbaa !22
  %39 = tail call double @llvm.fmuladd.f64(double %14, double 8.000000e+00, double 5.000000e-01)
  %40 = fptoui double %39 to i16
  %41 = load ptr, ptr %13, align 8, !tbaa !28
  store i16 %40, ptr %41, align 2, !tbaa !22
  br label %42

42:                                               ; preds = %.preheader, %34
  %43 = getelementptr inbounds i8, ptr %4, i64 8
  %44 = load double, ptr %43, align 8, !tbaa !5
  %45 = fcmp ult double %44, 1.000000e+00
  br i1 %45, label %56, label %46

46:                                               ; preds = %42
  %47 = fdiv double 8.000000e+00, %44
  %48 = fadd double %47, 5.000000e-01
  %49 = fptoui double %48 to i16
  %50 = load ptr, ptr %12, align 8, !tbaa !27
  %51 = getelementptr inbounds i8, ptr %50, i64 2
  store i16 %49, ptr %51, align 2, !tbaa !22
  %52 = tail call double @llvm.fmuladd.f64(double %44, double 8.000000e+00, double 5.000000e-01)
  %53 = fptoui double %52 to i16
  %54 = load ptr, ptr %13, align 8, !tbaa !28
  %55 = getelementptr inbounds i8, ptr %54, i64 2
  store i16 %53, ptr %55, align 2, !tbaa !22
  br label %56

56:                                               ; preds = %46, %42
  %57 = getelementptr inbounds i8, ptr %4, i64 16
  %58 = load double, ptr %57, align 8, !tbaa !5
  %59 = fcmp ult double %58, 1.000000e+00
  br i1 %59, label %70, label %60

60:                                               ; preds = %56
  %61 = fdiv double 8.000000e+00, %58
  %62 = fadd double %61, 5.000000e-01
  %63 = fptoui double %62 to i16
  %64 = load ptr, ptr %12, align 8, !tbaa !27
  %65 = getelementptr inbounds i8, ptr %64, i64 4
  store i16 %63, ptr %65, align 2, !tbaa !22
  %66 = tail call double @llvm.fmuladd.f64(double %58, double 8.000000e+00, double 5.000000e-01)
  %67 = fptoui double %66 to i16
  %68 = load ptr, ptr %13, align 8, !tbaa !28
  %69 = getelementptr inbounds i8, ptr %68, i64 4
  store i16 %67, ptr %69, align 2, !tbaa !22
  br label %70

70:                                               ; preds = %60, %56
  %71 = getelementptr inbounds i8, ptr %4, i64 24
  %72 = load double, ptr %71, align 8, !tbaa !5
  %73 = fcmp ult double %72, 1.000000e+00
  br i1 %73, label %84, label %74

74:                                               ; preds = %70
  %75 = fdiv double 8.000000e+00, %72
  %76 = fadd double %75, 5.000000e-01
  %77 = fptoui double %76 to i16
  %78 = load ptr, ptr %12, align 8, !tbaa !27
  %79 = getelementptr inbounds i8, ptr %78, i64 6
  store i16 %77, ptr %79, align 2, !tbaa !22
  %80 = tail call double @llvm.fmuladd.f64(double %72, double 8.000000e+00, double 5.000000e-01)
  %81 = fptoui double %80 to i16
  %82 = load ptr, ptr %13, align 8, !tbaa !28
  %83 = getelementptr inbounds i8, ptr %82, i64 6
  store i16 %81, ptr %83, align 2, !tbaa !22
  br label %84

84:                                               ; preds = %74, %70
  %85 = getelementptr inbounds i8, ptr %4, i64 32
  %86 = load double, ptr %85, align 8, !tbaa !5
  %87 = fcmp ult double %86, 1.000000e+00
  br i1 %87, label %.loopexit, label %88

88:                                               ; preds = %84
  %89 = fdiv double 8.000000e+00, %86
  %90 = fadd double %89, 5.000000e-01
  %91 = fptoui double %90 to i16
  %92 = load ptr, ptr %12, align 8, !tbaa !27
  %93 = getelementptr inbounds i8, ptr %92, i64 8
  store i16 %91, ptr %93, align 2, !tbaa !22
  %94 = tail call double @llvm.fmuladd.f64(double %86, double 8.000000e+00, double 5.000000e-01)
  %95 = fptoui double %94 to i16
  %96 = load ptr, ptr %13, align 8, !tbaa !28
  %97 = getelementptr inbounds i8, ptr %96, i64 8
  store i16 %95, ptr %97, align 2, !tbaa !22
  br label %.loopexit

.loopexit:                                        ; preds = %84, %88, %5
  ret void
}

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

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #1

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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !11, i64 936}
!10 = !{!"png_struct_def", !7, i64 0, !11, i64 200, !11, i64 208, !12, i64 216, !11, i64 224, !11, i64 232, !11, i64 240, !11, i64 248, !11, i64 256, !11, i64 264, !11, i64 272, !11, i64 280, !11, i64 288, !7, i64 296, !7, i64 297, !13, i64 300, !13, i64 304, !13, i64 308, !13, i64 312, !14, i64 320, !11, i64 432, !13, i64 440, !13, i64 444, !13, i64 448, !13, i64 452, !13, i64 456, !13, i64 460, !13, i64 464, !13, i64 468, !13, i64 472, !13, i64 476, !13, i64 480, !13, i64 484, !13, i64 488, !13, i64 492, !13, i64 496, !13, i64 500, !13, i64 504, !13, i64 508, !13, i64 512, !13, i64 516, !12, i64 520, !13, i64 528, !13, i64 532, !13, i64 536, !11, i64 544, !11, i64 552, !11, i64 560, !11, i64 568, !11, i64 576, !11, i64 584, !12, i64 592, !13, i64 600, !13, i64 604, !11, i64 608, !15, i64 616, !13, i64 620, !15, i64 624, !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, !7, i64 637, !7, i64 638, !7, i64 639, !15, i64 640, !7, i64 642, !13, i64 644, !16, i64 648, !16, i64 658, !11, i64 672, !13, i64 680, !13, i64 684, !13, i64 688, !13, i64 692, !11, i64 696, !11, i64 704, !11, i64 712, !11, i64 720, !11, i64 728, !11, i64 736, !17, i64 744, !17, i64 749, !11, i64 760, !16, i64 768, !11, i64 784, !11, i64 792, !11, i64 800, !11, i64 808, !11, i64 816, !11, i64 824, !11, i64 832, !11, i64 840, !11, i64 848, !13, i64 856, !13, i64 860, !12, i64 864, !12, i64 872, !12, i64 880, !12, i64 888, !13, i64 896, !13, i64 900, !11, i64 904, !11, i64 912, !7, i64 920, !7, i64 921, !11, i64 928, !11, i64 936, !11, i64 944, !11, i64 952, !11, i64 960, !7, i64 968, !7, i64 969, !13, i64 1000, !11, i64 1008, !11, i64 1016, !13, i64 1024, !13, i64 1028, !11, i64 1032, !7, i64 1040, !7, i64 1041, !15, i64 1042, !15, i64 1044, !13, i64 1048, !7, i64 1052, !11, i64 1056, !11, i64 1064, !11, i64 1072, !11, i64 1080, !11, i64 1088, !11, i64 1096, !11, i64 1104, !7, i64 1112, !13, i64 1116, !13, i64 1120, !13, i64 1124, !12, i64 1128, !18, i64 1136, !12, i64 1168, !11, i64 1176, !12, i64 1184, !13, i64 1192, !13, i64 1196, !11, i64 1200, !7, i64 1208, !19, i64 1240}
!11 = !{!"any pointer", !7, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = !{!"z_stream_s", !11, i64 0, !13, i64 8, !12, i64 16, !11, i64 24, !13, i64 32, !12, i64 40, !11, i64 48, !11, i64 56, !11, i64 64, !11, i64 72, !11, i64 80, !13, i64 88, !12, i64 96, !12, i64 104}
!15 = !{!"short", !7, i64 0}
!16 = !{!"png_color_16_struct", !7, i64 0, !15, i64 2, !15, i64 4, !15, i64 6, !15, i64 8}
!17 = !{!"png_color_8_struct", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3, !7, i64 4}
!18 = !{!"png_unknown_chunk_t", !7, i64 0, !11, i64 8, !12, i64 16, !7, i64 24}
!19 = !{!"png_colorspace", !13, i64 0, !20, i64 4, !21, i64 36, !15, i64 72, !15, i64 74}
!20 = !{!"png_xy", !13, i64 0, !13, i64 4, !13, i64 8, !13, i64 12, !13, i64 16, !13, i64 20, !13, i64 24, !13, i64 28}
!21 = !{!"png_XYZ", !13, i64 0, !13, i64 4, !13, i64 8, !13, i64 12, !13, i64 16, !13, i64 20, !13, i64 24, !13, i64 28, !13, i64 32}
!22 = !{!15, !15, i64 0}
!23 = !{!10, !11, i64 944}
!24 = !{!11, !11, i64 0}
!25 = distinct !{!25, !26}
!26 = !{!"llvm.loop.mustprogress"}
!27 = !{!10, !11, i64 960}
!28 = !{!10, !11, i64 952}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass