; LLVM IR from aap/librw :: src/frame.ll (ZN2rw5Frame8addChildEPS0_i)

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

; 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 @_ZNK2rw5Frame9getParentEv(ptr noundef nonnull align 8 dereferenceable(200)) #1 align 2

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN2rw5Frame8addChildEPS0_i(ptr noundef nonnull align 8 dereferenceable(200) %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
  %7 = alloca ptr, align 8
  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
  %8 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %9 = load ptr, ptr %5, align 8, !tbaa !5
  %10 = call noundef ptr @_ZNK2rw5Frame9getParentEv(ptr noundef nonnull align 8 dereferenceable(200) %9)
  %11 = icmp ne ptr %10, null
  br i1 %11, label %12, label %15

12:                                               ; preds = %3
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = call noundef ptr @_ZN2rw5Frame11removeChildEv(ptr noundef nonnull align 8 dereferenceable(200) %13)
  br label %15

15:                                               ; preds = %12, %3
  %16 = load i32, ptr %6, align 4, !tbaa !9
  %17 = icmp ne i32 %16, 0
  br i1 %17, label %18, label %45

18:                                               ; preds = %15
  %19 = getelementptr inbounds %"struct.rw::Frame", ptr %8, i32 0, i32 5
  %20 = load ptr, ptr %19, align 8, !tbaa !11
  %21 = icmp eq ptr %20, null
  br i1 %21, label %22, label %25

22:                                               ; preds = %18
  %23 = load ptr, ptr %5, align 8, !tbaa !5
  %24 = getelementptr inbounds %"struct.rw::Frame", ptr %8, i32 0, i32 5
  store ptr %23, ptr %24, align 8, !tbaa !11
  br label %42

25:                                               ; preds = %18
  %26 = getelementptr inbounds %"struct.rw::Frame", ptr %8, i32 0, i32 5
  %27 = load ptr, ptr %26, align 8, !tbaa !11
  store ptr %27, ptr %7, align 8, !tbaa !5
  br label %28

28:                                               ; preds = %34, %25
  %29 = load ptr, ptr %7, align 8, !tbaa !5
  %30 = getelementptr inbounds %"struct.rw::Frame", ptr %29, i32 0, i32 6
  %31 = load ptr, ptr %30, align 8, !tbaa !19
  %32 = icmp ne ptr %31, null
  br i1 %32, label %33, label %38

33:                                               ; preds = %28
  br label %34

34:                                               ; preds = %33
  %35 = load ptr, ptr %7, align 8, !tbaa !5
  %36 = getelementptr inbounds %"struct.rw::Frame", ptr %35, i32 0, i32 6
  %37 = load ptr, ptr %36, align 8, !tbaa !19
  store ptr %37, ptr %7, align 8, !tbaa !5
  br label %28, !llvm.loop !20

38:                                               ; preds = %28
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %40 = load ptr, ptr %7, align 8, !tbaa !5
  %41 = getelementptr inbounds %"struct.rw::Frame", ptr %40, i32 0, i32 6
  store ptr %39, ptr %41, align 8, !tbaa !19
  br label %42

42:                                               ; preds = %38, %22
  %43 = load ptr, ptr %5, align 8, !tbaa !5
  %44 = getelementptr inbounds %"struct.rw::Frame", ptr %43, i32 0, i32 6
  store ptr null, ptr %44, align 8, !tbaa !19
  br label %52

45:                                               ; preds = %15
  %46 = getelementptr inbounds %"struct.rw::Frame", ptr %8, i32 0, i32 5
  %47 = load ptr, ptr %46, align 8, !tbaa !11
  %48 = load ptr, ptr %5, align 8, !tbaa !5
  %49 = getelementptr inbounds %"struct.rw::Frame", ptr %48, i32 0, i32 6
  store ptr %47, ptr %49, align 8, !tbaa !19
  %50 = load ptr, ptr %5, align 8, !tbaa !5
  %51 = getelementptr inbounds %"struct.rw::Frame", ptr %8, i32 0, i32 5
  store ptr %50, ptr %51, align 8, !tbaa !11
  br label %52

52:                                               ; preds = %45, %42
  %53 = load ptr, ptr %5, align 8, !tbaa !5
  %54 = getelementptr inbounds %"struct.rw::Frame", ptr %53, i32 0, i32 0
  %55 = getelementptr inbounds %"struct.rw::Object", ptr %54, i32 0, i32 4
  store ptr %8, ptr %55, align 8, !tbaa !22
  %56 = getelementptr inbounds %"struct.rw::Frame", ptr %8, i32 0, i32 7
  %57 = load ptr, ptr %56, align 8, !tbaa !23
  %58 = load ptr, ptr %5, align 8, !tbaa !5
  %59 = getelementptr inbounds %"struct.rw::Frame", ptr %58, i32 0, i32 7
  store ptr %57, ptr %59, align 8, !tbaa !23
  %60 = load ptr, ptr %5, align 8, !tbaa !5
  %61 = getelementptr inbounds %"struct.rw::Frame", ptr %60, i32 0, i32 5
  %62 = load ptr, ptr %61, align 8, !tbaa !11
  store ptr %62, ptr %7, align 8, !tbaa !5
  br label %63

63:                                               ; preds = %68, %52
  %64 = load ptr, ptr %7, align 8, !tbaa !5
  %65 = icmp ne ptr %64, null
  br i1 %65, label %66, label %72

66:                                               ; preds = %63
  %67 = load ptr, ptr %7, align 8, !tbaa !5
  call void @_ZN2rw5Frame16setHierarchyRootEPS0_(ptr noundef nonnull align 8 dereferenceable(200) %67, ptr noundef %8)
  br label %68

68:                                               ; preds = %66
  %69 = load ptr, ptr %7, align 8, !tbaa !5
  %70 = getelementptr inbounds %"struct.rw::Frame", ptr %69, i32 0, i32 6
  %71 = load ptr, ptr %70, align 8, !tbaa !19
  store ptr %71, ptr %7, align 8, !tbaa !5
  br label %63, !llvm.loop !24

72:                                               ; preds = %63
  %73 = load ptr, ptr %5, align 8, !tbaa !5
  %74 = getelementptr inbounds %"struct.rw::Frame", ptr %73, i32 0, i32 0
  %75 = getelementptr inbounds %"struct.rw::Object", ptr %74, i32 0, i32 3
  %76 = load i8, ptr %75, align 1, !tbaa !25
  %77 = zext i8 %76 to i32
  %78 = and i32 %77, 3
  %79 = icmp ne i32 %78, 0
  br i1 %79, label %80, label %90

80:                                               ; preds = %72
  %81 = load ptr, ptr %5, align 8, !tbaa !5
  %82 = getelementptr inbounds %"struct.rw::Frame", ptr %81, i32 0, i32 1
  call void @_ZN2rw6LLLink6removeEv(ptr noundef nonnull align 8 dereferenceable(16) %82)
  %83 = load ptr, ptr %5, align 8, !tbaa !5
  %84 = getelementptr inbounds %"struct.rw::Frame", ptr %83, i32 0, i32 0
  %85 = getelementptr inbounds %"struct.rw::Object", ptr %84, i32 0, i32 3
  %86 = load i8, ptr %85, align 1, !tbaa !25
  %87 = zext i8 %86 to i32
  %88 = and i32 %87, -4
  %89 = trunc i32 %88 to i8
  store i8 %89, ptr %85, align 1, !tbaa !25
  br label %90

90:                                               ; preds = %80, %72
  call void @_ZN2rw5Frame13updateObjectsEv(ptr noundef nonnull align 8 dereferenceable(200) %8)
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  ret ptr %8
}

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN2rw5Frame13updateObjectsEv(ptr noundef nonnull align 8 dereferenceable(200)) #2 align 2

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 = { 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 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 176}
!12 = !{!"_ZTSN2rw5FrameE", !13, i64 0, !14, i64 16, !15, i64 32, !16, i64 48, !16, i64 112, !6, i64 176, !6, i64 184, !6, i64 192}
!13 = !{!"_ZTSN2rw6ObjectE", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3, !6, i64 8}
!14 = !{!"_ZTSN2rw6LLLinkE", !6, i64 0, !6, i64 8}
!15 = !{!"_ZTSN2rw8LinkListE", !14, i64 0}
!16 = !{!"_ZTSN2rw6MatrixE", !17, i64 0, !10, i64 12, !17, i64 16, !10, i64 28, !17, i64 32, !10, i64 44, !17, i64 48, !10, i64 60}
!17 = !{!"_ZTSN2rw3V3dE", !18, i64 0, !18, i64 4, !18, i64 8}
!18 = !{!"float", !7, i64 0}
!19 = !{!12, !6, i64 184}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}
!22 = !{!12, !6, i64 8}
!23 = !{!12, !6, i64 192}
!24 = distinct !{!24, !21}
!25 = !{!12, !7, i64 3}


; 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 @_ZNK2rw5Frame9getParentEv(ptr noundef nonnull align 8 dereferenceable(200)) local_unnamed_addr #0 align 2

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef nonnull ptr @_ZN2rw5Frame8addChildEPS0_i(ptr noundef nonnull returned align 8 dereferenceable(200) %0, ptr noundef nonnull %1, i32 noundef %2) local_unnamed_addr #1 align 2 {
  %4 = tail call noundef ptr @_ZNK2rw5Frame9getParentEv(ptr noundef nonnull align 8 dereferenceable(200) %1)
  %.not = icmp eq ptr %4, null
  br i1 %.not, label %7, label %5

5:                                                ; preds = %3
  %6 = tail call noundef ptr @_ZN2rw5Frame11removeChildEv(ptr noundef nonnull align 8 dereferenceable(200) %1)
  br label %7

7:                                                ; preds = %5, %3
  %.not22 = icmp eq i32 %2, 0
  %8 = getelementptr inbounds i8, ptr %0, i64 176
  %9 = load ptr, ptr %8, align 8, !tbaa !5
  br i1 %.not22, label %18, label %10

10:                                               ; preds = %7
  %11 = icmp eq ptr %9, null
  br i1 %11, label %16, label %.preheader

.preheader:                                       ; preds = %10, %.preheader
  %.0 = phi ptr [ %13, %.preheader ], [ %9, %10 ]
  %12 = getelementptr inbounds i8, ptr %.0, i64 184
  %13 = load ptr, ptr %12, align 8, !tbaa !17
  %.not23 = icmp eq ptr %13, null
  br i1 %.not23, label %14, label %.preheader, !llvm.loop !18

14:                                               ; preds = %.preheader
  %15 = getelementptr inbounds i8, ptr %.0, i64 184
  br label %16

16:                                               ; preds = %10, %14
  %.sink = phi ptr [ %15, %14 ], [ %8, %10 ]
  store ptr %1, ptr %.sink, align 8, !tbaa !20
  %17 = getelementptr inbounds i8, ptr %1, i64 184
  store ptr null, ptr %17, align 8, !tbaa !17
  br label %20

18:                                               ; preds = %7
  %19 = getelementptr inbounds i8, ptr %1, i64 184
  store ptr %9, ptr %19, align 8, !tbaa !17
  store ptr %1, ptr %8, align 8, !tbaa !5
  br label %20

20:                                               ; preds = %18, %16
  %21 = getelementptr inbounds i8, ptr %1, i64 8
  store ptr %0, ptr %21, align 8, !tbaa !21
  %22 = getelementptr inbounds i8, ptr %0, i64 192
  %23 = load ptr, ptr %22, align 8, !tbaa !22
  %24 = getelementptr inbounds i8, ptr %1, i64 192
  store ptr %23, ptr %24, align 8, !tbaa !22
  %25 = getelementptr inbounds i8, ptr %1, i64 176
  %.126 = load ptr, ptr %25, align 8, !tbaa !20
  %.not2427 = icmp eq ptr %.126, null
  br i1 %.not2427, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %20, %.lr.ph
  %.128 = phi ptr [ %.1, %.lr.ph ], [ %.126, %20 ]
  tail call void @_ZN2rw5Frame16setHierarchyRootEPS0_(ptr noundef nonnull align 8 dereferenceable(200) %.128, ptr noundef nonnull %0)
  %26 = getelementptr inbounds i8, ptr %.128, i64 184
  %.1 = load ptr, ptr %26, align 8, !tbaa !20
  %.not24 = icmp eq ptr %.1, null
  br i1 %.not24, label %._crit_edge, label %.lr.ph, !llvm.loop !23

._crit_edge:                                      ; preds = %.lr.ph, %20
  %27 = getelementptr inbounds i8, ptr %1, i64 3
  %28 = load i8, ptr %27, align 1, !tbaa !24
  %29 = and i8 %28, 3
  %.not25 = icmp eq i8 %29, 0
  br i1 %.not25, label %34, label %30

30:                                               ; preds = %._crit_edge
  %31 = getelementptr inbounds i8, ptr %1, i64 16
  tail call void @_ZN2rw6LLLink6removeEv(ptr noundef nonnull align 8 dereferenceable(16) %31)
  %32 = load i8, ptr %27, align 1, !tbaa !24
  %33 = and i8 %32, -4
  store i8 %33, ptr %27, align 1, !tbaa !24
  br label %34

34:                                               ; preds = %30, %._crit_edge
  tail call void @_ZN2rw5Frame13updateObjectsEv(ptr noundef nonnull align 8 dereferenceable(200) %0)
  ret ptr %0
}

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN2rw5Frame13updateObjectsEv(ptr noundef nonnull align 8 dereferenceable(200)) local_unnamed_addr #1 align 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" }

!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 176}
!6 = !{!"_ZTSN2rw5FrameE", !7, i64 0, !11, i64 16, !12, i64 32, !13, i64 48, !13, i64 112, !10, i64 176, !10, i64 184, !10, i64 192}
!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 = !{!"_ZTSN2rw6LLLinkE", !10, i64 0, !10, i64 8}
!12 = !{!"_ZTSN2rw8LinkListE", !11, i64 0}
!13 = !{!"_ZTSN2rw6MatrixE", !14, i64 0, !16, i64 12, !14, i64 16, !16, i64 28, !14, i64 32, !16, i64 44, !14, i64 48, !16, i64 60}
!14 = !{!"_ZTSN2rw3V3dE", !15, i64 0, !15, i64 4, !15, i64 8}
!15 = !{!"float", !8, i64 0}
!16 = !{!"int", !8, i64 0}
!17 = !{!6, !10, i64 184}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = !{!10, !10, i64 0}
!21 = !{!6, !10, i64 8}
!22 = !{!6, !10, i64 192}
!23 = distinct !{!23, !19}
!24 = !{!6, !8, i64 3}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass