; 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_fixed(ptr noundef %0, ptr noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5, i32 noundef %6, i32 noundef %7, i32 noundef %8, i32 noundef %9) #0 {
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  %19 = alloca i32, align 4
  %20 = alloca i32, align 4
  store ptr %0, ptr %11, align 8, !tbaa !5
  store ptr %1, ptr %12, align 8, !tbaa !5
  store i32 %2, ptr %13, align 4, !tbaa !9
  store i32 %3, ptr %14, align 4, !tbaa !9
  store i32 %4, ptr %15, align 4, !tbaa !9
  store i32 %5, ptr %16, align 4, !tbaa !9
  store i32 %6, ptr %17, align 4, !tbaa !9
  store i32 %7, ptr %18, align 4, !tbaa !9
  store i32 %8, ptr %19, align 4, !tbaa !9
  store i32 %9, ptr %20, align 4, !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 %116

27:                                               ; preds = %23
  %28 = load ptr, ptr %11, align 8, !tbaa !5
  %29 = load i32, ptr %13, align 4, !tbaa !9
  %30 = load i32, ptr %14, align 4, !tbaa !9
  %31 = load i32, ptr %15, align 4, !tbaa !9
  %32 = load i32, ptr %16, align 4, !tbaa !9
  %33 = load i32, ptr %17, align 4, !tbaa !9
  %34 = load i32, ptr %18, align 4, !tbaa !9
  %35 = load i32, ptr %19, align 4, !tbaa !9
  %36 = load i32, ptr %20, align 4, !tbaa !9
  %37 = call i32 @png_check_cHRM_fixed(ptr noundef %28, i32 noundef %29, i32 noundef %30, i32 noundef %31, i32 noundef %32, i32 noundef %33, i32 noundef %34, i32 noundef %35, i32 noundef %36)
  %38 = icmp ne i32 %37, 0
  br i1 %38, label %39, label %116

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

116:                                              ; preds = %39, %27, %26
  ret void
}

declare i32 @png_check_cHRM_fixed(ptr noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) #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 = { "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" }

!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, !10, i64 332}
!12 = !{!"png_info_struct", !10, i64 0, !10, i64 4, !10, i64 8, !13, i64 16, !6, i64 24, !14, i64 32, !14, 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, !15, i64 52, !7, i64 56, !10, i64 60, !10, i64 64, !6, i64 72, !16, i64 80, !17, i64 88, !6, 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, !6, i64 152, !15, i64 160, !15, i64 164, !15, i64 168, !15, i64 172, !15, i64 176, !15, i64 180, !15, i64 184, !15, i64 188, !6, i64 192, !10, i64 200, !10, i64 204, !6, i64 208, !6, i64 216, !7, i64 224, !7, i64 225, !10, i64 228, !6, i64 232, !13, i64 240, !6, i64 248, !6, i64 256, !10, i64 264, !7, i64 268, !6, i64 272, !10, i64 280, !7, i64 284, !19, i64 288, !19, i64 296, !6, i64 304, !6, i64 312, !6, 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 = !{!"short", !7, i64 0}
!15 = !{!"float", !7, i64 0}
!16 = !{!"png_time_struct", !14, 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, !14, i64 2, !14, i64 4, !14, i64 6, !14, i64 8}
!19 = !{!"double", !7, i64 0}
!20 = !{!12, !10, i64 336}
!21 = !{!12, !10, i64 340}
!22 = !{!12, !10, i64 344}
!23 = !{!12, !10, i64 348}
!24 = !{!12, !10, i64 352}
!25 = !{!12, !10, i64 356}
!26 = !{!12, !10, i64 360}
!27 = !{!12, !15, i64 160}
!28 = !{!12, !15, i64 164}
!29 = !{!12, !15, i64 168}
!30 = !{!12, !15, i64 172}
!31 = !{!12, !15, i64 176}
!32 = !{!12, !15, i64 180}
!33 = !{!12, !15, i64 184}
!34 = !{!12, !15, i64 188}
!35 = !{!12, !10, 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: nounwind uwtable
define dso_local void @png_set_cHRM_fixed(ptr noundef %0, ptr noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5, i32 noundef %6, i32 noundef %7, i32 noundef %8, i32 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 %43, label %13

13:                                               ; preds = %10
  %14 = tail call i32 @png_check_cHRM_fixed(ptr noundef nonnull %0, i32 noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5, i32 noundef %6, i32 noundef %7, i32 noundef %8, i32 noundef %9) #2
  %.not = icmp eq i32 %14, 0
  br i1 %.not, label %43, label %15

15:                                               ; preds = %13
  %16 = getelementptr inbounds i8, ptr %1, i64 332
  store i32 %2, ptr %16, align 4, !tbaa !5
  %17 = getelementptr inbounds i8, ptr %1, i64 336
  store i32 %3, ptr %17, align 8, !tbaa !18
  %18 = getelementptr inbounds i8, ptr %1, i64 340
  store i32 %4, ptr %18, align 4, !tbaa !19
  %19 = getelementptr inbounds i8, ptr %1, i64 344
  store i32 %5, ptr %19, align 8, !tbaa !20
  %20 = getelementptr inbounds i8, ptr %1, i64 348
  store i32 %6, ptr %20, align 4, !tbaa !21
  %21 = getelementptr inbounds i8, ptr %1, i64 352
  store i32 %7, ptr %21, align 8, !tbaa !22
  %22 = getelementptr inbounds i8, ptr %1, i64 356
  store i32 %8, ptr %22, align 4, !tbaa !23
  %23 = getelementptr inbounds i8, ptr %1, i64 360
  store i32 %9, ptr %23, align 8, !tbaa !24
  %24 = insertelement <4 x i32> poison, i32 %2, i64 0
  %25 = insertelement <4 x i32> %24, i32 %3, i64 1
  %26 = insertelement <4 x i32> %25, i32 %4, i64 2
  %27 = insertelement <4 x i32> %26, i32 %5, i64 3
  %28 = sitofp <4 x i32> %27 to <4 x double>
  %29 = getelementptr inbounds i8, ptr %1, i64 160
  %30 = fdiv <4 x double> %28, <double 1.000000e+05, double 1.000000e+05, double 1.000000e+05, double 1.000000e+05>
  %31 = fptrunc <4 x double> %30 to <4 x float>
  store <4 x float> %31, ptr %29, align 8, !tbaa !25
  %32 = insertelement <4 x i32> poison, i32 %6, i64 0
  %33 = insertelement <4 x i32> %32, i32 %7, i64 1
  %34 = insertelement <4 x i32> %33, i32 %8, i64 2
  %35 = insertelement <4 x i32> %34, i32 %9, i64 3
  %36 = sitofp <4 x i32> %35 to <4 x double>
  %37 = getelementptr inbounds i8, ptr %1, i64 176
  %38 = fdiv <4 x double> %36, <double 1.000000e+05, double 1.000000e+05, double 1.000000e+05, double 1.000000e+05>
  %39 = fptrunc <4 x double> %38 to <4 x float>
  store <4 x float> %39, ptr %37, align 8, !tbaa !25
  %40 = getelementptr inbounds i8, ptr %1, i64 8
  %41 = load i32, ptr %40, align 8, !tbaa !26
  %42 = or i32 %41, 4
  store i32 %42, ptr %40, align 8, !tbaa !26
  br label %43

43:                                               ; preds = %10, %15, %13
  ret void
}

declare i32 @png_check_cHRM_fixed(ptr noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #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 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { nounwind }

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


; Effective O3 passes: CorrelatedValuePropagationPass,GlobalOptPass,InstCombinePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass