; LLVM IR from jrouwe/JoltPhysics :: Jolt/ObjectStream/SerializableObject.ll (ZN3JPH13GetRTTIOfTypeEPNS_18SerializableObjectE)

; 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.JPH::RTTI" = type { ptr, i32, [4 x i8], %"class.JPH::StaticArray", ptr, ptr }
%"class.JPH::StaticArray" = type { i32, [4 x i8], [4 x %"struct.JPH::StaticArray<JPH::RTTI::BaseClass, 4>::Storage"] }
%"struct.JPH::StaticArray<JPH::RTTI::BaseClass, 4>::Storage" = type { [16 x i8] }
%class.anon = type { i8 }

@_ZZN3JPH13GetRTTIOfTypeEPNS_18SerializableObjectEE4rtti = external hidden global %"class.JPH::RTTI", align 8
@_ZGVZN3JPH13GetRTTIOfTypeEPNS_18SerializableObjectEE4rtti = external hidden global i64, align 8
@.str = external hidden unnamed_addr constant [19 x i8], align 1
@__dso_handle = external hidden global i8

; Function Attrs: nounwind
declare i32 @__cxa_guard_acquire(ptr) #0

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

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: nounwind
declare void @__cxa_guard_abort(ptr) #0

; Function Attrs: nounwind
declare void @__cxa_guard_release(ptr) #0

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN3JPH13GetRTTIOfTypeEPNS_18SerializableObjectE(ptr noundef %0) #2 personality ptr @__gxx_personality_v0 {
  %2 = alloca ptr, align 8
  %3 = alloca %class.anon, align 1
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %6 = load atomic i8, ptr @_ZGVZN3JPH13GetRTTIOfTypeEPNS_18SerializableObjectEE4rtti acquire, align 8
  %7 = icmp eq i8 %6, 0
  br i1 %7, label %8, label %15, !prof !9

8:                                                ; preds = %1
  %9 = call i32 @__cxa_guard_acquire(ptr @_ZGVZN3JPH13GetRTTIOfTypeEPNS_18SerializableObjectEE4rtti) #0
  %10 = icmp ne i32 %9, 0
  br i1 %10, label %11, label %15

11:                                               ; preds = %8
  call void @llvm.lifetime.start.p0(i64 1, ptr %3) #0
  %12 = call noundef ptr @"_ZZN3JPH13GetRTTIOfTypeEPNS_18SerializableObjectEENK3$_0cvPFvPvEEv"(ptr noundef nonnull align 1 dereferenceable(1) %3) #0
  invoke void @_ZN3JPH4RTTIC1EPKciPFPvvEPFvS3_EPFvRS0_E(ptr noundef nonnull align 8 dereferenceable(104) @_ZZN3JPH13GetRTTIOfTypeEPNS_18SerializableObjectEE4rtti, ptr noundef @.str, i32 noundef 8, ptr noundef null, ptr noundef %12, ptr noundef @_ZN3JPH18SerializableObject11sCreateRTTIERNS_4RTTIE)
          to label %13 unwind label %16

13:                                               ; preds = %11
  call void @llvm.lifetime.end.p0(i64 1, ptr %3) #0
  %14 = call i32 @__cxa_atexit(ptr @_ZN3JPH4RTTID2Ev, ptr @_ZZN3JPH13GetRTTIOfTypeEPNS_18SerializableObjectEE4rtti, ptr @__dso_handle) #0
  call void @__cxa_guard_release(ptr @_ZGVZN3JPH13GetRTTIOfTypeEPNS_18SerializableObjectEE4rtti) #0
  br label %15

15:                                               ; preds = %13, %8, %1
  ret ptr @_ZZN3JPH13GetRTTIOfTypeEPNS_18SerializableObjectEE4rtti

16:                                               ; preds = %11
  %17 = landingpad { ptr, i32 }
          cleanup
  %18 = extractvalue { ptr, i32 } %17, 0
  store ptr %18, ptr %4, align 8
  %19 = extractvalue { ptr, i32 } %17, 1
  store i32 %19, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 1, ptr %3) #0
  call void @__cxa_guard_abort(ptr @_ZGVZN3JPH13GetRTTIOfTypeEPNS_18SerializableObjectEE4rtti) #0
  br label %20

20:                                               ; preds = %16
  %21 = load ptr, ptr %4, align 8
  %22 = load i32, ptr %5, align 4
  %23 = insertvalue { ptr, i32 } poison, ptr %21, 0
  %24 = insertvalue { ptr, i32 } %23, i32 %22, 1
  resume { ptr, i32 } %24
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden noundef ptr @"_ZZN3JPH13GetRTTIOfTypeEPNS_18SerializableObjectEENK3$_0cvPFvPvEEv"(ptr noundef nonnull align 1 dereferenceable(1)) #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3JPH18SerializableObject11sCreateRTTIERNS_4RTTIE(ptr noundef nonnull align 8 dereferenceable(104)) #4 align 2

declare void @_ZN3JPH4RTTIC1EPKciPFPvvEPFvS3_EPFvRS0_E(ptr noundef nonnull align 8 dereferenceable(104), ptr noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef) unnamed_addr #5

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN3JPH4RTTID2Ev(ptr noundef nonnull align 8 dereferenceable(104)) unnamed_addr #3 align 2

; Function Attrs: nounwind
declare i32 @__cxa_atexit(ptr, ptr, ptr) #0

attributes #0 = { nounwind }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #4 = { 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 #5 = { "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 = !{!"branch_weights", i32 1, i32 1048575}


; 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.JPH::RTTI" = type { ptr, i32, [4 x i8], %"class.JPH::StaticArray", ptr, ptr }
%"class.JPH::StaticArray" = type { i32, [4 x i8], [4 x %"struct.JPH::StaticArray<JPH::RTTI::BaseClass, 4>::Storage"] }
%"struct.JPH::StaticArray<JPH::RTTI::BaseClass, 4>::Storage" = type { [16 x i8] }
%class.anon = type { i8 }

@_ZZN3JPH13GetRTTIOfTypeEPNS_18SerializableObjectEE4rtti = external hidden global %"class.JPH::RTTI", align 8
@_ZGVZN3JPH13GetRTTIOfTypeEPNS_18SerializableObjectEE4rtti = external hidden global i64, align 8
@.str = external hidden unnamed_addr constant [19 x i8], align 1
@__dso_handle = external hidden global i8

; Function Attrs: nofree nounwind
declare i32 @__cxa_guard_acquire(ptr) local_unnamed_addr #0

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

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: nofree nounwind
declare void @__cxa_guard_abort(ptr) local_unnamed_addr #0

; Function Attrs: nofree nounwind
declare void @__cxa_guard_release(ptr) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local noundef nonnull ptr @_ZN3JPH13GetRTTIOfTypeEPNS_18SerializableObjectE(ptr nocapture noundef readnone %0) local_unnamed_addr #2 personality ptr @__gxx_personality_v0 {
  %2 = alloca %class.anon, align 1
  %3 = load atomic i8, ptr @_ZGVZN3JPH13GetRTTIOfTypeEPNS_18SerializableObjectEE4rtti acquire, align 8
  %4 = icmp eq i8 %3, 0
  br i1 %4, label %5, label %11, !prof !5

5:                                                ; preds = %1
  %6 = tail call i32 @__cxa_guard_acquire(ptr nonnull @_ZGVZN3JPH13GetRTTIOfTypeEPNS_18SerializableObjectEE4rtti) #6
  %.not = icmp eq i32 %6, 0
  br i1 %.not, label %11, label %7

7:                                                ; preds = %5
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %2) #6
  %8 = call noundef ptr @"_ZZN3JPH13GetRTTIOfTypeEPNS_18SerializableObjectEENK3$_0cvPFvPvEEv"(ptr noundef nonnull align 1 dereferenceable(1) %2) #6
  invoke void @_ZN3JPH4RTTIC1EPKciPFPvvEPFvS3_EPFvRS0_E(ptr noundef nonnull align 8 dereferenceable(104) @_ZZN3JPH13GetRTTIOfTypeEPNS_18SerializableObjectEE4rtti, ptr noundef nonnull @.str, i32 noundef 8, ptr noundef null, ptr noundef %8, ptr noundef nonnull @_ZN3JPH18SerializableObject11sCreateRTTIERNS_4RTTIE)
          to label %9 unwind label %12

9:                                                ; preds = %7
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %2) #6
  %10 = call i32 @__cxa_atexit(ptr nonnull @_ZN3JPH4RTTID2Ev, ptr nonnull @_ZZN3JPH13GetRTTIOfTypeEPNS_18SerializableObjectEE4rtti, ptr nonnull @__dso_handle) #6
  call void @__cxa_guard_release(ptr nonnull @_ZGVZN3JPH13GetRTTIOfTypeEPNS_18SerializableObjectEE4rtti) #6
  br label %11

11:                                               ; preds = %9, %5, %1
  ret ptr @_ZZN3JPH13GetRTTIOfTypeEPNS_18SerializableObjectEE4rtti

12:                                               ; preds = %7
  %13 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %2) #6
  call void @__cxa_guard_abort(ptr nonnull @_ZGVZN3JPH13GetRTTIOfTypeEPNS_18SerializableObjectEE4rtti) #6
  resume { ptr, i32 } %13
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden noundef ptr @"_ZZN3JPH13GetRTTIOfTypeEPNS_18SerializableObjectEENK3$_0cvPFvPvEEv"(ptr noundef nonnull align 1 dereferenceable(1)) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3JPH18SerializableObject11sCreateRTTIERNS_4RTTIE(ptr noundef nonnull align 8 dereferenceable(104)) #4 align 2

declare void @_ZN3JPH4RTTIC1EPKciPFPvvEPFvS3_EPFvRS0_E(ptr noundef nonnull align 8 dereferenceable(104), ptr noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef) unnamed_addr #5

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN3JPH4RTTID2Ev(ptr noundef nonnull align 8 dereferenceable(104)) unnamed_addr #3 align 2

; Function Attrs: nofree nounwind
declare i32 @__cxa_atexit(ptr, ptr, ptr) local_unnamed_addr #0

attributes #0 = { nofree nounwind }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #4 = { 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 #5 = { "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 #6 = { 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 = !{!"branch_weights", i32 1, i32 1048575}


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