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

; 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::Atomic" = type { %"struct.rw::ObjectWithFrame", ptr, %"struct.rw::Sphere", %"struct.rw::Sphere", ptr, %"struct.rw::LLLink", ptr, ptr, ptr, ptr }
%"struct.rw::ObjectWithFrame" = type { %"struct.rw::Object", %"struct.rw::LLLink", ptr }
%"struct.rw::Object" = type { i8, i8, i8, i8, ptr }
%"struct.rw::Sphere" = type { %"struct.rw::V3d", float }
%"struct.rw::V3d" = type { float, float, float }

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

; 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 uwtable
define dso_local noundef ptr @_ZN2rw6Atomic5cloneEv(ptr noundef nonnull align 8 dereferenceable(136) %0) #1 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  %6 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  %7 = call noundef ptr @_ZN2rw6Atomic6createEv()
  store ptr %7, ptr %4, align 8, !tbaa !5
  %8 = load ptr, ptr %4, align 8, !tbaa !5
  %9 = icmp eq ptr %8, null
  br i1 %9, label %10, label %11

10:                                               ; preds = %1
  store ptr null, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %43

11:                                               ; preds = %1
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = getelementptr inbounds %"struct.rw::Atomic", ptr %12, i32 0, i32 0
  %14 = getelementptr inbounds %"struct.rw::ObjectWithFrame", ptr %13, i32 0, i32 0
  %15 = getelementptr inbounds %"struct.rw::Atomic", ptr %6, i32 0, i32 0
  %16 = getelementptr inbounds %"struct.rw::ObjectWithFrame", ptr %15, i32 0, i32 0
  call void @_ZN2rw6Object4copyEPS0_(ptr noundef nonnull align 8 dereferenceable(16) %14, ptr noundef %16)
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = getelementptr inbounds %"struct.rw::Atomic", ptr %17, i32 0, i32 0
  %19 = getelementptr inbounds %"struct.rw::ObjectWithFrame", ptr %18, i32 0, i32 0
  %20 = getelementptr inbounds %"struct.rw::Object", ptr %19, i32 0, i32 3
  %21 = load i8, ptr %20, align 1, !tbaa !9
  %22 = zext i8 %21 to i32
  %23 = or i32 %22, 1
  %24 = trunc i32 %23 to i8
  store i8 %24, ptr %20, align 1, !tbaa !9
  %25 = getelementptr inbounds %"struct.rw::Atomic", ptr %6, i32 0, i32 1
  %26 = load ptr, ptr %25, align 8, !tbaa !17
  %27 = icmp ne ptr %26, null
  br i1 %27, label %28, label %32

28:                                               ; preds = %11
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  %30 = getelementptr inbounds %"struct.rw::Atomic", ptr %6, i32 0, i32 1
  %31 = load ptr, ptr %30, align 8, !tbaa !17
  call void @_ZN2rw6Atomic11setGeometryEPNS_8GeometryEj(ptr noundef nonnull align 8 dereferenceable(136) %29, ptr noundef %31, i32 noundef 0)
  br label %32

32:                                               ; preds = %28, %11
  %33 = getelementptr inbounds %"struct.rw::Atomic", ptr %6, i32 0, i32 7
  %34 = load ptr, ptr %33, align 8, !tbaa !18
  %35 = load ptr, ptr %4, align 8, !tbaa !5
  %36 = getelementptr inbounds %"struct.rw::Atomic", ptr %35, i32 0, i32 7
  store ptr %34, ptr %36, align 8, !tbaa !18
  %37 = getelementptr inbounds %"struct.rw::Atomic", ptr %6, i32 0, i32 6
  %38 = load ptr, ptr %37, align 8, !tbaa !19
  %39 = load ptr, ptr %4, align 8, !tbaa !5
  %40 = getelementptr inbounds %"struct.rw::Atomic", ptr %39, i32 0, i32 6
  store ptr %38, ptr %40, align 8, !tbaa !19
  %41 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_ZN2rw10PluginList4copyEPvS1_(ptr noundef nonnull align 8 dereferenceable(24) @_ZN2rw6Atomic9s_plglistE, ptr noundef %41, ptr noundef %6)
  %42 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %42, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %43

43:                                               ; preds = %32, %10
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  %44 = load ptr, ptr %2, align 8
  ret ptr %44
}

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

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

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

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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" }
attributes #3 = { 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 #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, !7, i64 3}
!10 = !{!"_ZTSN2rw6AtomicE", !11, i64 0, !6, i64 40, !14, i64 48, !14, i64 64, !6, i64 80, !13, i64 88, !6, i64 104, !6, i64 112, !6, i64 120, !6, i64 128}
!11 = !{!"_ZTSN2rw15ObjectWithFrameE", !12, i64 0, !13, i64 16, !6, i64 32}
!12 = !{!"_ZTSN2rw6ObjectE", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3, !6, i64 8}
!13 = !{!"_ZTSN2rw6LLLinkE", !6, i64 0, !6, i64 8}
!14 = !{!"_ZTSN2rw6SphereE", !15, i64 0, !16, i64 12}
!15 = !{!"_ZTSN2rw3V3dE", !16, i64 0, !16, i64 4, !16, i64 8}
!16 = !{!"float", !7, i64 0}
!17 = !{!10, !6, i64 40}
!18 = !{!10, !6, i64 112}
!19 = !{!10, !6, i64 104}


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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN2rw6Atomic5cloneEv(ptr noundef nonnull align 8 dereferenceable(136) %0) local_unnamed_addr #0 align 2 {
  %2 = tail call noundef ptr @_ZN2rw6Atomic6createEv()
  %3 = icmp eq ptr %2, null
  br i1 %3, label %15, label %4

4:                                                ; preds = %1
  tail call void @_ZN2rw6Object4copyEPS0_(ptr noundef nonnull align 8 dereferenceable(16) %2, ptr noundef nonnull %0)
  %5 = getelementptr inbounds i8, ptr %2, i64 3
  %6 = load i8, ptr %5, align 1, !tbaa !5
  %7 = or i8 %6, 1
  store i8 %7, ptr %5, align 1, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %0, i64 40
  %9 = load ptr, ptr %8, align 8, !tbaa !16
  %.not = icmp eq ptr %9, null
  br i1 %.not, label %11, label %10

10:                                               ; preds = %4
  tail call void @_ZN2rw6Atomic11setGeometryEPNS_8GeometryEj(ptr noundef nonnull align 8 dereferenceable(136) %2, ptr noundef nonnull %9, i32 noundef 0)
  br label %11

11:                                               ; preds = %10, %4
  %12 = getelementptr inbounds i8, ptr %0, i64 104
  %13 = getelementptr inbounds i8, ptr %2, i64 104
  %14 = load <2 x ptr>, ptr %12, align 8, !tbaa !17
  store <2 x ptr> %14, ptr %13, align 8, !tbaa !17
  tail call void @_ZN2rw10PluginList4copyEPvS1_(ptr noundef nonnull align 8 dereferenceable(24) @_ZN2rw6Atomic9s_plglistE, ptr noundef nonnull %2, ptr noundef nonnull %0)
  br label %15

15:                                               ; preds = %1, %11
  ret ptr %2
}

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN2rw6Atomic11setGeometryEPNS_8GeometryEj(ptr noundef nonnull align 8 dereferenceable(136), ptr noundef, i32 noundef) local_unnamed_addr #0 align 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 = { "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 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, !9, i64 3}
!6 = !{!"_ZTSN2rw6AtomicE", !7, i64 0, !11, i64 40, !13, i64 48, !13, i64 64, !11, i64 80, !12, i64 88, !11, i64 104, !11, i64 112, !11, i64 120, !11, i64 128}
!7 = !{!"_ZTSN2rw15ObjectWithFrameE", !8, i64 0, !12, i64 16, !11, i64 32}
!8 = !{!"_ZTSN2rw6ObjectE", !9, i64 0, !9, i64 1, !9, i64 2, !9, i64 3, !11, i64 8}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"any pointer", !9, i64 0}
!12 = !{!"_ZTSN2rw6LLLinkE", !11, i64 0, !11, i64 8}
!13 = !{!"_ZTSN2rw6SphereE", !14, i64 0, !15, i64 12}
!14 = !{!"_ZTSN2rw3V3dE", !15, i64 0, !15, i64 4, !15, i64 8}
!15 = !{!"float", !9, i64 0}
!16 = !{!6, !11, i64 40}
!17 = !{!11, !11, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass