; LLVM IR from jrouwe/JoltPhysics :: Samples/Tests/General (ChangeShapeTest)

; 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.Test::PreUpdateParams" = type { float, [12 x i8], %struct.CameraState }
%struct.CameraState = type <{ %"class.JPH::Vec3", %"class.JPH::Vec3", %"class.JPH::Vec3", float, [12 x i8] }>
%"class.JPH::Vec3" = type { %union.anon }
%union.anon = type { <4 x float> }
%class.ChangeShapeTest = type { %class.Test, i8, %"class.JPH::BodyID", %"class.JPH::Array", float, i32 }
%class.Test = type { ptr, ptr, ptr, ptr, ptr, ptr, i8, %"class.std::unordered_map" }
%"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 }
%"class.JPH::BodyID" = type { i32 }
%"class.JPH::Array" = type { i64, i64, 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: inlinehint mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZN3JPH5ArrayINS_8RefConstINS_5ShapeEEENS_12STLAllocatorIS3_EEEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #1 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN15ChangeShapeTest16PrePhysicsUpdateERKN4Test15PreUpdateParamsE(ptr noundef nonnull align 8 dereferenceable(152) %0, ptr noundef nonnull align 16 dereferenceable(80) %1) unnamed_addr #3 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca float, align 4
  %6 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %7 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  store float 3.000000e+00, ptr %5, align 4, !tbaa !9
  %8 = load ptr, ptr %4, align 8, !tbaa !5
  %9 = getelementptr inbounds %"class.Test::PreUpdateParams", ptr %8, i32 0, i32 0
  %10 = load float, ptr %9, align 16, !tbaa !11
  %11 = getelementptr inbounds %class.ChangeShapeTest, ptr %7, i32 0, i32 4
  %12 = load float, ptr %11, align 8, !tbaa !15
  %13 = fadd float %12, %10
  store float %13, ptr %11, align 8, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  %14 = getelementptr inbounds %class.ChangeShapeTest, ptr %7, i32 0, i32 4
  %15 = load float, ptr %14, align 8, !tbaa !15
  %16 = fdiv float %15, 3.000000e+00
  %17 = fptosi float %16 to i32
  %18 = sext i32 %17 to i64
  %19 = getelementptr inbounds %class.ChangeShapeTest, ptr %7, i32 0, i32 3
  %20 = call noundef i64 @_ZNK3JPH5ArrayINS_8RefConstINS_5ShapeEEENS_12STLAllocatorIS3_EEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %19)
  %21 = urem i64 %18, %20
  %22 = trunc i64 %21 to i32
  store i32 %22, ptr %6, align 4, !tbaa !27
  %23 = getelementptr inbounds %class.ChangeShapeTest, ptr %7, i32 0, i32 5
  %24 = load i32, ptr %23, align 4, !tbaa !28
  %25 = load i32, ptr %6, align 4, !tbaa !27
  %26 = icmp ne i32 %24, %25
  br i1 %26, label %27, label %44

27:                                               ; preds = %2
  %28 = load i32, ptr %6, align 4, !tbaa !27
  %29 = getelementptr inbounds %class.ChangeShapeTest, ptr %7, i32 0, i32 5
  store i32 %28, ptr %29, align 4, !tbaa !28
  %30 = getelementptr inbounds %class.Test, ptr %7, i32 0, i32 3
  %31 = load ptr, ptr %30, align 8, !tbaa !29
  %32 = getelementptr inbounds %class.ChangeShapeTest, ptr %7, i32 0, i32 2
  %33 = getelementptr inbounds %class.ChangeShapeTest, ptr %7, i32 0, i32 3
  %34 = getelementptr inbounds %class.ChangeShapeTest, ptr %7, i32 0, i32 5
  %35 = load i32, ptr %34, align 4, !tbaa !28
  %36 = sext i32 %35 to i64
  %37 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN3JPH5ArrayINS_8RefConstINS_5ShapeEEENS_12STLAllocatorIS3_EEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %33, i64 noundef %36)
  %38 = call noundef ptr @_ZNK3JPH8RefConstINS_5ShapeEEcvPKS1_Ev(ptr noundef nonnull align 8 dereferenceable(8) %37)
  %39 = getelementptr inbounds %class.ChangeShapeTest, ptr %7, i32 0, i32 1
  %40 = load i8, ptr %39, align 8, !tbaa !30, !range !31, !noundef !32
  %41 = trunc i8 %40 to i1
  %42 = zext i1 %41 to i64
  %43 = select i1 %41, i32 0, i32 1
  call void @_ZNK3JPH13BodyInterface8SetShapeERKNS_6BodyIDEPKNS_5ShapeEbNS_11EActivationE(ptr noundef nonnull align 8 dereferenceable(24) %31, ptr noundef nonnull align 4 dereferenceable(4) %32, ptr noundef %38, i1 noundef zeroext true, i32 noundef %43)
  br label %44

44:                                               ; preds = %27, %2
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  ret void
}

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

declare void @_ZNK3JPH13BodyInterface8SetShapeERKNS_6BodyIDEPKNS_5ShapeEbNS_11EActivationE(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 4 dereferenceable(4), ptr noundef, i1 noundef zeroext, i32 noundef) #4

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { inlinehint 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 = { 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 #4 = { "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 #5 = { 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 = !{!"float", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"_ZTSN4Test15PreUpdateParamsE", !10, i64 0, !13, i64 16}
!13 = !{!"_ZTS11CameraState", !14, i64 0, !14, i64 16, !14, i64 32, !10, i64 48}
!14 = !{!"_ZTSN3JPH4Vec3E", !7, i64 0}
!15 = !{!16, !10, i64 144}
!16 = !{!"_ZTS15ChangeShapeTest", !17, i64 0, !18, i64 112, !24, i64 116, !26, i64 120, !10, i64 144, !25, i64 148}
!17 = !{!"_ZTS4Test", !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !18, i64 48, !19, i64 56}
!18 = !{!"bool", !7, i64 0}
!19 = !{!"_ZTSSt13unordered_mapIN3JPH6BodyIDENSt7__cxx1112basic_stringIcSt11char_traitsIcENS0_12STLAllocatorIcEEEESt4hashIS1_ESt8equal_toIS1_ESaISt4pairIKS1_S8_EEE", !20, i64 0}
!20 = !{!"_ZTSSt10_HashtableIN3JPH6BodyIDESt4pairIKS1_NSt7__cxx1112basic_stringIcSt11char_traitsIcENS0_12STLAllocatorIcEEEEESaISB_ENSt8__detail10_Select1stESt8equal_toIS1_ESt4hashIS1_ENSD_18_Mod_range_hashingENSD_20_Default_ranged_hashENSD_20_Prime_rehash_policyENSD_17_Hashtable_traitsILb1ELb0ELb1EEEE", !6, i64 0, !21, i64 8, !22, i64 16, !21, i64 24, !23, i64 32, !6, i64 48}
!21 = !{!"long", !7, i64 0}
!22 = !{!"_ZTSNSt8__detail15_Hash_node_baseE", !6, i64 0}
!23 = !{!"_ZTSNSt8__detail20_Prime_rehash_policyE", !10, i64 0, !21, i64 8}
!24 = !{!"_ZTSN3JPH6BodyIDE", !25, i64 0}
!25 = !{!"int", !7, i64 0}
!26 = !{!"_ZTSN3JPH5ArrayINS_8RefConstINS_5ShapeEEENS_12STLAllocatorIS3_EEEE", !21, i64 0, !21, i64 8, !6, i64 16}
!27 = !{!25, !25, i64 0}
!28 = !{!16, !25, i64 148}
!29 = !{!17, !6, i64 24}
!30 = !{!16, !18, i64 112}
!31 = !{i8 0, i8 2}
!32 = !{}


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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN15ChangeShapeTest16PrePhysicsUpdateERKN4Test15PreUpdateParamsE(ptr noundef nonnull align 8 dereferenceable(152) %0, ptr nocapture noundef nonnull readonly align 16 dereferenceable(80) %1) unnamed_addr #2 align 2 {
  %3 = load float, ptr %1, align 16, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 144
  %5 = load float, ptr %4, align 8, !tbaa !12
  %6 = fadd float %3, %5
  store float %6, ptr %4, align 8, !tbaa !12
  %7 = fdiv float %6, 3.000000e+00
  %8 = fptosi float %7 to i32
  %9 = sext i32 %8 to i64
  %10 = getelementptr inbounds i8, ptr %0, i64 120
  %11 = tail call noundef i64 @_ZNK3JPH5ArrayINS_8RefConstINS_5ShapeEEENS_12STLAllocatorIS3_EEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %10)
  %12 = urem i64 %9, %11
  %13 = trunc i64 %12 to i32
  %14 = getelementptr inbounds i8, ptr %0, i64 148
  %15 = load i32, ptr %14, align 4, !tbaa !25
  %.not = icmp eq i32 %15, %13
  br i1 %.not, label %26, label %16

16:                                               ; preds = %2
  store i32 %13, ptr %14, align 4, !tbaa !25
  %17 = getelementptr inbounds i8, ptr %0, i64 24
  %18 = load ptr, ptr %17, align 8, !tbaa !26
  %19 = getelementptr inbounds i8, ptr %0, i64 116
  %sext = shl i64 %12, 32
  %20 = ashr exact i64 %sext, 32
  %21 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZN3JPH5ArrayINS_8RefConstINS_5ShapeEEENS_12STLAllocatorIS3_EEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %10, i64 noundef %20)
  %22 = tail call noundef ptr @_ZNK3JPH8RefConstINS_5ShapeEEcvPKS1_Ev(ptr noundef nonnull align 8 dereferenceable(8) %21)
  %23 = getelementptr inbounds i8, ptr %0, i64 112
  %24 = load i8, ptr %23, align 8, !tbaa !27, !range !28, !noundef !29
  %25 = xor i8 %24, 1
  %not. = zext nneg i8 %25 to i32
  tail call void @_ZNK3JPH13BodyInterface8SetShapeERKNS_6BodyIDEPKNS_5ShapeEbNS_11EActivationE(ptr noundef nonnull align 8 dereferenceable(24) %18, ptr noundef nonnull align 4 dereferenceable(4) %19, ptr noundef %22, i1 noundef zeroext true, i32 noundef %not.)
  br label %26

26:                                               ; preds = %16, %2
  ret void
}

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

declare void @_ZNK3JPH13BodyInterface8SetShapeERKNS_6BodyIDEPKNS_5ShapeEbNS_11EActivationE(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 4 dereferenceable(4), ptr noundef, i1 noundef zeroext, i32 noundef) local_unnamed_addr #3

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

!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 = !{!"_ZTSN4Test15PreUpdateParamsE", !7, i64 0, !10, i64 16}
!7 = !{!"float", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTS11CameraState", !11, i64 0, !11, i64 16, !11, i64 32, !7, i64 48}
!11 = !{!"_ZTSN3JPH4Vec3E", !8, i64 0}
!12 = !{!13, !7, i64 144}
!13 = !{!"_ZTS15ChangeShapeTest", !14, i64 0, !16, i64 112, !22, i64 116, !24, i64 120, !7, i64 144, !23, i64 148}
!14 = !{!"_ZTS4Test", !15, i64 8, !15, i64 16, !15, i64 24, !15, i64 32, !15, i64 40, !16, i64 48, !17, i64 56}
!15 = !{!"any pointer", !8, i64 0}
!16 = !{!"bool", !8, i64 0}
!17 = !{!"_ZTSSt13unordered_mapIN3JPH6BodyIDENSt7__cxx1112basic_stringIcSt11char_traitsIcENS0_12STLAllocatorIcEEEESt4hashIS1_ESt8equal_toIS1_ESaISt4pairIKS1_S8_EEE", !18, i64 0}
!18 = !{!"_ZTSSt10_HashtableIN3JPH6BodyIDESt4pairIKS1_NSt7__cxx1112basic_stringIcSt11char_traitsIcENS0_12STLAllocatorIcEEEEESaISB_ENSt8__detail10_Select1stESt8equal_toIS1_ESt4hashIS1_ENSD_18_Mod_range_hashingENSD_20_Default_ranged_hashENSD_20_Prime_rehash_policyENSD_17_Hashtable_traitsILb1ELb0ELb1EEEE", !15, i64 0, !19, i64 8, !20, i64 16, !19, i64 24, !21, i64 32, !15, i64 48}
!19 = !{!"long", !8, i64 0}
!20 = !{!"_ZTSNSt8__detail15_Hash_node_baseE", !15, i64 0}
!21 = !{!"_ZTSNSt8__detail20_Prime_rehash_policyE", !7, i64 0, !19, i64 8}
!22 = !{!"_ZTSN3JPH6BodyIDE", !23, i64 0}
!23 = !{!"int", !8, i64 0}
!24 = !{!"_ZTSN3JPH5ArrayINS_8RefConstINS_5ShapeEEENS_12STLAllocatorIS3_EEEE", !19, i64 0, !19, i64 8, !15, i64 16}
!25 = !{!13, !23, i64 148}
!26 = !{!14, !15, i64 24}
!27 = !{!13, !16, i64 112}
!28 = !{i8 0, i8 2}
!29 = !{}


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