; 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] }

@.str.1 = external hidden unnamed_addr constant [131 x i8], align 1
@_ZZN17double_conversion6Bignum20MultiplyByPowerOfTenEiE12kFive1_to_12 = external hidden constant [12 x i32], align 16
@.str.9 = external hidden unnamed_addr constant [14 x i8], align 1
@__PRETTY_FUNCTION__._ZN17double_conversion6Bignum20MultiplyByPowerOfTenEi = external hidden unnamed_addr constant [64 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #0

; 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 uwtable
define dso_local void @_ZN17double_conversion6Bignum20MultiplyByPowerOfTenEi(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 i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  %6 = load ptr, ptr %3, align 8
  %7 = load i32, ptr %4, align 4, !tbaa !9
  %8 = icmp sge i32 %7, 0
  br i1 %8, label %9, label %10

9:                                                ; preds = %2
  br label %12

10:                                               ; preds = %2
  call void @__assert_fail(ptr noundef @.str.9, ptr noundef @.str.1, i32 noundef 330, ptr noundef @__PRETTY_FUNCTION__._ZN17double_conversion6Bignum20MultiplyByPowerOfTenEi) #3
  unreachable

11:                                               ; No predecessors!
  br label %12

12:                                               ; preds = %11, %9
  %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
  br label %48

16:                                               ; preds = %12
  %17 = getelementptr inbounds %"class.double_conversion::Bignum", ptr %6, 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 %48

22:                                               ; preds = %16
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  %23 = load i32, ptr %4, align 4, !tbaa !9
  store i32 %23, ptr %5, align 4, !tbaa !9
  br label %24

24:                                               ; preds = %27, %22
  %25 = load i32, ptr %5, align 4, !tbaa !9
  %26 = icmp sge i32 %25, 27
  br i1 %26, label %27, label %30

27:                                               ; preds = %24
  call void @_ZN17double_conversion6Bignum16MultiplyByUInt64Em(ptr noundef nonnull align 4 dereferenceable(516) %6, i64 noundef 7450580596923828125)
  %28 = load i32, ptr %5, align 4, !tbaa !9
  %29 = sub nsw i32 %28, 27
  store i32 %29, ptr %5, align 4, !tbaa !9
  br label %24, !llvm.loop !14

30:                                               ; preds = %24
  br label %31

31:                                               ; preds = %34, %30
  %32 = load i32, ptr %5, align 4, !tbaa !9
  %33 = icmp sge i32 %32, 13
  br i1 %33, label %34, label %37

34:                                               ; preds = %31
  call void @_ZN17double_conversion6Bignum16MultiplyByUInt32Ej(ptr noundef nonnull align 4 dereferenceable(516) %6, i32 noundef 1220703125)
  %35 = load i32, ptr %5, align 4, !tbaa !9
  %36 = sub nsw i32 %35, 13
  store i32 %36, ptr %5, align 4, !tbaa !9
  br label %31, !llvm.loop !16

37:                                               ; preds = %31
  %38 = load i32, ptr %5, align 4, !tbaa !9
  %39 = icmp sgt i32 %38, 0
  br i1 %39, label %40, label %46

40:                                               ; preds = %37
  %41 = load i32, ptr %5, align 4, !tbaa !9
  %42 = sub nsw i32 %41, 1
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds [12 x i32], ptr @_ZZN17double_conversion6Bignum20MultiplyByPowerOfTenEiE12kFive1_to_12, i64 0, i64 %43
  %45 = load i32, ptr %44, align 4, !tbaa !9
  call void @_ZN17double_conversion6Bignum16MultiplyByUInt32Ej(ptr noundef nonnull align 4 dereferenceable(516) %6, i32 noundef %45)
  br label %46

46:                                               ; preds = %40, %37
  %47 = load i32, ptr %4, align 4, !tbaa !9
  call void @_ZN17double_conversion6Bignum9ShiftLeftEi(ptr noundef nonnull align 4 dereferenceable(516) %6, i32 noundef %47)
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  br label %48

48:                                               ; preds = %46, %21, %15
  ret void
}

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN17double_conversion6Bignum16MultiplyByUInt64Em(ptr noundef nonnull align 4 dereferenceable(516), i64 noundef) #2 align 2

attributes #0 = { noreturn nounwind "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 = { noreturn nounwind }
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 = !{!12, !13, i64 0}
!12 = !{!"_ZTSN17double_conversion6BignumE", !13, i64 0, !13, i64 2, !7, i64 4}
!13 = !{!"short", !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = distinct !{!16, !15}


; 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"

@.str.1 = external hidden unnamed_addr constant [131 x i8], align 1
@_ZZN17double_conversion6Bignum20MultiplyByPowerOfTenEiE12kFive1_to_12 = external hidden local_unnamed_addr constant [12 x i32], align 16
@.str.9 = external hidden unnamed_addr constant [14 x i8], align 1
@__PRETTY_FUNCTION__._ZN17double_conversion6Bignum20MultiplyByPowerOfTenEi = external hidden unnamed_addr constant [64 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN17double_conversion6Bignum20MultiplyByPowerOfTenEi(ptr noundef nonnull align 4 dereferenceable(516) %0, i32 noundef %1) local_unnamed_addr #1 align 2 {
  %3 = icmp sgt i32 %1, -1
  br i1 %3, label %5, label %4

4:                                                ; preds = %2
  tail call void @__assert_fail(ptr noundef nonnull @.str.9, ptr noundef nonnull @.str.1, i32 noundef 330, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN17double_conversion6Bignum20MultiplyByPowerOfTenEi) #2
  unreachable

5:                                                ; preds = %2
  %6 = icmp eq i32 %1, 0
  %7 = load i16, ptr %0, align 4
  %8 = icmp eq i16 %7, 0
  %or.cond = select i1 %6, i1 true, i1 %8
  br i1 %or.cond, label %21, label %.preheader12

.preheader12:                                     ; preds = %5
  %9 = icmp ugt i32 %1, 26
  br i1 %9, label %.lr.ph, label %.preheader

.preheader:                                       ; preds = %.lr.ph, %.preheader12
  %.0.lcssa = phi i32 [ %1, %.preheader12 ], [ %11, %.lr.ph ]
  %10 = icmp ugt i32 %.0.lcssa, 12
  br i1 %10, label %.lr.ph15, label %._crit_edge

.lr.ph:                                           ; preds = %.preheader12, %.lr.ph
  %.013 = phi i32 [ %11, %.lr.ph ], [ %1, %.preheader12 ]
  tail call void @_ZN17double_conversion6Bignum16MultiplyByUInt64Em(ptr noundef nonnull align 4 dereferenceable(516) %0, i64 noundef 7450580596923828125)
  %11 = add nsw i32 %.013, -27
  %12 = icmp ugt i32 %.013, 53
  br i1 %12, label %.lr.ph, label %.preheader, !llvm.loop !5

.lr.ph15:                                         ; preds = %.preheader, %.lr.ph15
  %.114 = phi i32 [ %13, %.lr.ph15 ], [ %.0.lcssa, %.preheader ]
  tail call void @_ZN17double_conversion6Bignum16MultiplyByUInt32Ej(ptr noundef nonnull align 4 dereferenceable(516) %0, i32 noundef 1220703125)
  %13 = add nsw i32 %.114, -13
  %14 = icmp ugt i32 %.114, 25
  br i1 %14, label %.lr.ph15, label %._crit_edge, !llvm.loop !7

._crit_edge:                                      ; preds = %.lr.ph15, %.preheader
  %.1.lcssa = phi i32 [ %.0.lcssa, %.preheader ], [ %13, %.lr.ph15 ]
  %.not = icmp eq i32 %.1.lcssa, 0
  br i1 %.not, label %20, label %15

15:                                               ; preds = %._crit_edge
  %16 = add nsw i32 %.1.lcssa, -1
  %17 = zext nneg i32 %16 to i64
  %18 = getelementptr inbounds [12 x i32], ptr @_ZZN17double_conversion6Bignum20MultiplyByPowerOfTenEiE12kFive1_to_12, i64 0, i64 %17
  %19 = load i32, ptr %18, align 4, !tbaa !8
  tail call void @_ZN17double_conversion6Bignum16MultiplyByUInt32Ej(ptr noundef nonnull align 4 dereferenceable(516) %0, i32 noundef %19)
  br label %20

20:                                               ; preds = %15, %._crit_edge
  tail call void @_ZN17double_conversion6Bignum9ShiftLeftEi(ptr noundef nonnull align 4 dereferenceable(516) %0, i32 noundef %1)
  br label %21

21:                                               ; preds = %5, %20
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN17double_conversion6Bignum9ShiftLeftEi(ptr noundef nonnull align 4 dereferenceable(516), i32 noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN17double_conversion6Bignum16MultiplyByUInt32Ej(ptr noundef nonnull align 4 dereferenceable(516), i32 noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN17double_conversion6Bignum16MultiplyByUInt64Em(ptr noundef nonnull align 4 dereferenceable(516), i64 noundef) local_unnamed_addr #1 align 2

attributes #0 = { noreturn nounwind "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" }
attributes #2 = { noreturn 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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = distinct !{!7, !6}
!8 = !{!9, !9, i64 0}
!9 = !{!"int", !10, i64 0}
!10 = !{!"omnipotent char", !11, i64 0}
!11 = !{!"Simple C++ TBAA"}


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