; LLVM IR from Sopiro/Muli :: src/dynamics/collider.ll (ZN4muli8Collider7DestroyEPNS_9AllocatorE)

; 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.muli::Collider" = type <{ ptr, ptr, ptr, ptr, ptr, float, %"struct.muli::Material", %"struct.muli::CollisionFilter", i32, i8, [3 x i8] }>
%"struct.muli::Material" = type { float, float, float, float }
%"struct.muli::CollisionFilter" = type { i32, i32, i32 }

@.str = external hidden unnamed_addr constant [6 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [71 x i8], align 1
@__PRETTY_FUNCTION__._ZN4muli8Collider7DestroyEPNS_9AllocatorE = external hidden unnamed_addr constant [42 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4muli8Collider7DestroyEPNS_9AllocatorE(ptr noundef nonnull align 8 dereferenceable(77) %0, ptr noundef %1) #0 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %5 = load ptr, ptr %3, align 8
  %6 = getelementptr inbounds %"class.muli::Collider", ptr %5, i32 0, i32 4
  %7 = load ptr, ptr %6, align 8, !tbaa !9
  %8 = load ptr, ptr %7, align 8, !tbaa !16
  %9 = getelementptr inbounds ptr, ptr %8, i64 0
  %10 = load ptr, ptr %9, align 8
  call void %10(ptr noundef nonnull align 8 dereferenceable(28) %7) #3
  %11 = getelementptr inbounds %"class.muli::Collider", ptr %5, i32 0, i32 4
  %12 = load ptr, ptr %11, align 8, !tbaa !9
  %13 = call noundef i32 @_ZNK4muli5Shape7GetTypeEv(ptr noundef nonnull align 8 dereferenceable(28) %12)
  switch i32 %13, label %35 [
    i32 0, label %14
    i32 1, label %21
    i32 2, label %28
  ]

14:                                               ; preds = %2
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = getelementptr inbounds %"class.muli::Collider", ptr %5, i32 0, i32 4
  %17 = load ptr, ptr %16, align 8, !tbaa !9
  %18 = load ptr, ptr %15, align 8, !tbaa !16
  %19 = getelementptr inbounds ptr, ptr %18, i64 3
  %20 = load ptr, ptr %19, align 8
  call void %20(ptr noundef nonnull align 8 dereferenceable(8) %15, ptr noundef %17, i32 noundef 32)
  br label %36

21:                                               ; preds = %2
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  %23 = getelementptr inbounds %"class.muli::Collider", ptr %5, i32 0, i32 4
  %24 = load ptr, ptr %23, align 8, !tbaa !9
  %25 = load ptr, ptr %22, align 8, !tbaa !16
  %26 = getelementptr inbounds ptr, ptr %25, i64 3
  %27 = load ptr, ptr %26, align 8
  call void %27(ptr noundef nonnull align 8 dereferenceable(8) %22, ptr noundef %24, i32 noundef 48)
  br label %36

28:                                               ; preds = %2
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  %30 = getelementptr inbounds %"class.muli::Collider", ptr %5, i32 0, i32 4
  %31 = load ptr, ptr %30, align 8, !tbaa !9
  %32 = load ptr, ptr %29, align 8, !tbaa !16
  %33 = getelementptr inbounds ptr, ptr %32, i64 3
  %34 = load ptr, ptr %33, align 8
  call void %34(ptr noundef nonnull align 8 dereferenceable(8) %29, ptr noundef %31, i32 noundef 184)
  br label %36

35:                                               ; preds = %2
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.2, i32 noundef 59, ptr noundef @__PRETTY_FUNCTION__._ZN4muli8Collider7DestroyEPNS_9AllocatorE) #4
  unreachable

36:                                               ; preds = %28, %21, %14
  %37 = getelementptr inbounds %"class.muli::Collider", ptr %5, i32 0, i32 4
  store ptr null, ptr %37, align 8, !tbaa !9
  ret void
}

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

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #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 = { 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 = { noreturn nounwind "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 }
attributes #4 = { noreturn 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 32}
!10 = !{!"_ZTSN4muli8ColliderE", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !11, i64 40, !12, i64 44, !13, i64 60, !14, i64 72, !15, i64 76}
!11 = !{!"float", !7, i64 0}
!12 = !{!"_ZTSN4muli8MaterialE", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12}
!13 = !{!"_ZTSN4muli15CollisionFilterE", !14, i64 0, !14, i64 4, !14, i64 8}
!14 = !{!"int", !7, i64 0}
!15 = !{!"bool", !7, i64 0}
!16 = !{!17, !17, i64 0}
!17 = !{!"vtable pointer", !8, 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"

@.str = external hidden unnamed_addr constant [6 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [71 x i8], align 1
@__PRETTY_FUNCTION__._ZN4muli8Collider7DestroyEPNS_9AllocatorE = external hidden unnamed_addr constant [42 x i8], align 1
@switch.table._ZN4muli8Collider7DestroyEPNS_9AllocatorE = private unnamed_addr constant [3 x i32] [i32 32, i32 48, i32 184], align 4

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4muli8Collider7DestroyEPNS_9AllocatorE(ptr nocapture noundef nonnull align 8 dereferenceable(77) %0, ptr noundef %1) local_unnamed_addr #0 align 2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 32
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %5 = load ptr, ptr %4, align 8, !tbaa !15
  %6 = load ptr, ptr %5, align 8
  tail call void %6(ptr noundef nonnull align 8 dereferenceable(28) %4) #3
  %7 = load ptr, ptr %3, align 8, !tbaa !5
  %8 = tail call noundef i32 @_ZNK4muli5Shape7GetTypeEv(ptr noundef nonnull align 8 dereferenceable(28) %7)
  %9 = icmp ult i32 %8, 3
  br i1 %9, label %switch.lookup, label %10

10:                                               ; preds = %2
  tail call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.2, i32 noundef 59, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN4muli8Collider7DestroyEPNS_9AllocatorE) #4
  unreachable

switch.lookup:                                    ; preds = %2
  %11 = zext nneg i32 %8 to i64
  %switch.gep = getelementptr inbounds [3 x i32], ptr @switch.table._ZN4muli8Collider7DestroyEPNS_9AllocatorE, i64 0, i64 %11
  %switch.load = load i32, ptr %switch.gep, align 4
  %12 = load ptr, ptr %3, align 8, !tbaa !5
  %13 = load ptr, ptr %1, align 8, !tbaa !15
  %14 = getelementptr inbounds i8, ptr %13, i64 24
  %15 = load ptr, ptr %14, align 8
  tail call void %15(ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef %12, i32 noundef %switch.load)
  store ptr null, ptr %3, align 8, !tbaa !5
  ret void
}

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

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #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 = { 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 = { noreturn nounwind "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 }
attributes #4 = { noreturn 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, !7, i64 32}
!6 = !{!"_ZTSN4muli8ColliderE", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !10, i64 40, !11, i64 44, !12, i64 60, !13, i64 72, !14, i64 76}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"float", !8, i64 0}
!11 = !{!"_ZTSN4muli8MaterialE", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12}
!12 = !{!"_ZTSN4muli15CollisionFilterE", !13, i64 0, !13, i64 4, !13, i64 8}
!13 = !{!"int", !8, i64 0}
!14 = !{!"bool", !8, i64 0}
!15 = !{!16, !16, i64 0}
!16 = !{!"vtable pointer", !9, i64 0}


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