; 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::Bignum" = type { [128 x i32], %"class.double_conversion::Vector", i32, i32 }
%"class.double_conversion::Vector" = 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: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNK17double_conversion6VectorIjEixEi(ptr noundef nonnull align 8 dereferenceable(12), i32 noundef) #1 align 2

; 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)) #2 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN17double_conversion6Bignum16MultiplyByUInt32Ej(ptr noundef nonnull align 8 dereferenceable(536) %0, i32 noundef %1) #2 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i64, align 8
  %6 = alloca i32, align 4
  %7 = alloca i64, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  %8 = load ptr, ptr %3, align 8
  %9 = load i32, ptr %4, align 4, !tbaa !9
  %10 = icmp eq i32 %9, 1
  br i1 %10, label %11, label %12

11:                                               ; preds = %2
  br label %71

12:                                               ; preds = %2
  %13 = load i32, ptr %4, align 4, !tbaa !9
  %14 = icmp eq i32 %13, 0
  br i1 %14, label %15, label %16

15:                                               ; preds = %12
  call void @_ZN17double_conversion6Bignum4ZeroEv(ptr noundef nonnull align 8 dereferenceable(536) %8)
  br label %71

16:                                               ; preds = %12
  %17 = getelementptr inbounds %"class.double_conversion::Bignum", ptr %8, i32 0, i32 2
  %18 = load i32, ptr %17, align 8, !tbaa !11
  %19 = icmp eq i32 %18, 0
  br i1 %19, label %20, label %21

20:                                               ; preds = %16
  br label %71

21:                                               ; preds = %16
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  store i64 0, ptr %5, align 8, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  store i32 0, ptr %6, align 4, !tbaa !9
  br label %22

22:                                               ; preds = %47, %21
  %23 = load i32, ptr %6, align 4, !tbaa !9
  %24 = getelementptr inbounds %"class.double_conversion::Bignum", ptr %8, i32 0, i32 2
  %25 = load i32, ptr %24, align 8, !tbaa !11
  %26 = icmp slt i32 %23, %25
  br i1 %26, label %28, label %27

27:                                               ; preds = %22
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  br label %50

28:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %29 = load i32, ptr %4, align 4, !tbaa !9
  %30 = zext i32 %29 to i64
  %31 = getelementptr inbounds %"class.double_conversion::Bignum", ptr %8, i32 0, i32 1
  %32 = load i32, ptr %6, align 4, !tbaa !9
  %33 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK17double_conversion6VectorIjEixEi(ptr noundef nonnull align 8 dereferenceable(12) %31, i32 noundef %32)
  %34 = load i32, ptr %33, align 4, !tbaa !9
  %35 = zext i32 %34 to i64
  %36 = mul i64 %30, %35
  %37 = load i64, ptr %5, align 8, !tbaa !14
  %38 = add i64 %36, %37
  store i64 %38, ptr %7, align 8, !tbaa !14
  %39 = load i64, ptr %7, align 8, !tbaa !14
  %40 = and i64 %39, 268435455
  %41 = trunc i64 %40 to i32
  %42 = getelementptr inbounds %"class.double_conversion::Bignum", ptr %8, i32 0, i32 1
  %43 = load i32, ptr %6, align 4, !tbaa !9
  %44 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK17double_conversion6VectorIjEixEi(ptr noundef nonnull align 8 dereferenceable(12) %42, i32 noundef %43)
  store i32 %41, ptr %44, align 4, !tbaa !9
  %45 = load i64, ptr %7, align 8, !tbaa !14
  %46 = lshr i64 %45, 28
  store i64 %46, ptr %5, align 8, !tbaa !14
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  br label %47

47:                                               ; preds = %28
  %48 = load i32, ptr %6, align 4, !tbaa !9
  %49 = add nsw i32 %48, 1
  store i32 %49, ptr %6, align 4, !tbaa !9
  br label %22, !llvm.loop !16

50:                                               ; preds = %27
  br label %51

51:                                               ; preds = %54, %50
  %52 = load i64, ptr %5, align 8, !tbaa !14
  %53 = icmp ne i64 %52, 0
  br i1 %53, label %54, label %70

54:                                               ; preds = %51
  %55 = getelementptr inbounds %"class.double_conversion::Bignum", ptr %8, i32 0, i32 2
  %56 = load i32, ptr %55, align 8, !tbaa !11
  %57 = add nsw i32 %56, 1
  call void @_ZN17double_conversion6Bignum14EnsureCapacityEi(ptr noundef nonnull align 8 dereferenceable(536) %8, i32 noundef %57)
  %58 = load i64, ptr %5, align 8, !tbaa !14
  %59 = and i64 %58, 268435455
  %60 = trunc i64 %59 to i32
  %61 = getelementptr inbounds %"class.double_conversion::Bignum", ptr %8, i32 0, i32 1
  %62 = getelementptr inbounds %"class.double_conversion::Bignum", ptr %8, i32 0, i32 2
  %63 = load i32, ptr %62, align 8, !tbaa !11
  %64 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK17double_conversion6VectorIjEixEi(ptr noundef nonnull align 8 dereferenceable(12) %61, i32 noundef %63)
  store i32 %60, ptr %64, align 4, !tbaa !9
  %65 = getelementptr inbounds %"class.double_conversion::Bignum", ptr %8, i32 0, i32 2
  %66 = load i32, ptr %65, align 8, !tbaa !11
  %67 = add nsw i32 %66, 1
  store i32 %67, ptr %65, align 8, !tbaa !11
  %68 = load i64, ptr %5, align 8, !tbaa !14
  %69 = lshr i64 %68, 28
  store i64 %69, ptr %5, align 8, !tbaa !14
  br label %51, !llvm.loop !18

70:                                               ; preds = %51
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  br label %71

71:                                               ; preds = %70, %20, %15, %11
  ret void
}

attributes #0 = { nocallback nofree nosync 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 = { 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 = !{!12, !10, i64 528}
!12 = !{!"_ZTSN17double_conversion6BignumE", !7, i64 0, !13, i64 512, !10, i64 528, !10, i64 532}
!13 = !{!"_ZTSN17double_conversion6VectorIjEE", !6, i64 0, !10, i64 8}
!14 = !{!15, !15, i64 0}
!15 = !{!"long", !7, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = distinct !{!18, !17}


; 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 nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNK17double_conversion6VectorIjEixEi(ptr noundef nonnull align 8 dereferenceable(12), i32 noundef) local_unnamed_addr #0 align 2

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN17double_conversion6Bignum16MultiplyByUInt32Ej(ptr noundef nonnull align 8 dereferenceable(536) %0, i32 noundef %1) local_unnamed_addr #1 align 2 {
  switch i32 %1, label %4 [
    i32 1, label %.loopexit
    i32 0, label %3
  ]

3:                                                ; preds = %2
  tail call void @_ZN17double_conversion6Bignum4ZeroEv(ptr noundef nonnull align 8 dereferenceable(536) %0)
  br label %.loopexit

4:                                                ; preds = %2
  %5 = getelementptr inbounds i8, ptr %0, i64 528
  %6 = load i32, ptr %5, align 8, !tbaa !5
  %7 = icmp sgt i32 %6, 0
  br i1 %7, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %4
  %8 = zext i32 %1 to i64
  %9 = getelementptr inbounds i8, ptr %0, i64 512
  br label %11

.preheader:                                       ; preds = %11
  %.not18 = icmp ult i64 %16, 268435456
  br i1 %.not18, label %.loopexit, label %.lr.ph20

.lr.ph20:                                         ; preds = %.preheader
  %10 = getelementptr inbounds i8, ptr %0, i64 512
  br label %24

11:                                               ; preds = %.lr.ph, %11
  %.017 = phi i64 [ 0, %.lr.ph ], [ %20, %11 ]
  %.01316 = phi i32 [ 0, %.lr.ph ], [ %21, %11 ]
  %12 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK17double_conversion6VectorIjEixEi(ptr noundef nonnull align 8 dereferenceable(12) %9, i32 noundef %.01316)
  %13 = load i32, ptr %12, align 4, !tbaa !12
  %14 = zext i32 %13 to i64
  %15 = mul nuw i64 %14, %8
  %16 = add i64 %15, %.017
  %17 = trunc i64 %16 to i32
  %18 = and i32 %17, 268435455
  %19 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK17double_conversion6VectorIjEixEi(ptr noundef nonnull align 8 dereferenceable(12) %9, i32 noundef %.01316)
  store i32 %18, ptr %19, align 4, !tbaa !12
  %20 = lshr i64 %16, 28
  %21 = add nuw nsw i32 %.01316, 1
  %22 = load i32, ptr %5, align 8, !tbaa !5
  %23 = icmp slt i32 %21, %22
  br i1 %23, label %11, label %.preheader, !llvm.loop !13

24:                                               ; preds = %.lr.ph20, %24
  %25 = phi i32 [ %22, %.lr.ph20 ], [ %32, %24 ]
  %.119 = phi i64 [ %20, %.lr.ph20 ], [ %33, %24 ]
  %26 = add nsw i32 %25, 1
  tail call void @_ZN17double_conversion6Bignum14EnsureCapacityEi(ptr noundef nonnull align 8 dereferenceable(536) %0, i32 noundef %26)
  %27 = trunc i64 %.119 to i32
  %28 = and i32 %27, 268435455
  %29 = load i32, ptr %5, align 8, !tbaa !5
  %30 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK17double_conversion6VectorIjEixEi(ptr noundef nonnull align 8 dereferenceable(12) %10, i32 noundef %29)
  store i32 %28, ptr %30, align 4, !tbaa !12
  %31 = load i32, ptr %5, align 8, !tbaa !5
  %32 = add nsw i32 %31, 1
  store i32 %32, ptr %5, align 8, !tbaa !5
  %33 = lshr i64 %.119, 28
  %.not = icmp ult i64 %.119, 268435456
  br i1 %.not, label %.loopexit, label %24, !llvm.loop !15

.loopexit:                                        ; preds = %24, %.preheader, %2, %4, %3
  ret void
}

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

!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, !11, i64 528}
!6 = !{!"_ZTSN17double_conversion6BignumE", !7, i64 0, !9, i64 512, !11, i64 528, !11, i64 532}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!"_ZTSN17double_conversion6VectorIjEE", !10, i64 0, !11, i64 8}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!"int", !7, i64 0}
!12 = !{!11, !11, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}


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