; 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::Vector" = type <{ ptr, i32, [4 x i8] }>
%"class.double_conversion::Bignum" = type { i16, i16, [128 x i32] }

@.str.1 = external hidden unnamed_addr constant [131 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [18 x i8], align 1
@__PRETTY_FUNCTION__._ZN17double_conversion6Bignum15AssignHexStringENS_6VectorIKcEE = external hidden unnamed_addr constant [68 x i8], align 1

; 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: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #1

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK17double_conversion6VectorIKcE6lengthEv(ptr noundef nonnull align 8 dereferenceable(12)) #0 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN17double_conversion6Bignum15AssignHexStringENS_6VectorIKcEE(ptr noundef nonnull align 4 dereferenceable(516) %0, ptr %1, i32 %2) #3 align 2 {
  %4 = alloca %"class.double_conversion::Vector", align 8
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca i32, align 4
  %8 = getelementptr inbounds { ptr, i32 }, ptr %4, i32 0, i32 0
  store ptr %1, ptr %8, align 8
  %9 = getelementptr inbounds { ptr, i32 }, ptr %4, i32 0, i32 1
  store i32 %2, ptr %9, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  %10 = load ptr, ptr %5, align 8
  call void @_ZN17double_conversion6Bignum4ZeroEv(ptr noundef nonnull align 4 dereferenceable(516) %10)
  %11 = call noundef i32 @_ZNK17double_conversion6VectorIKcE6lengthEv(ptr noundef nonnull align 8 dereferenceable(12) %4)
  %12 = mul nsw i32 %11, 4
  %13 = add nsw i32 %12, 28
  %14 = sub nsw i32 %13, 1
  %15 = sdiv i32 %14, 28
  call void @_ZN17double_conversion6Bignum14EnsureCapacityEi(i32 noundef %15)
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  store i64 0, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  store i32 0, ptr %7, align 4, !tbaa !11
  br label %16

16:                                               ; preds = %47, %3
  %17 = call noundef zeroext i1 @_ZNK17double_conversion6VectorIKcE8is_emptyEv(ptr noundef nonnull align 8 dereferenceable(12) %4)
  %18 = xor i1 %17, true
  br i1 %18, label %20, label %19

19:                                               ; preds = %16
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  br label %48

20:                                               ; preds = %16
  %21 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZN17double_conversion6VectorIKcE4lastEv(ptr noundef nonnull align 8 dereferenceable(12) %4)
  %22 = load i8, ptr %21, align 1, !tbaa !13
  %23 = sext i8 %22 to i32
  %24 = call noundef i64 @_ZN17double_conversionL12HexCharValueEi(i32 noundef %23)
  %25 = load i32, ptr %7, align 4, !tbaa !11
  %26 = zext i32 %25 to i64
  %27 = shl i64 %24, %26
  %28 = load i64, ptr %6, align 8, !tbaa !9
  %29 = or i64 %28, %27
  store i64 %29, ptr %6, align 8, !tbaa !9
  %30 = load i32, ptr %7, align 4, !tbaa !11
  %31 = add nsw i32 %30, 4
  store i32 %31, ptr %7, align 4, !tbaa !11
  %32 = icmp sge i32 %31, 28
  br i1 %32, label %33, label %46

33:                                               ; preds = %20
  %34 = load i64, ptr %6, align 8, !tbaa !9
  %35 = and i64 %34, 268435455
  %36 = trunc i64 %35 to i32
  %37 = getelementptr inbounds %"class.double_conversion::Bignum", ptr %10, i32 0, i32 0
  %38 = load i16, ptr %37, align 4, !tbaa !14
  %39 = add i16 %38, 1
  store i16 %39, ptr %37, align 4, !tbaa !14
  %40 = sext i16 %38 to i32
  %41 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN17double_conversion6Bignum8RawBigitEi(ptr noundef nonnull align 4 dereferenceable(516) %10, i32 noundef %40)
  store i32 %36, ptr %41, align 4, !tbaa !11
  %42 = load i32, ptr %7, align 4, !tbaa !11
  %43 = sub nsw i32 %42, 28
  store i32 %43, ptr %7, align 4, !tbaa !11
  %44 = load i64, ptr %6, align 8, !tbaa !9
  %45 = lshr i64 %44, 28
  store i64 %45, ptr %6, align 8, !tbaa !9
  br label %46

46:                                               ; preds = %33, %20
  br label %47

47:                                               ; preds = %46
  call void @_ZN17double_conversion6VectorIKcE8pop_backEv(ptr noundef nonnull align 8 dereferenceable(12) %4)
  br label %16, !llvm.loop !17

48:                                               ; preds = %19
  %49 = load i64, ptr %6, align 8, !tbaa !9
  %50 = icmp ugt i64 %49, 0
  br i1 %50, label %51, label %66

51:                                               ; preds = %48
  %52 = load i64, ptr %6, align 8, !tbaa !9
  %53 = icmp ule i64 %52, 268435455
  br i1 %53, label %54, label %55

54:                                               ; preds = %51
  br label %57

55:                                               ; preds = %51
  call void @__assert_fail(ptr noundef @.str.3, ptr noundef @.str.1, i32 noundef 149, ptr noundef @__PRETTY_FUNCTION__._ZN17double_conversion6Bignum15AssignHexStringENS_6VectorIKcEE) #5
  unreachable

56:                                               ; No predecessors!
  br label %57

57:                                               ; preds = %56, %54
  %58 = load i64, ptr %6, align 8, !tbaa !9
  %59 = and i64 %58, 268435455
  %60 = trunc i64 %59 to i32
  %61 = getelementptr inbounds %"class.double_conversion::Bignum", ptr %10, i32 0, i32 0
  %62 = load i16, ptr %61, align 4, !tbaa !14
  %63 = add i16 %62, 1
  store i16 %63, ptr %61, align 4, !tbaa !14
  %64 = sext i16 %62 to i32
  %65 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN17double_conversion6Bignum8RawBigitEi(ptr noundef nonnull align 4 dereferenceable(516) %10, i32 noundef %64)
  store i32 %60, ptr %65, align 4, !tbaa !11
  br label %66

66:                                               ; preds = %57, %48
  call void @_ZN17double_conversion6Bignum5ClampEv(ptr noundef nonnull align 4 dereferenceable(516) %10)
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  ret void
}

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK17double_conversion6VectorIKcE8is_emptyEv(ptr noundef nonnull align 8 dereferenceable(12)) #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef i64 @_ZN17double_conversionL12HexCharValueEi(i32 noundef) #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 1 dereferenceable(1) ptr @_ZN17double_conversion6VectorIKcE4lastEv(ptr noundef nonnull align 8 dereferenceable(12)) #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN17double_conversion6VectorIKcE8pop_backEv(ptr noundef nonnull align 8 dereferenceable(12)) #0 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 = { 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 #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #4 = { nounwind }
attributes #5 = { 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 = !{!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 = !{!7, !7, i64 0}
!14 = !{!15, !16, i64 0}
!15 = !{!"_ZTSN17double_conversion6BignumE", !16, i64 0, !16, i64 2, !7, i64 4}
!16 = !{!"short", !7, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}


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

%"class.double_conversion::Vector" = type <{ ptr, i32, [4 x i8] }>

@.str.1 = external hidden unnamed_addr constant [131 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [18 x i8], align 1
@__PRETTY_FUNCTION__._ZN17double_conversion6Bignum15AssignHexStringENS_6VectorIKcEE = external hidden unnamed_addr constant [68 x i8], align 1

; 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: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

; 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 noundef i32 @_ZNK17double_conversion6VectorIKcE6lengthEv(ptr noundef nonnull align 8 dereferenceable(12)) local_unnamed_addr #0 align 2

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN17double_conversion6Bignum15AssignHexStringENS_6VectorIKcEE(ptr noundef nonnull align 4 dereferenceable(516) %0, ptr %1, i32 %2) local_unnamed_addr #0 align 2 {
  %4 = alloca %"class.double_conversion::Vector", align 8
  store ptr %1, ptr %4, align 8
  %5 = getelementptr inbounds i8, ptr %4, i64 8
  store i32 %2, ptr %5, align 8
  tail call void @_ZN17double_conversion6Bignum4ZeroEv(ptr noundef nonnull align 4 dereferenceable(516) %0)
  %6 = call noundef i32 @_ZNK17double_conversion6VectorIKcE6lengthEv(ptr noundef nonnull align 8 dereferenceable(12) %4)
  %7 = shl nsw i32 %6, 2
  %8 = add nsw i32 %7, 27
  %9 = sdiv i32 %8, 28
  call void @_ZN17double_conversion6Bignum14EnsureCapacityEi(i32 noundef %9)
  %10 = call noundef zeroext i1 @_ZNK17double_conversion6VectorIKcE8is_emptyEv(ptr noundef nonnull align 8 dereferenceable(12) %4)
  br i1 %10, label %._crit_edge.thread, label %.lr.ph

._crit_edge:                                      ; preds = %29
  %.not = icmp eq i64 %.110, 0
  br i1 %.not, label %._crit_edge.thread, label %31

.lr.ph:                                           ; preds = %3, %29
  %.014 = phi i32 [ %.1, %29 ], [ 0, %3 ]
  %.0913 = phi i64 [ %.110, %29 ], [ 0, %3 ]
  %11 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZN17double_conversion6VectorIKcE4lastEv(ptr noundef nonnull align 8 dereferenceable(12) %4)
  %12 = load i8, ptr %11, align 1, !tbaa !5
  %13 = sext i8 %12 to i32
  %14 = call noundef i64 @_ZN17double_conversionL12HexCharValueEi(i32 noundef %13)
  %15 = zext nneg i32 %.014 to i64
  %16 = shl i64 %14, %15
  %17 = or i64 %16, %.0913
  %18 = add nsw i32 %.014, 4
  %19 = icmp sgt i32 %.014, 23
  br i1 %19, label %20, label %29

20:                                               ; preds = %.lr.ph
  %21 = trunc i64 %17 to i32
  %22 = and i32 %21, 268435455
  %23 = load i16, ptr %0, align 4, !tbaa !8
  %24 = add i16 %23, 1
  store i16 %24, ptr %0, align 4, !tbaa !8
  %25 = sext i16 %23 to i32
  %26 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN17double_conversion6Bignum8RawBigitEi(ptr noundef nonnull align 4 dereferenceable(516) %0, i32 noundef %25)
  store i32 %22, ptr %26, align 4, !tbaa !11
  %27 = add nsw i32 %.014, -24
  %28 = lshr i64 %17, 28
  br label %29

29:                                               ; preds = %.lr.ph, %20
  %.110 = phi i64 [ %28, %20 ], [ %17, %.lr.ph ]
  %.1 = phi i32 [ %27, %20 ], [ %18, %.lr.ph ]
  call void @_ZN17double_conversion6VectorIKcE8pop_backEv(ptr noundef nonnull align 8 dereferenceable(12) %4)
  %30 = call noundef zeroext i1 @_ZNK17double_conversion6VectorIKcE8is_emptyEv(ptr noundef nonnull align 8 dereferenceable(12) %4)
  br i1 %30, label %._crit_edge, label %.lr.ph, !llvm.loop !13

31:                                               ; preds = %._crit_edge
  %32 = icmp ult i64 %.110, 268435456
  br i1 %32, label %34, label %33

33:                                               ; preds = %31
  call void @__assert_fail(ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.1, i32 noundef 149, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN17double_conversion6Bignum15AssignHexStringENS_6VectorIKcEE) #2
  unreachable

34:                                               ; preds = %31
  %35 = trunc nuw nsw i64 %.110 to i32
  %36 = load i16, ptr %0, align 4, !tbaa !8
  %37 = add i16 %36, 1
  store i16 %37, ptr %0, align 4, !tbaa !8
  %38 = sext i16 %36 to i32
  %39 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN17double_conversion6Bignum8RawBigitEi(ptr noundef nonnull align 4 dereferenceable(516) %0, i32 noundef %38)
  store i32 %35, ptr %39, align 4, !tbaa !11
  br label %._crit_edge.thread

._crit_edge.thread:                               ; preds = %3, %34, %._crit_edge
  call void @_ZN17double_conversion6Bignum5ClampEv(ptr noundef nonnull align 4 dereferenceable(516) %0)
  ret void
}

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK17double_conversion6VectorIKcE8is_emptyEv(ptr noundef nonnull align 8 dereferenceable(12)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef i64 @_ZN17double_conversionL12HexCharValueEi(i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 1 dereferenceable(1) ptr @_ZN17double_conversion6VectorIKcE4lastEv(ptr noundef nonnull align 8 dereferenceable(12)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN17double_conversion6VectorIKcE8pop_backEv(ptr noundef nonnull align 8 dereferenceable(12)) local_unnamed_addr #0 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 = { 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 #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 = !{!6, !6, i64 0}
!6 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !10, i64 0}
!9 = !{!"_ZTSN17double_conversion6BignumE", !10, i64 0, !10, i64 2, !6, i64 4}
!10 = !{!"short", !6, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !6, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


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