; LLVM IR from niessner/Matterport :: code/gaps/pkgs/png (pngset)

; 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_info_struct = type { i32, i32, i32, 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, i32, i32, i8, i32, i32, i8, ptr, float, float, float, float, float, float, float, float, ptr, i32, i32, ptr, ptr, i8, i8, i32, ptr, i64, ptr, ptr, i32, i8, ptr, i32, i8, double, double, ptr, ptr, ptr, i32, i32, i32, i32, i32, i32, i32, i32, i32 }
%struct.png_time_struct = type { i16, i8, 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 }

; Function Attrs: nounwind uwtable
define dso_local void @png_set_cHRM(ptr noundef %0, ptr noundef %1, double noundef %2, double noundef %3, double noundef %4, double noundef %5, double noundef %6, double noundef %7, double noundef %8, double noundef %9) #0 {
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca double, align 8
  %14 = alloca double, align 8
  %15 = alloca double, align 8
  %16 = alloca double, align 8
  %17 = alloca double, align 8
  %18 = alloca double, align 8
  %19 = alloca double, align 8
  %20 = alloca double, align 8
  store ptr %0, ptr %11, align 8, !tbaa !5
  store ptr %1, ptr %12, align 8, !tbaa !5
  store double %2, ptr %13, align 8, !tbaa !9
  store double %3, ptr %14, align 8, !tbaa !9
  store double %4, ptr %15, align 8, !tbaa !9
  store double %5, ptr %16, align 8, !tbaa !9
  store double %6, ptr %17, align 8, !tbaa !9
  store double %7, ptr %18, align 8, !tbaa !9
  store double %8, ptr %19, align 8, !tbaa !9
  store double %9, ptr %20, align 8, !tbaa !9
  %21 = load ptr, ptr %11, align 8, !tbaa !5
  %22 = icmp eq ptr %21, null
  br i1 %22, label %26, label %23

23:                                               ; preds = %10
  %24 = load ptr, ptr %12, align 8, !tbaa !5
  %25 = icmp eq ptr %24, null
  br i1 %25, label %26, label %27

26:                                               ; preds = %23, %10
  br label %104

27:                                               ; preds = %23
  %28 = load double, ptr %13, align 8, !tbaa !9
  %29 = fptrunc double %28 to float
  %30 = load ptr, ptr %12, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.png_info_struct, ptr %30, i32 0, i32 33
  store float %29, ptr %31, align 8, !tbaa !11
  %32 = load double, ptr %14, align 8, !tbaa !9
  %33 = fptrunc double %32 to float
  %34 = load ptr, ptr %12, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.png_info_struct, ptr %34, i32 0, i32 34
  store float %33, ptr %35, align 4, !tbaa !20
  %36 = load double, ptr %15, align 8, !tbaa !9
  %37 = fptrunc double %36 to float
  %38 = load ptr, ptr %12, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.png_info_struct, ptr %38, i32 0, i32 35
  store float %37, ptr %39, align 8, !tbaa !21
  %40 = load double, ptr %16, align 8, !tbaa !9
  %41 = fptrunc double %40 to float
  %42 = load ptr, ptr %12, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.png_info_struct, ptr %42, i32 0, i32 36
  store float %41, ptr %43, align 4, !tbaa !22
  %44 = load double, ptr %17, align 8, !tbaa !9
  %45 = fptrunc double %44 to float
  %46 = load ptr, ptr %12, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.png_info_struct, ptr %46, i32 0, i32 37
  store float %45, ptr %47, align 8, !tbaa !23
  %48 = load double, ptr %18, align 8, !tbaa !9
  %49 = fptrunc double %48 to float
  %50 = load ptr, ptr %12, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.png_info_struct, ptr %50, i32 0, i32 38
  store float %49, ptr %51, align 4, !tbaa !24
  %52 = load double, ptr %19, align 8, !tbaa !9
  %53 = fptrunc double %52 to float
  %54 = load ptr, ptr %12, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.png_info_struct, ptr %54, i32 0, i32 39
  store float %53, ptr %55, align 8, !tbaa !25
  %56 = load double, ptr %20, align 8, !tbaa !9
  %57 = fptrunc double %56 to float
  %58 = load ptr, ptr %12, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.png_info_struct, ptr %58, i32 0, i32 40
  store float %57, ptr %59, align 4, !tbaa !26
  %60 = load double, ptr %13, align 8, !tbaa !9
  %61 = call double @llvm.fmuladd.f64(double %60, double 1.000000e+05, double 5.000000e-01)
  %62 = fptosi double %61 to i32
  %63 = load ptr, ptr %12, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.png_info_struct, ptr %63, i32 0, i32 64
  store i32 %62, ptr %64, align 4, !tbaa !27
  %65 = load double, ptr %14, align 8, !tbaa !9
  %66 = call double @llvm.fmuladd.f64(double %65, double 1.000000e+05, double 5.000000e-01)
  %67 = fptosi double %66 to i32
  %68 = load ptr, ptr %12, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.png_info_struct, ptr %68, i32 0, i32 65
  store i32 %67, ptr %69, align 8, !tbaa !28
  %70 = load double, ptr %15, align 8, !tbaa !9
  %71 = call double @llvm.fmuladd.f64(double %70, double 1.000000e+05, double 5.000000e-01)
  %72 = fptosi double %71 to i32
  %73 = load ptr, ptr %12, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.png_info_struct, ptr %73, i32 0, i32 66
  store i32 %72, ptr %74, align 4, !tbaa !29
  %75 = load double, ptr %16, align 8, !tbaa !9
  %76 = call double @llvm.fmuladd.f64(double %75, double 1.000000e+05, double 5.000000e-01)
  %77 = fptosi double %76 to i32
  %78 = load ptr, ptr %12, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.png_info_struct, ptr %78, i32 0, i32 67
  store i32 %77, ptr %79, align 8, !tbaa !30
  %80 = load double, ptr %17, align 8, !tbaa !9
  %81 = call double @llvm.fmuladd.f64(double %80, double 1.000000e+05, double 5.000000e-01)
  %82 = fptosi double %81 to i32
  %83 = load ptr, ptr %12, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.png_info_struct, ptr %83, i32 0, i32 68
  store i32 %82, ptr %84, align 4, !tbaa !31
  %85 = load double, ptr %18, align 8, !tbaa !9
  %86 = call double @llvm.fmuladd.f64(double %85, double 1.000000e+05, double 5.000000e-01)
  %87 = fptosi double %86 to i32
  %88 = load ptr, ptr %12, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct.png_info_struct, ptr %88, i32 0, i32 69
  store i32 %87, ptr %89, align 8, !tbaa !32
  %90 = load double, ptr %19, align 8, !tbaa !9
  %91 = call double @llvm.fmuladd.f64(double %90, double 1.000000e+05, double 5.000000e-01)
  %92 = fptosi double %91 to i32
  %93 = load ptr, ptr %12, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.png_info_struct, ptr %93, i32 0, i32 70
  store i32 %92, ptr %94, align 4, !tbaa !33
  %95 = load double, ptr %20, align 8, !tbaa !9
  %96 = call double @llvm.fmuladd.f64(double %95, double 1.000000e+05, double 5.000000e-01)
  %97 = fptosi double %96 to i32
  %98 = load ptr, ptr %12, align 8, !tbaa !5
  %99 = getelementptr inbounds %struct.png_info_struct, ptr %98, i32 0, i32 71
  store i32 %97, ptr %99, align 8, !tbaa !34
  %100 = load ptr, ptr %12, align 8, !tbaa !5
  %101 = getelementptr inbounds %struct.png_info_struct, ptr %100, i32 0, i32 2
  %102 = load i32, ptr %101, align 8, !tbaa !35
  %103 = or i32 %102, 4
  store i32 %103, ptr %101, align 8, !tbaa !35
  br label %104

104:                                              ; preds = %27, %26
  ret void
}

; Function Attrs: 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 = { 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = !{!12, !16, i64 160}
!12 = !{!"png_info_struct", !13, i64 0, !13, i64 4, !13, i64 8, !14, i64 16, !6, i64 24, !15, i64 32, !15, i64 34, !7, i64 36, !7, i64 37, !7, i64 38, !7, i64 39, !7, i64 40, !7, i64 41, !7, i64 42, !7, i64 43, !7, i64 44, !16, i64 52, !7, i64 56, !13, i64 60, !13, i64 64, !6, i64 72, !17, i64 80, !18, i64 88, !6, i64 96, !19, i64 104, !19, i64 114, !13, i64 124, !13, i64 128, !7, i64 132, !13, i64 136, !13, i64 140, !7, i64 144, !6, i64 152, !16, i64 160, !16, i64 164, !16, i64 168, !16, i64 172, !16, i64 176, !16, i64 180, !16, i64 184, !16, i64 188, !6, i64 192, !13, i64 200, !13, i64 204, !6, i64 208, !6, i64 216, !7, i64 224, !7, i64 225, !13, i64 228, !6, i64 232, !14, i64 240, !6, i64 248, !6, i64 256, !13, i64 264, !7, i64 268, !6, i64 272, !13, i64 280, !7, i64 284, !10, i64 288, !10, i64 296, !6, i64 304, !6, i64 312, !6, i64 320, !13, i64 328, !13, i64 332, !13, i64 336, !13, i64 340, !13, i64 344, !13, i64 348, !13, i64 352, !13, i64 356, !13, i64 360}
!13 = !{!"int", !7, i64 0}
!14 = !{!"long", !7, i64 0}
!15 = !{!"short", !7, i64 0}
!16 = !{!"float", !7, i64 0}
!17 = !{!"png_time_struct", !15, i64 0, !7, i64 2, !7, i64 3, !7, i64 4, !7, i64 5, !7, i64 6}
!18 = !{!"png_color_8_struct", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3, !7, i64 4}
!19 = !{!"png_color_16_struct", !7, i64 0, !15, i64 2, !15, i64 4, !15, i64 6, !15, i64 8}
!20 = !{!12, !16, i64 164}
!21 = !{!12, !16, i64 168}
!22 = !{!12, !16, i64 172}
!23 = !{!12, !16, i64 176}
!24 = !{!12, !16, i64 180}
!25 = !{!12, !16, i64 184}
!26 = !{!12, !16, i64 188}
!27 = !{!12, !13, i64 332}
!28 = !{!12, !13, i64 336}
!29 = !{!12, !13, i64 340}
!30 = !{!12, !13, i64 344}
!31 = !{!12, !13, i64 348}
!32 = !{!12, !13, i64 352}
!33 = !{!12, !13, i64 356}
!34 = !{!12, !13, i64 360}
!35 = !{!12, !13, i64 8}


; 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: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable
define dso_local void @png_set_cHRM(ptr noundef readnone %0, ptr noundef %1, double noundef %2, double noundef %3, double noundef %4, double noundef %5, double noundef %6, double noundef %7, double noundef %8, double noundef %9) local_unnamed_addr #0 {
  %11 = icmp eq ptr %0, null
  %12 = icmp eq ptr %1, null
  %or.cond = or i1 %11, %12
  br i1 %or.cond, label %35, label %13

13:                                               ; preds = %10
  %14 = insertelement <4 x double> poison, double %2, i64 0
  %15 = insertelement <4 x double> %14, double %3, i64 1
  %16 = insertelement <4 x double> %15, double %4, i64 2
  %17 = insertelement <4 x double> %16, double %5, i64 3
  %18 = fptrunc <4 x double> %17 to <4 x float>
  %19 = getelementptr inbounds i8, ptr %1, i64 160
  store <4 x float> %18, ptr %19, align 8, !tbaa !5
  %20 = insertelement <4 x double> poison, double %6, i64 0
  %21 = insertelement <4 x double> %20, double %7, i64 1
  %22 = insertelement <4 x double> %21, double %8, i64 2
  %23 = insertelement <4 x double> %22, double %9, i64 3
  %24 = fptrunc <4 x double> %23 to <4 x float>
  %25 = getelementptr inbounds i8, ptr %1, i64 176
  store <4 x float> %24, ptr %25, align 8, !tbaa !5
  %26 = tail call <4 x double> @llvm.fmuladd.v4f64(<4 x double> %17, <4 x double> <double 1.000000e+05, double 1.000000e+05, double 1.000000e+05, double 1.000000e+05>, <4 x double> <double 5.000000e-01, double 5.000000e-01, double 5.000000e-01, double 5.000000e-01>)
  %27 = getelementptr inbounds i8, ptr %1, i64 332
  %28 = fptosi <4 x double> %26 to <4 x i32>
  store <4 x i32> %28, ptr %27, align 4, !tbaa !9
  %29 = tail call <4 x double> @llvm.fmuladd.v4f64(<4 x double> %23, <4 x double> <double 1.000000e+05, double 1.000000e+05, double 1.000000e+05, double 1.000000e+05>, <4 x double> <double 5.000000e-01, double 5.000000e-01, double 5.000000e-01, double 5.000000e-01>)
  %30 = getelementptr inbounds i8, ptr %1, i64 348
  %31 = fptosi <4 x double> %29 to <4 x i32>
  store <4 x i32> %31, ptr %30, align 4, !tbaa !9
  %32 = getelementptr inbounds i8, ptr %1, i64 8
  %33 = load i32, ptr %32, align 8, !tbaa !11
  %34 = or i32 %33, 4
  store i32 %34, ptr %32, align 8, !tbaa !11
  br label %35

35:                                               ; preds = %10, %13
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <4 x double> @llvm.fmuladd.v4f64(<4 x double>, <4 x double>, <4 x double>) #1

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) 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 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 = !{!"float", !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, !10, i64 8}
!12 = !{!"png_info_struct", !10, i64 0, !10, i64 4, !10, i64 8, !13, i64 16, !14, i64 24, !15, i64 32, !15, i64 34, !7, i64 36, !7, i64 37, !7, i64 38, !7, i64 39, !7, i64 40, !7, i64 41, !7, i64 42, !7, i64 43, !7, i64 44, !6, i64 52, !7, i64 56, !10, i64 60, !10, i64 64, !14, i64 72, !16, i64 80, !17, i64 88, !14, i64 96, !18, i64 104, !18, i64 114, !10, i64 124, !10, i64 128, !7, i64 132, !10, i64 136, !10, i64 140, !7, i64 144, !14, i64 152, !6, i64 160, !6, i64 164, !6, i64 168, !6, i64 172, !6, i64 176, !6, i64 180, !6, i64 184, !6, i64 188, !14, i64 192, !10, i64 200, !10, i64 204, !14, i64 208, !14, i64 216, !7, i64 224, !7, i64 225, !10, i64 228, !14, i64 232, !13, i64 240, !14, i64 248, !14, i64 256, !10, i64 264, !7, i64 268, !14, i64 272, !10, i64 280, !7, i64 284, !19, i64 288, !19, i64 296, !14, i64 304, !14, i64 312, !14, i64 320, !10, i64 328, !10, i64 332, !10, i64 336, !10, i64 340, !10, i64 344, !10, i64 348, !10, i64 352, !10, i64 356, !10, i64 360}
!13 = !{!"long", !7, i64 0}
!14 = !{!"any pointer", !7, i64 0}
!15 = !{!"short", !7, i64 0}
!16 = !{!"png_time_struct", !15, i64 0, !7, i64 2, !7, i64 3, !7, i64 4, !7, i64 5, !7, i64 6}
!17 = !{!"png_color_8_struct", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3, !7, i64 4}
!18 = !{!"png_color_16_struct", !7, i64 0, !15, i64 2, !15, i64 4, !15, i64 6, !15, i64 8}
!19 = !{!"double", !7, i64 0}


; Effective O3 passes: GlobalDCEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass