; LLVM IR from Sonryle/JoePhys :: JoePhys/src/World.ll (ZN5World20HashKeyToChunkCoordsElPfS0_)

; 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.World = type <{ %"class.std::vector", %"class.std::unordered_map", i32, i32, %struct.vec2, float, [4 x i8] }>
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<Cluster *, std::allocator<Cluster *>>::_Vector_impl" }
%"struct.std::_Vector_base<Cluster *, std::allocator<Cluster *>>::_Vector_impl" = type { %"struct.std::_Vector_base<Cluster *, std::allocator<Cluster *>>::_Vector_impl_data" }
%"struct.std::_Vector_base<Cluster *, std::allocator<Cluster *>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::unordered_map" = type { %"class.std::_Hashtable" }
%"class.std::_Hashtable" = type { ptr, i64, %"struct.std::__detail::_Hash_node_base", i64, %"struct.std::__detail::_Prime_rehash_policy", ptr }
%"struct.std::__detail::_Hash_node_base" = type { ptr }
%"struct.std::__detail::_Prime_rehash_policy" = type { float, i64 }
%struct.vec2 = type { float, float }

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN5World20HashKeyToChunkCoordsElPfS0_(ptr noundef nonnull align 8 dereferenceable(100) %0, i64 noundef %1, ptr noundef %2, ptr noundef %3) #0 align 2 {
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i64 %1, ptr %6, align 8, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !5
  store ptr %3, ptr %8, align 8, !tbaa !5
  %9 = load ptr, ptr %5, align 8
  %10 = load i64, ptr %6, align 8, !tbaa !9
  %11 = ashr i64 %10, 32
  %12 = trunc i64 %11 to i32
  %13 = sitofp i32 %12 to float
  %14 = getelementptr inbounds %struct.World, ptr %9, i32 0, i32 5
  %15 = load float, ptr %14, align 8, !tbaa !11
  %16 = fmul float %13, %15
  %17 = load ptr, ptr %7, align 8, !tbaa !5
  store float %16, ptr %17, align 4, !tbaa !24
  %18 = load i64, ptr %6, align 8, !tbaa !9
  %19 = trunc i64 %18 to i32
  %20 = sitofp i32 %19 to float
  %21 = getelementptr inbounds %struct.World, ptr %9, i32 0, i32 5
  %22 = load float, ptr %21, align 8, !tbaa !11
  %23 = fmul float %20, %22
  %24 = load ptr, ptr %8, align 8, !tbaa !5
  store float %23, ptr %24, align 4, !tbaa !24
  ret void
}

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

!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 = !{!"long", !7, i64 0}
!11 = !{!12, !21, i64 96}
!12 = !{!"_ZTS5World", !13, i64 0, !17, i64 24, !22, i64 80, !22, i64 84, !23, i64 88, !21, i64 96}
!13 = !{!"_ZTSSt6vectorIP7ClusterSaIS1_EE", !14, i64 0}
!14 = !{!"_ZTSSt12_Vector_baseIP7ClusterSaIS1_EE", !15, i64 0}
!15 = !{!"_ZTSNSt12_Vector_baseIP7ClusterSaIS1_EE12_Vector_implE", !16, i64 0}
!16 = !{!"_ZTSNSt12_Vector_baseIP7ClusterSaIS1_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!17 = !{!"_ZTSSt13unordered_mapIlSt6vectorIP8ParticleSaIS2_EESt4hashIlESt8equal_toIlESaISt4pairIKlS4_EEE", !18, i64 0}
!18 = !{!"_ZTSSt10_HashtableIlSt4pairIKlSt6vectorIP8ParticleSaIS4_EEESaIS7_ENSt8__detail10_Select1stESt8equal_toIlESt4hashIlENS9_18_Mod_range_hashingENS9_20_Default_ranged_hashENS9_20_Prime_rehash_policyENS9_17_Hashtable_traitsILb0ELb0ELb1EEEE", !6, i64 0, !10, i64 8, !19, i64 16, !10, i64 24, !20, i64 32, !6, i64 48}
!19 = !{!"_ZTSNSt8__detail15_Hash_node_baseE", !6, i64 0}
!20 = !{!"_ZTSNSt8__detail20_Prime_rehash_policyE", !21, i64 0, !10, i64 8}
!21 = !{!"float", !7, i64 0}
!22 = !{!"int", !7, i64 0}
!23 = !{!"_ZTS4vec2", !21, i64 0, !21, i64 4}
!24 = !{!21, !21, 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 nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable
define dso_local void @_ZN5World20HashKeyToChunkCoordsElPfS0_(ptr nocapture noundef nonnull readonly align 8 dereferenceable(100) %0, i64 noundef %1, ptr nocapture noundef writeonly %2, ptr nocapture noundef writeonly %3) local_unnamed_addr #0 align 2 {
  %5 = lshr i64 %1, 32
  %6 = trunc nuw i64 %5 to i32
  %7 = sitofp i32 %6 to float
  %8 = getelementptr inbounds i8, ptr %0, i64 96
  %9 = load float, ptr %8, align 8, !tbaa !5
  %10 = fmul float %9, %7
  store float %10, ptr %2, align 4, !tbaa !22
  %11 = trunc i64 %1 to i32
  %12 = sitofp i32 %11 to float
  %13 = load float, ptr %8, align 8, !tbaa !5
  %14 = fmul float %13, %12
  store float %14, ptr %3, align 4, !tbaa !22
  ret void
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) 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, !19, i64 96}
!6 = !{!"_ZTS5World", !7, i64 0, !14, i64 24, !20, i64 80, !20, i64 84, !21, i64 88, !19, i64 96}
!7 = !{!"_ZTSSt6vectorIP7ClusterSaIS1_EE", !8, i64 0}
!8 = !{!"_ZTSSt12_Vector_baseIP7ClusterSaIS1_EE", !9, i64 0}
!9 = !{!"_ZTSNSt12_Vector_baseIP7ClusterSaIS1_EE12_Vector_implE", !10, i64 0}
!10 = !{!"_ZTSNSt12_Vector_baseIP7ClusterSaIS1_EE17_Vector_impl_dataE", !11, i64 0, !11, i64 8, !11, i64 16}
!11 = !{!"any pointer", !12, i64 0}
!12 = !{!"omnipotent char", !13, i64 0}
!13 = !{!"Simple C++ TBAA"}
!14 = !{!"_ZTSSt13unordered_mapIlSt6vectorIP8ParticleSaIS2_EESt4hashIlESt8equal_toIlESaISt4pairIKlS4_EEE", !15, i64 0}
!15 = !{!"_ZTSSt10_HashtableIlSt4pairIKlSt6vectorIP8ParticleSaIS4_EEESaIS7_ENSt8__detail10_Select1stESt8equal_toIlESt4hashIlENS9_18_Mod_range_hashingENS9_20_Default_ranged_hashENS9_20_Prime_rehash_policyENS9_17_Hashtable_traitsILb0ELb0ELb1EEEE", !11, i64 0, !16, i64 8, !17, i64 16, !16, i64 24, !18, i64 32, !11, i64 48}
!16 = !{!"long", !12, i64 0}
!17 = !{!"_ZTSNSt8__detail15_Hash_node_baseE", !11, i64 0}
!18 = !{!"_ZTSNSt8__detail20_Prime_rehash_policyE", !19, i64 0, !16, i64 8}
!19 = !{!"float", !12, i64 0}
!20 = !{!"int", !12, i64 0}
!21 = !{!"_ZTS4vec2", !19, i64 0, !19, i64 4}
!22 = !{!19, !19, i64 0}


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