; LLVM IR from vectozavr/3dzavr :: engine/io/Image.ll (ZN5Image9set_pixelEttRK5Color)

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

%class.Image = type { i16, i16, ptr, i8, %class.FilePath }
%class.FilePath = type { %"class.std::filesystem::__cxx11::path" }
%"class.std::filesystem::__cxx11::path" = type { %"class.std::__cxx11::basic_string", %"struct.std::filesystem::__cxx11::path::_List" }
%"class.std::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }
%"struct.std::filesystem::__cxx11::path::_List" = type { %"class.std::unique_ptr" }
%"class.std::unique_ptr" = type { %"struct.std::__uniq_ptr_data" }
%"struct.std::__uniq_ptr_data" = type { %"class.std::__uniq_ptr_impl" }
%"class.std::__uniq_ptr_impl" = type { %"class.std::tuple" }
%"class.std::tuple" = type { %"struct.std::_Tuple_impl" }
%"struct.std::_Tuple_impl" = type { %"struct.std::_Head_base.2" }
%"struct.std::_Head_base.2" = type { ptr }

; 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: mustprogress uwtable
define dso_local void @_ZN5Image9set_pixelEttRK5Color(ptr noundef nonnull align 8 dereferenceable(64) %0, i16 noundef zeroext %1, i16 noundef zeroext %2, ptr noundef nonnull align 1 dereferenceable(4) %3) #1 align 2 {
  %5 = alloca ptr, align 8
  %6 = alloca i16, align 2
  %7 = alloca i16, align 2
  %8 = alloca ptr, align 8
  %9 = alloca i64, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i16 %1, ptr %6, align 2, !tbaa !9
  store i16 %2, ptr %7, align 2, !tbaa !9
  store ptr %3, ptr %8, align 8, !tbaa !5
  %10 = load ptr, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %11 = load i16, ptr %7, align 2, !tbaa !9
  %12 = zext i16 %11 to i32
  %13 = getelementptr inbounds %class.Image, ptr %10, i32 0, i32 0
  %14 = load i16, ptr %13, align 8, !tbaa !11
  %15 = zext i16 %14 to i32
  %16 = mul nsw i32 %12, %15
  %17 = load i16, ptr %6, align 2, !tbaa !9
  %18 = zext i16 %17 to i32
  %19 = add nsw i32 %16, %18
  %20 = mul nsw i32 %19, 4
  %21 = sext i32 %20 to i64
  store i64 %21, ptr %9, align 8, !tbaa !26
  %22 = load ptr, ptr %8, align 8, !tbaa !5
  %23 = call noundef zeroext i8 @_ZNK5Color1rEv(ptr noundef nonnull align 1 dereferenceable(4) %22)
  %24 = getelementptr inbounds %class.Image, ptr %10, i32 0, i32 2
  %25 = load ptr, ptr %24, align 8, !tbaa !27
  %26 = load i64, ptr %9, align 8, !tbaa !26
  %27 = add i64 %26, 0
  %28 = getelementptr inbounds i8, ptr %25, i64 %27
  store i8 %23, ptr %28, align 1, !tbaa !28
  %29 = load ptr, ptr %8, align 8, !tbaa !5
  %30 = call noundef zeroext i8 @_ZNK5Color1gEv(ptr noundef nonnull align 1 dereferenceable(4) %29)
  %31 = getelementptr inbounds %class.Image, ptr %10, i32 0, i32 2
  %32 = load ptr, ptr %31, align 8, !tbaa !27
  %33 = load i64, ptr %9, align 8, !tbaa !26
  %34 = add i64 %33, 1
  %35 = getelementptr inbounds i8, ptr %32, i64 %34
  store i8 %30, ptr %35, align 1, !tbaa !28
  %36 = load ptr, ptr %8, align 8, !tbaa !5
  %37 = call noundef zeroext i8 @_ZNK5Color1bEv(ptr noundef nonnull align 1 dereferenceable(4) %36)
  %38 = getelementptr inbounds %class.Image, ptr %10, i32 0, i32 2
  %39 = load ptr, ptr %38, align 8, !tbaa !27
  %40 = load i64, ptr %9, align 8, !tbaa !26
  %41 = add i64 %40, 2
  %42 = getelementptr inbounds i8, ptr %39, i64 %41
  store i8 %37, ptr %42, align 1, !tbaa !28
  %43 = load ptr, ptr %8, align 8, !tbaa !5
  %44 = call noundef zeroext i8 @_ZNK5Color1aEv(ptr noundef nonnull align 1 dereferenceable(4) %43)
  %45 = getelementptr inbounds %class.Image, ptr %10, i32 0, i32 2
  %46 = load ptr, ptr %45, align 8, !tbaa !27
  %47 = load i64, ptr %9, align 8, !tbaa !26
  %48 = add i64 %47, 3
  %49 = getelementptr inbounds i8, ptr %46, i64 %48
  store i8 %44, ptr %49, align 1, !tbaa !28
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i8 @_ZNK5Color1rEv(ptr noundef nonnull align 1 dereferenceable(4)) #2 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i8 @_ZNK5Color1gEv(ptr noundef nonnull align 1 dereferenceable(4)) #2 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i8 @_ZNK5Color1bEv(ptr noundef nonnull align 1 dereferenceable(4)) #2 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i8 @_ZNK5Color1aEv(ptr noundef nonnull align 1 dereferenceable(4)) #2 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress 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 = { inlinehint mustprogress 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"short", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"_ZTS5Image", !10, i64 0, !10, i64 2, !6, i64 8, !13, i64 16, !14, i64 24}
!13 = !{!"bool", !7, i64 0}
!14 = !{!"_ZTS8FilePath", !15, i64 0}
!15 = !{!"_ZTSNSt10filesystem7__cxx114pathE", !16, i64 0, !19, i64 32}
!16 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !17, i64 0, !18, i64 8, !7, i64 16}
!17 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !6, i64 0}
!18 = !{!"long", !7, i64 0}
!19 = !{!"_ZTSNSt10filesystem7__cxx114path5_ListE", !20, i64 0}
!20 = !{!"_ZTSSt10unique_ptrINSt10filesystem7__cxx114path5_List5_ImplENS3_13_Impl_deleterEE", !21, i64 0}
!21 = !{!"_ZTSSt15__uniq_ptr_dataINSt10filesystem7__cxx114path5_List5_ImplENS3_13_Impl_deleterELb1ELb1EE", !22, i64 0}
!22 = !{!"_ZTSSt15__uniq_ptr_implINSt10filesystem7__cxx114path5_List5_ImplENS3_13_Impl_deleterEE", !23, i64 0}
!23 = !{!"_ZTSSt5tupleIJPNSt10filesystem7__cxx114path5_List5_ImplENS3_13_Impl_deleterEEE", !24, i64 0}
!24 = !{!"_ZTSSt11_Tuple_implILm0EJPNSt10filesystem7__cxx114path5_List5_ImplENS3_13_Impl_deleterEEE", !25, i64 0}
!25 = !{!"_ZTSSt10_Head_baseILm0EPNSt10filesystem7__cxx114path5_List5_ImplELb0EE", !6, i64 0}
!26 = !{!18, !18, i64 0}
!27 = !{!12, !6, i64 8}
!28 = !{!7, !7, i64 0}


; 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 nounwind uwtable
define dso_local void @_ZN5Image9set_pixelEttRK5Color(ptr nocapture noundef nonnull readonly align 8 dereferenceable(64) %0, i16 noundef zeroext %1, i16 noundef zeroext %2, ptr noundef nonnull align 1 dereferenceable(4) %3) local_unnamed_addr #0 align 2 {
  %5 = zext i16 %2 to i64
  %6 = load i16, ptr %0, align 8, !tbaa !5
  %7 = zext i16 %6 to i64
  %8 = mul nuw nsw i64 %7, %5
  %9 = zext i16 %1 to i64
  %10 = add nuw nsw i64 %8, %9
  %11 = shl nuw nsw i64 %10, 2
  %12 = and i64 %11, 4294967292
  %13 = tail call noundef zeroext i8 @_ZNK5Color1rEv(ptr noundef nonnull align 1 dereferenceable(4) %3)
  %14 = getelementptr inbounds i8, ptr %0, i64 8
  %15 = load ptr, ptr %14, align 8, !tbaa !24
  %16 = getelementptr inbounds i8, ptr %15, i64 %12
  store i8 %13, ptr %16, align 1, !tbaa !25
  %17 = tail call noundef zeroext i8 @_ZNK5Color1gEv(ptr noundef nonnull align 1 dereferenceable(4) %3)
  %18 = load ptr, ptr %14, align 8, !tbaa !24
  %19 = or disjoint i64 %12, 1
  %20 = getelementptr inbounds i8, ptr %18, i64 %19
  store i8 %17, ptr %20, align 1, !tbaa !25
  %21 = tail call noundef zeroext i8 @_ZNK5Color1bEv(ptr noundef nonnull align 1 dereferenceable(4) %3)
  %22 = load ptr, ptr %14, align 8, !tbaa !24
  %23 = or disjoint i64 %12, 2
  %24 = getelementptr inbounds i8, ptr %22, i64 %23
  store i8 %21, ptr %24, align 1, !tbaa !25
  %25 = tail call noundef zeroext i8 @_ZNK5Color1aEv(ptr noundef nonnull align 1 dereferenceable(4) %3)
  %26 = load ptr, ptr %14, align 8, !tbaa !24
  %27 = or disjoint i64 %12, 3
  %28 = getelementptr inbounds i8, ptr %26, i64 %27
  store i8 %25, ptr %28, align 1, !tbaa !25
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i8 @_ZNK5Color1rEv(ptr noundef nonnull align 1 dereferenceable(4)) local_unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i8 @_ZNK5Color1gEv(ptr noundef nonnull align 1 dereferenceable(4)) local_unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i8 @_ZNK5Color1bEv(ptr noundef nonnull align 1 dereferenceable(4)) local_unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i8 @_ZNK5Color1aEv(ptr noundef nonnull align 1 dereferenceable(4)) local_unnamed_addr #1 align 2

attributes #0 = { mustprogress 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 = { inlinehint mustprogress 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" }

!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 = !{!"_ZTS5Image", !7, i64 0, !7, i64 2, !10, i64 8, !11, i64 16, !12, i64 24}
!7 = !{!"short", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"bool", !8, i64 0}
!12 = !{!"_ZTS8FilePath", !13, i64 0}
!13 = !{!"_ZTSNSt10filesystem7__cxx114pathE", !14, i64 0, !17, i64 32}
!14 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !15, i64 0, !16, i64 8, !8, i64 16}
!15 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !10, i64 0}
!16 = !{!"long", !8, i64 0}
!17 = !{!"_ZTSNSt10filesystem7__cxx114path5_ListE", !18, i64 0}
!18 = !{!"_ZTSSt10unique_ptrINSt10filesystem7__cxx114path5_List5_ImplENS3_13_Impl_deleterEE", !19, i64 0}
!19 = !{!"_ZTSSt15__uniq_ptr_dataINSt10filesystem7__cxx114path5_List5_ImplENS3_13_Impl_deleterELb1ELb1EE", !20, i64 0}
!20 = !{!"_ZTSSt15__uniq_ptr_implINSt10filesystem7__cxx114path5_List5_ImplENS3_13_Impl_deleterEE", !21, i64 0}
!21 = !{!"_ZTSSt5tupleIJPNSt10filesystem7__cxx114path5_List5_ImplENS3_13_Impl_deleterEEE", !22, i64 0}
!22 = !{!"_ZTSSt11_Tuple_implILm0EJPNSt10filesystem7__cxx114path5_List5_ImplENS3_13_Impl_deleterEEE", !23, i64 0}
!23 = !{!"_ZTSSt10_Head_baseILm0EPNSt10filesystem7__cxx114path5_List5_ImplELb0EE", !10, i64 0}
!24 = !{!6, !10, i64 8}
!25 = !{!8, !8, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,TailCallElimPass