; LLVM IR from zig-gamedev/zphysics :: libs/JoltC (JoltPhysicsC)

; 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.PhysicsSystemData = type { i64, ptr }
%class.ContactListener = type { %"class.JPH::ContactListener", ptr }
%"class.JPH::ContactListener" = type { ptr }

@_ZN3JPH8AllocateE = external global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [82 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [41 x i8], align 1
@__PRETTY_FUNCTION__.JPC_PhysicsSystem_SetContactListener = external hidden unnamed_addr constant [71 x i8], align 1

; 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: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #1

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef ptr @_ZL5toJphP17JPC_PhysicsSystem(ptr noundef) #3

; Function Attrs: mustprogress uwtable
define dso_local void @JPC_PhysicsSystem_SetContactListener(ptr noundef %0, ptr noundef %1) #4 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %6 = load ptr, ptr %4, align 8, !tbaa !5
  %7 = icmp eq ptr %6, null
  br i1 %7, label %8, label %11

8:                                                ; preds = %2
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = call noundef ptr @_ZL5toJphP17JPC_PhysicsSystem(ptr noundef %9)
  call void @_ZN3JPH13PhysicsSystem18SetContactListenerEPNS_15ContactListenerE(ptr noundef nonnull align 16 dereferenceable(1140) %10, ptr noundef null)
  br label %45

11:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #6
  %12 = load ptr, ptr %3, align 8, !tbaa !5
  %13 = getelementptr inbounds i8, ptr %12, i64 1152
  store ptr %13, ptr %5, align 8, !tbaa !5
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.PhysicsSystemData, ptr %14, i32 0, i32 0
  %16 = load i64, ptr %15, align 8, !tbaa !9
  %17 = icmp eq i64 %16, -4548986510646525730
  br i1 %17, label %18, label %19

18:                                               ; preds = %11
  br label %21

19:                                               ; preds = %11
  call void @__assert_fail(ptr noundef @.str.10, ptr noundef @.str.1, i32 noundef 1021, ptr noundef @__PRETTY_FUNCTION__.JPC_PhysicsSystem_SetContactListener) #7
  unreachable

20:                                               ; No predecessors!
  br label %21

21:                                               ; preds = %20, %18
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.PhysicsSystemData, ptr %22, i32 0, i32 1
  %24 = load ptr, ptr %23, align 8, !tbaa !12
  %25 = icmp eq ptr %24, null
  br i1 %25, label %26, label %34

26:                                               ; preds = %21
  %27 = load ptr, ptr @_ZN3JPH8AllocateE, align 8, !tbaa !5
  %28 = call noundef ptr %27(i64 noundef 16)
  %29 = load ptr, ptr %5, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.PhysicsSystemData, ptr %29, i32 0, i32 1
  store ptr %28, ptr %30, align 8, !tbaa !12
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.PhysicsSystemData, ptr %31, i32 0, i32 1
  %33 = load ptr, ptr %32, align 8, !tbaa !12
  call void @llvm.memset.p0.i64(ptr align 8 %33, i8 0, i64 16, i1 false)
  call void @_ZN15ContactListenerC2Ev(ptr noundef nonnull align 8 dereferenceable(16) %33) #6
  br label %34

34:                                               ; preds = %26, %21
  %35 = load ptr, ptr %3, align 8, !tbaa !5
  %36 = call noundef ptr @_ZL5toJphP17JPC_PhysicsSystem(ptr noundef %35)
  %37 = load ptr, ptr %5, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.PhysicsSystemData, ptr %37, i32 0, i32 1
  %39 = load ptr, ptr %38, align 8, !tbaa !12
  call void @_ZN3JPH13PhysicsSystem18SetContactListenerEPNS_15ContactListenerE(ptr noundef nonnull align 16 dereferenceable(1140) %36, ptr noundef %39)
  %40 = load ptr, ptr %4, align 8, !tbaa !5
  %41 = load ptr, ptr %5, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.PhysicsSystemData, ptr %41, i32 0, i32 1
  %43 = load ptr, ptr %42, align 8, !tbaa !12
  %44 = getelementptr inbounds %class.ContactListener, ptr %43, i32 0, i32 1
  store ptr %40, ptr %44, align 8, !tbaa !13
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  br label %45

45:                                               ; preds = %34, %8
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3JPH13PhysicsSystem18SetContactListenerEPNS_15ContactListenerE(ptr noundef nonnull align 16 dereferenceable(1140), ptr noundef) #4 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN15ContactListenerC2Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #5 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { 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 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 = { 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 #6 = { nounwind }
attributes #7 = { 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, !11, i64 0}
!10 = !{!"_ZTS17PhysicsSystemData", !11, i64 0, !6, i64 8}
!11 = !{!"long", !7, i64 0}
!12 = !{!10, !6, i64 8}
!13 = !{!14, !6, i64 8}
!14 = !{!"_ZTS15ContactListener", !15, i64 0, !6, i64 8}
!15 = !{!"_ZTSN3JPH15ContactListenerE"}


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

@_ZN3JPH8AllocateE = external local_unnamed_addr global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [82 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [41 x i8], align 1
@__PRETTY_FUNCTION__.JPC_PhysicsSystem_SetContactListener = external hidden unnamed_addr constant [71 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef ptr @_ZL5toJphP17JPC_PhysicsSystem(ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
define dso_local void @JPC_PhysicsSystem_SetContactListener(ptr noundef %0, ptr noundef %1) local_unnamed_addr #3 {
  %3 = icmp eq ptr %1, null
  br i1 %3, label %4, label %6

4:                                                ; preds = %2
  %5 = tail call noundef ptr @_ZL5toJphP17JPC_PhysicsSystem(ptr noundef %0)
  tail call void @_ZN3JPH13PhysicsSystem18SetContactListenerEPNS_15ContactListenerE(ptr noundef nonnull align 16 dereferenceable(1140) %5, ptr noundef null)
  br label %23

6:                                                ; preds = %2
  %7 = getelementptr inbounds i8, ptr %0, i64 1152
  %8 = load i64, ptr %7, align 8, !tbaa !5
  %9 = icmp eq i64 %8, -4548986510646525730
  br i1 %9, label %11, label %10

10:                                               ; preds = %6
  tail call void @__assert_fail(ptr noundef nonnull @.str.10, ptr noundef nonnull @.str.1, i32 noundef 1021, ptr noundef nonnull @__PRETTY_FUNCTION__.JPC_PhysicsSystem_SetContactListener) #5
  unreachable

11:                                               ; preds = %6
  %12 = getelementptr inbounds i8, ptr %0, i64 1160
  %13 = load ptr, ptr %12, align 8, !tbaa !11
  %14 = icmp eq ptr %13, null
  br i1 %14, label %15, label %18

15:                                               ; preds = %11
  %16 = load ptr, ptr @_ZN3JPH8AllocateE, align 8, !tbaa !12
  %17 = tail call noundef ptr %16(i64 noundef 16)
  store ptr %17, ptr %12, align 8, !tbaa !11
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %17, i8 0, i64 16, i1 false)
  tail call void @_ZN15ContactListenerC2Ev(ptr noundef nonnull align 8 dereferenceable(16) %17) #6
  br label %18

18:                                               ; preds = %15, %11
  %19 = tail call noundef ptr @_ZL5toJphP17JPC_PhysicsSystem(ptr noundef nonnull %0)
  %20 = load ptr, ptr %12, align 8, !tbaa !11
  tail call void @_ZN3JPH13PhysicsSystem18SetContactListenerEPNS_15ContactListenerE(ptr noundef nonnull align 16 dereferenceable(1140) %19, ptr noundef %20)
  %21 = load ptr, ptr %12, align 8, !tbaa !11
  %22 = getelementptr inbounds i8, ptr %21, i64 8
  store ptr %1, ptr %22, align 8, !tbaa !13
  br label %23

23:                                               ; preds = %18, %4
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3JPH13PhysicsSystem18SetContactListenerEPNS_15ContactListenerE(ptr noundef nonnull align 16 dereferenceable(1140), ptr noundef) local_unnamed_addr #3 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN15ContactListenerC2Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #4 align 2

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
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 = { 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 = { 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 #5 = { noreturn nounwind }
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 = !{!6, !7, i64 0}
!6 = !{!"_ZTS17PhysicsSystemData", !7, i64 0, !10, i64 8}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !10, i64 8}
!12 = !{!10, !10, i64 0}
!13 = !{!14, !10, i64 8}
!14 = !{!"_ZTS15ContactListener", !15, i64 0, !10, i64 8}
!15 = !{!"_ZTSN3JPH15ContactListenerE"}


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