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

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

; 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
declare dso_local noundef nonnull align 8 dereferenceable(144) ptr @_ZNSt6vectorIN3sim15TriangleGraphicESaIS1_EE2atEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3sim15BufferInterface20updateTileGraphicFogEiid(ptr noundef nonnull align 8 dereferenceable(160) %0, i32 noundef %1, i32 noundef %2, double noundef %3) #1 align 2 {
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca double, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store i32 %2, ptr %7, align 4, !tbaa !9
  store double %3, ptr %8, align 8, !tbaa !11
  %12 = load ptr, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  %13 = load i32, ptr %6, align 4, !tbaa !9
  %14 = load i32, ptr %7, align 4, !tbaa !9
  %15 = call noundef i32 @_ZN3sim15BufferInterface30getTileGraphicFogStartingIndexEii(ptr noundef nonnull align 8 dereferenceable(160) %12, i32 noundef %13, i32 noundef %14)
  store i32 %15, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  store i32 0, ptr %10, align 4, !tbaa !9
  br label %16

16:                                               ; preds = %40, %4
  %17 = load i32, ptr %10, align 4, !tbaa !9
  %18 = icmp slt i32 %17, 2
  br i1 %18, label %20, label %19

19:                                               ; preds = %16
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  br label %43

20:                                               ; preds = %16
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  %21 = getelementptr inbounds %"class.sim::BufferInterface", ptr %12, i32 0, i32 1
  %22 = load ptr, ptr %21, align 8, !tbaa !13
  %23 = load i32, ptr %9, align 4, !tbaa !9
  %24 = load i32, ptr %10, align 4, !tbaa !9
  %25 = add nsw i32 %23, %24
  %26 = sext i32 %25 to i64
  %27 = call noundef nonnull align 8 dereferenceable(144) ptr @_ZNSt6vectorIN3sim15TriangleGraphicESaIS1_EE2atEm(ptr noundef nonnull align 8 dereferenceable(24) %22, i64 noundef %26)
  store ptr %27, ptr %11, align 8, !tbaa !5
  %28 = load double, ptr %8, align 8, !tbaa !11
  %29 = load ptr, ptr %11, align 8, !tbaa !5
  %30 = getelementptr inbounds %"struct.sim::TriangleGraphic", ptr %29, i32 0, i32 0
  %31 = getelementptr inbounds %"struct.sim::VertexGraphic", ptr %30, i32 0, i32 5
  store double %28, ptr %31, align 8, !tbaa !33
  %32 = load double, ptr %8, align 8, !tbaa !11
  %33 = load ptr, ptr %11, align 8, !tbaa !5
  %34 = getelementptr inbounds %"struct.sim::TriangleGraphic", ptr %33, i32 0, i32 1
  %35 = getelementptr inbounds %"struct.sim::VertexGraphic", ptr %34, i32 0, i32 5
  store double %32, ptr %35, align 8, !tbaa !36
  %36 = load double, ptr %8, align 8, !tbaa !11
  %37 = load ptr, ptr %11, align 8, !tbaa !5
  %38 = getelementptr inbounds %"struct.sim::TriangleGraphic", ptr %37, i32 0, i32 2
  %39 = getelementptr inbounds %"struct.sim::VertexGraphic", ptr %38, i32 0, i32 5
  store double %36, ptr %39, align 8, !tbaa !37
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  br label %40

40:                                               ; preds = %20
  %41 = load i32, ptr %10, align 4, !tbaa !9
  %42 = add nsw i32 %41, 1
  store i32 %42, ptr %10, align 4, !tbaa !9
  br label %16, !llvm.loop !38

43:                                               ; preds = %19
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN3sim15BufferInterface30getTileGraphicFogStartingIndexEii(ptr noundef nonnull align 8 dereferenceable(160), i32 noundef, i32 noundef) #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 = { 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 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = !{!14, !6, i64 8}
!14 = !{!"_ZTSN3sim15BufferInterfaceE", !15, i64 0, !6, i64 8, !6, i64 16, !16, i64 24}
!15 = !{!"_ZTSSt4pairIiiE", !10, i64 0, !10, i64 4}
!16 = !{!"_ZTSN3sim20TileGraphicTextCacheE", !17, i64 0, !17, i64 16, !15, i64 32, !19, i64 40, !28, i64 88}
!17 = !{!"_ZTSN3sim6MetersE", !18, i64 0}
!18 = !{!"_ZTSN3sim8DistanceE", !12, i64 8}
!19 = !{!"_ZTSSt3mapIcSt4pairIddESt4lessIcESaIS0_IKcS1_EEE", !20, i64 0}
!20 = !{!"_ZTSSt8_Rb_treeIcSt4pairIKcS0_IddEESt10_Select1stIS3_ESt4lessIcESaIS3_EE", !21, i64 0}
!21 = !{!"_ZTSNSt8_Rb_treeIcSt4pairIKcS0_IddEESt10_Select1stIS3_ESt4lessIcESaIS3_EE13_Rb_tree_implIS7_Lb1EEE", !22, i64 0, !24, i64 8}
!22 = !{!"_ZTSSt20_Rb_tree_key_compareISt4lessIcEE", !23, i64 0}
!23 = !{!"_ZTSSt4lessIcE"}
!24 = !{!"_ZTSSt15_Rb_tree_header", !25, i64 0, !27, i64 32}
!25 = !{!"_ZTSSt18_Rb_tree_node_base", !26, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!26 = !{!"_ZTSSt14_Rb_tree_color", !7, i64 0}
!27 = !{!"long", !7, i64 0}
!28 = !{!"_ZTSSt3mapISt4pairIS0_IiiES1_ES0_IN3sim9CartesianES4_ESt4lessIS2_ESaIS0_IKS2_S5_EEE", !29, i64 0}
!29 = !{!"_ZTSSt8_Rb_treeISt4pairIS0_IiiES1_ES0_IKS2_S0_IN3sim9CartesianES5_EESt10_Select1stIS7_ESt4lessIS2_ESaIS7_EE", !30, i64 0}
!30 = !{!"_ZTSNSt8_Rb_treeISt4pairIS0_IiiES1_ES0_IKS2_S0_IN3sim9CartesianES5_EESt10_Select1stIS7_ESt4lessIS2_ESaIS7_EE13_Rb_tree_implISB_Lb1EEE", !31, i64 0, !24, i64 8}
!31 = !{!"_ZTSSt20_Rb_tree_key_compareISt4lessISt4pairIS1_IiiES2_EEE", !32, i64 0}
!32 = !{!"_ZTSSt4lessISt4pairIS0_IiiES1_EE"}
!33 = !{!34, !12, i64 40}
!34 = !{!"_ZTSN3sim15TriangleGraphicE", !35, i64 0, !35, i64 48, !35, i64 96}
!35 = !{!"_ZTSN3sim13VertexGraphicE", !12, i64 0, !12, i64 8, !12, i64 16, !12, i64 24, !12, i64 32, !12, i64 40}
!36 = !{!34, !12, i64 88}
!37 = !{!34, !12, i64 136}
!38 = distinct !{!38, !39}
!39 = !{!"llvm.loop.mustprogress"}


; 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 uwtable
declare dso_local noundef nonnull align 8 dereferenceable(144) ptr @_ZNSt6vectorIN3sim15TriangleGraphicESaIS1_EE2atEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3sim15BufferInterface20updateTileGraphicFogEiid(ptr noundef nonnull align 8 dereferenceable(160) %0, i32 noundef %1, i32 noundef %2, double noundef %3) local_unnamed_addr #0 align 2 {
  %5 = tail call noundef i32 @_ZN3sim15BufferInterface30getTileGraphicFogStartingIndexEii(ptr noundef nonnull align 8 dereferenceable(160) %0, i32 noundef %1, i32 noundef %2)
  %6 = getelementptr inbounds i8, ptr %0, i64 8
  %7 = sext i32 %5 to i64
  %8 = load ptr, ptr %6, align 8, !tbaa !5
  %9 = tail call noundef nonnull align 8 dereferenceable(144) ptr @_ZNSt6vectorIN3sim15TriangleGraphicESaIS1_EE2atEm(ptr noundef nonnull align 8 dereferenceable(24) %8, i64 noundef %7)
  %10 = getelementptr inbounds i8, ptr %9, i64 40
  store double %3, ptr %10, align 8, !tbaa !30
  %11 = getelementptr inbounds i8, ptr %9, i64 88
  store double %3, ptr %11, align 8, !tbaa !33
  %12 = getelementptr inbounds i8, ptr %9, i64 136
  store double %3, ptr %12, align 8, !tbaa !34
  %13 = load ptr, ptr %6, align 8, !tbaa !5
  %14 = add nsw i64 %7, 1
  %15 = tail call noundef nonnull align 8 dereferenceable(144) ptr @_ZNSt6vectorIN3sim15TriangleGraphicESaIS1_EE2atEm(ptr noundef nonnull align 8 dereferenceable(24) %13, i64 noundef %14)
  %16 = getelementptr inbounds i8, ptr %15, i64 40
  store double %3, ptr %16, align 8, !tbaa !30
  %17 = getelementptr inbounds i8, ptr %15, i64 88
  store double %3, ptr %17, align 8, !tbaa !33
  %18 = getelementptr inbounds i8, ptr %15, i64 136
  store double %3, ptr %18, align 8, !tbaa !34
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN3sim15BufferInterface30getTileGraphicFogStartingIndexEii(ptr noundef nonnull align 8 dereferenceable(160), i32 noundef, i32 noundef) local_unnamed_addr #1 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 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, !11, i64 8}
!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"}
!30 = !{!31, !15, i64 40}
!31 = !{!"_ZTSN3sim15TriangleGraphicE", !32, i64 0, !32, i64 48, !32, i64 96}
!32 = !{!"_ZTSN3sim13VertexGraphicE", !15, i64 0, !15, i64 8, !15, i64 16, !15, i64 24, !15, i64 32, !15, i64 40}
!33 = !{!31, !15, i64 88}
!34 = !{!31, !15, i64 136}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass