; LLVM IR from vczh/herodb :: Kernel/Source/Vlpp.ll (ZN2vl4wtoaERKNS_12ObjectStringIwEE)

; 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.vl::ObjectString.1123" = type { %"class.vl::Object", ptr, ptr, i64, i64, i64 }
%"class.vl::Object" = type { ptr }

; 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: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

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

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

; Function Attrs: nobuiltin nounwind
declare void @_ZdaPv(ptr noundef) #4

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN2vl4wtoaERKNS_12ObjectStringIwEE(ptr dead_on_unwind noalias writable sret(%"class.vl::ObjectString.1123") align 8 %0, ptr noundef nonnull align 8 dereferenceable(48) %1) #2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i1, align 1
  store ptr %0, ptr %3, align 8
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #6
  %8 = load ptr, ptr %4, align 8, !tbaa !5
  %9 = call noundef ptr @_ZNK2vl12ObjectStringIwE6BufferEv(ptr noundef nonnull align 8 dereferenceable(48) %8)
  %10 = call noundef i64 @_ZN2vl5_wtoaEPKwPcl(ptr noundef %9, ptr noundef null, i64 noundef 0)
  store i64 %10, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #6
  %11 = load i64, ptr %5, align 8, !tbaa !9
  %12 = call noalias noundef nonnull ptr @_Znam(i64 noundef %11) #7
  store ptr %12, ptr %6, align 8, !tbaa !5
  %13 = load ptr, ptr %6, align 8, !tbaa !5
  %14 = load i64, ptr %5, align 8, !tbaa !9
  %15 = mul i64 %14, 1
  call void @llvm.memset.p0.i64(ptr align 1 %13, i8 0, i64 %15, i1 false)
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = call noundef ptr @_ZNK2vl12ObjectStringIwE6BufferEv(ptr noundef nonnull align 8 dereferenceable(48) %16)
  %18 = load ptr, ptr %6, align 8, !tbaa !5
  %19 = load i64, ptr %5, align 8, !tbaa !9
  %20 = trunc i64 %19 to i32
  %21 = sext i32 %20 to i64
  %22 = call noundef i64 @_ZN2vl5_wtoaEPKwPcl(ptr noundef %17, ptr noundef %18, i64 noundef %21)
  store i1 false, ptr %7, align 1
  %23 = load ptr, ptr %6, align 8, !tbaa !5
  call void @_ZN2vl12ObjectStringIcEC2EPKcb(ptr noundef nonnull align 8 dereferenceable(48) %0, ptr noundef %23, i1 noundef zeroext true)
  %24 = load ptr, ptr %6, align 8, !tbaa !5
  %25 = icmp eq ptr %24, null
  br i1 %25, label %27, label %26

26:                                               ; preds = %2
  call void @_ZdaPv(ptr noundef %24) #8
  br label %27

27:                                               ; preds = %26, %2
  store i1 true, ptr %7, align 1
  %28 = load i1, ptr %7, align 1
  br i1 %28, label %30, label %29

29:                                               ; preds = %27
  call void @_ZN2vl12ObjectStringIcED2Ev(ptr noundef nonnull align 8 dereferenceable(48) %0) #6
  br label %30

30:                                               ; preds = %29, %27
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN2vl12ObjectStringIcED2Ev(ptr noundef nonnull align 8 dereferenceable(48)) unnamed_addr #5 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN2vl12ObjectStringIcEC2EPKcb(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef, i1 noundef zeroext) unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZN2vl5_wtoaEPKwPcl(ptr noundef, ptr noundef, i64 noundef) #5

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


; 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.vl::ObjectString.1123" = type { %"class.vl::Object", ptr, ptr, i64, i64, i64 }
%"class.vl::Object" = type { ptr }

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

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

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

; Function Attrs: nobuiltin nounwind
declare void @_ZdaPv(ptr noundef) local_unnamed_addr #3

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN2vl4wtoaERKNS_12ObjectStringIwEE(ptr dead_on_unwind noalias writable sret(%"class.vl::ObjectString.1123") align 8 %0, ptr noundef nonnull align 8 dereferenceable(48) %1) local_unnamed_addr #1 {
  %3 = tail call noundef ptr @_ZNK2vl12ObjectStringIwE6BufferEv(ptr noundef nonnull align 8 dereferenceable(48) %1)
  %4 = tail call noundef i64 @_ZN2vl5_wtoaEPKwPcl(ptr noundef %3, ptr noundef null, i64 noundef 0)
  %5 = tail call noalias noundef nonnull ptr @_Znam(i64 noundef %4) #5
  tail call void @llvm.memset.p0.i64(ptr nonnull align 1 %5, i8 0, i64 %4, i1 false)
  %6 = tail call noundef ptr @_ZNK2vl12ObjectStringIwE6BufferEv(ptr noundef nonnull align 8 dereferenceable(48) %1)
  %sext = shl i64 %4, 32
  %7 = ashr exact i64 %sext, 32
  %8 = tail call noundef i64 @_ZN2vl5_wtoaEPKwPcl(ptr noundef %6, ptr noundef nonnull %5, i64 noundef %7)
  tail call void @_ZN2vl12ObjectStringIcEC2EPKcb(ptr noundef nonnull align 8 dereferenceable(48) %0, ptr noundef nonnull %5, i1 noundef zeroext true)
  tail call void @_ZdaPv(ptr noundef nonnull %5) #6
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN2vl12ObjectStringIcEC2EPKcb(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef, i1 noundef zeroext) unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZN2vl5_wtoaEPKwPcl(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #4

attributes #0 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
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" }
attributes #2 = { 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 #3 = { 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 #4 = { 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 #5 = { builtin allocsize(0) }
attributes #6 = { 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)"}


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