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

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

; 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 nounwind uwtable
declare dso_local noundef ptr @_ZNK2rw6Atomic8getFrameEv(ptr noundef nonnull align 8 dereferenceable(136)) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN2rw6Atomic22getWorldBoundingSphereEv(ptr noundef nonnull align 8 dereferenceable(136) %0) #2 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  %7 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  %8 = getelementptr inbounds %"struct.rw::Atomic", ptr %7, i32 0, i32 3
  store ptr %8, ptr %4, align 8, !tbaa !5
  %9 = call noundef ptr @_ZNK2rw6Atomic8getFrameEv(ptr noundef nonnull align 8 dereferenceable(136) %7)
  %10 = call noundef i32 @_ZNK2rw5Frame5dirtyEv(ptr noundef nonnull align 8 dereferenceable(200) %9)
  %11 = icmp ne i32 %10, 0
  br i1 %11, label %22, label %12

12:                                               ; preds = %1
  %13 = getelementptr inbounds %"struct.rw::Atomic", ptr %7, i32 0, i32 0
  %14 = getelementptr inbounds %"struct.rw::ObjectWithFrame", ptr %13, i32 0, i32 0
  %15 = getelementptr inbounds %"struct.rw::Object", ptr %14, i32 0, i32 3
  %16 = load i8, ptr %15, align 1, !tbaa !9
  %17 = zext i8 %16 to i32
  %18 = and i32 %17, 1
  %19 = icmp eq i32 %18, 0
  br i1 %19, label %20, label %22

20:                                               ; preds = %12
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %21, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %43

22:                                               ; preds = %12, %1
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %23 = call noundef ptr @_ZNK2rw6Atomic8getFrameEv(ptr noundef nonnull align 8 dereferenceable(136) %7)
  %24 = call noundef ptr @_ZN2rw5Frame6getLTMEv(ptr noundef nonnull align 8 dereferenceable(200) %23)
  store ptr %24, ptr %6, align 8, !tbaa !5
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = getelementptr inbounds %"struct.rw::Sphere", ptr %25, i32 0, i32 0
  %27 = getelementptr inbounds %"struct.rw::Atomic", ptr %7, i32 0, i32 2
  %28 = getelementptr inbounds %"struct.rw::Sphere", ptr %27, i32 0, i32 0
  %29 = load ptr, ptr %6, align 8, !tbaa !5
  call void @_ZN2rw3V3d15transformPointsEPS0_PKS0_iPKNS_6MatrixE(ptr noundef %26, ptr noundef %28, i32 noundef 1, ptr noundef %29)
  %30 = getelementptr inbounds %"struct.rw::Atomic", ptr %7, i32 0, i32 2
  %31 = getelementptr inbounds %"struct.rw::Sphere", ptr %30, i32 0, i32 1
  %32 = load float, ptr %31, align 4, !tbaa !17
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  %34 = getelementptr inbounds %"struct.rw::Sphere", ptr %33, i32 0, i32 1
  store float %32, ptr %34, align 4, !tbaa !18
  %35 = getelementptr inbounds %"struct.rw::Atomic", ptr %7, i32 0, i32 0
  %36 = getelementptr inbounds %"struct.rw::ObjectWithFrame", ptr %35, i32 0, i32 0
  %37 = getelementptr inbounds %"struct.rw::Object", ptr %36, i32 0, i32 3
  %38 = load i8, ptr %37, align 1, !tbaa !9
  %39 = zext i8 %38 to i32
  %40 = and i32 %39, -2
  %41 = trunc i32 %40 to i8
  store i8 %41, ptr %37, align 1, !tbaa !9
  %42 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %42, ptr %2, align 8
  store i32 1, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  br label %43

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK2rw5Frame5dirtyEv(ptr noundef nonnull align 8 dereferenceable(200)) #1 align 2

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

declare void @_ZN2rw3V3d15transformPointsEPS0_PKS0_iPKNS_6MatrixE(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = { "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, !16, i64 60}
!18 = !{!14, !16, i64 12}


; 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

; Function Attrs: mustprogress uwtable
define dso_local noundef nonnull ptr @_ZN2rw6Atomic22getWorldBoundingSphereEv(ptr noundef nonnull align 8 dereferenceable(136) %0) local_unnamed_addr #1 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 64
  %3 = tail call noundef ptr @_ZNK2rw6Atomic8getFrameEv(ptr noundef nonnull align 8 dereferenceable(136) %0)
  %4 = tail call noundef i32 @_ZNK2rw5Frame5dirtyEv(ptr noundef nonnull align 8 dereferenceable(200) %3)
  %.not = icmp eq i32 %4, 0
  br i1 %.not, label %5, label %10

5:                                                ; preds = %1
  %6 = getelementptr inbounds i8, ptr %0, i64 3
  %7 = load i8, ptr %6, align 1, !tbaa !5
  %8 = and i8 %7, 1
  %9 = icmp eq i8 %8, 0
  br i1 %9, label %20, label %10

10:                                               ; preds = %5, %1
  %11 = tail call noundef ptr @_ZNK2rw6Atomic8getFrameEv(ptr noundef nonnull align 8 dereferenceable(136) %0)
  %12 = tail call noundef ptr @_ZN2rw5Frame6getLTMEv(ptr noundef nonnull align 8 dereferenceable(200) %11)
  %13 = getelementptr inbounds i8, ptr %0, i64 48
  tail call void @_ZN2rw3V3d15transformPointsEPS0_PKS0_iPKNS_6MatrixE(ptr noundef nonnull %2, ptr noundef nonnull %13, i32 noundef 1, ptr noundef %12)
  %14 = getelementptr inbounds i8, ptr %0, i64 60
  %15 = load float, ptr %14, align 4, !tbaa !16
  %16 = getelementptr inbounds i8, ptr %0, i64 76
  store float %15, ptr %16, align 4, !tbaa !17
  %17 = getelementptr inbounds i8, ptr %0, i64 3
  %18 = load i8, ptr %17, align 1, !tbaa !5
  %19 = and i8 %18, -2
  store i8 %19, ptr %17, align 1, !tbaa !5
  br label %20

20:                                               ; preds = %5, %10
  ret ptr %2
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK2rw5Frame5dirtyEv(ptr noundef nonnull align 8 dereferenceable(200)) local_unnamed_addr #0 align 2

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

declare void @_ZN2rw3V3d15transformPointsEPS0_PKS0_iPKNS_6MatrixE(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #2

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

!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, !15, i64 60}
!17 = !{!13, !15, i64 12}


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