; LLVM IR from yangfengzzz/DigitalVox3 :: vox.render/containers (string_archive)

; 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.vox::io::internal::Array.0" = type { ptr, i64 }
%"class.std::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char, std::char_traits<char>, vox::StdAllocator<char>>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char, std::char_traits<char>, vox::StdAllocator<char>>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }

; 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: mustprogress uwtable
define dso_local void @_ZN3vox2io6ExternINSt7__cxx1112basic_stringIcSt11char_traitsIcENS_12StdAllocatorIcEEEEE4LoadERNS0_8IArchiveEPS8_mj(ptr noundef nonnull align 8 dereferenceable(9) %0, ptr noundef %1, i64 noundef %2, i32 noundef %3) #1 align 2 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca i32, align 4
  %9 = alloca i64, align 8
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca [128 x i8], align 16
  %14 = alloca i64, align 8
  %15 = alloca i64, align 8
  %16 = alloca %"struct.vox::io::internal::Array.0", align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i64 %2, ptr %7, align 8, !tbaa !9
  store i32 %3, ptr %8, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  store i64 0, ptr %9, align 8, !tbaa !9
  br label %17

17:                                               ; preds = %56, %4
  %18 = load i64, ptr %9, align 8, !tbaa !9
  %19 = load i64, ptr %7, align 8, !tbaa !9
  %20 = icmp ult i64 %18, %19
  br i1 %20, label %22, label %21

21:                                               ; preds = %17
  store i32 2, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  br label %59

22:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %23 = load ptr, ptr %6, align 8, !tbaa !5
  %24 = load i64, ptr %9, align 8, !tbaa !9
  %25 = getelementptr inbounds %"class.std::__cxx11::basic_string", ptr %23, i64 %24
  store ptr %25, ptr %11, align 8, !tbaa !5
  %26 = load ptr, ptr %11, align 8, !tbaa !5
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcEN3vox12StdAllocatorIcEEE5clearEv(ptr noundef nonnull align 8 dereferenceable(32) %26) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  call void @_ZN3vox2io8IArchiversERj(ptr noundef nonnull align 8 dereferenceable(9) %27, ptr noundef nonnull align 4 dereferenceable(4) %12)
  %28 = load ptr, ptr %11, align 8, !tbaa !5
  %29 = load i32, ptr %12, align 4, !tbaa !11
  %30 = zext i32 %29 to i64
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcEN3vox12StdAllocatorIcEEE7reserveEm(ptr noundef nonnull align 8 dereferenceable(32) %28, i64 noundef %30)
  call void @llvm.lifetime.start.p0(i64 128, ptr %13) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  %31 = load i32, ptr %12, align 4, !tbaa !11
  %32 = zext i32 %31 to i64
  store i64 %32, ptr %14, align 8, !tbaa !9
  br label %33

33:                                               ; preds = %37, %22
  %34 = load i64, ptr %14, align 8, !tbaa !9
  %35 = icmp ne i64 %34, 0
  br i1 %35, label %37, label %36

36:                                               ; preds = %33
  store i32 5, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  br label %55

37:                                               ; preds = %33
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #4
  %38 = load i64, ptr %14, align 8, !tbaa !9
  %39 = call noundef i64 @_ZN3vox4math3MinImEET_S2_S2_(i64 noundef %38, i64 noundef 128)
  store i64 %39, ptr %15, align 8, !tbaa !9
  %40 = load ptr, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %16) #4
  %41 = getelementptr inbounds [128 x i8], ptr %13, i64 0, i64 0
  %42 = load i64, ptr %15, align 8, !tbaa !9
  %43 = call { ptr, i64 } @_ZN3vox2io9MakeArrayIcEEKNS0_8internal5ArrayIT_EEPS4_m(ptr noundef %41, i64 noundef %42)
  %44 = getelementptr inbounds { ptr, i64 }, ptr %16, i32 0, i32 0
  %45 = extractvalue { ptr, i64 } %43, 0
  store ptr %45, ptr %44, align 8
  %46 = getelementptr inbounds { ptr, i64 }, ptr %16, i32 0, i32 1
  %47 = extractvalue { ptr, i64 } %43, 1
  store i64 %47, ptr %46, align 8
  call void @_ZN3vox2io8IArchiversIKNS0_8internal5ArrayIcEEEEvRT_(ptr noundef nonnull align 8 dereferenceable(9) %40, ptr noundef nonnull align 8 dereferenceable(16) %16)
  call void @llvm.lifetime.end.p0(i64 16, ptr %16) #4
  %48 = load i64, ptr %15, align 8, !tbaa !9
  %49 = load i64, ptr %14, align 8, !tbaa !9
  %50 = sub i64 %49, %48
  store i64 %50, ptr %14, align 8, !tbaa !9
  %51 = load ptr, ptr %11, align 8, !tbaa !5
  %52 = getelementptr inbounds [128 x i8], ptr %13, i64 0, i64 0
  %53 = load i64, ptr %15, align 8, !tbaa !9
  %54 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcEN3vox12StdAllocatorIcEEE6appendEPKcm(ptr noundef nonnull align 8 dereferenceable(32) %51, ptr noundef %52, i64 noundef %53)
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #4
  br label %33, !llvm.loop !13

55:                                               ; preds = %36
  call void @llvm.lifetime.end.p0(i64 128, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  br label %56

56:                                               ; preds = %55
  %57 = load i64, ptr %9, align 8, !tbaa !9
  %58 = add i64 %57, 1
  store i64 %58, ptr %9, align 8, !tbaa !9
  br label %17, !llvm.loop !15

59:                                               ; preds = %21
  ret void
}

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3vox2io8IArchiversERj(ptr noundef nonnull align 8 dereferenceable(9), ptr noundef nonnull align 4 dereferenceable(4)) #1 align 2

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

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZN3vox4math3MinImEET_S2_S2_(i64 noundef, i64 noundef) #3

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3vox2io8IArchiversIKNS0_8internal5ArrayIcEEEEvRT_(ptr noundef nonnull align 8 dereferenceable(9), ptr noundef nonnull align 8 dereferenceable(16)) #1 align 2

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local { ptr, i64 } @_ZN3vox2io9MakeArrayIcEEKNS0_8internal5ArrayIT_EEPS4_m(ptr noundef, i64 noundef) #3

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcEN3vox12StdAllocatorIcEEE6appendEPKcm(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef, i64 noundef) #1 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #3 = { alwaysinline 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 = { 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, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}


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

%"struct.vox::io::internal::Array.0" = type { ptr, i64 }
%"class.std::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char, std::char_traits<char>, vox::StdAllocator<char>>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char, std::char_traits<char>, vox::StdAllocator<char>>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3vox2io6ExternINSt7__cxx1112basic_stringIcSt11char_traitsIcENS_12StdAllocatorIcEEEEE4LoadERNS0_8IArchiveEPS8_mj(ptr noundef nonnull align 8 dereferenceable(9) %0, ptr noundef %1, i64 noundef %2, i32 noundef %3) local_unnamed_addr #1 align 2 {
  %5 = alloca i32, align 4
  %6 = alloca [128 x i8], align 16
  %7 = alloca %"struct.vox::io::internal::Array.0", align 8
  %.not22 = icmp eq i64 %2, 0
  br i1 %.not22, label %._crit_edge21, label %.lr.ph20

.lr.ph20:                                         ; preds = %4
  %8 = getelementptr inbounds i8, ptr %7, i64 8
  br label %9

._crit_edge21:                                    ; preds = %._crit_edge, %4
  ret void

9:                                                ; preds = %.lr.ph20, %._crit_edge
  %.018 = phi i64 [ 0, %.lr.ph20 ], [ %15, %._crit_edge ]
  %10 = getelementptr inbounds %"class.std::__cxx11::basic_string", ptr %1, i64 %.018
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcEN3vox12StdAllocatorIcEEE5clearEv(ptr noundef nonnull align 8 dereferenceable(32) %10) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #4
  call void @_ZN3vox2io8IArchiversERj(ptr noundef nonnull align 8 dereferenceable(9) %0, ptr noundef nonnull align 4 dereferenceable(4) %5)
  %11 = load i32, ptr %5, align 4, !tbaa !5
  %12 = zext i32 %11 to i64
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcEN3vox12StdAllocatorIcEEE7reserveEm(ptr noundef nonnull align 8 dereferenceable(32) %10, i64 noundef %12)
  call void @llvm.lifetime.start.p0(i64 128, ptr nonnull %6) #4
  %13 = load i32, ptr %5, align 4, !tbaa !5
  %.not16 = icmp eq i32 %13, 0
  br i1 %.not16, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %9
  %14 = zext i32 %13 to i64
  br label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %9
  call void @llvm.lifetime.end.p0(i64 128, ptr nonnull %6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #4
  %15 = add nuw i64 %.018, 1
  %exitcond.not = icmp eq i64 %15, %2
  br i1 %exitcond.not, label %._crit_edge21, label %9, !llvm.loop !9

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %.01517 = phi i64 [ %20, %.lr.ph ], [ %14, %.lr.ph.preheader ]
  %16 = call noundef i64 @_ZN3vox4math3MinImEET_S2_S2_(i64 noundef %.01517, i64 noundef 128)
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %7) #4
  %17 = call { ptr, i64 } @_ZN3vox2io9MakeArrayIcEEKNS0_8internal5ArrayIT_EEPS4_m(ptr noundef nonnull %6, i64 noundef %16)
  %18 = extractvalue { ptr, i64 } %17, 0
  store ptr %18, ptr %7, align 8
  %19 = extractvalue { ptr, i64 } %17, 1
  store i64 %19, ptr %8, align 8
  call void @_ZN3vox2io8IArchiversIKNS0_8internal5ArrayIcEEEEvRT_(ptr noundef nonnull align 8 dereferenceable(9) %0, ptr noundef nonnull align 8 dereferenceable(16) %7)
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %7) #4
  %20 = sub i64 %.01517, %16
  %21 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcEN3vox12StdAllocatorIcEEE6appendEPKcm(ptr noundef nonnull align 8 dereferenceable(32) %10, ptr noundef nonnull %6, i64 noundef %16)
  %.not = icmp eq i64 %20, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !11
}

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3vox2io8IArchiversERj(ptr noundef nonnull align 8 dereferenceable(9), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcEN3vox12StdAllocatorIcEEE7reserveEm(ptr noundef nonnull align 8 dereferenceable(32), i64 noundef) local_unnamed_addr #1 align 2

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZN3vox4math3MinImEET_S2_S2_(i64 noundef, i64 noundef) local_unnamed_addr #3

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3vox2io8IArchiversIKNS0_8internal5ArrayIcEEEEvRT_(ptr noundef nonnull align 8 dereferenceable(9), ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #1 align 2

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local { ptr, i64 } @_ZN3vox2io9MakeArrayIcEEKNS0_8internal5ArrayIT_EEPS4_m(ptr noundef, i64 noundef) local_unnamed_addr #3

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcEN3vox12StdAllocatorIcEEE6appendEPKcm(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef, i64 noundef) local_unnamed_addr #1 align 2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #3 = { alwaysinline 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 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass