; 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_conversion6Bignum12AssignUInt64Em(ptr noundef nonnull align 8 dereferenceable(536) %0, i64 noundef %1) #2 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca i64, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i64 %1, ptr %4, align 8, !tbaa !9
  %9 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  store i32 64, ptr %5, align 4, !tbaa !11
  call void @_ZN17double_conversion6Bignum4ZeroEv(ptr noundef nonnull align 8 dereferenceable(536) %9)
  %10 = load i64, ptr %4, align 8, !tbaa !9
  %11 = icmp eq i64 %10, 0
  br i1 %11, label %12, label %13

12:                                               ; preds = %2
  store i32 1, ptr %6, align 4
  br label %35

13:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  store i32 3, ptr %7, align 4, !tbaa !11
  %14 = load i32, ptr %7, align 4, !tbaa !11
  call void @_ZN17double_conversion6Bignum14EnsureCapacityEi(ptr noundef nonnull align 8 dereferenceable(536) %9, i32 noundef %14)
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  store i32 0, ptr %8, align 4, !tbaa !11
  br label %15

15:                                               ; preds = %29, %13
  %16 = load i32, ptr %8, align 4, !tbaa !11
  %17 = load i32, ptr %7, align 4, !tbaa !11
  %18 = icmp slt i32 %16, %17
  br i1 %18, label %20, label %19

19:                                               ; preds = %15
  store i32 2, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  br label %32

20:                                               ; preds = %15
  %21 = load i64, ptr %4, align 8, !tbaa !9
  %22 = and i64 %21, 268435455
  %23 = trunc i64 %22 to i32
  %24 = getelementptr inbounds %"class.double_conversion::Bignum", ptr %9, i32 0, i32 1
  %25 = load i32, ptr %8, align 4, !tbaa !11
  %26 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK17double_conversion6VectorIjEixEi(ptr noundef nonnull align 8 dereferenceable(12) %24, i32 noundef %25)
  store i32 %23, ptr %26, align 4, !tbaa !11
  %27 = load i64, ptr %4, align 8, !tbaa !9
  %28 = lshr i64 %27, 28
  store i64 %28, ptr %4, align 8, !tbaa !9
  br label %29

29:                                               ; preds = %20
  %30 = load i32, ptr %8, align 4, !tbaa !11
  %31 = add nsw i32 %30, 1
  store i32 %31, ptr %8, align 4, !tbaa !11
  br label %15, !llvm.loop !13

32:                                               ; preds = %19
  %33 = load i32, ptr %7, align 4, !tbaa !11
  %34 = getelementptr inbounds %"class.double_conversion::Bignum", ptr %9, i32 0, i32 2
  store i32 %33, ptr %34, align 8, !tbaa !15
  call void @_ZN17double_conversion6Bignum5ClampEv(ptr noundef nonnull align 8 dereferenceable(536) %9)
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  store i32 0, ptr %6, align 4
  br label %35

35:                                               ; preds = %32, %12
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  %36 = load i32, ptr %6, align 4
  switch i32 %36, label %38 [
    i32 0, label %37
    i32 1, label %37
  ]

37:                                               ; preds = %35, %35
  ret void

38:                                               ; preds = %35
  unreachable
}

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

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 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{!16, !12, i64 528}
!16 = !{!"_ZTSN17double_conversion6BignumE", !7, i64 0, !17, i64 512, !12, i64 528, !12, i64 532}
!17 = !{!"_ZTSN17double_conversion6VectorIjEE", !6, i64 0, !12, i64 8}


; 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_conversion6Bignum12AssignUInt64Em(ptr noundef nonnull align 8 dereferenceable(536) %0, i64 noundef %1) local_unnamed_addr #1 align 2 {
  tail call void @_ZN17double_conversion6Bignum4ZeroEv(ptr noundef nonnull align 8 dereferenceable(536) %0)
  %3 = icmp eq i64 %1, 0
  br i1 %3, label %17, label %4

4:                                                ; preds = %2
  tail call void @_ZN17double_conversion6Bignum14EnsureCapacityEi(ptr noundef nonnull align 8 dereferenceable(536) %0, i32 noundef 3)
  %5 = getelementptr inbounds i8, ptr %0, i64 512
  %6 = trunc i64 %1 to i32
  %7 = and i32 %6, 268435455
  %8 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK17double_conversion6VectorIjEixEi(ptr noundef nonnull align 8 dereferenceable(12) %5, i32 noundef 0)
  store i32 %7, ptr %8, align 4, !tbaa !5
  %9 = lshr i64 %1, 28
  %10 = trunc i64 %9 to i32
  %11 = and i32 %10, 268435455
  %12 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK17double_conversion6VectorIjEixEi(ptr noundef nonnull align 8 dereferenceable(12) %5, i32 noundef 1)
  store i32 %11, ptr %12, align 4, !tbaa !5
  %13 = lshr i64 %1, 56
  %14 = trunc nuw nsw i64 %13 to i32
  %15 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK17double_conversion6VectorIjEixEi(ptr noundef nonnull align 8 dereferenceable(12) %5, i32 noundef 2)
  store i32 %14, ptr %15, align 4, !tbaa !5
  %16 = getelementptr inbounds i8, ptr %0, i64 528
  store i32 3, ptr %16, align 8, !tbaa !9
  tail call void @_ZN17double_conversion6Bignum5ClampEv(ptr noundef nonnull align 8 dereferenceable(536) %0)
  br label %17

17:                                               ; preds = %2, %4
  ret void
}

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

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


; Effective O3 passes: GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass