; LLVM IR from Try/Tempest :: Engine/thirdparty/libpng (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_xy = type { i32, i32, i32, i32, i32, i32, i32, i32 }
%struct.png_info_def = type { i32, i32, i32, i64, ptr, i16, i16, i8, i8, i8, i8, i8, i8, i8, i8, [8 x i8], %struct.png_colorspace, ptr, ptr, i32, 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, i32, ptr, ptr, ptr, ptr, i32, i32, ptr, ptr, i8, i8, i32, ptr, i32, ptr, i32, i8, ptr, ptr, ptr }
%struct.png_colorspace = type { i32, %struct.png_xy, %struct.png_XYZ, i16, i16 }
%struct.png_XYZ = type { 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 noalias noundef %0, ptr noalias 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
  %21 = alloca %struct.png_xy, align 4
  %22 = 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
  call void @llvm.lifetime.start.p0(i64 32, ptr %21) #3
  %23 = load ptr, ptr %11, align 8, !tbaa !5
  %24 = icmp eq ptr %23, null
  br i1 %24, label %28, label %25

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

28:                                               ; preds = %25, %10
  store i32 1, ptr %22, align 4
  br label %62

29:                                               ; preds = %25
  %30 = load i32, ptr %15, align 4, !tbaa !9
  %31 = getelementptr inbounds %struct.png_xy, ptr %21, i32 0, i32 0
  store i32 %30, ptr %31, align 4, !tbaa !11
  %32 = load i32, ptr %16, align 4, !tbaa !9
  %33 = getelementptr inbounds %struct.png_xy, ptr %21, i32 0, i32 1
  store i32 %32, ptr %33, align 4, !tbaa !13
  %34 = load i32, ptr %17, align 4, !tbaa !9
  %35 = getelementptr inbounds %struct.png_xy, ptr %21, i32 0, i32 2
  store i32 %34, ptr %35, align 4, !tbaa !14
  %36 = load i32, ptr %18, align 4, !tbaa !9
  %37 = getelementptr inbounds %struct.png_xy, ptr %21, i32 0, i32 3
  store i32 %36, ptr %37, align 4, !tbaa !15
  %38 = load i32, ptr %19, align 4, !tbaa !9
  %39 = getelementptr inbounds %struct.png_xy, ptr %21, i32 0, i32 4
  store i32 %38, ptr %39, align 4, !tbaa !16
  %40 = load i32, ptr %20, align 4, !tbaa !9
  %41 = getelementptr inbounds %struct.png_xy, ptr %21, i32 0, i32 5
  store i32 %40, ptr %41, align 4, !tbaa !17
  %42 = load i32, ptr %13, align 4, !tbaa !9
  %43 = getelementptr inbounds %struct.png_xy, ptr %21, i32 0, i32 6
  store i32 %42, ptr %43, align 4, !tbaa !18
  %44 = load i32, ptr %14, align 4, !tbaa !9
  %45 = getelementptr inbounds %struct.png_xy, ptr %21, i32 0, i32 7
  store i32 %44, ptr %45, align 4, !tbaa !19
  %46 = load ptr, ptr %11, align 8, !tbaa !5
  %47 = load ptr, ptr %12, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.png_info_def, ptr %47, i32 0, i32 16
  %49 = call i32 @png_colorspace_set_chromaticities(ptr noundef %46, ptr noundef %48, ptr noundef %21, i32 noundef 2)
  %50 = icmp ne i32 %49, 0
  br i1 %50, label %51, label %59

51:                                               ; preds = %29
  %52 = load ptr, ptr %12, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.png_info_def, ptr %52, i32 0, i32 16
  %54 = getelementptr inbounds %struct.png_colorspace, ptr %53, i32 0, i32 4
  %55 = load i16, ptr %54, align 2, !tbaa !20
  %56 = zext i16 %55 to i32
  %57 = or i32 %56, 16
  %58 = trunc i32 %57 to i16
  store i16 %58, ptr %54, align 2, !tbaa !20
  br label %59

59:                                               ; preds = %51, %29
  %60 = load ptr, ptr %11, align 8, !tbaa !5
  %61 = load ptr, ptr %12, align 8, !tbaa !5
  call void @png_colorspace_sync_info(ptr noundef %60, ptr noundef %61)
  store i32 0, ptr %22, align 4
  br label %62

62:                                               ; preds = %59, %28
  call void @llvm.lifetime.end.p0(i64 32, ptr %21) #3
  %63 = load i32, ptr %22, align 4
  switch i32 %63, label %65 [
    i32 0, label %64
    i32 1, label %64
  ]

64:                                               ; preds = %62, %62
  ret void

65:                                               ; preds = %62
  unreachable
}

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

declare i32 @png_colorspace_set_chromaticities(ptr noundef, ptr noundef, ptr noundef, i32 noundef) #2

declare void @png_colorspace_sync_info(ptr noundef, ptr noundef) #2

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 willreturn memory(argmem: readwrite) }
attributes #2 = { "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 = { 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, !10, i64 0}
!12 = !{!"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}
!13 = !{!12, !10, i64 4}
!14 = !{!12, !10, i64 8}
!15 = !{!12, !10, i64 12}
!16 = !{!12, !10, i64 16}
!17 = !{!12, !10, i64 20}
!18 = !{!12, !10, i64 24}
!19 = !{!12, !10, i64 28}
!20 = !{!21, !23, i64 126}
!21 = !{!"png_info_def", !10, i64 0, !10, i64 4, !10, i64 8, !22, i64 16, !6, i64 24, !23, i64 32, !23, 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, !24, i64 52, !6, i64 128, !6, i64 136, !10, i64 144, !10, i64 148, !10, i64 152, !6, i64 160, !26, i64 168, !27, i64 176, !6, i64 184, !28, i64 192, !28, i64 202, !10, i64 212, !10, i64 216, !7, i64 220, !10, i64 224, !10, i64 228, !7, i64 232, !10, i64 236, !6, i64 240, !6, i64 248, !6, i64 256, !6, i64 264, !10, i64 272, !10, i64 276, !6, i64 280, !6, i64 288, !7, i64 296, !7, i64 297, !10, i64 300, !6, i64 304, !10, i64 312, !6, i64 320, !10, i64 328, !7, i64 332, !6, i64 336, !6, i64 344, !6, i64 352}
!22 = !{!"long", !7, i64 0}
!23 = !{!"short", !7, i64 0}
!24 = !{!"png_colorspace", !10, i64 0, !12, i64 4, !25, i64 36, !23, i64 72, !23, i64 74}
!25 = !{!"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}
!26 = !{!"png_time_struct", !23, i64 0, !7, i64 2, !7, i64 3, !7, i64 4, !7, i64 5, !7, i64 6}
!27 = !{!"png_color_8_struct", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3, !7, i64 4}
!28 = !{!"png_color_16_struct", !7, i64 0, !23, i64 2, !23, i64 4, !23, i64 6, !23, 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"

%struct.png_xy = type { i32, i32, i32, i32, i32, i32, i32, i32 }

; Function Attrs: nounwind uwtable
define dso_local void @png_set_cHRM_fixed(ptr noalias noundef %0, ptr noalias 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 = alloca %struct.png_xy, align 4
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %11) #3
  %12 = icmp eq ptr %0, null
  %13 = icmp eq ptr %1, null
  %or.cond = or i1 %12, %13
  br i1 %or.cond, label %29, label %14

14:                                               ; preds = %10
  store i32 %4, ptr %11, align 4, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %11, i64 4
  store i32 %5, ptr %15, align 4, !tbaa !10
  %16 = getelementptr inbounds i8, ptr %11, i64 8
  store i32 %6, ptr %16, align 4, !tbaa !11
  %17 = getelementptr inbounds i8, ptr %11, i64 12
  store i32 %7, ptr %17, align 4, !tbaa !12
  %18 = getelementptr inbounds i8, ptr %11, i64 16
  store i32 %8, ptr %18, align 4, !tbaa !13
  %19 = getelementptr inbounds i8, ptr %11, i64 20
  store i32 %9, ptr %19, align 4, !tbaa !14
  %20 = getelementptr inbounds i8, ptr %11, i64 24
  store i32 %2, ptr %20, align 4, !tbaa !15
  %21 = getelementptr inbounds i8, ptr %11, i64 28
  store i32 %3, ptr %21, align 4, !tbaa !16
  %22 = getelementptr inbounds i8, ptr %1, i64 52
  %23 = call i32 @png_colorspace_set_chromaticities(ptr noundef nonnull %0, ptr noundef nonnull %22, ptr noundef nonnull %11, i32 noundef 2) #3
  %.not = icmp eq i32 %23, 0
  br i1 %.not, label %28, label %24

24:                                               ; preds = %14
  %25 = getelementptr inbounds i8, ptr %1, i64 126
  %26 = load i16, ptr %25, align 2, !tbaa !17
  %27 = or i16 %26, 16
  store i16 %27, ptr %25, align 2, !tbaa !17
  br label %28

28:                                               ; preds = %24, %14
  call void @png_colorspace_sync_info(ptr noundef nonnull %0, ptr noundef nonnull %1) #3
  br label %29

29:                                               ; preds = %10, %28
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %11) #3
  ret void
}

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

declare i32 @png_colorspace_set_chromaticities(ptr noundef, ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

declare void @png_colorspace_sync_info(ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 willreturn memory(argmem: readwrite) }
attributes #2 = { "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 = { 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 0}
!6 = !{!"png_xy", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20, !7, i64 24, !7, i64 28}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!6, !7, i64 4}
!11 = !{!6, !7, i64 8}
!12 = !{!6, !7, i64 12}
!13 = !{!6, !7, i64 16}
!14 = !{!6, !7, i64 20}
!15 = !{!6, !7, i64 24}
!16 = !{!6, !7, i64 28}
!17 = !{!18, !21, i64 126}
!18 = !{!"png_info_def", !7, i64 0, !7, i64 4, !7, i64 8, !19, i64 16, !20, i64 24, !21, i64 32, !21, 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, !22, i64 52, !20, i64 128, !20, i64 136, !7, i64 144, !7, i64 148, !7, i64 152, !20, i64 160, !24, i64 168, !25, i64 176, !20, i64 184, !26, i64 192, !26, i64 202, !7, i64 212, !7, i64 216, !8, i64 220, !7, i64 224, !7, i64 228, !8, i64 232, !7, i64 236, !20, i64 240, !20, i64 248, !20, i64 256, !20, i64 264, !7, i64 272, !7, i64 276, !20, i64 280, !20, i64 288, !8, i64 296, !8, i64 297, !7, i64 300, !20, i64 304, !7, i64 312, !20, i64 320, !7, i64 328, !8, i64 332, !20, i64 336, !20, i64 344, !20, i64 352}
!19 = !{!"long", !8, i64 0}
!20 = !{!"any pointer", !8, i64 0}
!21 = !{!"short", !8, i64 0}
!22 = !{!"png_colorspace", !7, i64 0, !6, i64 4, !23, i64 36, !21, i64 72, !21, i64 74}
!23 = !{!"png_XYZ", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20, !7, i64 24, !7, i64 28, !7, i64 32}
!24 = !{!"png_time_struct", !21, i64 0, !8, i64 2, !8, i64 3, !8, i64 4, !8, i64 5, !8, i64 6}
!25 = !{!"png_color_8_struct", !8, i64 0, !8, i64 1, !8, i64 2, !8, i64 3, !8, i64 4}
!26 = !{!"png_color_16_struct", !8, i64 0, !21, i64 2, !21, i64 4, !21, i64 6, !21, i64 8}


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