; LLVM IR from aap/librw :: src/clump.ll (ZN2rw5Clump5cloneEv)

; 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.rw::PluginList" = type { i32, i32, %"struct.rw::LinkList" }
%"struct.rw::LinkList" = type { %"struct.rw::LLLink" }
%"struct.rw::LLLink" = type { ptr, ptr }
%"struct.rw::Clump" = type { %"struct.rw::Object", %"struct.rw::LinkList", %"struct.rw::LinkList", %"struct.rw::LinkList", ptr, %"struct.rw::LLLink" }
%"struct.rw::Object" = type { i8, i8, i8, i8, ptr }
%"struct.rw::Frame" = type { %"struct.rw::Object", %"struct.rw::LLLink", %"struct.rw::LinkList", %"struct.rw::Matrix", %"struct.rw::Matrix", ptr, ptr, ptr }
%"struct.rw::Matrix" = type { %"struct.rw::V3d", i32, %"struct.rw::V3d", i32, %"struct.rw::V3d", i32, %"struct.rw::V3d", i32 }
%"struct.rw::V3d" = type { float, float, float }

@_ZN2rw5Clump9s_plglistE = external dso_local global %"struct.rw::PluginList", align 8

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN2rw5Clump6createEv() #0 align 2

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN2rw5Clump5cloneEv(ptr noundef nonnull align 8 dereferenceable(88) %0) #0 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %9 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  %10 = call noundef ptr @_ZN2rw5Clump6createEv()
  store ptr %10, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  %11 = call noundef ptr @_ZNK2rw5Clump8getFrameEv(ptr noundef nonnull align 8 dereferenceable(88) %9)
  %12 = call noundef ptr @_ZN2rw5Frame12cloneAndLinkEv(ptr noundef nonnull align 8 dereferenceable(200) %11)
  store ptr %12, ptr %4, align 8, !tbaa !5
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_ZN2rw5Clump8setFrameEPNS_5FrameE(ptr noundef nonnull align 8 dereferenceable(88) %13, ptr noundef %14)
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  store ptr null, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %15 = getelementptr inbounds %"struct.rw::Clump", ptr %9, i32 0, i32 1
  %16 = getelementptr inbounds %"struct.rw::LinkList", ptr %15, i32 0, i32 0
  %17 = getelementptr inbounds %"struct.rw::LLLink", ptr %16, i32 0, i32 0
  %18 = load ptr, ptr %17, align 8, !tbaa !9
  store ptr %18, ptr %6, align 8, !tbaa !5
  br label %19

19:                                               ; preds = %40, %1
  %20 = load ptr, ptr %6, align 8, !tbaa !5
  %21 = getelementptr inbounds %"struct.rw::LLLink", ptr %20, i32 0, i32 0
  %22 = load ptr, ptr %21, align 8, !tbaa !14
  store ptr %22, ptr %5, align 8, !tbaa !5
  %23 = load ptr, ptr %6, align 8, !tbaa !5
  %24 = getelementptr inbounds %"struct.rw::Clump", ptr %9, i32 0, i32 1
  %25 = call noundef ptr @_ZN2rw8LinkList3endEv(ptr noundef nonnull align 8 dereferenceable(16) %24)
  %26 = icmp ne ptr %23, %25
  br i1 %26, label %28, label %27

27:                                               ; preds = %19
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  br label %42

28:                                               ; preds = %19
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %29 = load ptr, ptr %6, align 8, !tbaa !5
  %30 = call noundef ptr @_ZN2rw6Atomic9fromClumpEPNS_6LLLinkE(ptr noundef %29)
  store ptr %30, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %31 = load ptr, ptr %7, align 8, !tbaa !5
  %32 = call noundef ptr @_ZN2rw6Atomic5cloneEv(ptr noundef nonnull align 8 dereferenceable(136) %31)
  store ptr %32, ptr %8, align 8, !tbaa !5
  %33 = load ptr, ptr %8, align 8, !tbaa !5
  %34 = load ptr, ptr %7, align 8, !tbaa !5
  %35 = call noundef ptr @_ZNK2rw6Atomic8getFrameEv(ptr noundef nonnull align 8 dereferenceable(136) %34)
  %36 = getelementptr inbounds %"struct.rw::Frame", ptr %35, i32 0, i32 7
  %37 = load ptr, ptr %36, align 8, !tbaa !15
  call void @_ZN2rw6Atomic8setFrameEPNS_5FrameE(ptr noundef nonnull align 8 dereferenceable(136) %33, ptr noundef %37)
  %38 = load ptr, ptr %3, align 8, !tbaa !5
  %39 = load ptr, ptr %8, align 8, !tbaa !5
  call void @_ZN2rw5Clump9addAtomicEPNS_6AtomicE(ptr noundef nonnull align 8 dereferenceable(88) %38, ptr noundef %39)
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  br label %40

40:                                               ; preds = %28
  %41 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %41, ptr %6, align 8, !tbaa !5
  br label %19, !llvm.loop !21

42:                                               ; preds = %27
  %43 = call noundef ptr @_ZNK2rw5Clump8getFrameEv(ptr noundef nonnull align 8 dereferenceable(88) %9)
  call void @_ZN2rw5Frame10purgeCloneEv(ptr noundef nonnull align 8 dereferenceable(200) %43)
  %44 = getelementptr inbounds %"struct.rw::Clump", ptr %9, i32 0, i32 4
  %45 = load ptr, ptr %44, align 8, !tbaa !23
  %46 = icmp ne ptr %45, null
  br i1 %46, label %47, label %51

47:                                               ; preds = %42
  %48 = getelementptr inbounds %"struct.rw::Clump", ptr %9, i32 0, i32 4
  %49 = load ptr, ptr %48, align 8, !tbaa !23
  %50 = load ptr, ptr %3, align 8, !tbaa !5
  call void @_ZN2rw5World8addClumpEPNS_5ClumpE(ptr noundef nonnull align 8 dereferenceable(64) %49, ptr noundef %50)
  br label %51

51:                                               ; preds = %47, %42
  %52 = load ptr, ptr %3, align 8, !tbaa !5
  call void @_ZN2rw10PluginList4copyEPvS1_(ptr noundef nonnull align 8 dereferenceable(24) @_ZN2rw5Clump9s_plglistE, ptr noundef %52, ptr noundef %9)
  %53 = load ptr, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  ret ptr %53
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK2rw5Clump8getFrameEv(ptr noundef nonnull align 8 dereferenceable(88)) #2 align 2

declare noundef ptr @_ZN2rw5Frame12cloneAndLinkEv(ptr noundef nonnull align 8 dereferenceable(200)) #3

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN2rw5Clump8setFrameEPNS_5FrameE(ptr noundef nonnull align 8 dereferenceable(88), ptr noundef) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN2rw8LinkList3endEv(ptr noundef nonnull align 8 dereferenceable(16)) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN2rw6Atomic9fromClumpEPNS_6LLLinkE(ptr noundef) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN2rw6Atomic5cloneEv(ptr noundef nonnull align 8 dereferenceable(136)) #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN2rw6Atomic8setFrameEPNS_5FrameE(ptr noundef nonnull align 8 dereferenceable(136), ptr noundef) #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK2rw6Atomic8getFrameEv(ptr noundef nonnull align 8 dereferenceable(136)) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN2rw5Clump9addAtomicEPNS_6AtomicE(ptr noundef nonnull align 8 dereferenceable(88), ptr noundef) #0 align 2

declare void @_ZN2rw5Frame10purgeCloneEv(ptr noundef nonnull align 8 dereferenceable(200)) #3

declare void @_ZN2rw5World8addClumpEPNS_5ClumpE(ptr noundef nonnull align 8 dereferenceable(64), ptr noundef) #3

declare void @_ZN2rw10PluginList4copyEPvS1_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef, ptr noundef) #3

attributes #0 = { 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { "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 = { 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, !6, i64 16}
!10 = !{!"_ZTSN2rw5ClumpE", !11, i64 0, !12, i64 16, !12, i64 32, !12, i64 48, !6, i64 64, !13, i64 72}
!11 = !{!"_ZTSN2rw6ObjectE", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3, !6, i64 8}
!12 = !{!"_ZTSN2rw8LinkListE", !13, i64 0}
!13 = !{!"_ZTSN2rw6LLLinkE", !6, i64 0, !6, i64 8}
!14 = !{!13, !6, i64 0}
!15 = !{!16, !6, i64 192}
!16 = !{!"_ZTSN2rw5FrameE", !11, i64 0, !13, i64 16, !12, i64 32, !17, i64 48, !17, i64 112, !6, i64 176, !6, i64 184, !6, i64 192}
!17 = !{!"_ZTSN2rw6MatrixE", !18, i64 0, !20, i64 12, !18, i64 16, !20, i64 28, !18, i64 32, !20, i64 44, !18, i64 48, !20, i64 60}
!18 = !{!"_ZTSN2rw3V3dE", !19, i64 0, !19, i64 4, !19, i64 8}
!19 = !{!"float", !7, i64 0}
!20 = !{!"int", !7, i64 0}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}
!23 = !{!10, !6, i64 64}


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

%"struct.rw::PluginList" = type { i32, i32, %"struct.rw::LinkList" }
%"struct.rw::LinkList" = type { %"struct.rw::LLLink" }
%"struct.rw::LLLink" = type { ptr, ptr }

@_ZN2rw5Clump9s_plglistE = external dso_local global %"struct.rw::PluginList", align 8

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN2rw5Clump6createEv() local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN2rw5Clump5cloneEv(ptr noundef nonnull align 8 dereferenceable(88) %0) local_unnamed_addr #0 align 2 {
  %2 = tail call noundef ptr @_ZN2rw5Clump6createEv()
  %3 = tail call noundef ptr @_ZNK2rw5Clump8getFrameEv(ptr noundef nonnull align 8 dereferenceable(88) %0)
  %4 = tail call noundef ptr @_ZN2rw5Frame12cloneAndLinkEv(ptr noundef nonnull align 8 dereferenceable(200) %3)
  tail call void @_ZN2rw5Clump8setFrameEPNS_5FrameE(ptr noundef nonnull align 8 dereferenceable(88) %2, ptr noundef %4)
  %5 = getelementptr inbounds i8, ptr %0, i64 16
  %6 = load ptr, ptr %5, align 8, !tbaa !5
  %7 = load ptr, ptr %6, align 8, !tbaa !13
  %8 = tail call noundef ptr @_ZN2rw8LinkList3endEv(ptr noundef nonnull align 8 dereferenceable(16) %5)
  %.not17 = icmp eq ptr %6, %8
  br i1 %.not17, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %1
  %9 = tail call noundef ptr @_ZNK2rw5Clump8getFrameEv(ptr noundef nonnull align 8 dereferenceable(88) %0)
  tail call void @_ZN2rw5Frame10purgeCloneEv(ptr noundef nonnull align 8 dereferenceable(200) %9)
  %10 = getelementptr inbounds i8, ptr %0, i64 64
  %11 = load ptr, ptr %10, align 8, !tbaa !14
  %.not16 = icmp eq ptr %11, null
  br i1 %.not16, label %21, label %20

.lr.ph:                                           ; preds = %1, %.lr.ph
  %12 = phi ptr [ %18, %.lr.ph ], [ %7, %1 ]
  %.018 = phi ptr [ %12, %.lr.ph ], [ %6, %1 ]
  %13 = tail call noundef ptr @_ZN2rw6Atomic9fromClumpEPNS_6LLLinkE(ptr noundef nonnull %.018)
  %14 = tail call noundef ptr @_ZN2rw6Atomic5cloneEv(ptr noundef nonnull align 8 dereferenceable(136) %13)
  %15 = tail call noundef ptr @_ZNK2rw6Atomic8getFrameEv(ptr noundef nonnull align 8 dereferenceable(136) %13)
  %16 = getelementptr inbounds i8, ptr %15, i64 192
  %17 = load ptr, ptr %16, align 8, !tbaa !15
  tail call void @_ZN2rw6Atomic8setFrameEPNS_5FrameE(ptr noundef nonnull align 8 dereferenceable(136) %14, ptr noundef %17)
  tail call void @_ZN2rw5Clump9addAtomicEPNS_6AtomicE(ptr noundef nonnull align 8 dereferenceable(88) %2, ptr noundef nonnull %14)
  %18 = load ptr, ptr %12, align 8, !tbaa !13
  %19 = tail call noundef ptr @_ZN2rw8LinkList3endEv(ptr noundef nonnull align 8 dereferenceable(16) %5)
  %.not = icmp eq ptr %12, %19
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !21

20:                                               ; preds = %._crit_edge
  tail call void @_ZN2rw5World8addClumpEPNS_5ClumpE(ptr noundef nonnull align 8 dereferenceable(64) %11, ptr noundef nonnull %2)
  br label %21

21:                                               ; preds = %20, %._crit_edge
  tail call void @_ZN2rw10PluginList4copyEPvS1_(ptr noundef nonnull align 8 dereferenceable(24) @_ZN2rw5Clump9s_plglistE, ptr noundef nonnull %2, ptr noundef nonnull %0)
  ret ptr %2
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK2rw5Clump8getFrameEv(ptr noundef nonnull align 8 dereferenceable(88)) local_unnamed_addr #1 align 2

declare noundef ptr @_ZN2rw5Frame12cloneAndLinkEv(ptr noundef nonnull align 8 dereferenceable(200)) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN2rw5Clump8setFrameEPNS_5FrameE(ptr noundef nonnull align 8 dereferenceable(88), ptr noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN2rw8LinkList3endEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN2rw6Atomic9fromClumpEPNS_6LLLinkE(ptr noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN2rw6Atomic5cloneEv(ptr noundef nonnull align 8 dereferenceable(136)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN2rw6Atomic8setFrameEPNS_5FrameE(ptr noundef nonnull align 8 dereferenceable(136), ptr noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK2rw6Atomic8getFrameEv(ptr noundef nonnull align 8 dereferenceable(136)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN2rw5Clump9addAtomicEPNS_6AtomicE(ptr noundef nonnull align 8 dereferenceable(88), ptr noundef) local_unnamed_addr #0 align 2

declare void @_ZN2rw5Frame10purgeCloneEv(ptr noundef nonnull align 8 dereferenceable(200)) local_unnamed_addr #2

declare void @_ZN2rw5World8addClumpEPNS_5ClumpE(ptr noundef nonnull align 8 dereferenceable(64), ptr noundef) local_unnamed_addr #2

declare void @_ZN2rw10PluginList4copyEPvS1_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef, ptr noundef) local_unnamed_addr #2

attributes #0 = { 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 = { 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 = { "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, !10, i64 16}
!6 = !{!"_ZTSN2rw5ClumpE", !7, i64 0, !11, i64 16, !11, i64 32, !11, i64 48, !10, i64 64, !12, i64 72}
!7 = !{!"_ZTSN2rw6ObjectE", !8, i64 0, !8, i64 1, !8, i64 2, !8, i64 3, !10, i64 8}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"_ZTSN2rw8LinkListE", !12, i64 0}
!12 = !{!"_ZTSN2rw6LLLinkE", !10, i64 0, !10, i64 8}
!13 = !{!12, !10, i64 0}
!14 = !{!6, !10, i64 64}
!15 = !{!16, !10, i64 192}
!16 = !{!"_ZTSN2rw5FrameE", !7, i64 0, !12, i64 16, !11, i64 32, !17, i64 48, !17, i64 112, !10, i64 176, !10, i64 184, !10, i64 192}
!17 = !{!"_ZTSN2rw6MatrixE", !18, i64 0, !20, i64 12, !18, i64 16, !20, i64 28, !18, i64 32, !20, i64 44, !18, i64 48, !20, i64 60}
!18 = !{!"_ZTSN2rw3V3dE", !19, i64 0, !19, i64 4, !19, i64 8}
!19 = !{!"float", !8, i64 0}
!20 = !{!"int", !8, i64 0}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass