; 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_XYZ = type { i32, 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_xy = type { 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

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

; 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_cHRM_XYZ_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, i32 noundef %10) #2 {
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %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 i32, align 4
  %22 = alloca i32, align 4
  %23 = alloca %struct.png_XYZ, align 4
  %24 = alloca i32, align 4
  store ptr %0, ptr %12, align 8, !tbaa !5
  store ptr %1, ptr %13, align 8, !tbaa !5
  store i32 %2, ptr %14, align 4, !tbaa !9
  store i32 %3, ptr %15, align 4, !tbaa !9
  store i32 %4, ptr %16, align 4, !tbaa !9
  store i32 %5, ptr %17, align 4, !tbaa !9
  store i32 %6, ptr %18, align 4, !tbaa !9
  store i32 %7, ptr %19, align 4, !tbaa !9
  store i32 %8, ptr %20, align 4, !tbaa !9
  store i32 %9, ptr %21, align 4, !tbaa !9
  store i32 %10, ptr %22, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 36, ptr %23) #3
  %25 = load ptr, ptr %12, align 8, !tbaa !5
  %26 = icmp eq ptr %25, null
  br i1 %26, label %30, label %27

27:                                               ; preds = %11
  %28 = load ptr, ptr %13, align 8, !tbaa !5
  %29 = icmp eq ptr %28, null
  br i1 %29, label %30, label %31

30:                                               ; preds = %27, %11
  store i32 1, ptr %24, align 4
  br label %66

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

55:                                               ; preds = %31
  %56 = load ptr, ptr %13, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.png_info_def, ptr %56, i32 0, i32 16
  %58 = getelementptr inbounds %struct.png_colorspace, ptr %57, i32 0, i32 4
  %59 = load i16, ptr %58, align 2, !tbaa !21
  %60 = zext i16 %59 to i32
  %61 = or i32 %60, 16
  %62 = trunc i32 %61 to i16
  store i16 %62, ptr %58, align 2, !tbaa !21
  br label %63

63:                                               ; preds = %55, %31
  %64 = load ptr, ptr %12, align 8, !tbaa !5
  %65 = load ptr, ptr %13, align 8, !tbaa !5
  call void @png_colorspace_sync_info(ptr noundef %64, ptr noundef %65)
  store i32 0, ptr %24, align 4
  br label %66

66:                                               ; preds = %63, %30
  call void @llvm.lifetime.end.p0(i64 36, ptr %23) #3
  %67 = load i32, ptr %24, align 4
  switch i32 %67, label %69 [
    i32 0, label %68
    i32 1, label %68
  ]

68:                                               ; preds = %66, %66
  ret void

69:                                               ; preds = %66
  unreachable
}

declare i32 @png_colorspace_set_endpoints(ptr noundef, ptr noundef, ptr noundef, i32 noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 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 #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_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}
!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 = !{!12, !10, i64 32}
!21 = !{!22, !24, i64 126}
!22 = !{!"png_info_def", !10, i64 0, !10, i64 4, !10, i64 8, !23, i64 16, !6, i64 24, !24, i64 32, !24, 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, !25, i64 52, !6, i64 128, !6, i64 136, !10, i64 144, !10, i64 148, !10, i64 152, !6, i64 160, !27, i64 168, !28, i64 176, !6, i64 184, !29, i64 192, !29, 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}
!23 = !{!"long", !7, i64 0}
!24 = !{!"short", !7, i64 0}
!25 = !{!"png_colorspace", !10, i64 0, !26, i64 4, !12, i64 36, !24, i64 72, !24, i64 74}
!26 = !{!"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}
!27 = !{!"png_time_struct", !24, i64 0, !7, i64 2, !7, i64 3, !7, i64 4, !7, i64 5, !7, i64 6}
!28 = !{!"png_color_8_struct", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3, !7, i64 4}
!29 = !{!"png_color_16_struct", !7, i64 0, !24, i64 2, !24, i64 4, !24, i64 6, !24, 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_XYZ = type { i32, i32, i32, i32, i32, i32, i32, i32, i32 }

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

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

; Function Attrs: mustprogress 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_cHRM_XYZ_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, i32 noundef %10) local_unnamed_addr #2 {
  %12 = alloca %struct.png_XYZ, align 4
  call void @llvm.lifetime.start.p0(i64 36, ptr nonnull %12) #3
  %13 = icmp eq ptr %0, null
  %14 = icmp eq ptr %1, null
  %or.cond = or i1 %13, %14
  br i1 %or.cond, label %31, label %15

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

26:                                               ; preds = %15
  %27 = getelementptr inbounds i8, ptr %1, i64 126
  %28 = load i16, ptr %27, align 2, !tbaa !18
  %29 = or i16 %28, 16
  store i16 %29, ptr %27, align 2, !tbaa !18
  br label %30

30:                                               ; preds = %26, %15
  call void @png_colorspace_sync_info(ptr noundef nonnull %0, ptr noundef nonnull %1) #3
  br label %31

31:                                               ; preds = %11, %30
  call void @llvm.lifetime.end.p0(i64 36, ptr nonnull %12) #3
  ret void
}

declare i32 @png_colorspace_set_endpoints(ptr noundef, ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 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 #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_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}
!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 = !{!6, !7, i64 32}
!18 = !{!19, !22, i64 126}
!19 = !{!"png_info_def", !7, i64 0, !7, i64 4, !7, i64 8, !20, i64 16, !21, i64 24, !22, i64 32, !22, 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, !23, i64 52, !21, i64 128, !21, i64 136, !7, i64 144, !7, i64 148, !7, i64 152, !21, i64 160, !25, i64 168, !26, i64 176, !21, i64 184, !27, i64 192, !27, i64 202, !7, i64 212, !7, i64 216, !8, i64 220, !7, i64 224, !7, i64 228, !8, i64 232, !7, i64 236, !21, i64 240, !21, i64 248, !21, i64 256, !21, i64 264, !7, i64 272, !7, i64 276, !21, i64 280, !21, i64 288, !8, i64 296, !8, i64 297, !7, i64 300, !21, i64 304, !7, i64 312, !21, i64 320, !7, i64 328, !8, i64 332, !21, i64 336, !21, i64 344, !21, i64 352}
!20 = !{!"long", !8, i64 0}
!21 = !{!"any pointer", !8, i64 0}
!22 = !{!"short", !8, i64 0}
!23 = !{!"png_colorspace", !7, i64 0, !24, i64 4, !6, i64 36, !22, i64 72, !22, i64 74}
!24 = !{!"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}
!25 = !{!"png_time_struct", !22, i64 0, !8, i64 2, !8, i64 3, !8, i64 4, !8, i64 5, !8, i64 6}
!26 = !{!"png_color_8_struct", !8, i64 0, !8, i64 1, !8, i64 2, !8, i64 3, !8, i64 4}
!27 = !{!"png_color_16_struct", !8, i64 0, !22, i64 2, !22, i64 4, !22, i64 6, !22, i64 8}


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