; LLVM IR from InsightSoftwareConsortium/ITK :: Modules/ThirdParty/DoubleConversion/src/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 { i16, i16, [128 x i32] }

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZN17double_conversion6Bignum8RawBigitEi(ptr noundef nonnull align 4 dereferenceable(516), i32 noundef) #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN17double_conversion6Bignum4ZeroEv(ptr noundef nonnull align 4 dereferenceable(516)) #0 align 2

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN17double_conversion6Bignum14EnsureCapacityEi(i32 noundef) #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN17double_conversion6Bignum16MultiplyByUInt32Ej(ptr noundef nonnull align 4 dereferenceable(516) %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 %72

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 4 dereferenceable(516) %8)
  br label %72

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

21:                                               ; preds = %16
  br label %72

22:                                               ; 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 %23

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

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

30:                                               ; preds = %23
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %31 = load i32, ptr %4, align 4, !tbaa !9
  %32 = zext i32 %31 to i64
  %33 = load i32, ptr %6, align 4, !tbaa !9
  %34 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN17double_conversion6Bignum8RawBigitEi(ptr noundef nonnull align 4 dereferenceable(516) %8, i32 noundef %33)
  %35 = load i32, ptr %34, align 4, !tbaa !9
  %36 = zext i32 %35 to i64
  %37 = mul i64 %32, %36
  %38 = load i64, ptr %5, align 8, !tbaa !14
  %39 = add i64 %37, %38
  store i64 %39, ptr %7, align 8, !tbaa !14
  %40 = load i64, ptr %7, align 8, !tbaa !14
  %41 = and i64 %40, 268435455
  %42 = trunc i64 %41 to i32
  %43 = load i32, ptr %6, align 4, !tbaa !9
  %44 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN17double_conversion6Bignum8RawBigitEi(ptr noundef nonnull align 4 dereferenceable(516) %8, i32 noundef %43)
  store i32 %42, 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 = %30
  %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 %23, !llvm.loop !16

50:                                               ; preds = %29
  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 %71

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

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

72:                                               ; preds = %71, %21, %15, %11
  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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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, !13, i64 0}
!12 = !{!"_ZTSN17double_conversion6BignumE", !13, i64 0, !13, i64 2, !7, i64 4}
!13 = !{!"short", !7, i64 0}
!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 @_ZN17double_conversion6Bignum8RawBigitEi(ptr noundef nonnull align 4 dereferenceable(516), i32 noundef) local_unnamed_addr #0 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN17double_conversion6Bignum14EnsureCapacityEi(i32 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN17double_conversion6Bignum16MultiplyByUInt32Ej(ptr noundef nonnull align 4 dereferenceable(516) %0, i32 noundef %1) local_unnamed_addr #0 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 4 dereferenceable(516) %0)
  br label %.loopexit

4:                                                ; preds = %2
  %5 = load i16, ptr %0, align 4, !tbaa !5
  %6 = icmp sgt i16 %5, 0
  br i1 %6, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %4
  %7 = zext i32 %1 to i64
  br label %8

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

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

.lr.ph20:                                         ; preds = %.preheader, %.lr.ph20
  %22 = phi i16 [ %31, %.lr.ph20 ], [ %19, %.preheader ]
  %.119 = phi i64 [ %32, %.lr.ph20 ], [ %17, %.preheader ]
  %23 = sext i16 %22 to i32
  %24 = add nsw i32 %23, 1
  tail call void @_ZN17double_conversion6Bignum14EnsureCapacityEi(i32 noundef %24)
  %25 = trunc i64 %.119 to i32
  %26 = and i32 %25, 268435455
  %27 = load i16, ptr %0, align 4, !tbaa !5
  %28 = sext i16 %27 to i32
  %29 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN17double_conversion6Bignum8RawBigitEi(ptr noundef nonnull align 4 dereferenceable(516) %0, i32 noundef %28)
  store i32 %26, ptr %29, align 4, !tbaa !10
  %30 = load i16, ptr %0, align 4, !tbaa !5
  %31 = add i16 %30, 1
  store i16 %31, ptr %0, align 4, !tbaa !5
  %32 = lshr i64 %.119, 28
  %.not = icmp ult i64 %.119, 268435456
  br i1 %.not, label %.loopexit, label %.lr.ph20, !llvm.loop !14

.loopexit:                                        ; preds = %.lr.ph20, %.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" }

!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, !7, i64 0}
!6 = !{!"_ZTSN17double_conversion6BignumE", !7, i64 0, !7, i64 2, !8, i64 4}
!7 = !{!"short", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!11, !11, i64 0}
!11 = !{!"int", !8, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !13}


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