; 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_conversion6Bignum16MultiplyByUInt64Em(ptr noundef nonnull align 4 dereferenceable(516) %0, i64 noundef %1) #2 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca i32, align 4
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  %11 = alloca i64, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i64 %1, ptr %4, align 8, !tbaa !9
  %12 = load ptr, ptr %3, align 8
  %13 = load i64, ptr %4, align 8, !tbaa !9
  %14 = icmp eq i64 %13, 1
  br i1 %14, label %15, label %16

15:                                               ; preds = %2
  br label %93

16:                                               ; preds = %2
  %17 = load i64, ptr %4, align 8, !tbaa !9
  %18 = icmp eq i64 %17, 0
  br i1 %18, label %19, label %20

19:                                               ; preds = %16
  call void @_ZN17double_conversion6Bignum4ZeroEv(ptr noundef nonnull align 4 dereferenceable(516) %12)
  br label %93

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

25:                                               ; preds = %20
  br label %93

26:                                               ; preds = %20
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  store i64 0, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %27 = load i64, ptr %4, align 8, !tbaa !9
  %28 = and i64 %27, 4294967295
  store i64 %28, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %29 = load i64, ptr %4, align 8, !tbaa !9
  %30 = lshr i64 %29, 32
  store i64 %30, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  store i32 0, ptr %8, align 4, !tbaa !14
  br label %31

31:                                               ; preds = %68, %26
  %32 = load i32, ptr %8, align 4, !tbaa !14
  %33 = getelementptr inbounds %"class.double_conversion::Bignum", ptr %12, i32 0, i32 0
  %34 = load i16, ptr %33, align 4, !tbaa !11
  %35 = sext i16 %34 to i32
  %36 = icmp slt i32 %32, %35
  br i1 %36, label %38, label %37

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

38:                                               ; preds = %31
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %39 = load i64, ptr %6, align 8, !tbaa !9
  %40 = load i32, ptr %8, align 4, !tbaa !14
  %41 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN17double_conversion6Bignum8RawBigitEi(ptr noundef nonnull align 4 dereferenceable(516) %12, i32 noundef %40)
  %42 = load i32, ptr %41, align 4, !tbaa !14
  %43 = zext i32 %42 to i64
  %44 = mul i64 %39, %43
  store i64 %44, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %45 = load i64, ptr %7, align 8, !tbaa !9
  %46 = load i32, ptr %8, align 4, !tbaa !14
  %47 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN17double_conversion6Bignum8RawBigitEi(ptr noundef nonnull align 4 dereferenceable(516) %12, i32 noundef %46)
  %48 = load i32, ptr %47, align 4, !tbaa !14
  %49 = zext i32 %48 to i64
  %50 = mul i64 %45, %49
  store i64 %50, ptr %10, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  %51 = load i64, ptr %5, align 8, !tbaa !9
  %52 = and i64 %51, 268435455
  %53 = load i64, ptr %9, align 8, !tbaa !9
  %54 = add i64 %52, %53
  store i64 %54, ptr %11, align 8, !tbaa !9
  %55 = load i64, ptr %11, align 8, !tbaa !9
  %56 = and i64 %55, 268435455
  %57 = trunc i64 %56 to i32
  %58 = load i32, ptr %8, align 4, !tbaa !14
  %59 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN17double_conversion6Bignum8RawBigitEi(ptr noundef nonnull align 4 dereferenceable(516) %12, i32 noundef %58)
  store i32 %57, ptr %59, align 4, !tbaa !14
  %60 = load i64, ptr %5, align 8, !tbaa !9
  %61 = lshr i64 %60, 28
  %62 = load i64, ptr %11, align 8, !tbaa !9
  %63 = lshr i64 %62, 28
  %64 = add i64 %61, %63
  %65 = load i64, ptr %10, align 8, !tbaa !9
  %66 = shl i64 %65, 4
  %67 = add i64 %64, %66
  store i64 %67, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  br label %68

68:                                               ; preds = %38
  %69 = load i32, ptr %8, align 4, !tbaa !14
  %70 = add nsw i32 %69, 1
  store i32 %70, ptr %8, align 4, !tbaa !14
  br label %31, !llvm.loop !16

71:                                               ; preds = %37
  br label %72

72:                                               ; preds = %75, %71
  %73 = load i64, ptr %5, align 8, !tbaa !9
  %74 = icmp ne i64 %73, 0
  br i1 %74, label %75, label %92

75:                                               ; preds = %72
  %76 = getelementptr inbounds %"class.double_conversion::Bignum", ptr %12, i32 0, i32 0
  %77 = load i16, ptr %76, align 4, !tbaa !11
  %78 = sext i16 %77 to i32
  %79 = add nsw i32 %78, 1
  call void @_ZN17double_conversion6Bignum14EnsureCapacityEi(i32 noundef %79)
  %80 = load i64, ptr %5, align 8, !tbaa !9
  %81 = and i64 %80, 268435455
  %82 = trunc i64 %81 to i32
  %83 = getelementptr inbounds %"class.double_conversion::Bignum", ptr %12, i32 0, i32 0
  %84 = load i16, ptr %83, align 4, !tbaa !11
  %85 = sext i16 %84 to i32
  %86 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN17double_conversion6Bignum8RawBigitEi(ptr noundef nonnull align 4 dereferenceable(516) %12, i32 noundef %85)
  store i32 %82, ptr %86, align 4, !tbaa !14
  %87 = getelementptr inbounds %"class.double_conversion::Bignum", ptr %12, i32 0, i32 0
  %88 = load i16, ptr %87, align 4, !tbaa !11
  %89 = add i16 %88, 1
  store i16 %89, ptr %87, align 4, !tbaa !11
  %90 = load i64, ptr %5, align 8, !tbaa !9
  %91 = lshr i64 %90, 28
  store i64 %91, ptr %5, align 8, !tbaa !9
  br label %72, !llvm.loop !18

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

93:                                               ; preds = %92, %25, %19, %15
  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 = !{!"long", !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 = !{!"int", !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_conversion6Bignum16MultiplyByUInt64Em(ptr noundef nonnull align 4 dereferenceable(516) %0, i64 noundef %1) local_unnamed_addr #0 align 2 {
  switch i64 %1, label %4 [
    i64 1, label %.loopexit
    i64 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 eq i16 %5, 0
  br i1 %6, label %.loopexit, label %7

7:                                                ; preds = %4
  %8 = and i64 %1, 4294967295
  %9 = icmp sgt i16 %5, 0
  br i1 %9, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %7
  %10 = lshr i64 %1, 28
  %11 = and i64 %10, 68719476720
  br label %12

.preheader:                                       ; preds = %12
  %.not24 = icmp eq i64 %29, 0
  br i1 %.not24, label %.loopexit, label %.lr.ph26

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

.lr.ph26:                                         ; preds = %.preheader, %.lr.ph26
  %34 = phi i16 [ %43, %.lr.ph26 ], [ %31, %.preheader ]
  %.125 = phi i64 [ %44, %.lr.ph26 ], [ %29, %.preheader ]
  %35 = sext i16 %34 to i32
  %36 = add nsw i32 %35, 1
  tail call void @_ZN17double_conversion6Bignum14EnsureCapacityEi(i32 noundef %36)
  %37 = trunc i64 %.125 to i32
  %38 = and i32 %37, 268435455
  %39 = load i16, ptr %0, align 4, !tbaa !5
  %40 = sext i16 %39 to i32
  %41 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN17double_conversion6Bignum8RawBigitEi(ptr noundef nonnull align 4 dereferenceable(516) %0, i32 noundef %40)
  store i32 %38, ptr %41, align 4, !tbaa !10
  %42 = load i16, ptr %0, align 4, !tbaa !5
  %43 = add i16 %42, 1
  store i16 %43, ptr %0, align 4, !tbaa !5
  %44 = lshr i64 %.125, 28
  %.not = icmp ult i64 %.125, 268435456
  br i1 %.not, label %.loopexit, label %.lr.ph26, !llvm.loop !14

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