; LLVM IR from Razakhel/RaZ :: src/RaZ/Render/Texture.ll (ZN3Raz9Texture1D4fillERKNS_5ColorE)

; 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.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<Raz::Vector<unsigned char, 3>, std::allocator<Raz::Vector<unsigned char, 3>>>::_Vector_impl" }
%"struct.std::_Vector_base<Raz::Vector<unsigned char, 3>, std::allocator<Raz::Vector<unsigned char, 3>>>::_Vector_impl" = type { %"struct.std::_Vector_base<Raz::Vector<unsigned char, 3>, std::allocator<Raz::Vector<unsigned char, 3>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<Raz::Vector<unsigned char, 3>, std::allocator<Raz::Vector<unsigned char, 3>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.Raz::Vector.9" = type { %"struct.std::array.10" }
%"struct.std::array.10" = type { [3 x i8] }
%"class.std::allocator.6" = type { i8 }
%"class.Raz::Texture" = type { ptr, %"class.Raz::OwnerValue", i32, i32, i32 }
%"class.Raz::OwnerValue" = type { i32 }
%"class.Raz::Texture1D" = type <{ %"class.Raz::Texture", i32, [4 x i8] }>

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK3Raz7Texture4bindEv(ptr noundef nonnull align 8 dereferenceable(24)) #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK3Raz7Texture6unbindEv(ptr noundef nonnull align 8 dereferenceable(24)) #0 align 2

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

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

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3Raz9Texture1D4fillERKNS_5ColorE(ptr noundef nonnull align 8 dereferenceable(32) %0, ptr noundef nonnull align 4 dereferenceable(12) %1) #0 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca %"class.std::vector", align 8
  %6 = alloca %"class.Raz::Vector.9", align 1
  %7 = alloca %"class.std::allocator.6", align 1
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %10 = load ptr, ptr %3, align 8
  %11 = getelementptr inbounds %"class.Raz::Texture", ptr %10, i32 0, i32 3
  store i32 2, ptr %11, align 8, !tbaa !9
  %12 = getelementptr inbounds %"class.Raz::Texture", ptr %10, i32 0, i32 4
  store i32 0, ptr %12, align 4, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 24, ptr %5) #4
  %13 = getelementptr inbounds %"class.Raz::Texture1D", ptr %10, i32 0, i32 1
  %14 = load i32, ptr %13, align 8, !tbaa !17
  %15 = mul i32 %14, 3
  %16 = zext i32 %15 to i64
  call void @llvm.lifetime.start.p0(i64 3, ptr %6) #4
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = call i24 @_ZNK3Raz5ColorcvNS_6VectorIhLm3EEEEv(ptr noundef nonnull align 4 dereferenceable(12) %17) #4
  %19 = getelementptr inbounds %"class.Raz::Vector.9", ptr %6, i32 0, i32 0
  %20 = getelementptr inbounds %"struct.std::array.10", ptr %19, i32 0, i32 0
  store i24 %18, ptr %20, align 1
  call void @llvm.lifetime.start.p0(i64 1, ptr %7) #4
  call void @_ZNSaIN3Raz6VectorIhLm3EEEEC2Ev(ptr noundef nonnull align 1 dereferenceable(1) %7) #4
  invoke void @_ZNSt6vectorIN3Raz6VectorIhLm3EEESaIS2_EEC2EmRKS2_RKS3_(ptr noundef nonnull align 8 dereferenceable(24) %5, i64 noundef %16, ptr noundef nonnull align 1 dereferenceable(3) %6, ptr noundef nonnull align 1 dereferenceable(1) %7)
          to label %21 unwind label %28

21:                                               ; preds = %2
  call void @_ZNSt15__new_allocatorIN3Raz6VectorIhLm3EEEED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %7) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 3, ptr %6) #4
  invoke void @_ZNK3Raz7Texture4bindEv(ptr noundef nonnull align 8 dereferenceable(24) %10)
          to label %22 unwind label %32

22:                                               ; preds = %21
  %23 = getelementptr inbounds %"class.Raz::Texture1D", ptr %10, i32 0, i32 1
  %24 = load i32, ptr %23, align 8, !tbaa !17
  %25 = call noundef ptr @_ZNKSt6vectorIN3Raz6VectorIhLm3EEESaIS2_EE4dataEv(ptr noundef nonnull align 8 dereferenceable(24) %5) #4
  invoke void @_ZN3Raz8Renderer15sendImageData1DENS_11TextureTypeEjNS_21TextureInternalFormatEjNS_13TextureFormatENS_13PixelDataTypeEPKv(i32 noundef 3552, i32 noundef 0, i32 noundef 6407, i32 noundef %24, i32 noundef 6407, i32 noundef 5121, ptr noundef %25)
          to label %26 unwind label %32

26:                                               ; preds = %22
  invoke void @_ZNK3Raz7Texture6unbindEv(ptr noundef nonnull align 8 dereferenceable(24) %10)
          to label %27 unwind label %32

27:                                               ; preds = %26
  call void @_ZNSt6vectorIN3Raz6VectorIhLm3EEESaIS2_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %5) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr %5) #4
  ret void

28:                                               ; preds = %2
  %29 = landingpad { ptr, i32 }
          cleanup
  %30 = extractvalue { ptr, i32 } %29, 0
  store ptr %30, ptr %8, align 8
  %31 = extractvalue { ptr, i32 } %29, 1
  store i32 %31, ptr %9, align 4
  call void @_ZNSt15__new_allocatorIN3Raz6VectorIhLm3EEEED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %7) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 3, ptr %6) #4
  br label %36

32:                                               ; preds = %26, %22, %21
  %33 = landingpad { ptr, i32 }
          cleanup
  %34 = extractvalue { ptr, i32 } %33, 0
  store ptr %34, ptr %8, align 8
  %35 = extractvalue { ptr, i32 } %33, 1
  store i32 %35, ptr %9, align 4
  call void @_ZNSt6vectorIN3Raz6VectorIhLm3EEESaIS2_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %5) #4
  br label %36

36:                                               ; preds = %32, %28
  call void @llvm.lifetime.end.p0(i64 24, ptr %5) #4
  br label %37

37:                                               ; preds = %36
  %38 = load ptr, ptr %8, align 8
  %39 = load i32, ptr %9, align 4
  %40 = insertvalue { ptr, i32 } poison, ptr %38, 0
  %41 = insertvalue { ptr, i32 } %40, i32 %39, 1
  resume { ptr, i32 } %41
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local i24 @_ZNK3Raz5ColorcvNS_6VectorIhLm3EEEEv(ptr noundef nonnull align 4 dereferenceable(12)) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSaIN3Raz6VectorIhLm3EEEEC2Ev(ptr noundef nonnull align 1 dereferenceable(1)) unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorIN3Raz6VectorIhLm3EEESaIS2_EEC2EmRKS2_RKS3_(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef, ptr noundef nonnull align 1 dereferenceable(3), ptr noundef nonnull align 1 dereferenceable(1)) unnamed_addr #0 align 2

declare void @_ZN3Raz8Renderer15sendImageData1DENS_11TextureTypeEjNS_21TextureInternalFormatEjNS_13TextureFormatENS_13PixelDataTypeEPKv(i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, ptr noundef) #3

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNKSt6vectorIN3Raz6VectorIhLm3EEESaIS2_EE4dataEv(ptr noundef nonnull align 8 dereferenceable(24)) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6vectorIN3Raz6VectorIhLm3EEESaIS2_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt15__new_allocatorIN3Raz6VectorIhLm3EEEED2Ev(ptr noundef nonnull align 1 dereferenceable(1)) unnamed_addr #2 align 2

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 = { "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 #4 = { 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, !14, i64 16}
!10 = !{!"_ZTSN3Raz7TextureE", !11, i64 8, !13, i64 12, !14, i64 16, !15, i64 20}
!11 = !{!"_ZTSN3Raz10OwnerValueIjLj0EEE", !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!"_ZTSN3Raz11TextureTypeE", !7, i64 0}
!14 = !{!"_ZTSN3Raz17TextureColorspaceE", !7, i64 0}
!15 = !{!"_ZTSN3Raz15TextureDataTypeE", !7, i64 0}
!16 = !{!10, !15, i64 20}
!17 = !{!18, !12, i64 24}
!18 = !{!"_ZTSN3Raz9Texture1DE", !10, i64 0, !12, i64 24}


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

%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<Raz::Vector<unsigned char, 3>, std::allocator<Raz::Vector<unsigned char, 3>>>::_Vector_impl" }
%"struct.std::_Vector_base<Raz::Vector<unsigned char, 3>, std::allocator<Raz::Vector<unsigned char, 3>>>::_Vector_impl" = type { %"struct.std::_Vector_base<Raz::Vector<unsigned char, 3>, std::allocator<Raz::Vector<unsigned char, 3>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<Raz::Vector<unsigned char, 3>, std::allocator<Raz::Vector<unsigned char, 3>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.Raz::Vector.9" = type { %"struct.std::array.10" }
%"struct.std::array.10" = type { [3 x i8] }
%"class.std::allocator.6" = type { i8 }

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK3Raz7Texture4bindEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK3Raz7Texture6unbindEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #0 align 2

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

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

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3Raz9Texture1D4fillERKNS_5ColorE(ptr noundef nonnull align 8 dereferenceable(32) %0, ptr noundef nonnull align 4 dereferenceable(12) %1) local_unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca %"class.std::vector", align 8
  %4 = alloca %"class.Raz::Vector.9", align 4
  %5 = alloca %"class.std::allocator.6", align 1
  %6 = getelementptr inbounds i8, ptr %0, i64 16
  store i32 2, ptr %6, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %0, i64 20
  store i32 0, ptr %7, align 4, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %3) #4
  %8 = getelementptr inbounds i8, ptr %0, i64 24
  %9 = load i32, ptr %8, align 8, !tbaa !15
  %10 = mul i32 %9, 3
  %11 = zext i32 %10 to i64
  call void @llvm.lifetime.start.p0(i64 3, ptr nonnull %4) #4
  %12 = tail call i24 @_ZNK3Raz5ColorcvNS_6VectorIhLm3EEEEv(ptr noundef nonnull align 4 dereferenceable(12) %1) #4
  store i24 %12, ptr %4, align 4
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %5) #4
  call void @_ZNSaIN3Raz6VectorIhLm3EEEEC2Ev(ptr noundef nonnull align 1 dereferenceable(1) %5) #4
  invoke void @_ZNSt6vectorIN3Raz6VectorIhLm3EEESaIS2_EEC2EmRKS2_RKS3_(ptr noundef nonnull align 8 dereferenceable(24) %3, i64 noundef %11, ptr noundef nonnull align 1 dereferenceable(3) %4, ptr noundef nonnull align 1 dereferenceable(1) %5)
          to label %13 unwind label %19

13:                                               ; preds = %2
  call void @_ZNSt15__new_allocatorIN3Raz6VectorIhLm3EEEED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %5) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %5) #4
  call void @llvm.lifetime.end.p0(i64 3, ptr nonnull %4) #4
  invoke void @_ZNK3Raz7Texture4bindEv(ptr noundef nonnull align 8 dereferenceable(24) %0)
          to label %14 unwind label %21

14:                                               ; preds = %13
  %15 = load i32, ptr %8, align 8, !tbaa !15
  %16 = call noundef ptr @_ZNKSt6vectorIN3Raz6VectorIhLm3EEESaIS2_EE4dataEv(ptr noundef nonnull align 8 dereferenceable(24) %3) #4
  invoke void @_ZN3Raz8Renderer15sendImageData1DENS_11TextureTypeEjNS_21TextureInternalFormatEjNS_13TextureFormatENS_13PixelDataTypeEPKv(i32 noundef 3552, i32 noundef 0, i32 noundef 6407, i32 noundef %15, i32 noundef 6407, i32 noundef 5121, ptr noundef %16)
          to label %17 unwind label %21

17:                                               ; preds = %14
  invoke void @_ZNK3Raz7Texture6unbindEv(ptr noundef nonnull align 8 dereferenceable(24) %0)
          to label %18 unwind label %21

18:                                               ; preds = %17
  call void @_ZNSt6vectorIN3Raz6VectorIhLm3EEESaIS2_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %3) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %3) #4
  ret void

19:                                               ; preds = %2
  %20 = landingpad { ptr, i32 }
          cleanup
  call void @_ZNSt15__new_allocatorIN3Raz6VectorIhLm3EEEED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %5) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %5) #4
  call void @llvm.lifetime.end.p0(i64 3, ptr nonnull %4) #4
  br label %23

21:                                               ; preds = %17, %14, %13
  %22 = landingpad { ptr, i32 }
          cleanup
  call void @_ZNSt6vectorIN3Raz6VectorIhLm3EEESaIS2_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %3) #4
  br label %23

23:                                               ; preds = %21, %19
  %.pn = phi { ptr, i32 } [ %22, %21 ], [ %20, %19 ]
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %3) #4
  resume { ptr, i32 } %.pn
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local i24 @_ZNK3Raz5ColorcvNS_6VectorIhLm3EEEEv(ptr noundef nonnull align 4 dereferenceable(12)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSaIN3Raz6VectorIhLm3EEEEC2Ev(ptr noundef nonnull align 1 dereferenceable(1)) unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorIN3Raz6VectorIhLm3EEESaIS2_EEC2EmRKS2_RKS3_(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef, ptr noundef nonnull align 1 dereferenceable(3), ptr noundef nonnull align 1 dereferenceable(1)) unnamed_addr #0 align 2

declare void @_ZN3Raz8Renderer15sendImageData1DENS_11TextureTypeEjNS_21TextureInternalFormatEjNS_13TextureFormatENS_13PixelDataTypeEPKv(i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNKSt6vectorIN3Raz6VectorIhLm3EEESaIS2_EE4dataEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6vectorIN3Raz6VectorIhLm3EEESaIS2_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt15__new_allocatorIN3Raz6VectorIhLm3EEEED2Ev(ptr noundef nonnull align 1 dereferenceable(1)) unnamed_addr #2 align 2

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 = { "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 #4 = { 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, !12, i64 16}
!6 = !{!"_ZTSN3Raz7TextureE", !7, i64 8, !11, i64 12, !12, i64 16, !13, i64 20}
!7 = !{!"_ZTSN3Raz10OwnerValueIjLj0EEE", !8, i64 0}
!8 = !{!"int", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"_ZTSN3Raz11TextureTypeE", !9, i64 0}
!12 = !{!"_ZTSN3Raz17TextureColorspaceE", !9, i64 0}
!13 = !{!"_ZTSN3Raz15TextureDataTypeE", !9, i64 0}
!14 = !{!6, !13, i64 20}
!15 = !{!16, !8, i64 24}
!16 = !{!"_ZTSN3Raz9Texture1DE", !6, i64 0, !8, i64 24}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass