; LLVM IR from stan-dev/math :: lib/boost_1.84.0/tools/quickbook/src (tree)

; 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.quickbook::detail::tree_node_base" = type { ptr, ptr, ptr, ptr }
%"struct.quickbook::detail::tree_base" = type { ptr }

@.str.1 = external hidden unnamed_addr constant [93 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [11 x i8], align 1
@__PRETTY_FUNCTION__._ZN9quickbook6detail9tree_base7extractEPNS0_14tree_node_baseE = external hidden unnamed_addr constant [72 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef ptr @_ZN9quickbook6detail9tree_base7extractEPNS0_14tree_node_baseE(ptr noundef nonnull align 8 dereferenceable(8) %0, ptr noundef %1) #1 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %5 = load ptr, ptr %3, align 8
  %6 = load ptr, ptr %4, align 8, !tbaa !5
  %7 = getelementptr inbounds %"struct.quickbook::detail::tree_node_base", ptr %6, i32 0, i32 3
  %8 = load ptr, ptr %7, align 8, !tbaa !9
  %9 = icmp ne ptr %8, null
  br i1 %9, label %37, label %10

10:                                               ; preds = %2
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = getelementptr inbounds %"struct.quickbook::detail::tree_node_base", ptr %11, i32 0, i32 0
  %13 = load ptr, ptr %12, align 8, !tbaa !11
  %14 = icmp ne ptr %13, null
  br i1 %14, label %15, label %23

15:                                               ; preds = %10
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = getelementptr inbounds %"struct.quickbook::detail::tree_node_base", ptr %16, i32 0, i32 2
  %18 = load ptr, ptr %17, align 8, !tbaa !12
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = getelementptr inbounds %"struct.quickbook::detail::tree_node_base", ptr %19, i32 0, i32 0
  %21 = load ptr, ptr %20, align 8, !tbaa !11
  %22 = getelementptr inbounds %"struct.quickbook::detail::tree_node_base", ptr %21, i32 0, i32 1
  store ptr %18, ptr %22, align 8, !tbaa !13
  br label %36

23:                                               ; preds = %10
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = getelementptr inbounds %"struct.quickbook::detail::tree_base", ptr %5, i32 0, i32 0
  %26 = load ptr, ptr %25, align 8, !tbaa !14
  %27 = icmp eq ptr %24, %26
  br i1 %27, label %28, label %29

28:                                               ; preds = %23
  br label %31

29:                                               ; preds = %23
  call void @__assert_fail(ptr noundef @.str.2, ptr noundef @.str.1, i32 noundef 101, ptr noundef @__PRETTY_FUNCTION__._ZN9quickbook6detail9tree_base7extractEPNS0_14tree_node_baseE) #2
  unreachable

30:                                               ; No predecessors!
  br label %31

31:                                               ; preds = %30, %28
  %32 = load ptr, ptr %4, align 8, !tbaa !5
  %33 = getelementptr inbounds %"struct.quickbook::detail::tree_node_base", ptr %32, i32 0, i32 2
  %34 = load ptr, ptr %33, align 8, !tbaa !12
  %35 = getelementptr inbounds %"struct.quickbook::detail::tree_base", ptr %5, i32 0, i32 0
  store ptr %34, ptr %35, align 8, !tbaa !14
  br label %36

36:                                               ; preds = %31, %15
  br label %45

37:                                               ; preds = %2
  %38 = load ptr, ptr %4, align 8, !tbaa !5
  %39 = getelementptr inbounds %"struct.quickbook::detail::tree_node_base", ptr %38, i32 0, i32 2
  %40 = load ptr, ptr %39, align 8, !tbaa !12
  %41 = load ptr, ptr %4, align 8, !tbaa !5
  %42 = getelementptr inbounds %"struct.quickbook::detail::tree_node_base", ptr %41, i32 0, i32 3
  %43 = load ptr, ptr %42, align 8, !tbaa !9
  %44 = getelementptr inbounds %"struct.quickbook::detail::tree_node_base", ptr %43, i32 0, i32 2
  store ptr %40, ptr %44, align 8, !tbaa !12
  br label %45

45:                                               ; preds = %37, %36
  %46 = load ptr, ptr %4, align 8, !tbaa !5
  %47 = getelementptr inbounds %"struct.quickbook::detail::tree_node_base", ptr %46, i32 0, i32 2
  %48 = load ptr, ptr %47, align 8, !tbaa !12
  %49 = icmp ne ptr %48, null
  br i1 %49, label %50, label %58

50:                                               ; preds = %45
  %51 = load ptr, ptr %4, align 8, !tbaa !5
  %52 = getelementptr inbounds %"struct.quickbook::detail::tree_node_base", ptr %51, i32 0, i32 3
  %53 = load ptr, ptr %52, align 8, !tbaa !9
  %54 = load ptr, ptr %4, align 8, !tbaa !5
  %55 = getelementptr inbounds %"struct.quickbook::detail::tree_node_base", ptr %54, i32 0, i32 2
  %56 = load ptr, ptr %55, align 8, !tbaa !12
  %57 = getelementptr inbounds %"struct.quickbook::detail::tree_node_base", ptr %56, i32 0, i32 3
  store ptr %53, ptr %57, align 8, !tbaa !9
  br label %58

58:                                               ; preds = %50, %45
  %59 = load ptr, ptr %4, align 8, !tbaa !5
  %60 = getelementptr inbounds %"struct.quickbook::detail::tree_node_base", ptr %59, i32 0, i32 0
  store ptr null, ptr %60, align 8, !tbaa !11
  %61 = load ptr, ptr %4, align 8, !tbaa !5
  %62 = getelementptr inbounds %"struct.quickbook::detail::tree_node_base", ptr %61, i32 0, i32 2
  store ptr null, ptr %62, align 8, !tbaa !12
  %63 = load ptr, ptr %4, align 8, !tbaa !5
  %64 = getelementptr inbounds %"struct.quickbook::detail::tree_node_base", ptr %63, i32 0, i32 3
  store ptr null, ptr %64, align 8, !tbaa !9
  %65 = load ptr, ptr %4, align 8, !tbaa !5
  ret ptr %65
}

attributes #0 = { noreturn nounwind "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 = { noreturn 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 24}
!10 = !{!"_ZTSN9quickbook6detail14tree_node_baseE", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!11 = !{!10, !6, i64 0}
!12 = !{!10, !6, i64 16}
!13 = !{!10, !6, i64 8}
!14 = !{!15, !6, i64 0}
!15 = !{!"_ZTSN9quickbook6detail9tree_baseE", !6, 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"

@.str.1 = external hidden unnamed_addr constant [93 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [11 x i8], align 1
@__PRETTY_FUNCTION__._ZN9quickbook6detail9tree_base7extractEPNS0_14tree_node_baseE = external hidden unnamed_addr constant [72 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef ptr @_ZN9quickbook6detail9tree_base7extractEPNS0_14tree_node_baseE(ptr nocapture noundef nonnull align 8 dereferenceable(8) %0, ptr noundef returned %1) local_unnamed_addr #1 align 2 {
  %3 = getelementptr inbounds i8, ptr %1, i64 24
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %.not = icmp eq ptr %4, null
  br i1 %.not, label %5, label %18

5:                                                ; preds = %2
  %6 = load ptr, ptr %1, align 8, !tbaa !10
  %.not19 = icmp eq ptr %6, null
  br i1 %.not19, label %11, label %7

7:                                                ; preds = %5
  %8 = getelementptr inbounds i8, ptr %1, i64 16
  %9 = load ptr, ptr %8, align 8, !tbaa !11
  %10 = getelementptr inbounds i8, ptr %6, i64 8
  store ptr %9, ptr %10, align 8, !tbaa !12
  br label %22

11:                                               ; preds = %5
  %12 = load ptr, ptr %0, align 8, !tbaa !13
  %13 = icmp eq ptr %12, %1
  br i1 %13, label %15, label %14

14:                                               ; preds = %11
  tail call void @__assert_fail(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.1, i32 noundef 101, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN9quickbook6detail9tree_base7extractEPNS0_14tree_node_baseE) #3
  unreachable

15:                                               ; preds = %11
  %16 = getelementptr inbounds i8, ptr %1, i64 16
  %17 = load ptr, ptr %16, align 8, !tbaa !11
  store ptr %17, ptr %0, align 8, !tbaa !13
  br label %22

18:                                               ; preds = %2
  %19 = getelementptr inbounds i8, ptr %1, i64 16
  %20 = load ptr, ptr %19, align 8, !tbaa !11
  %21 = getelementptr inbounds i8, ptr %4, i64 16
  store ptr %20, ptr %21, align 8, !tbaa !11
  br label %22

22:                                               ; preds = %7, %15, %18
  %23 = phi ptr [ %9, %7 ], [ %17, %15 ], [ %20, %18 ]
  %.not20 = icmp eq ptr %23, null
  br i1 %.not20, label %26, label %24

24:                                               ; preds = %22
  %25 = getelementptr inbounds i8, ptr %23, i64 24
  store ptr %4, ptr %25, align 8, !tbaa !5
  br label %26

26:                                               ; preds = %24, %22
  %27 = getelementptr inbounds i8, ptr %1, i64 16
  store ptr null, ptr %1, align 8, !tbaa !10
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %27, i8 0, i64 16, i1 false)
  ret ptr %1
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

attributes #0 = { noreturn nounwind "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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { noreturn 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, !7, i64 24}
!6 = !{!"_ZTSN9quickbook6detail14tree_node_baseE", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!6, !7, i64 0}
!11 = !{!6, !7, i64 16}
!12 = !{!6, !7, i64 8}
!13 = !{!14, !7, i64 0}
!14 = !{!"_ZTSN9quickbook6detail9tree_baseE", !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InstCombinePass,MemCpyOptPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass