; LLVM IR from weicao/cascadb :: src/tree/tree.ll (ZN7cascadb4Tree15TreeNodeFactory8new_nodeEm)

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

%"class.cascadb::Tree::TreeNodeFactory" = type { %"class.cascadb::NodeFactory", ptr }
%"class.cascadb::NodeFactory" = type { ptr }
%"class.cascadb::Tree" = type { %"class.std::__cxx11::basic_string", %"class.cascadb::Options", ptr, ptr, ptr, ptr, ptr, ptr }
%"class.std::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }
%"class.cascadb::Options" = type <{ ptr, ptr, i64, i64, i64, i64, i64, i64, i64, i32, i32, i32, i32, i32, i32, i32, i8, [3 x i8] }>

declare i32 @__gxx_personality_v0(...)

; 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: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) #1

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) #2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7cascadb10SchemaNodeC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(ptr noundef nonnull align 8 dereferenceable(232), ptr noundef nonnull align 8 dereferenceable(32)) unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN7cascadb4Tree15TreeNodeFactory8new_nodeEm(ptr noundef nonnull align 8 dereferenceable(16) %0, i64 noundef %1) unnamed_addr #3 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i64 %1, ptr %5, align 8, !tbaa !9
  %9 = load ptr, ptr %4, align 8
  %10 = load i64, ptr %5, align 8, !tbaa !9
  %11 = icmp eq i64 %10, 1
  br i1 %11, label %12, label %22

12:                                               ; preds = %2
  %13 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 232) #5
  %14 = getelementptr inbounds %"class.cascadb::Tree::TreeNodeFactory", ptr %9, i32 0, i32 1
  %15 = load ptr, ptr %14, align 8, !tbaa !11
  %16 = getelementptr inbounds %"class.cascadb::Tree", ptr %15, i32 0, i32 0
  invoke void @_ZN7cascadb10SchemaNodeC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(ptr noundef nonnull align 8 dereferenceable(232) %13, ptr noundef nonnull align 8 dereferenceable(32) %16)
          to label %17 unwind label %18

17:                                               ; preds = %12
  store ptr %13, ptr %3, align 8
  br label %54

18:                                               ; preds = %12
  %19 = landingpad { ptr, i32 }
          cleanup
  %20 = extractvalue { ptr, i32 } %19, 0
  store ptr %20, ptr %6, align 8
  %21 = extractvalue { ptr, i32 } %19, 1
  store i32 %21, ptr %7, align 4
  call void @_ZdlPvm(ptr noundef %13, i64 noundef 232) #6
  br label %56

22:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #7
  %23 = load i64, ptr %5, align 8, !tbaa !9
  %24 = icmp uge i64 %23, 281474976710657
  br i1 %24, label %25, label %38

25:                                               ; preds = %22
  %26 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 320) #5
  %27 = getelementptr inbounds %"class.cascadb::Tree::TreeNodeFactory", ptr %9, i32 0, i32 1
  %28 = load ptr, ptr %27, align 8, !tbaa !11
  %29 = getelementptr inbounds %"class.cascadb::Tree", ptr %28, i32 0, i32 0
  %30 = load i64, ptr %5, align 8, !tbaa !9
  %31 = getelementptr inbounds %"class.cascadb::Tree::TreeNodeFactory", ptr %9, i32 0, i32 1
  %32 = load ptr, ptr %31, align 8, !tbaa !11
  invoke void @_ZN7cascadb8LeafNodeC1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEmPNS_4TreeE(ptr noundef nonnull align 8 dereferenceable(320) %26, ptr noundef nonnull align 8 dereferenceable(32) %29, i64 noundef %30, ptr noundef %32)
          to label %33 unwind label %34

33:                                               ; preds = %25
  store ptr %26, ptr %8, align 8, !tbaa !5
  br label %51

34:                                               ; preds = %25
  %35 = landingpad { ptr, i32 }
          cleanup
  %36 = extractvalue { ptr, i32 } %35, 0
  store ptr %36, ptr %6, align 8
  %37 = extractvalue { ptr, i32 } %35, 1
  store i32 %37, ptr %7, align 4
  call void @_ZdlPvm(ptr noundef %26, i64 noundef 320) #6
  br label %53

38:                                               ; preds = %22
  %39 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 312) #5
  %40 = getelementptr inbounds %"class.cascadb::Tree::TreeNodeFactory", ptr %9, i32 0, i32 1
  %41 = load ptr, ptr %40, align 8, !tbaa !11
  %42 = getelementptr inbounds %"class.cascadb::Tree", ptr %41, i32 0, i32 0
  %43 = load i64, ptr %5, align 8, !tbaa !9
  %44 = getelementptr inbounds %"class.cascadb::Tree::TreeNodeFactory", ptr %9, i32 0, i32 1
  %45 = load ptr, ptr %44, align 8, !tbaa !11
  invoke void @_ZN7cascadb9InnerNodeC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEmPNS_4TreeE(ptr noundef nonnull align 8 dereferenceable(312) %39, ptr noundef nonnull align 8 dereferenceable(32) %42, i64 noundef %43, ptr noundef %45)
          to label %46 unwind label %47

46:                                               ; preds = %38
  store ptr %39, ptr %8, align 8, !tbaa !5
  br label %51

47:                                               ; preds = %38
  %48 = landingpad { ptr, i32 }
          cleanup
  %49 = extractvalue { ptr, i32 } %48, 0
  store ptr %49, ptr %6, align 8
  %50 = extractvalue { ptr, i32 } %48, 1
  store i32 %50, ptr %7, align 4
  call void @_ZdlPvm(ptr noundef %39, i64 noundef 312) #6
  br label %53

51:                                               ; preds = %46, %33
  %52 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %52, ptr %3, align 8
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #7
  br label %54

53:                                               ; preds = %47, %34
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #7
  br label %56

54:                                               ; preds = %51, %17
  %55 = load ptr, ptr %3, align 8
  ret ptr %55

56:                                               ; preds = %53, %18
  %57 = load ptr, ptr %6, align 8
  %58 = load i32, ptr %7, align 4
  %59 = insertvalue { ptr, i32 } poison, ptr %57, 0
  %60 = insertvalue { ptr, i32 } %59, i32 %58, 1
  resume { ptr, i32 } %60
}

declare void @_ZN7cascadb8LeafNodeC1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEmPNS_4TreeE(ptr noundef nonnull align 8 dereferenceable(320), ptr noundef nonnull align 8 dereferenceable(32), i64 noundef, ptr noundef) unnamed_addr #4

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7cascadb9InnerNodeC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEmPNS_4TreeE(ptr noundef nonnull align 8 dereferenceable(312), ptr noundef nonnull align 8 dereferenceable(32), i64 noundef, ptr noundef) unnamed_addr #3 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nobuiltin allocsize(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 = { nobuiltin 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 #3 = { 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 #4 = { "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 #5 = { builtin allocsize(0) }
attributes #6 = { builtin nounwind }
attributes #7 = { 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 = !{!"long", !7, i64 0}
!11 = !{!12, !6, i64 8}
!12 = !{!"_ZTSN7cascadb4Tree15TreeNodeFactoryE", !13, i64 0, !6, i64 8}
!13 = !{!"_ZTSN7cascadb11NodeFactoryE"}


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

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) local_unnamed_addr #0

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7cascadb10SchemaNodeC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(ptr noundef nonnull align 8 dereferenceable(232), ptr noundef nonnull align 8 dereferenceable(32)) unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef nonnull ptr @_ZN7cascadb4Tree15TreeNodeFactory8new_nodeEm(ptr nocapture noundef nonnull readonly align 8 dereferenceable(16) %0, i64 noundef %1) unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  %3 = icmp eq i64 %1, 1
  %4 = getelementptr inbounds i8, ptr %0, i64 8
  br i1 %3, label %5, label %10

5:                                                ; preds = %2
  %6 = tail call noalias noundef nonnull dereferenceable(232) ptr @_Znwm(i64 noundef 232) #4
  %7 = load ptr, ptr %4, align 8, !tbaa !5
  invoke void @_ZN7cascadb10SchemaNodeC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(ptr noundef nonnull align 8 dereferenceable(232) %6, ptr noundef nonnull align 8 dereferenceable(32) %7)
          to label %22 unwind label %8

8:                                                ; preds = %5
  %9 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZdlPvm(ptr noundef nonnull %6, i64 noundef 232) #5
  br label %23

10:                                               ; preds = %2
  %11 = icmp ugt i64 %1, 281474976710656
  br i1 %11, label %12, label %17

12:                                               ; preds = %10
  %13 = tail call noalias noundef nonnull dereferenceable(320) ptr @_Znwm(i64 noundef 320) #4
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  invoke void @_ZN7cascadb8LeafNodeC1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEmPNS_4TreeE(ptr noundef nonnull align 8 dereferenceable(320) %13, ptr noundef nonnull align 8 dereferenceable(32) %14, i64 noundef %1, ptr noundef %14)
          to label %22 unwind label %15

15:                                               ; preds = %12
  %16 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZdlPvm(ptr noundef nonnull %13, i64 noundef 320) #5
  br label %23

17:                                               ; preds = %10
  %18 = tail call noalias noundef nonnull dereferenceable(312) ptr @_Znwm(i64 noundef 312) #4
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  invoke void @_ZN7cascadb9InnerNodeC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEmPNS_4TreeE(ptr noundef nonnull align 8 dereferenceable(312) %18, ptr noundef nonnull align 8 dereferenceable(32) %19, i64 noundef %1, ptr noundef %19)
          to label %22 unwind label %20

20:                                               ; preds = %17
  %21 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZdlPvm(ptr noundef nonnull %18, i64 noundef 312) #5
  br label %23

22:                                               ; preds = %12, %17, %5
  %.011 = phi ptr [ %6, %5 ], [ %13, %12 ], [ %18, %17 ]
  ret ptr %.011

23:                                               ; preds = %15, %20, %8
  %.pn14 = phi { ptr, i32 } [ %9, %8 ], [ %16, %15 ], [ %21, %20 ]
  resume { ptr, i32 } %.pn14
}

declare void @_ZN7cascadb8LeafNodeC1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEmPNS_4TreeE(ptr noundef nonnull align 8 dereferenceable(320), ptr noundef nonnull align 8 dereferenceable(32), i64 noundef, ptr noundef) unnamed_addr #3

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7cascadb9InnerNodeC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEmPNS_4TreeE(ptr noundef nonnull align 8 dereferenceable(312), ptr noundef nonnull align 8 dereferenceable(32), i64 noundef, ptr noundef) unnamed_addr #2 align 2

attributes #0 = { nobuiltin allocsize(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 = { nobuiltin 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 #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 = { builtin allocsize(0) }
attributes #5 = { builtin 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, !8, i64 8}
!6 = !{!"_ZTSN7cascadb4Tree15TreeNodeFactoryE", !7, i64 0, !8, i64 8}
!7 = !{!"_ZTSN7cascadb11NodeFactoryE"}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}


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