; LLVM IR from mackorone/mms :: old/v2/src/sim/BufferInterface.ll (ZN3sim15BufferInterface26insertIntoTextureCpuBufferEv)

; 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.sim::TriangleTexture" = type { %"struct.sim::VertexTexture", %"struct.sim::VertexTexture", %"struct.sim::VertexTexture" }
%"struct.sim::VertexTexture" = type { double, double, double, double }
%"class.sim::BufferInterface" = type { %"struct.std::pair.133", ptr, ptr, %"class.sim::TileGraphicTextCache" }
%"struct.std::pair.133" = type { i32, i32 }
%"class.sim::TileGraphicTextCache" = type { %"class.sim::Meters", %"class.sim::Meters", %"struct.std::pair.133", %"class.std::map.135", %"class.std::map.140" }
%"class.sim::Meters" = type { %"class.sim::Distance" }
%"class.sim::Distance" = type { ptr, double }
%"class.std::map.135" = type { %"class.std::_Rb_tree.136" }
%"class.std::_Rb_tree.136" = type { %"struct.std::_Rb_tree<char, std::pair<const char, std::pair<double, double>>, std::_Select1st<std::pair<const char, std::pair<double, double>>>, std::less<char>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<char, std::pair<const char, std::pair<double, double>>, std::_Select1st<std::pair<const char, std::pair<double, double>>>, std::less<char>>::_Rb_tree_impl" = type { [8 x i8], %"struct.std::_Rb_tree_header" }
%"struct.std::_Rb_tree_header" = type { %"struct.std::_Rb_tree_node_base", i64 }
%"struct.std::_Rb_tree_node_base" = type { i32, ptr, ptr, ptr }
%"class.std::map.140" = type { %"class.std::_Rb_tree.141" }
%"class.std::_Rb_tree.141" = type { %"struct.std::_Rb_tree<std::pair<std::pair<int, int>, std::pair<int, int>>, std::pair<const std::pair<std::pair<int, int>, std::pair<int, int>>, std::pair<sim::Cartesian, sim::Cartesian>>, std::_Select1st<std::pair<const std::pair<std::pair<int, int>, std::pair<int, int>>, std::pair<sim::Cartesian, sim::Cartesian>>>, std::less<std::pair<std::pair<int, int>, std::pair<int, int>>>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<std::pair<std::pair<int, int>, std::pair<int, int>>, std::pair<const std::pair<std::pair<int, int>, std::pair<int, int>>, std::pair<sim::Cartesian, sim::Cartesian>>, std::_Select1st<std::pair<const std::pair<std::pair<int, int>, std::pair<int, int>>, std::pair<sim::Cartesian, sim::Cartesian>>>, std::less<std::pair<std::pair<int, int>, std::pair<int, int>>>>::_Rb_tree_impl" = type { [8 x i8], %"struct.std::_Rb_tree_header" }

; 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 @_ZN3sim15BufferInterface26insertIntoTextureCpuBufferEv(ptr noundef nonnull align 8 dereferenceable(160) %0) #1 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca %"struct.sim::TriangleTexture", align 8
  %4 = alloca %"struct.sim::TriangleTexture", align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %5 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 96, ptr %3) #3
  call void @llvm.memset.p0.i64(ptr align 8 %3, i8 0, i64 96, i1 false)
  %6 = getelementptr inbounds %"struct.sim::TriangleTexture", ptr %3, i32 0, i32 1
  %7 = getelementptr inbounds %"struct.sim::VertexTexture", ptr %6, i32 0, i32 3
  store double 1.000000e+00, ptr %7, align 8
  %8 = getelementptr inbounds %"struct.sim::TriangleTexture", ptr %3, i32 0, i32 2
  %9 = getelementptr inbounds %"struct.sim::VertexTexture", ptr %8, i32 0, i32 3
  store double 1.000000e+00, ptr %9, align 8
  call void @llvm.lifetime.start.p0(i64 96, ptr %4) #3
  call void @llvm.memset.p0.i64(ptr align 8 %4, i8 0, i64 96, i1 false)
  %10 = getelementptr inbounds %"struct.sim::TriangleTexture", ptr %4, i32 0, i32 1
  %11 = getelementptr inbounds %"struct.sim::VertexTexture", ptr %10, i32 0, i32 3
  store double 1.000000e+00, ptr %11, align 8
  %12 = getelementptr inbounds %"class.sim::BufferInterface", ptr %5, i32 0, i32 2
  %13 = load ptr, ptr %12, align 8, !tbaa !9
  call void @_ZNSt6vectorIN3sim15TriangleTextureESaIS1_EE9push_backERKS1_(ptr noundef nonnull align 8 dereferenceable(24) %13, ptr noundef nonnull align 8 dereferenceable(96) %3)
  %14 = getelementptr inbounds %"class.sim::BufferInterface", ptr %5, i32 0, i32 2
  %15 = load ptr, ptr %14, align 8, !tbaa !9
  call void @_ZNSt6vectorIN3sim15TriangleTextureESaIS1_EE9push_backERKS1_(ptr noundef nonnull align 8 dereferenceable(24) %15, ptr noundef nonnull align 8 dereferenceable(96) %4)
  call void @llvm.lifetime.end.p0(i64 96, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 96, ptr %3) #3
  ret void
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorIN3sim15TriangleTextureESaIS1_EE9push_backERKS1_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(96)) #1 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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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, !6, i64 16}
!10 = !{!"_ZTSN3sim15BufferInterfaceE", !11, i64 0, !6, i64 8, !6, i64 16, !13, i64 24}
!11 = !{!"_ZTSSt4pairIiiE", !12, i64 0, !12, i64 4}
!12 = !{!"int", !7, i64 0}
!13 = !{!"_ZTSN3sim20TileGraphicTextCacheE", !14, i64 0, !14, i64 16, !11, i64 32, !17, i64 40, !26, i64 88}
!14 = !{!"_ZTSN3sim6MetersE", !15, i64 0}
!15 = !{!"_ZTSN3sim8DistanceE", !16, i64 8}
!16 = !{!"double", !7, i64 0}
!17 = !{!"_ZTSSt3mapIcSt4pairIddESt4lessIcESaIS0_IKcS1_EEE", !18, i64 0}
!18 = !{!"_ZTSSt8_Rb_treeIcSt4pairIKcS0_IddEESt10_Select1stIS3_ESt4lessIcESaIS3_EE", !19, i64 0}
!19 = !{!"_ZTSNSt8_Rb_treeIcSt4pairIKcS0_IddEESt10_Select1stIS3_ESt4lessIcESaIS3_EE13_Rb_tree_implIS7_Lb1EEE", !20, i64 0, !22, i64 8}
!20 = !{!"_ZTSSt20_Rb_tree_key_compareISt4lessIcEE", !21, i64 0}
!21 = !{!"_ZTSSt4lessIcE"}
!22 = !{!"_ZTSSt15_Rb_tree_header", !23, i64 0, !25, i64 32}
!23 = !{!"_ZTSSt18_Rb_tree_node_base", !24, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!24 = !{!"_ZTSSt14_Rb_tree_color", !7, i64 0}
!25 = !{!"long", !7, i64 0}
!26 = !{!"_ZTSSt3mapISt4pairIS0_IiiES1_ES0_IN3sim9CartesianES4_ESt4lessIS2_ESaIS0_IKS2_S5_EEE", !27, i64 0}
!27 = !{!"_ZTSSt8_Rb_treeISt4pairIS0_IiiES1_ES0_IKS2_S0_IN3sim9CartesianES5_EESt10_Select1stIS7_ESt4lessIS2_ESaIS7_EE", !28, i64 0}
!28 = !{!"_ZTSNSt8_Rb_treeISt4pairIS0_IiiES1_ES0_IKS2_S0_IN3sim9CartesianES5_EESt10_Select1stIS7_ESt4lessIS2_ESaIS7_EE13_Rb_tree_implISB_Lb1EEE", !29, i64 0, !22, i64 8}
!29 = !{!"_ZTSSt20_Rb_tree_key_compareISt4lessISt4pairIS1_IiiES2_EEE", !30, i64 0}
!30 = !{!"_ZTSSt4lessISt4pairIS0_IiiES1_EE"}


; 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.sim::TriangleTexture" = type { %"struct.sim::VertexTexture", %"struct.sim::VertexTexture", %"struct.sim::VertexTexture" }
%"struct.sim::VertexTexture" = type { double, double, double, double }

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

; Function Attrs: mustprogress 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 @_ZN3sim15BufferInterface26insertIntoTextureCpuBufferEv(ptr nocapture noundef nonnull readonly align 8 dereferenceable(160) %0) local_unnamed_addr #1 align 2 {
  %2 = alloca %"struct.sim::TriangleTexture", align 8
  %3 = alloca %"struct.sim::TriangleTexture", align 8
  call void @llvm.lifetime.start.p0(i64 96, ptr nonnull %2) #3
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(96) %2, i8 0, i64 88, i1 false)
  %4 = getelementptr inbounds i8, ptr %2, i64 56
  store double 1.000000e+00, ptr %4, align 8
  %5 = getelementptr inbounds i8, ptr %2, i64 88
  store double 1.000000e+00, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 96, ptr nonnull %3) #3
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(96) %3, i8 0, i64 96, i1 false)
  %6 = getelementptr inbounds i8, ptr %3, i64 56
  store double 1.000000e+00, ptr %6, align 8
  %7 = getelementptr inbounds i8, ptr %0, i64 16
  %8 = load ptr, ptr %7, align 8, !tbaa !5
  call void @_ZNSt6vectorIN3sim15TriangleTextureESaIS1_EE9push_backERKS1_(ptr noundef nonnull align 8 dereferenceable(24) %8, ptr noundef nonnull align 8 dereferenceable(96) %2)
  %9 = load ptr, ptr %7, align 8, !tbaa !5
  call void @_ZNSt6vectorIN3sim15TriangleTextureESaIS1_EE9push_backERKS1_(ptr noundef nonnull align 8 dereferenceable(24) %9, ptr noundef nonnull align 8 dereferenceable(96) %3)
  call void @llvm.lifetime.end.p0(i64 96, ptr nonnull %3) #3
  call void @llvm.lifetime.end.p0(i64 96, ptr nonnull %2) #3
  ret void
}

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorIN3sim15TriangleTextureESaIS1_EE9push_backERKS1_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(96)) local_unnamed_addr #1 align 2

attributes #0 = { mustprogress 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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
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, !11, i64 16}
!6 = !{!"_ZTSN3sim15BufferInterfaceE", !7, i64 0, !11, i64 8, !11, i64 16, !12, i64 24}
!7 = !{!"_ZTSSt4pairIiiE", !8, i64 0, !8, i64 4}
!8 = !{!"int", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"any pointer", !9, i64 0}
!12 = !{!"_ZTSN3sim20TileGraphicTextCacheE", !13, i64 0, !13, i64 16, !7, i64 32, !16, i64 40, !25, i64 88}
!13 = !{!"_ZTSN3sim6MetersE", !14, i64 0}
!14 = !{!"_ZTSN3sim8DistanceE", !15, i64 8}
!15 = !{!"double", !9, i64 0}
!16 = !{!"_ZTSSt3mapIcSt4pairIddESt4lessIcESaIS0_IKcS1_EEE", !17, i64 0}
!17 = !{!"_ZTSSt8_Rb_treeIcSt4pairIKcS0_IddEESt10_Select1stIS3_ESt4lessIcESaIS3_EE", !18, i64 0}
!18 = !{!"_ZTSNSt8_Rb_treeIcSt4pairIKcS0_IddEESt10_Select1stIS3_ESt4lessIcESaIS3_EE13_Rb_tree_implIS7_Lb1EEE", !19, i64 0, !21, i64 8}
!19 = !{!"_ZTSSt20_Rb_tree_key_compareISt4lessIcEE", !20, i64 0}
!20 = !{!"_ZTSSt4lessIcE"}
!21 = !{!"_ZTSSt15_Rb_tree_header", !22, i64 0, !24, i64 32}
!22 = !{!"_ZTSSt18_Rb_tree_node_base", !23, i64 0, !11, i64 8, !11, i64 16, !11, i64 24}
!23 = !{!"_ZTSSt14_Rb_tree_color", !9, i64 0}
!24 = !{!"long", !9, i64 0}
!25 = !{!"_ZTSSt3mapISt4pairIS0_IiiES1_ES0_IN3sim9CartesianES4_ESt4lessIS2_ESaIS0_IKS2_S5_EEE", !26, i64 0}
!26 = !{!"_ZTSSt8_Rb_treeISt4pairIS0_IiiES1_ES0_IKS2_S0_IN3sim9CartesianES5_EESt10_Select1stIS7_ESt4lessIS2_ESaIS7_EE", !27, i64 0}
!27 = !{!"_ZTSNSt8_Rb_treeISt4pairIS0_IiiES1_ES0_IKS2_S0_IN3sim9CartesianES5_EESt10_Select1stIS7_ESt4lessIS2_ESaIS7_EE13_Rb_tree_implISB_Lb1EEE", !28, i64 0, !21, i64 8}
!28 = !{!"_ZTSSt20_Rb_tree_key_compareISt4lessISt4pairIS1_IiiES2_EEE", !29, i64 0}
!29 = !{!"_ZTSSt4lessISt4pairIS0_IiiES1_EE"}


; Effective O3 passes: DSEPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass