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

; 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::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 }
%"struct.rw::LLLink" = type { ptr, ptr }
%"struct.rw::Geometry" = type { %"struct.rw::Object", i32, i16, i32, i32, i32, i32, ptr, ptr, [8 x ptr], ptr, %"struct.rw::MaterialList", ptr, ptr, i32 }
%"struct.rw::MaterialList" = type { ptr, i32, i32 }
%"struct.rw::MorphTarget" = type { ptr, %"struct.rw::Sphere", ptr, ptr }

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

declare void @_ZN2rw8Geometry7destroyEv(ptr noundef nonnull align 8 dereferenceable(168)) #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN2rw6Atomic11setGeometryEPNS_8GeometryEj(ptr noundef nonnull align 8 dereferenceable(136) %0, ptr noundef %1, i32 noundef %2) #2 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i32 %2, ptr %6, align 4, !tbaa !9
  %7 = load ptr, ptr %4, align 8
  %8 = getelementptr inbounds %"struct.rw::Atomic", ptr %7, i32 0, i32 1
  %9 = load ptr, ptr %8, align 8, !tbaa !11
  %10 = icmp ne ptr %9, null
  br i1 %10, label %11, label %14

11:                                               ; preds = %3
  %12 = getelementptr inbounds %"struct.rw::Atomic", ptr %7, i32 0, i32 1
  %13 = load ptr, ptr %12, align 8, !tbaa !11
  call void @_ZN2rw8Geometry7destroyEv(ptr noundef nonnull align 8 dereferenceable(168) %13)
  br label %14

14:                                               ; preds = %11, %3
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = icmp ne ptr %15, null
  br i1 %16, label %17, label %19

17:                                               ; preds = %14
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  call void @_ZN2rw8Geometry6addRefEv(ptr noundef nonnull align 8 dereferenceable(168) %18)
  br label %19

19:                                               ; preds = %17, %14
  %20 = load ptr, ptr %5, align 8, !tbaa !5
  %21 = getelementptr inbounds %"struct.rw::Atomic", ptr %7, i32 0, i32 1
  store ptr %20, ptr %21, align 8, !tbaa !11
  %22 = load i32, ptr %6, align 4, !tbaa !9
  %23 = and i32 %22, 1
  %24 = icmp ne i32 %23, 0
  br i1 %24, label %25, label %26

25:                                               ; preds = %19
  br label %41

26:                                               ; preds = %19
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = icmp ne ptr %27, null
  br i1 %28, label %29, label %41

29:                                               ; preds = %26
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = getelementptr inbounds %"struct.rw::Geometry", ptr %30, i32 0, i32 10
  %32 = load ptr, ptr %31, align 8, !tbaa !19
  %33 = getelementptr inbounds %"struct.rw::MorphTarget", ptr %32, i64 0
  %34 = getelementptr inbounds %"struct.rw::MorphTarget", ptr %33, i32 0, i32 1
  %35 = getelementptr inbounds %"struct.rw::Atomic", ptr %7, i32 0, i32 2
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %35, ptr align 8 %34, i64 16, i1 false), !tbaa.struct !23
  %36 = call noundef ptr @_ZNK2rw6Atomic8getFrameEv(ptr noundef nonnull align 8 dereferenceable(136) %7)
  %37 = icmp ne ptr %36, null
  br i1 %37, label %38, label %40

38:                                               ; preds = %29
  %39 = call noundef ptr @_ZNK2rw6Atomic8getFrameEv(ptr noundef nonnull align 8 dereferenceable(136) %7)
  call void @_ZN2rw5Frame13updateObjectsEv(ptr noundef nonnull align 8 dereferenceable(200) %39)
  br label %40

40:                                               ; preds = %38, %29
  br label %41

41:                                               ; preds = %40, %26, %25
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN2rw8Geometry6addRefEv(ptr noundef nonnull align 8 dereferenceable(168)) #0 align 2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

declare void @_ZN2rw5Frame13updateObjectsEv(ptr noundef nonnull align 8 dereferenceable(200)) #1

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 = { "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 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }

!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, !6, i64 40}
!12 = !{!"_ZTSN2rw6AtomicE", !13, i64 0, !6, i64 40, !16, i64 48, !16, i64 64, !6, i64 80, !15, i64 88, !6, i64 104, !6, i64 112, !6, i64 120, !6, i64 128}
!13 = !{!"_ZTSN2rw15ObjectWithFrameE", !14, i64 0, !15, i64 16, !6, i64 32}
!14 = !{!"_ZTSN2rw6ObjectE", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3, !6, i64 8}
!15 = !{!"_ZTSN2rw6LLLinkE", !6, i64 0, !6, i64 8}
!16 = !{!"_ZTSN2rw6SphereE", !17, i64 0, !18, i64 12}
!17 = !{!"_ZTSN2rw3V3dE", !18, i64 0, !18, i64 4, !18, i64 8}
!18 = !{!"float", !7, i64 0}
!19 = !{!20, !6, i64 120}
!20 = !{!"_ZTSN2rw8GeometryE", !14, i64 0, !10, i64 16, !21, i64 20, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !6, i64 40, !6, i64 48, !7, i64 56, !6, i64 120, !22, i64 128, !6, i64 144, !6, i64 152, !10, i64 160}
!21 = !{!"short", !7, i64 0}
!22 = !{!"_ZTSN2rw12MaterialListE", !6, i64 0, !10, i64 8, !10, i64 12}
!23 = !{i64 0, i64 4, !24, i64 4, i64 4, !24, i64 8, i64 4, !24, i64 12, i64 4, !24}
!24 = !{!18, !18, 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 nounwind uwtable
declare dso_local noundef ptr @_ZNK2rw6Atomic8getFrameEv(ptr noundef nonnull align 8 dereferenceable(136)) local_unnamed_addr #0 align 2

declare void @_ZN2rw8Geometry7destroyEv(ptr noundef nonnull align 8 dereferenceable(168)) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN2rw6Atomic11setGeometryEPNS_8GeometryEj(ptr noundef nonnull align 8 dereferenceable(136) %0, ptr noundef %1, i32 noundef %2) local_unnamed_addr #2 align 2 {
  %4 = getelementptr inbounds i8, ptr %0, i64 40
  %5 = load ptr, ptr %4, align 8, !tbaa !5
  %.not = icmp eq ptr %5, null
  br i1 %.not, label %7, label %6

6:                                                ; preds = %3
  tail call void @_ZN2rw8Geometry7destroyEv(ptr noundef nonnull align 8 dereferenceable(168) %5)
  br label %7

7:                                                ; preds = %6, %3
  %.not10 = icmp eq ptr %1, null
  br i1 %.not10, label %.thread, label %8

.thread:                                          ; preds = %7
  store ptr null, ptr %4, align 8, !tbaa !5
  br label %19

8:                                                ; preds = %7
  tail call void @_ZN2rw8Geometry6addRefEv(ptr noundef nonnull align 8 dereferenceable(168) %1)
  store ptr %1, ptr %4, align 8, !tbaa !5
  %9 = and i32 %2, 1
  %10 = icmp eq i32 %9, 0
  br i1 %10, label %11, label %19

11:                                               ; preds = %8
  %12 = getelementptr inbounds i8, ptr %1, i64 120
  %13 = load ptr, ptr %12, align 8, !tbaa !16
  %14 = getelementptr inbounds i8, ptr %13, i64 8
  %15 = getelementptr inbounds i8, ptr %0, i64 48
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %15, ptr noundef nonnull align 8 dereferenceable(16) %14, i64 16, i1 false), !tbaa.struct !21
  %16 = tail call noundef ptr @_ZNK2rw6Atomic8getFrameEv(ptr noundef nonnull align 8 dereferenceable(136) %0)
  %.not8 = icmp eq ptr %16, null
  br i1 %.not8, label %19, label %17

17:                                               ; preds = %11
  %18 = tail call noundef ptr @_ZNK2rw6Atomic8getFrameEv(ptr noundef nonnull align 8 dereferenceable(136) %0)
  tail call void @_ZN2rw5Frame13updateObjectsEv(ptr noundef nonnull align 8 dereferenceable(200) %18)
  br label %19

19:                                               ; preds = %.thread, %11, %17, %8
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN2rw8Geometry6addRefEv(ptr noundef nonnull align 8 dereferenceable(168)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

declare void @_ZN2rw5Frame13updateObjectsEv(ptr noundef nonnull align 8 dereferenceable(200)) local_unnamed_addr #1

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 = { "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 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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }

!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, !11, i64 40}
!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 = !{!17, !11, i64 120}
!17 = !{!"_ZTSN2rw8GeometryE", !8, i64 0, !18, i64 16, !19, i64 20, !18, i64 24, !18, i64 28, !18, i64 32, !18, i64 36, !11, i64 40, !11, i64 48, !9, i64 56, !11, i64 120, !20, i64 128, !11, i64 144, !11, i64 152, !18, i64 160}
!18 = !{!"int", !9, i64 0}
!19 = !{!"short", !9, i64 0}
!20 = !{!"_ZTSN2rw12MaterialListE", !11, i64 0, !18, i64 8, !18, i64 12}
!21 = !{i64 0, i64 4, !22, i64 4, i64 4, !22, i64 8, i64 4, !22, i64 12, i64 4, !22}
!22 = !{!15, !15, i64 0}


; Effective O3 passes: ConstraintEliminationPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass