; LLVM IR from iyinoluwamt/Tensorframe :: main/ios/Pods/DoubleConversion/double-conversion (bignum)

; 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.double_conversion::Vector.0" = type <{ ptr, i32, [4 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
declare dso_local void @_ZN17double_conversion6Bignum4ZeroEv(ptr noundef nonnull align 8 dereferenceable(536)) #1 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN17double_conversion6Bignum19AssignDecimalStringENS_6VectorIKcEE(ptr noundef nonnull align 8 dereferenceable(536) %0, ptr %1, i32 %2) #1 align 2 {
  %4 = alloca %"class.double_conversion::Vector.0", align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i64, align 8
  %10 = alloca %"class.double_conversion::Vector.0", align 8
  %11 = alloca i64, align 8
  %12 = alloca %"class.double_conversion::Vector.0", align 8
  %13 = getelementptr inbounds { ptr, i32 }, ptr %4, i32 0, i32 0
  store ptr %1, ptr %13, align 8
  %14 = getelementptr inbounds { ptr, i32 }, ptr %4, i32 0, i32 1
  store i32 %2, ptr %14, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  %15 = load ptr, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  store i32 19, ptr %6, align 4, !tbaa !9
  call void @_ZN17double_conversion6Bignum4ZeroEv(ptr noundef nonnull align 8 dereferenceable(536) %15)
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  %16 = call noundef i32 @_ZNK17double_conversion6VectorIKcE6lengthEv(ptr noundef nonnull align 8 dereferenceable(12) %4)
  store i32 %16, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  store i32 0, ptr %8, align 4, !tbaa !9
  br label %17

17:                                               ; preds = %20, %3
  %18 = load i32, ptr %7, align 4, !tbaa !9
  %19 = icmp sge i32 %18, 19
  br i1 %19, label %20, label %32

20:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %10, ptr align 8 %4, i64 16, i1 false), !tbaa.struct !11
  %21 = load i32, ptr %8, align 4, !tbaa !9
  %22 = getelementptr inbounds { ptr, i32 }, ptr %10, i32 0, i32 0
  %23 = load ptr, ptr %22, align 8
  %24 = getelementptr inbounds { ptr, i32 }, ptr %10, i32 0, i32 1
  %25 = load i32, ptr %24, align 8
  %26 = call noundef i64 @_ZN17double_conversionL10ReadUInt64ENS_6VectorIKcEEii(ptr %23, i32 %25, i32 noundef %21, i32 noundef 19)
  store i64 %26, ptr %9, align 8, !tbaa !12
  %27 = load i32, ptr %8, align 4, !tbaa !9
  %28 = add nsw i32 %27, 19
  store i32 %28, ptr %8, align 4, !tbaa !9
  %29 = load i32, ptr %7, align 4, !tbaa !9
  %30 = sub nsw i32 %29, 19
  store i32 %30, ptr %7, align 4, !tbaa !9
  call void @_ZN17double_conversion6Bignum20MultiplyByPowerOfTenEi(ptr noundef nonnull align 8 dereferenceable(536) %15, i32 noundef 19)
  %31 = load i64, ptr %9, align 8, !tbaa !12
  call void @_ZN17double_conversion6Bignum9AddUInt64Em(ptr noundef nonnull align 8 dereferenceable(536) %15, i64 noundef %31)
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  br label %17, !llvm.loop !14

32:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %12, ptr align 8 %4, i64 16, i1 false), !tbaa.struct !11
  %33 = load i32, ptr %8, align 4, !tbaa !9
  %34 = load i32, ptr %7, align 4, !tbaa !9
  %35 = getelementptr inbounds { ptr, i32 }, ptr %12, i32 0, i32 0
  %36 = load ptr, ptr %35, align 8
  %37 = getelementptr inbounds { ptr, i32 }, ptr %12, i32 0, i32 1
  %38 = load i32, ptr %37, align 8
  %39 = call noundef i64 @_ZN17double_conversionL10ReadUInt64ENS_6VectorIKcEEii(ptr %36, i32 %38, i32 noundef %33, i32 noundef %34)
  store i64 %39, ptr %11, align 8, !tbaa !12
  %40 = load i32, ptr %7, align 4, !tbaa !9
  call void @_ZN17double_conversion6Bignum20MultiplyByPowerOfTenEi(ptr noundef nonnull align 8 dereferenceable(536) %15, i32 noundef %40)
  %41 = load i64, ptr %11, align 8, !tbaa !12
  call void @_ZN17double_conversion6Bignum9AddUInt64Em(ptr noundef nonnull align 8 dereferenceable(536) %15, i64 noundef %41)
  call void @_ZN17double_conversion6Bignum5ClampEv(ptr noundef nonnull align 8 dereferenceable(536) %15)
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  ret void
}

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

; Function Attrs: mustprogress uwtable
declare hidden noundef i64 @_ZN17double_conversionL10ReadUInt64ENS_6VectorIKcEEii(ptr, i32, i32 noundef, i32 noundef) #1

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN17double_conversion6Bignum20MultiplyByPowerOfTenEi(ptr noundef nonnull align 8 dereferenceable(536), i32 noundef) #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN17double_conversion6Bignum9AddUInt64Em(ptr noundef nonnull align 8 dereferenceable(536), 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = !{!"int", !7, i64 0}
!11 = !{i64 0, i64 8, !5, i64 8, i64 4, !9}
!12 = !{!13, !13, i64 0}
!13 = !{!"long", !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}


; 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.double_conversion::Vector.0" = type <{ ptr, i32, [4 x i8] }>

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN17double_conversion6Bignum4ZeroEv(ptr noundef nonnull align 8 dereferenceable(536)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN17double_conversion6Bignum5ClampEv(ptr noundef nonnull align 8 dereferenceable(536)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN17double_conversion6Bignum19AssignDecimalStringENS_6VectorIKcEE(ptr noundef nonnull align 8 dereferenceable(536) %0, ptr %1, i32 %2) local_unnamed_addr #0 align 2 {
  %4 = alloca %"class.double_conversion::Vector.0", align 8
  store ptr %1, ptr %4, align 8
  %5 = getelementptr inbounds i8, ptr %4, i64 8
  store i32 %2, ptr %5, align 8
  tail call void @_ZN17double_conversion6Bignum4ZeroEv(ptr noundef nonnull align 8 dereferenceable(536) %0)
  %6 = call noundef i32 @_ZNK17double_conversion6VectorIKcE6lengthEv(ptr noundef nonnull align 8 dereferenceable(12) %4)
  %7 = icmp sgt i32 %6, 18
  br i1 %7, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %3, %.lr.ph
  %.014 = phi i32 [ %10, %.lr.ph ], [ %6, %3 ]
  %.01213 = phi i32 [ %9, %.lr.ph ], [ 0, %3 ]
  %.sroa.01.0.copyload = load ptr, ptr %4, align 8, !tbaa !5
  %.sroa.22.0.copyload = load i32, ptr %5, align 8, !tbaa !9
  %8 = call noundef i64 @_ZN17double_conversionL10ReadUInt64ENS_6VectorIKcEEii(ptr %.sroa.01.0.copyload, i32 %.sroa.22.0.copyload, i32 noundef %.01213, i32 noundef 19)
  %9 = add nuw nsw i32 %.01213, 19
  %10 = add nsw i32 %.014, -19
  call void @_ZN17double_conversion6Bignum20MultiplyByPowerOfTenEi(ptr noundef nonnull align 8 dereferenceable(536) %0, i32 noundef 19)
  call void @_ZN17double_conversion6Bignum9AddUInt64Em(ptr noundef nonnull align 8 dereferenceable(536) %0, i64 noundef %8)
  %11 = icmp ugt i32 %.014, 37
  br i1 %11, label %.lr.ph, label %._crit_edge, !llvm.loop !11

._crit_edge:                                      ; preds = %.lr.ph, %3
  %.012.lcssa = phi i32 [ 0, %3 ], [ %9, %.lr.ph ]
  %.0.lcssa = phi i32 [ %6, %3 ], [ %10, %.lr.ph ]
  %.sroa.0.0.copyload = load ptr, ptr %4, align 8, !tbaa !5
  %.sroa.2.0.copyload = load i32, ptr %5, align 8, !tbaa !9
  %12 = call noundef i64 @_ZN17double_conversionL10ReadUInt64ENS_6VectorIKcEEii(ptr %.sroa.0.0.copyload, i32 %.sroa.2.0.copyload, i32 noundef %.012.lcssa, i32 noundef %.0.lcssa)
  call void @_ZN17double_conversion6Bignum20MultiplyByPowerOfTenEi(ptr noundef nonnull align 8 dereferenceable(536) %0, i32 noundef %.0.lcssa)
  call void @_ZN17double_conversion6Bignum9AddUInt64Em(ptr noundef nonnull align 8 dereferenceable(536) %0, i64 noundef %12)
  call void @_ZN17double_conversion6Bignum5ClampEv(ptr noundef nonnull align 8 dereferenceable(536) %0)
  ret void
}

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

; Function Attrs: mustprogress uwtable
declare hidden noundef i64 @_ZN17double_conversionL10ReadUInt64ENS_6VectorIKcEEii(ptr, i32, i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN17double_conversion6Bignum20MultiplyByPowerOfTenEi(ptr noundef nonnull align 8 dereferenceable(536), i32 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN17double_conversion6Bignum9AddUInt64Em(ptr noundef nonnull align 8 dereferenceable(536), i64 noundef) local_unnamed_addr #0 align 2

attributes #0 = { 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 #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" }

!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 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass