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

; 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::Record" = type { %"class.cascadb::Slice", %"class.cascadb::Slice" }
%"class.cascadb::Slice" = type <{ ptr, i32, [4 x i8] }>
%"class.cascadb::Msg" = type { i32, [4 x i8], %"class.cascadb::Slice", %"class.cascadb::Slice" }

@.str.1 = external hidden unnamed_addr constant [66 x i8], align 1
@.str.36 = external hidden unnamed_addr constant [14 x i8], align 1
@__PRETTY_FUNCTION__._ZN7cascadb8LeafNode9to_recordERKNS_3MsgE = external hidden unnamed_addr constant [49 x i8], align 1

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

; 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) #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN7cascadb8LeafNode9to_recordERKNS_3MsgE(ptr dead_on_unwind noalias writable sret(%"class.cascadb::Record") align 8 %0, ptr noundef nonnull align 8 dereferenceable(320) %1, ptr noundef nonnull align 8 dereferenceable(40) %2) #2 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca %"class.cascadb::Slice", align 8
  %7 = alloca %"class.cascadb::Slice", align 8
  store ptr %1, ptr %4, align 8, !tbaa !5
  store ptr %2, ptr %5, align 8, !tbaa !5
  %8 = load ptr, ptr %4, align 8
  %9 = load ptr, ptr %5, align 8, !tbaa !5
  %10 = getelementptr inbounds %"class.cascadb::Msg", ptr %9, i32 0, i32 0
  %11 = load i32, ptr %10, align 8, !tbaa !9
  %12 = icmp eq i32 %11, 1
  br i1 %12, label %13, label %14

13:                                               ; preds = %3
  br label %16

14:                                               ; preds = %3
  call void @__assert_fail(ptr noundef @.str.36, ptr noundef @.str.1, i32 noundef 1085, ptr noundef @__PRETTY_FUNCTION__._ZN7cascadb8LeafNode9to_recordERKNS_3MsgE) #4
  unreachable

15:                                               ; No predecessors!
  br label %16

16:                                               ; preds = %15, %13
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = getelementptr inbounds %"class.cascadb::Msg", ptr %17, i32 0, i32 2
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %6, ptr align 8 %18, i64 16, i1 false), !tbaa.struct !14
  %19 = load ptr, ptr %5, align 8, !tbaa !5
  %20 = getelementptr inbounds %"class.cascadb::Msg", ptr %19, i32 0, i32 3
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %7, ptr align 8 %20, i64 16, i1 false), !tbaa.struct !14
  %21 = getelementptr inbounds { ptr, i32 }, ptr %6, i32 0, i32 0
  %22 = load ptr, ptr %21, align 8
  %23 = getelementptr inbounds { ptr, i32 }, ptr %6, i32 0, i32 1
  %24 = load i32, ptr %23, align 8
  %25 = getelementptr inbounds { ptr, i32 }, ptr %7, i32 0, i32 0
  %26 = load ptr, ptr %25, align 8
  %27 = getelementptr inbounds { ptr, i32 }, ptr %7, i32 0, i32 1
  %28 = load i32, ptr %27, align 8
  call void @_ZN7cascadb6RecordC2ENS_5SliceES1_(ptr noundef nonnull align 8 dereferenceable(32) %0, ptr %22, i32 %24, ptr %26, i32 %28)
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN7cascadb6RecordC2ENS_5SliceES1_(ptr noundef nonnull align 8 dereferenceable(32), ptr, i32, ptr, i32) unnamed_addr #3 align 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 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 #4 = { 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, !11, i64 0}
!10 = !{!"_ZTSN7cascadb3MsgE", !11, i64 0, !12, i64 8, !12, i64 24}
!11 = !{!"_ZTSN7cascadb7MsgTypeE", !7, i64 0}
!12 = !{!"_ZTSN7cascadb5SliceE", !6, i64 0, !13, i64 8}
!13 = !{!"int", !7, i64 0}
!14 = !{i64 0, i64 8, !5, i64 8, i64 4, !15}
!15 = !{!13, !13, 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"

%"class.cascadb::Record" = type { %"class.cascadb::Slice", %"class.cascadb::Slice" }
%"class.cascadb::Slice" = type <{ ptr, i32, [4 x i8] }>

@.str.1 = external hidden unnamed_addr constant [66 x i8], align 1
@.str.36 = external hidden unnamed_addr constant [14 x i8], align 1
@__PRETTY_FUNCTION__._ZN7cascadb8LeafNode9to_recordERKNS_3MsgE = external hidden unnamed_addr constant [49 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 void @_ZN7cascadb8LeafNode9to_recordERKNS_3MsgE(ptr dead_on_unwind noalias writable sret(%"class.cascadb::Record") align 8 %0, ptr nocapture noundef nonnull readnone align 8 dereferenceable(320) %1, ptr nocapture noundef nonnull readonly align 8 dereferenceable(40) %2) local_unnamed_addr #1 align 2 {
  %4 = load i32, ptr %2, align 8, !tbaa !5
  %5 = icmp eq i32 %4, 1
  br i1 %5, label %7, label %6

6:                                                ; preds = %3
  tail call void @__assert_fail(ptr noundef nonnull @.str.36, ptr noundef nonnull @.str.1, i32 noundef 1085, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN7cascadb8LeafNode9to_recordERKNS_3MsgE) #2
  unreachable

7:                                                ; preds = %3
  %8 = getelementptr inbounds i8, ptr %2, i64 8
  %.sroa.01.0.copyload = load ptr, ptr %8, align 8, !tbaa !13
  %.sroa.22.0..sroa_idx = getelementptr inbounds i8, ptr %2, i64 16
  %.sroa.22.0.copyload = load i32, ptr %.sroa.22.0..sroa_idx, align 8, !tbaa !14
  %9 = getelementptr inbounds i8, ptr %2, i64 24
  %.sroa.0.0.copyload = load ptr, ptr %9, align 8, !tbaa !13
  %.sroa.2.0..sroa_idx = getelementptr inbounds i8, ptr %2, i64 32
  %.sroa.2.0.copyload = load i32, ptr %.sroa.2.0..sroa_idx, align 8, !tbaa !14
  tail call void @_ZN7cascadb6RecordC2ENS_5SliceES1_(ptr noundef nonnull align 8 dereferenceable(32) %0, ptr %.sroa.01.0.copyload, i32 %.sroa.22.0.copyload, ptr %.sroa.0.0.copyload, i32 %.sroa.2.0.copyload)
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN7cascadb6RecordC2ENS_5SliceES1_(ptr noundef nonnull align 8 dereferenceable(32), ptr, i32, ptr, i32) unnamed_addr #1 align 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 = { 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 0}
!6 = !{!"_ZTSN7cascadb3MsgE", !7, i64 0, !10, i64 8, !10, i64 24}
!7 = !{!"_ZTSN7cascadb7MsgTypeE", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTSN7cascadb5SliceE", !11, i64 0, !12, i64 8}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!"int", !8, i64 0}
!13 = !{!11, !11, i64 0}
!14 = !{!12, !12, i64 0}


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