; LLVM IR from sbischoff-ai/simple-molecular-dynamics :: SimpleMolecularDynamics/SimpleMolecularDynamics/MDSim.ll (ZN19MDParticleListEntryD2Ev)

; 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.MDParticleListEntry = type { ptr, ptr, ptr, ptr }
%class.MDParticleList = type { i32, ptr, ptr }

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN19MDParticleListEntryD2Ev(ptr noundef nonnull align 8 dereferenceable(32) %0) unnamed_addr #0 align 2 {
  %2 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %3 = load ptr, ptr %2, align 8
  %4 = getelementptr inbounds %class.MDParticleListEntry, ptr %3, i32 0, i32 3
  %5 = load ptr, ptr %4, align 8, !tbaa !9
  %6 = icmp ne ptr %5, null
  br i1 %6, label %7, label %13

7:                                                ; preds = %1
  %8 = getelementptr inbounds %class.MDParticleListEntry, ptr %3, i32 0, i32 2
  %9 = load ptr, ptr %8, align 8, !tbaa !11
  %10 = getelementptr inbounds %class.MDParticleListEntry, ptr %3, i32 0, i32 3
  %11 = load ptr, ptr %10, align 8, !tbaa !9
  %12 = getelementptr inbounds %class.MDParticleListEntry, ptr %11, i32 0, i32 2
  store ptr %9, ptr %12, align 8, !tbaa !11
  br label %13

13:                                               ; preds = %7, %1
  %14 = getelementptr inbounds %class.MDParticleListEntry, ptr %3, i32 0, i32 2
  %15 = load ptr, ptr %14, align 8, !tbaa !11
  %16 = icmp ne ptr %15, null
  br i1 %16, label %17, label %23

17:                                               ; preds = %13
  %18 = getelementptr inbounds %class.MDParticleListEntry, ptr %3, i32 0, i32 3
  %19 = load ptr, ptr %18, align 8, !tbaa !9
  %20 = getelementptr inbounds %class.MDParticleListEntry, ptr %3, i32 0, i32 2
  %21 = load ptr, ptr %20, align 8, !tbaa !11
  %22 = getelementptr inbounds %class.MDParticleListEntry, ptr %21, i32 0, i32 3
  store ptr %19, ptr %22, align 8, !tbaa !9
  br label %23

23:                                               ; preds = %17, %13
  %24 = getelementptr inbounds %class.MDParticleListEntry, ptr %3, i32 0, i32 3
  %25 = load ptr, ptr %24, align 8, !tbaa !9
  %26 = icmp ne ptr %25, null
  br i1 %26, label %33, label %27

27:                                               ; preds = %23
  %28 = getelementptr inbounds %class.MDParticleListEntry, ptr %3, i32 0, i32 2
  %29 = load ptr, ptr %28, align 8, !tbaa !11
  %30 = getelementptr inbounds %class.MDParticleListEntry, ptr %3, i32 0, i32 0
  %31 = load ptr, ptr %30, align 8, !tbaa !12
  %32 = getelementptr inbounds %class.MDParticleList, ptr %31, i32 0, i32 2
  store ptr %29, ptr %32, align 8, !tbaa !13
  br label %33

33:                                               ; preds = %27, %23
  %34 = getelementptr inbounds %class.MDParticleListEntry, ptr %3, i32 0, i32 2
  %35 = load ptr, ptr %34, align 8, !tbaa !11
  %36 = icmp ne ptr %35, null
  br i1 %36, label %43, label %37

37:                                               ; preds = %33
  %38 = getelementptr inbounds %class.MDParticleListEntry, ptr %3, i32 0, i32 3
  %39 = load ptr, ptr %38, align 8, !tbaa !9
  %40 = getelementptr inbounds %class.MDParticleListEntry, ptr %3, i32 0, i32 0
  %41 = load ptr, ptr %40, align 8, !tbaa !12
  %42 = getelementptr inbounds %class.MDParticleList, ptr %41, i32 0, i32 1
  store ptr %39, ptr %42, align 8, !tbaa !16
  br label %43

43:                                               ; preds = %37, %33
  %44 = getelementptr inbounds %class.MDParticleListEntry, ptr %3, i32 0, i32 0
  %45 = load ptr, ptr %44, align 8, !tbaa !12
  %46 = getelementptr inbounds %class.MDParticleList, ptr %45, i32 0, i32 0
  %47 = load i32, ptr %46, align 8, !tbaa !17
  %48 = add nsw i32 %47, -1
  store i32 %48, ptr %46, align 8, !tbaa !17
  ret void
}

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

!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 24}
!10 = !{!"_ZTS19MDParticleListEntry", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!11 = !{!10, !6, i64 16}
!12 = !{!10, !6, i64 0}
!13 = !{!14, !6, i64 16}
!14 = !{!"_ZTS14MDParticleList", !15, i64 0, !6, i64 8, !6, i64 16}
!15 = !{!"int", !7, i64 0}
!16 = !{!14, !6, i64 8}
!17 = !{!14, !15, 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"

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(readwrite, inaccessiblemem: none) uwtable
define dso_local void @_ZN19MDParticleListEntryD2Ev(ptr nocapture noundef nonnull readonly align 8 dereferenceable(32) %0) unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 24
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %.not = icmp eq ptr %3, null
  %.phi.trans.insert = getelementptr inbounds i8, ptr %0, i64 16
  %.pre = load ptr, ptr %.phi.trans.insert, align 8, !tbaa !10
  br i1 %.not, label %._crit_edge, label %4

4:                                                ; preds = %1
  %5 = getelementptr inbounds i8, ptr %3, i64 16
  store ptr %.pre, ptr %5, align 8, !tbaa !10
  br label %._crit_edge

._crit_edge:                                      ; preds = %1, %4
  %.not2 = icmp eq ptr %.pre, null
  br i1 %.not2, label %8, label %6

6:                                                ; preds = %._crit_edge
  %7 = getelementptr inbounds i8, ptr %.pre, i64 24
  store ptr %3, ptr %7, align 8, !tbaa !5
  %.pre5 = load ptr, ptr %2, align 8, !tbaa !5
  br label %8

8:                                                ; preds = %6, %._crit_edge
  %9 = phi ptr [ %.pre5, %6 ], [ %3, %._crit_edge ]
  %.not3 = icmp eq ptr %9, null
  %.pre6.pre = load ptr, ptr %0, align 8, !tbaa !11
  br i1 %.not3, label %10, label %12

10:                                               ; preds = %8
  %11 = getelementptr inbounds i8, ptr %.pre6.pre, i64 16
  store ptr %.pre, ptr %11, align 8, !tbaa !12
  br label %12

12:                                               ; preds = %10, %8
  br i1 %.not2, label %13, label %15

13:                                               ; preds = %12
  %14 = getelementptr inbounds i8, ptr %.pre6.pre, i64 8
  store ptr %9, ptr %14, align 8, !tbaa !15
  br label %15

15:                                               ; preds = %13, %12
  %16 = load i32, ptr %.pre6.pre, align 8, !tbaa !16
  %17 = add nsw i32 %16, -1
  store i32 %17, ptr %.pre6.pre, align 8, !tbaa !16
  ret void
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(readwrite, inaccessiblemem: none) 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" }

!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 24}
!6 = !{!"_ZTS19MDParticleListEntry", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!6, !7, i64 16}
!11 = !{!6, !7, i64 0}
!12 = !{!13, !7, i64 16}
!13 = !{!"_ZTS14MDParticleList", !14, i64 0, !7, i64 8, !7, i64 16}
!14 = !{!"int", !8, i64 0}
!15 = !{!13, !7, i64 8}
!16 = !{!13, !14, i64 0}


; Effective O3 passes: BDCEPass,EarlyCSEPass,GVNPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass