; LLVM IR from devlinzhou/deterministic_physics :: UnrealDemo/Source/UnrealDemo/gphysics/src/collision/glacier_collision_algorithm._d93d0b6d (ZN18GCollisionManergerD2Ev)

; 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.GCollisionManerger = type { [10 x [10 x 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: mustprogress nounwind uwtable
define dso_local void @_ZN18GCollisionManergerD2Ev(ptr noundef nonnull align 8 dereferenceable(800) %0) unnamed_addr #1 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %6 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #2
  store i32 0, ptr %3, align 4, !tbaa !9
  br label %7

7:                                                ; preds = %53, %1
  %8 = load i32, ptr %3, align 4, !tbaa !9
  %9 = icmp slt i32 %8, 10
  br i1 %9, label %11, label %10

10:                                               ; preds = %7
  store i32 2, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #2
  br label %56

11:                                               ; preds = %7
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #2
  store i32 0, ptr %5, align 4, !tbaa !9
  br label %12

12:                                               ; preds = %49, %11
  %13 = load i32, ptr %5, align 4, !tbaa !9
  %14 = icmp slt i32 %13, 10
  br i1 %14, label %16, label %15

15:                                               ; preds = %12
  store i32 5, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  br label %52

16:                                               ; preds = %12
  %17 = getelementptr inbounds %class.GCollisionManerger, ptr %6, i32 0, i32 0
  %18 = load i32, ptr %3, align 4, !tbaa !9
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds [10 x [10 x ptr]], ptr %17, i64 0, i64 %19
  %21 = load i32, ptr %5, align 4, !tbaa !9
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds [10 x ptr], ptr %20, i64 0, i64 %22
  %24 = load ptr, ptr %23, align 8, !tbaa !5
  %25 = icmp ne ptr %24, null
  br i1 %25, label %26, label %48

26:                                               ; preds = %16
  %27 = getelementptr inbounds %class.GCollisionManerger, ptr %6, i32 0, i32 0
  %28 = load i32, ptr %3, align 4, !tbaa !9
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [10 x [10 x ptr]], ptr %27, i64 0, i64 %29
  %31 = load i32, ptr %5, align 4, !tbaa !9
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds [10 x ptr], ptr %30, i64 0, i64 %32
  %34 = load ptr, ptr %33, align 8, !tbaa !5
  %35 = icmp eq ptr %34, null
  br i1 %35, label %40, label %36

36:                                               ; preds = %26
  %37 = load ptr, ptr %34, align 8, !tbaa !11
  %38 = getelementptr inbounds ptr, ptr %37, i64 1
  %39 = load ptr, ptr %38, align 8
  call void %39(ptr noundef nonnull align 8 dereferenceable(16) %34) #2
  br label %40

40:                                               ; preds = %36, %26
  %41 = getelementptr inbounds %class.GCollisionManerger, ptr %6, i32 0, i32 0
  %42 = load i32, ptr %3, align 4, !tbaa !9
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds [10 x [10 x ptr]], ptr %41, i64 0, i64 %43
  %45 = load i32, ptr %5, align 4, !tbaa !9
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds [10 x ptr], ptr %44, i64 0, i64 %46
  store ptr null, ptr %47, align 8, !tbaa !5
  br label %48

48:                                               ; preds = %40, %16
  br label %49

49:                                               ; preds = %48
  %50 = load i32, ptr %5, align 4, !tbaa !9
  %51 = add nsw i32 %50, 1
  store i32 %51, ptr %5, align 4, !tbaa !9
  br label %12, !llvm.loop !13

52:                                               ; preds = %15
  br label %53

53:                                               ; preds = %52
  %54 = load i32, ptr %3, align 4, !tbaa !9
  %55 = add nsw i32 %54, 1
  store i32 %55, ptr %3, align 4, !tbaa !9
  br label %7, !llvm.loop !15

56:                                               ; preds = %10
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { 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 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"vtable pointer", !8, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}


; 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: mustprogress nounwind uwtable
define dso_local void @_ZN18GCollisionManergerD2Ev(ptr nocapture noundef nonnull align 8 dereferenceable(800) %0) unnamed_addr #0 align 2 {
  br label %.preheader

.preheader:                                       ; preds = %1, %72
  %indvars.iv = phi i64 [ 0, %1 ], [ %indvars.iv.next, %72 ]
  %2 = getelementptr inbounds [10 x [10 x ptr]], ptr %0, i64 0, i64 %indvars.iv, i64 0
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %.not = icmp eq ptr %3, null
  br i1 %.not, label %9, label %5

4:                                                ; preds = %72
  ret void

5:                                                ; preds = %.preheader
  %6 = load ptr, ptr %3, align 8, !tbaa !9
  %7 = getelementptr inbounds i8, ptr %6, i64 8
  %8 = load ptr, ptr %7, align 8
  tail call void %8(ptr noundef nonnull align 8 dereferenceable(16) %3) #1
  store ptr null, ptr %2, align 8, !tbaa !5
  br label %9

9:                                                ; preds = %.preheader, %5
  %10 = getelementptr inbounds [10 x [10 x ptr]], ptr %0, i64 0, i64 %indvars.iv, i64 1
  %11 = load ptr, ptr %10, align 8, !tbaa !5
  %.not.1 = icmp eq ptr %11, null
  br i1 %.not.1, label %16, label %12

12:                                               ; preds = %9
  %13 = load ptr, ptr %11, align 8, !tbaa !9
  %14 = getelementptr inbounds i8, ptr %13, i64 8
  %15 = load ptr, ptr %14, align 8
  tail call void %15(ptr noundef nonnull align 8 dereferenceable(16) %11) #1
  store ptr null, ptr %10, align 8, !tbaa !5
  br label %16

16:                                               ; preds = %12, %9
  %17 = getelementptr inbounds [10 x [10 x ptr]], ptr %0, i64 0, i64 %indvars.iv, i64 2
  %18 = load ptr, ptr %17, align 8, !tbaa !5
  %.not.2 = icmp eq ptr %18, null
  br i1 %.not.2, label %23, label %19

19:                                               ; preds = %16
  %20 = load ptr, ptr %18, align 8, !tbaa !9
  %21 = getelementptr inbounds i8, ptr %20, i64 8
  %22 = load ptr, ptr %21, align 8
  tail call void %22(ptr noundef nonnull align 8 dereferenceable(16) %18) #1
  store ptr null, ptr %17, align 8, !tbaa !5
  br label %23

23:                                               ; preds = %19, %16
  %24 = getelementptr inbounds [10 x [10 x ptr]], ptr %0, i64 0, i64 %indvars.iv, i64 3
  %25 = load ptr, ptr %24, align 8, !tbaa !5
  %.not.3 = icmp eq ptr %25, null
  br i1 %.not.3, label %30, label %26

26:                                               ; preds = %23
  %27 = load ptr, ptr %25, align 8, !tbaa !9
  %28 = getelementptr inbounds i8, ptr %27, i64 8
  %29 = load ptr, ptr %28, align 8
  tail call void %29(ptr noundef nonnull align 8 dereferenceable(16) %25) #1
  store ptr null, ptr %24, align 8, !tbaa !5
  br label %30

30:                                               ; preds = %26, %23
  %31 = getelementptr inbounds [10 x [10 x ptr]], ptr %0, i64 0, i64 %indvars.iv, i64 4
  %32 = load ptr, ptr %31, align 8, !tbaa !5
  %.not.4 = icmp eq ptr %32, null
  br i1 %.not.4, label %37, label %33

33:                                               ; preds = %30
  %34 = load ptr, ptr %32, align 8, !tbaa !9
  %35 = getelementptr inbounds i8, ptr %34, i64 8
  %36 = load ptr, ptr %35, align 8
  tail call void %36(ptr noundef nonnull align 8 dereferenceable(16) %32) #1
  store ptr null, ptr %31, align 8, !tbaa !5
  br label %37

37:                                               ; preds = %33, %30
  %38 = getelementptr inbounds [10 x [10 x ptr]], ptr %0, i64 0, i64 %indvars.iv, i64 5
  %39 = load ptr, ptr %38, align 8, !tbaa !5
  %.not.5 = icmp eq ptr %39, null
  br i1 %.not.5, label %44, label %40

40:                                               ; preds = %37
  %41 = load ptr, ptr %39, align 8, !tbaa !9
  %42 = getelementptr inbounds i8, ptr %41, i64 8
  %43 = load ptr, ptr %42, align 8
  tail call void %43(ptr noundef nonnull align 8 dereferenceable(16) %39) #1
  store ptr null, ptr %38, align 8, !tbaa !5
  br label %44

44:                                               ; preds = %40, %37
  %45 = getelementptr inbounds [10 x [10 x ptr]], ptr %0, i64 0, i64 %indvars.iv, i64 6
  %46 = load ptr, ptr %45, align 8, !tbaa !5
  %.not.6 = icmp eq ptr %46, null
  br i1 %.not.6, label %51, label %47

47:                                               ; preds = %44
  %48 = load ptr, ptr %46, align 8, !tbaa !9
  %49 = getelementptr inbounds i8, ptr %48, i64 8
  %50 = load ptr, ptr %49, align 8
  tail call void %50(ptr noundef nonnull align 8 dereferenceable(16) %46) #1
  store ptr null, ptr %45, align 8, !tbaa !5
  br label %51

51:                                               ; preds = %47, %44
  %52 = getelementptr inbounds [10 x [10 x ptr]], ptr %0, i64 0, i64 %indvars.iv, i64 7
  %53 = load ptr, ptr %52, align 8, !tbaa !5
  %.not.7 = icmp eq ptr %53, null
  br i1 %.not.7, label %58, label %54

54:                                               ; preds = %51
  %55 = load ptr, ptr %53, align 8, !tbaa !9
  %56 = getelementptr inbounds i8, ptr %55, i64 8
  %57 = load ptr, ptr %56, align 8
  tail call void %57(ptr noundef nonnull align 8 dereferenceable(16) %53) #1
  store ptr null, ptr %52, align 8, !tbaa !5
  br label %58

58:                                               ; preds = %54, %51
  %59 = getelementptr inbounds [10 x [10 x ptr]], ptr %0, i64 0, i64 %indvars.iv, i64 8
  %60 = load ptr, ptr %59, align 8, !tbaa !5
  %.not.8 = icmp eq ptr %60, null
  br i1 %.not.8, label %65, label %61

61:                                               ; preds = %58
  %62 = load ptr, ptr %60, align 8, !tbaa !9
  %63 = getelementptr inbounds i8, ptr %62, i64 8
  %64 = load ptr, ptr %63, align 8
  tail call void %64(ptr noundef nonnull align 8 dereferenceable(16) %60) #1
  store ptr null, ptr %59, align 8, !tbaa !5
  br label %65

65:                                               ; preds = %61, %58
  %66 = getelementptr inbounds [10 x [10 x ptr]], ptr %0, i64 0, i64 %indvars.iv, i64 9
  %67 = load ptr, ptr %66, align 8, !tbaa !5
  %.not.9 = icmp eq ptr %67, null
  br i1 %.not.9, label %72, label %68

68:                                               ; preds = %65
  %69 = load ptr, ptr %67, align 8, !tbaa !9
  %70 = getelementptr inbounds i8, ptr %69, i64 8
  %71 = load ptr, ptr %70, align 8
  tail call void %71(ptr noundef nonnull align 8 dereferenceable(16) %67) #1
  store ptr null, ptr %66, align 8, !tbaa !5
  br label %72

72:                                               ; preds = %68, %65
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 10
  br i1 %exitcond.not, label %4, label %.preheader, !llvm.loop !11
}

attributes #0 = { 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 #1 = { 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 = !{!"vtable pointer", !8, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,LoopSimplifyPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass