; LLVM IR from yinqiwen/ardb :: src/types.ll (ZN4ardb4Data5CloneERKS0_)

; 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.ardb::Data" = type <{ i64, i32, i8, [3 x i8] }>

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4ardb4Data5CloneERKS0_(ptr noundef nonnull align 8 dereferenceable(13) %0, ptr noundef nonnull align 8 dereferenceable(13) %1) #2 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %6 = load ptr, ptr %3, align 8
  call void @_ZN4ardb4Data5ClearEv(ptr noundef nonnull align 8 dereferenceable(13) %6)
  %7 = load ptr, ptr %4, align 8, !tbaa !5
  %8 = getelementptr inbounds %"struct.ardb::Data", ptr %7, i32 0, i32 2
  %9 = load i8, ptr %8, align 4, !tbaa !9
  %10 = getelementptr inbounds %"struct.ardb::Data", ptr %6, i32 0, i32 2
  store i8 %9, ptr %10, align 4, !tbaa !9
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = getelementptr inbounds %"struct.ardb::Data", ptr %11, i32 0, i32 1
  %13 = load i32, ptr %12, align 8, !tbaa !13
  %14 = getelementptr inbounds %"struct.ardb::Data", ptr %6, i32 0, i32 1
  store i32 %13, ptr %14, align 8, !tbaa !13
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = getelementptr inbounds %"struct.ardb::Data", ptr %15, i32 0, i32 2
  %17 = load i8, ptr %16, align 4, !tbaa !9
  %18 = zext i8 %17 to i32
  %19 = icmp eq i32 %18, 4
  br i1 %19, label %20, label %36

20:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = getelementptr inbounds %"struct.ardb::Data", ptr %21, i32 0, i32 1
  %23 = load i32, ptr %22, align 8, !tbaa !13
  %24 = zext i32 %23 to i64
  %25 = call noalias ptr @malloc(i64 noundef %24) #6
  store ptr %25, ptr %5, align 8, !tbaa !5
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = ptrtoint ptr %26 to i64
  %28 = getelementptr inbounds %"struct.ardb::Data", ptr %6, i32 0, i32 0
  store i64 %27, ptr %28, align 8, !tbaa !14
  %29 = load ptr, ptr %5, align 8, !tbaa !5
  %30 = load ptr, ptr %4, align 8, !tbaa !5
  %31 = call noundef ptr @_ZNK4ardb4Data4CStrEv(ptr noundef nonnull align 8 dereferenceable(13) %30)
  %32 = load ptr, ptr %4, align 8, !tbaa !5
  %33 = call noundef i32 @_ZNK4ardb4Data12StringLengthEv(ptr noundef nonnull align 8 dereferenceable(13) %32)
  %34 = zext i32 %33 to i64
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %29, ptr align 1 %31, i64 %34, i1 false)
  %35 = getelementptr inbounds %"struct.ardb::Data", ptr %6, i32 0, i32 2
  store i8 4, ptr %35, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  br label %41

36:                                               ; preds = %2
  %37 = load ptr, ptr %4, align 8, !tbaa !5
  %38 = getelementptr inbounds %"struct.ardb::Data", ptr %37, i32 0, i32 0
  %39 = load i64, ptr %38, align 8, !tbaa !14
  %40 = getelementptr inbounds %"struct.ardb::Data", ptr %6, i32 0, i32 0
  store i64 %39, ptr %40, align 8, !tbaa !14
  br label %41

41:                                               ; preds = %36, %20
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZNK4ardb4Data12StringLengthEv(ptr noundef nonnull align 8 dereferenceable(13)) #2 align 2

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #3

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #4

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

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #3

attributes #0 = { nocallback nofree 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { nounwind 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 #5 = { nounwind }
attributes #6 = { nounwind allocsize(0) }

!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 12}
!10 = !{!"_ZTSN4ardb4DataE", !11, i64 0, !12, i64 8, !7, i64 12}
!11 = !{!"long", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!10, !12, i64 8}
!14 = !{!10, !11, 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"

; Function Attrs: mustprogress 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) #0

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4ardb4Data5CloneERKS0_(ptr noundef nonnull align 8 dereferenceable(13) %0, ptr noundef nonnull align 8 dereferenceable(13) %1) local_unnamed_addr #2 align 2 {
  tail call void @_ZN4ardb4Data5ClearEv(ptr noundef nonnull align 8 dereferenceable(13) %0)
  %3 = getelementptr inbounds i8, ptr %1, i64 12
  %4 = load i8, ptr %3, align 4, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 12
  store i8 %4, ptr %5, align 4, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %1, i64 8
  %7 = load i32, ptr %6, align 8, !tbaa !11
  %8 = getelementptr inbounds i8, ptr %0, i64 8
  store i32 %7, ptr %8, align 8, !tbaa !11
  %9 = icmp eq i8 %4, 4
  br i1 %9, label %10, label %17

10:                                               ; preds = %2
  %11 = zext i32 %7 to i64
  %12 = tail call noalias ptr @malloc(i64 noundef %11) #4
  %13 = ptrtoint ptr %12 to i64
  store i64 %13, ptr %0, align 8, !tbaa !12
  %14 = tail call noundef ptr @_ZNK4ardb4Data4CStrEv(ptr noundef nonnull align 8 dereferenceable(13) %1)
  %15 = tail call noundef i32 @_ZNK4ardb4Data12StringLengthEv(ptr noundef nonnull align 8 dereferenceable(13) %1)
  %16 = zext i32 %15 to i64
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 1 %12, ptr align 1 %14, i64 %16, i1 false)
  store i8 4, ptr %5, align 4, !tbaa !5
  br label %19

17:                                               ; preds = %2
  %18 = load i64, ptr %1, align 8, !tbaa !12
  store i64 %18, ptr %0, align 8, !tbaa !12
  br label %19

19:                                               ; preds = %17, %10
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZNK4ardb4Data12StringLengthEv(ptr noundef nonnull align 8 dereferenceable(13)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #3

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

attributes #0 = { mustprogress nocallback nofree 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 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 allocsize(0) }

!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 12}
!6 = !{!"_ZTSN4ardb4DataE", !7, i64 0, !10, i64 8, !8, i64 12}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!6, !10, i64 8}
!12 = !{!6, !7, i64 0}


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