; LLVM IR from jrouwe/JoltPhysics :: Jolt/Physics (LargeIslandSplitter)

; 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.JPH::AssertLastParam" = type { i8 }
%"class.JPH::LargeIslandSplitter" = type <{ i32, [4 x i8], ptr, ptr, ptr, i32, %"struct.std::atomic.0", i32, [4 x i8], ptr, %"struct.std::atomic.0", [4 x i8] }>
%"struct.std::atomic.0" = type { %"struct.std::__atomic_base.1" }
%"struct.std::__atomic_base.1" = type { i32 }

@.str.1 = external hidden unnamed_addr constant [89 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [88 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [64 x i8], align 1

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef, ptr noundef, i32 noundef) #0

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local void @_ZNSt13__atomic_baseIjE5storeEjSt12memory_order(ptr noundef nonnull align 4 dereferenceable(4), i32 noundef, i32 noundef) #1 align 2

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNKSt13__atomic_baseIjE4loadESt12memory_order(ptr noundef nonnull align 4 dereferenceable(4), i32 noundef) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3JPH19LargeIslandSplitter5ResetEPNS_13TempAllocatorE(ptr noundef nonnull align 8 dereferenceable(60) %0, ptr noundef %1) #2 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca %"struct.JPH::AssertLastParam", align 1
  %6 = alloca %"struct.JPH::AssertLastParam", align 1
  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
  br label %8

8:                                                ; preds = %2
  %9 = getelementptr inbounds %"class.JPH::LargeIslandSplitter", ptr %7, i32 0, i32 6
  %10 = call noundef i32 @_ZNKSt13__atomic_baseIjE4loadESt12memory_order(ptr noundef nonnull align 4 dereferenceable(4) %9, i32 noundef 0) #3
  %11 = getelementptr inbounds %"class.JPH::LargeIslandSplitter", ptr %7, i32 0, i32 5
  %12 = load i32, ptr %11, align 8, !tbaa !9
  %13 = icmp eq i32 %10, %12
  br i1 %13, label %17, label %14

14:                                               ; preds = %8
  %15 = call noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef @.str.18, ptr noundef @.str.1, i32 noundef 546)
  br i1 %15, label %16, label %17

16:                                               ; preds = %14
  call void asm sideeffect "int $$0x3", "~{dirflag},~{fpsr},~{flags}"() #3, !srcloc !14
  br label %17

17:                                               ; preds = %16, %14, %8
  br label %18

18:                                               ; preds = %17
  br label %19

19:                                               ; preds = %18
  %20 = getelementptr inbounds %"class.JPH::LargeIslandSplitter", ptr %7, i32 0, i32 10
  %21 = call noundef i32 @_ZNKSt13__atomic_baseIjE4loadESt12memory_order(ptr noundef nonnull align 4 dereferenceable(4) %20, i32 noundef 0) #3
  %22 = getelementptr inbounds %"class.JPH::LargeIslandSplitter", ptr %7, i32 0, i32 7
  %23 = load i32, ptr %22, align 8, !tbaa !15
  %24 = icmp eq i32 %21, %23
  br i1 %24, label %28, label %25

25:                                               ; preds = %19
  %26 = call noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef @.str.19, ptr noundef @.str.1, i32 noundef 547)
  br i1 %26, label %27, label %28

27:                                               ; preds = %25
  call void asm sideeffect "int $$0x3", "~{dirflag},~{fpsr},~{flags}"() #3, !srcloc !16
  br label %28

28:                                               ; preds = %27, %25, %19
  br label %29

29:                                               ; preds = %28
  %30 = getelementptr inbounds %"class.JPH::LargeIslandSplitter", ptr %7, i32 0, i32 7
  %31 = load i32, ptr %30, align 8, !tbaa !15
  %32 = icmp ugt i32 %31, 0
  br i1 %32, label %33, label %48

33:                                               ; preds = %29
  %34 = load ptr, ptr %4, align 8, !tbaa !5
  %35 = getelementptr inbounds %"class.JPH::LargeIslandSplitter", ptr %7, i32 0, i32 9
  %36 = load ptr, ptr %35, align 8, !tbaa !17
  %37 = getelementptr inbounds %"class.JPH::LargeIslandSplitter", ptr %7, i32 0, i32 7
  %38 = load i32, ptr %37, align 8, !tbaa !15
  %39 = zext i32 %38 to i64
  %40 = mul i64 %39, 552
  %41 = trunc i64 %40 to i32
  %42 = load ptr, ptr %34, align 8, !tbaa !18
  %43 = getelementptr inbounds ptr, ptr %42, i64 3
  %44 = load ptr, ptr %43, align 8
  call void %44(ptr noundef nonnull align 8 dereferenceable(8) %34, ptr noundef %36, i32 noundef %41)
  %45 = getelementptr inbounds %"class.JPH::LargeIslandSplitter", ptr %7, i32 0, i32 9
  store ptr null, ptr %45, align 8, !tbaa !17
  %46 = getelementptr inbounds %"class.JPH::LargeIslandSplitter", ptr %7, i32 0, i32 7
  store i32 0, ptr %46, align 8, !tbaa !15
  %47 = getelementptr inbounds %"class.JPH::LargeIslandSplitter", ptr %7, i32 0, i32 10
  call void @_ZNSt13__atomic_baseIjE5storeEjSt12memory_order(ptr noundef nonnull align 4 dereferenceable(4) %47, i32 noundef 0, i32 noundef 0) #3
  br label %48

48:                                               ; preds = %33, %29
  %49 = getelementptr inbounds %"class.JPH::LargeIslandSplitter", ptr %7, i32 0, i32 5
  %50 = load i32, ptr %49, align 8, !tbaa !9
  %51 = icmp ugt i32 %50, 0
  br i1 %51, label %52, label %79

52:                                               ; preds = %48
  %53 = load ptr, ptr %4, align 8, !tbaa !5
  %54 = getelementptr inbounds %"class.JPH::LargeIslandSplitter", ptr %7, i32 0, i32 4
  %55 = load ptr, ptr %54, align 8, !tbaa !20
  %56 = getelementptr inbounds %"class.JPH::LargeIslandSplitter", ptr %7, i32 0, i32 5
  %57 = load i32, ptr %56, align 8, !tbaa !9
  %58 = zext i32 %57 to i64
  %59 = mul i64 %58, 4
  %60 = trunc i64 %59 to i32
  %61 = load ptr, ptr %53, align 8, !tbaa !18
  %62 = getelementptr inbounds ptr, ptr %61, i64 3
  %63 = load ptr, ptr %62, align 8
  call void %63(ptr noundef nonnull align 8 dereferenceable(8) %53, ptr noundef %55, i32 noundef %60)
  %64 = getelementptr inbounds %"class.JPH::LargeIslandSplitter", ptr %7, i32 0, i32 4
  store ptr null, ptr %64, align 8, !tbaa !20
  %65 = load ptr, ptr %4, align 8, !tbaa !5
  %66 = getelementptr inbounds %"class.JPH::LargeIslandSplitter", ptr %7, i32 0, i32 3
  %67 = load ptr, ptr %66, align 8, !tbaa !21
  %68 = getelementptr inbounds %"class.JPH::LargeIslandSplitter", ptr %7, i32 0, i32 5
  %69 = load i32, ptr %68, align 8, !tbaa !9
  %70 = zext i32 %69 to i64
  %71 = mul i64 %70, 4
  %72 = trunc i64 %71 to i32
  %73 = load ptr, ptr %65, align 8, !tbaa !18
  %74 = getelementptr inbounds ptr, ptr %73, i64 3
  %75 = load ptr, ptr %74, align 8
  call void %75(ptr noundef nonnull align 8 dereferenceable(8) %65, ptr noundef %67, i32 noundef %72)
  %76 = getelementptr inbounds %"class.JPH::LargeIslandSplitter", ptr %7, i32 0, i32 3
  store ptr null, ptr %76, align 8, !tbaa !21
  %77 = getelementptr inbounds %"class.JPH::LargeIslandSplitter", ptr %7, i32 0, i32 5
  store i32 0, ptr %77, align 8, !tbaa !9
  %78 = getelementptr inbounds %"class.JPH::LargeIslandSplitter", ptr %7, i32 0, i32 6
  call void @_ZNSt13__atomic_baseIjE5storeEjSt12memory_order(ptr noundef nonnull align 4 dereferenceable(4) %78, i32 noundef 0, i32 noundef 0) #3
  br label %79

79:                                               ; preds = %52, %48
  %80 = getelementptr inbounds %"class.JPH::LargeIslandSplitter", ptr %7, i32 0, i32 2
  %81 = load ptr, ptr %80, align 8, !tbaa !22
  %82 = icmp ne ptr %81, null
  br i1 %82, label %83, label %97

83:                                               ; preds = %79
  %84 = load ptr, ptr %4, align 8, !tbaa !5
  %85 = getelementptr inbounds %"class.JPH::LargeIslandSplitter", ptr %7, i32 0, i32 2
  %86 = load ptr, ptr %85, align 8, !tbaa !22
  %87 = getelementptr inbounds %"class.JPH::LargeIslandSplitter", ptr %7, i32 0, i32 0
  %88 = load i32, ptr %87, align 8, !tbaa !23
  %89 = zext i32 %88 to i64
  %90 = mul i64 %89, 4
  %91 = trunc i64 %90 to i32
  %92 = load ptr, ptr %84, align 8, !tbaa !18
  %93 = getelementptr inbounds ptr, ptr %92, i64 3
  %94 = load ptr, ptr %93, align 8
  call void %94(ptr noundef nonnull align 8 dereferenceable(8) %84, ptr noundef %86, i32 noundef %91)
  %95 = getelementptr inbounds %"class.JPH::LargeIslandSplitter", ptr %7, i32 0, i32 2
  store ptr null, ptr %95, align 8, !tbaa !22
  %96 = getelementptr inbounds %"class.JPH::LargeIslandSplitter", ptr %7, i32 0, i32 0
  store i32 0, ptr %96, align 8, !tbaa !23
  br label %97

97:                                               ; preds = %83, %79
  ret void
}

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 = { alwaysinline 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 = { 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 32}
!10 = !{!"_ZTSN3JPH19LargeIslandSplitterE", !11, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !11, i64 32, !12, i64 36, !11, i64 40, !6, i64 48, !12, i64 56}
!11 = !{!"int", !7, i64 0}
!12 = !{!"_ZTSSt6atomicIjE", !13, i64 0}
!13 = !{!"_ZTSSt13__atomic_baseIjE", !11, i64 0}
!14 = !{i64 2158948922}
!15 = !{!10, !11, i64 40}
!16 = !{i64 2158953406}
!17 = !{!10, !6, i64 48}
!18 = !{!19, !19, i64 0}
!19 = !{!"vtable pointer", !8, i64 0}
!20 = !{!10, !6, i64 24}
!21 = !{!10, !6, i64 16}
!22 = !{!10, !6, i64 8}
!23 = !{!10, !11, 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.1 = external hidden unnamed_addr constant [89 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [88 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [64 x i8], align 1

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local void @_ZNSt13__atomic_baseIjE5storeEjSt12memory_order(ptr noundef nonnull align 4 dereferenceable(4), i32 noundef, i32 noundef) local_unnamed_addr #1 align 2

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNKSt13__atomic_baseIjE4loadESt12memory_order(ptr noundef nonnull align 4 dereferenceable(4), i32 noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3JPH19LargeIslandSplitter5ResetEPNS_13TempAllocatorE(ptr noundef nonnull align 8 dereferenceable(60) %0, ptr noundef %1) local_unnamed_addr #2 align 2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 36
  %4 = tail call noundef i32 @_ZNKSt13__atomic_baseIjE4loadESt12memory_order(ptr noundef nonnull align 4 dereferenceable(4) %3, i32 noundef 0) #3
  %5 = getelementptr inbounds i8, ptr %0, i64 32
  %6 = load i32, ptr %5, align 8, !tbaa !5
  %7 = icmp eq i32 %4, %6
  br i1 %7, label %11, label %8

8:                                                ; preds = %2
  %9 = tail call noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef nonnull @.str.18, ptr noundef nonnull @.str.1, i32 noundef 546)
  br i1 %9, label %10, label %11

10:                                               ; preds = %8
  tail call void asm sideeffect "int $$0x3", "~{dirflag},~{fpsr},~{flags}"() #3, !srcloc !13
  br label %11

11:                                               ; preds = %10, %8, %2
  %12 = getelementptr inbounds i8, ptr %0, i64 56
  %13 = tail call noundef i32 @_ZNKSt13__atomic_baseIjE4loadESt12memory_order(ptr noundef nonnull align 4 dereferenceable(4) %12, i32 noundef 0) #3
  %14 = getelementptr inbounds i8, ptr %0, i64 40
  %15 = load i32, ptr %14, align 8, !tbaa !14
  %16 = icmp eq i32 %13, %15
  br i1 %16, label %20, label %17

17:                                               ; preds = %11
  %18 = tail call noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef nonnull @.str.19, ptr noundef nonnull @.str.1, i32 noundef 547)
  br i1 %18, label %19, label %thread-pre-split

19:                                               ; preds = %17
  tail call void asm sideeffect "int $$0x3", "~{dirflag},~{fpsr},~{flags}"() #3, !srcloc !15
  br label %thread-pre-split

thread-pre-split:                                 ; preds = %19, %17
  %.pr = load i32, ptr %14, align 8, !tbaa !14
  br label %20

20:                                               ; preds = %thread-pre-split, %11
  %21 = phi i32 [ %.pr, %thread-pre-split ], [ %13, %11 ]
  %.not = icmp eq i32 %21, 0
  br i1 %.not, label %29, label %22

22:                                               ; preds = %20
  %23 = getelementptr inbounds i8, ptr %0, i64 48
  %24 = load ptr, ptr %23, align 8, !tbaa !16
  %25 = mul i32 %21, 552
  %26 = load ptr, ptr %1, align 8, !tbaa !17
  %27 = getelementptr inbounds i8, ptr %26, i64 24
  %28 = load ptr, ptr %27, align 8
  tail call void %28(ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef %24, i32 noundef %25)
  store ptr null, ptr %23, align 8, !tbaa !16
  store i32 0, ptr %14, align 8, !tbaa !14
  tail call void @_ZNSt13__atomic_baseIjE5storeEjSt12memory_order(ptr noundef nonnull align 4 dereferenceable(4) %12, i32 noundef 0, i32 noundef 0) #3
  br label %29

29:                                               ; preds = %22, %20
  %30 = load i32, ptr %5, align 8, !tbaa !5
  %.not7 = icmp eq i32 %30, 0
  br i1 %.not7, label %45, label %31

31:                                               ; preds = %29
  %32 = getelementptr inbounds i8, ptr %0, i64 24
  %33 = load ptr, ptr %32, align 8, !tbaa !19
  %34 = shl i32 %30, 2
  %35 = load ptr, ptr %1, align 8, !tbaa !17
  %36 = getelementptr inbounds i8, ptr %35, i64 24
  %37 = load ptr, ptr %36, align 8
  tail call void %37(ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef %33, i32 noundef %34)
  store ptr null, ptr %32, align 8, !tbaa !19
  %38 = getelementptr inbounds i8, ptr %0, i64 16
  %39 = load ptr, ptr %38, align 8, !tbaa !20
  %40 = load i32, ptr %5, align 8, !tbaa !5
  %41 = shl i32 %40, 2
  %42 = load ptr, ptr %1, align 8, !tbaa !17
  %43 = getelementptr inbounds i8, ptr %42, i64 24
  %44 = load ptr, ptr %43, align 8
  tail call void %44(ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef %39, i32 noundef %41)
  store ptr null, ptr %38, align 8, !tbaa !20
  store i32 0, ptr %5, align 8, !tbaa !5
  tail call void @_ZNSt13__atomic_baseIjE5storeEjSt12memory_order(ptr noundef nonnull align 4 dereferenceable(4) %3, i32 noundef 0, i32 noundef 0) #3
  br label %45

45:                                               ; preds = %31, %29
  %46 = getelementptr inbounds i8, ptr %0, i64 8
  %47 = load ptr, ptr %46, align 8, !tbaa !21
  %.not8 = icmp eq ptr %47, null
  br i1 %.not8, label %54, label %48

48:                                               ; preds = %45
  %49 = load i32, ptr %0, align 8, !tbaa !22
  %50 = shl i32 %49, 2
  %51 = load ptr, ptr %1, align 8, !tbaa !17
  %52 = getelementptr inbounds i8, ptr %51, i64 24
  %53 = load ptr, ptr %52, align 8
  tail call void %53(ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef nonnull %47, i32 noundef %50)
  store ptr null, ptr %46, align 8, !tbaa !21
  store i32 0, ptr %0, align 8, !tbaa !22
  br label %54

54:                                               ; preds = %48, %45
  ret void
}

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 = { alwaysinline 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 = { 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 = !{!"_ZTSN3JPH19LargeIslandSplitterE", !7, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !7, i64 32, !11, i64 36, !7, i64 40, !10, i64 48, !11, i64 56}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"_ZTSSt6atomicIjE", !12, i64 0}
!12 = !{!"_ZTSSt13__atomic_baseIjE", !7, i64 0}
!13 = !{i64 2158948922}
!14 = !{!6, !7, i64 40}
!15 = !{i64 2158953406}
!16 = !{!6, !10, i64 48}
!17 = !{!18, !18, i64 0}
!18 = !{!"vtable pointer", !9, i64 0}
!19 = !{!6, !10, i64 24}
!20 = !{!6, !10, i64 16}
!21 = !{!6, !10, i64 8}
!22 = !{!6, !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InstCombinePass,JumpThreadingPass,SROAPass,SimplifyCFGPass,TailCallElimPass