; LLVM IR from achilles288/robot-monitor-graphics :: src/base/particle.ll (ZN3rmg10Particle3DD2Ev)

; 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.rmg::Particle3D" = type <{ %"class.rmg::Object", ptr, ptr, %"class.rmg::internal::Pending", %"struct.rmg::Vec3", %"struct.rmg::Vec2", float, %"struct.rmg::Mat3", [4 x i8] }>
%"class.rmg::Object" = type { ptr, i64, ptr, %"struct.rmg::ColorRGBA", i8, i32 }
%"struct.rmg::ColorRGBA" = type { float, float, float, float }
%"class.rmg::internal::Pending" = type { ptr, ptr }
%"struct.rmg::Vec3" = type { %union.anon }
%union.anon = type { %struct.anon }
%struct.anon = type { float, float, float }
%"struct.rmg::Vec2" = type { %union.anon.0 }
%union.anon.0 = type { %struct.anon.1 }
%struct.anon.1 = type { float, float }
%"struct.rmg::Mat3" = type { %union.anon.2 }
%union.anon.2 = type { [3 x [3 x float]] }

@_ZTVN3rmg10Particle3DE = external dso_local unnamed_addr constant { [4 x ptr] }, align 8

; Function Attrs: nounwind
declare void @_ZN3rmg8internal7PendingD1Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3rmg6ObjectD2Ev(ptr noundef nonnull align 8 dereferenceable(48)) unnamed_addr #1 align 2

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) #2

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN3rmg10Particle3DD2Ev(ptr noundef nonnull align 8 dereferenceable(140) %0) unnamed_addr #1 align 2 {
  %2 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %3 = load ptr, ptr %2, align 8
  store ptr getelementptr inbounds inrange(-16, 16) ({ [4 x ptr] }, ptr @_ZTVN3rmg10Particle3DE, i32 0, i32 0, i32 2), ptr %3, align 8, !tbaa !9
  %4 = getelementptr inbounds %"class.rmg::Particle3D", ptr %3, i32 0, i32 1
  %5 = load ptr, ptr %4, align 8, !tbaa !11
  %6 = icmp ne ptr %5, null
  br i1 %6, label %7, label %31

7:                                                ; preds = %1
  %8 = getelementptr inbounds %"class.rmg::Particle3D", ptr %3, i32 0, i32 2
  %9 = load ptr, ptr %8, align 8, !tbaa !23
  %10 = load i32, ptr %9, align 4, !tbaa !24
  %11 = add i32 %10, -1
  store i32 %11, ptr %9, align 4, !tbaa !24
  %12 = getelementptr inbounds %"class.rmg::Particle3D", ptr %3, i32 0, i32 2
  %13 = load ptr, ptr %12, align 8, !tbaa !23
  %14 = load i32, ptr %13, align 4, !tbaa !24
  %15 = icmp eq i32 %14, 0
  br i1 %15, label %16, label %30

16:                                               ; preds = %7
  %17 = getelementptr inbounds %"class.rmg::Particle3D", ptr %3, i32 0, i32 1
  %18 = load ptr, ptr %17, align 8, !tbaa !11
  %19 = icmp eq ptr %18, null
  br i1 %19, label %24, label %20

20:                                               ; preds = %16
  %21 = load ptr, ptr %18, align 8, !tbaa !9
  %22 = getelementptr inbounds ptr, ptr %21, i64 1
  %23 = load ptr, ptr %22, align 8
  call void %23(ptr noundef nonnull align 8 dereferenceable(12) %18) #3
  br label %24

24:                                               ; preds = %20, %16
  %25 = getelementptr inbounds %"class.rmg::Particle3D", ptr %3, i32 0, i32 2
  %26 = load ptr, ptr %25, align 8, !tbaa !23
  %27 = icmp eq ptr %26, null
  br i1 %27, label %29, label %28

28:                                               ; preds = %24
  call void @_ZdlPvm(ptr noundef %26, i64 noundef 4) #4
  br label %29

29:                                               ; preds = %28, %24
  br label %30

30:                                               ; preds = %29, %7
  br label %31

31:                                               ; preds = %30, %1
  %32 = getelementptr inbounds %"class.rmg::Particle3D", ptr %3, i32 0, i32 3
  call void @_ZN3rmg8internal7PendingD1Ev(ptr noundef nonnull align 8 dereferenceable(16) %32) #3
  call void @_ZN3rmg6ObjectD2Ev(ptr noundef nonnull align 8 dereferenceable(48) %3) #3
  ret void
}

attributes #0 = { 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 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 = { nobuiltin 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 = { builtin 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 = !{!12, !6, i64 48}
!12 = !{!"_ZTSN3rmg10Particle3DE", !13, i64 0, !6, i64 48, !6, i64 56, !19, i64 64, !20, i64 80, !21, i64 92, !16, i64 100, !22, i64 104}
!13 = !{!"_ZTSN3rmg6ObjectE", !14, i64 8, !6, i64 16, !15, i64 24, !17, i64 40, !18, i64 44}
!14 = !{!"long", !7, i64 0}
!15 = !{!"_ZTSN3rmg9ColorRGBAE", !16, i64 0, !16, i64 4, !16, i64 8, !16, i64 12}
!16 = !{!"float", !7, i64 0}
!17 = !{!"bool", !7, i64 0}
!18 = !{!"_ZTSN3rmg10ObjectTypeE", !7, i64 0}
!19 = !{!"_ZTSN3rmg8internal7PendingE", !6, i64 0, !6, i64 8}
!20 = !{!"_ZTSN3rmg4Vec3E", !7, i64 0}
!21 = !{!"_ZTSN3rmg4Vec2E", !7, i64 0}
!22 = !{!"_ZTSN3rmg4Mat3E", !7, i64 0}
!23 = !{!12, !6, i64 56}
!24 = !{!25, !25, i64 0}
!25 = !{!"int", !7, 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"

@_ZTVN3rmg10Particle3DE = external dso_local unnamed_addr constant { [4 x ptr] }, align 8

; Function Attrs: nounwind
declare void @_ZN3rmg8internal7PendingD1Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3rmg6ObjectD2Ev(ptr noundef nonnull align 8 dereferenceable(48)) unnamed_addr #1 align 2

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN3rmg10Particle3DD2Ev(ptr noundef nonnull align 8 dereferenceable(140) %0) unnamed_addr #1 align 2 {
  store ptr getelementptr inbounds inrange(-16, 16) (i8, ptr @_ZTVN3rmg10Particle3DE, i64 16), ptr %0, align 8, !tbaa !5
  %2 = getelementptr inbounds i8, ptr %0, i64 48
  %3 = load ptr, ptr %2, align 8, !tbaa !8
  %.not = icmp eq ptr %3, null
  br i1 %.not, label %17, label %4

4:                                                ; preds = %1
  %5 = getelementptr inbounds i8, ptr %0, i64 56
  %6 = load ptr, ptr %5, align 8, !tbaa !22
  %7 = load i32, ptr %6, align 4, !tbaa !23
  %8 = add i32 %7, -1
  store i32 %8, ptr %6, align 4, !tbaa !23
  %9 = icmp eq i32 %8, 0
  br i1 %9, label %10, label %17

10:                                               ; preds = %4
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %11, i64 8
  %13 = load ptr, ptr %12, align 8
  tail call void %13(ptr noundef nonnull align 8 dereferenceable(12) %3) #3
  %14 = load ptr, ptr %5, align 8, !tbaa !22
  %15 = icmp eq ptr %14, null
  br i1 %15, label %17, label %16

16:                                               ; preds = %10
  tail call void @_ZdlPvm(ptr noundef nonnull %14, i64 noundef 4) #4
  br label %17

17:                                               ; preds = %4, %16, %10, %1
  %18 = getelementptr inbounds i8, ptr %0, i64 64
  tail call void @_ZN3rmg8internal7PendingD1Ev(ptr noundef nonnull align 8 dereferenceable(16) %18) #3
  tail call void @_ZN3rmg6ObjectD2Ev(ptr noundef nonnull align 8 dereferenceable(48) %0) #3
  ret void
}

attributes #0 = { 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 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 = { nobuiltin 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 = { builtin 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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !13, i64 48}
!9 = !{!"_ZTSN3rmg10Particle3DE", !10, i64 0, !13, i64 48, !13, i64 56, !18, i64 64, !19, i64 80, !20, i64 92, !15, i64 100, !21, i64 104}
!10 = !{!"_ZTSN3rmg6ObjectE", !11, i64 8, !13, i64 16, !14, i64 24, !16, i64 40, !17, i64 44}
!11 = !{!"long", !12, i64 0}
!12 = !{!"omnipotent char", !7, i64 0}
!13 = !{!"any pointer", !12, i64 0}
!14 = !{!"_ZTSN3rmg9ColorRGBAE", !15, i64 0, !15, i64 4, !15, i64 8, !15, i64 12}
!15 = !{!"float", !12, i64 0}
!16 = !{!"bool", !12, i64 0}
!17 = !{!"_ZTSN3rmg10ObjectTypeE", !12, i64 0}
!18 = !{!"_ZTSN3rmg8internal7PendingE", !13, i64 0, !13, i64 8}
!19 = !{!"_ZTSN3rmg4Vec3E", !12, i64 0}
!20 = !{!"_ZTSN3rmg4Vec2E", !12, i64 0}
!21 = !{!"_ZTSN3rmg4Mat3E", !12, i64 0}
!22 = !{!9, !13, i64 56}
!23 = !{!24, !24, i64 0}
!24 = !{!"int", !12, i64 0}


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