; 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
@.str.20 = external hidden unnamed_addr constant [14 x i8], align 1
@__PRETTY_FUNCTION__._ZN17double_conversion6Bignum7CompareERKS0_S2_ = external hidden unnamed_addr constant [78 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [14 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 nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK17double_conversion6Bignum9IsClampedEv(ptr noundef nonnull align 4 dereferenceable(516)) #2 align 2

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN17double_conversion6Bignum7CompareERKS0_S2_(ptr noundef nonnull align 4 dereferenceable(516) %0, ptr noundef nonnull align 4 dereferenceable(516) %1) #3 align 2 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = call noundef zeroext i1 @_ZNK17double_conversion6Bignum9IsClampedEv(ptr noundef nonnull align 4 dereferenceable(516) %12)
  br i1 %13, label %14, label %15

14:                                               ; preds = %2
  br label %17

15:                                               ; preds = %2
  call void @__assert_fail(ptr noundef @.str.20, ptr noundef @.str.1, i32 noundef 645, ptr noundef @__PRETTY_FUNCTION__._ZN17double_conversion6Bignum7CompareERKS0_S2_) #5
  unreachable

16:                                               ; No predecessors!
  br label %17

17:                                               ; preds = %16, %14
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = call noundef zeroext i1 @_ZNK17double_conversion6Bignum9IsClampedEv(ptr noundef nonnull align 4 dereferenceable(516) %18)
  br i1 %19, label %20, label %21

20:                                               ; preds = %17
  br label %23

21:                                               ; preds = %17
  call void @__assert_fail(ptr noundef @.str.21, ptr noundef @.str.1, i32 noundef 646, ptr noundef @__PRETTY_FUNCTION__._ZN17double_conversion6Bignum7CompareERKS0_S2_) #5
  unreachable

22:                                               ; No predecessors!
  br label %23

23:                                               ; preds = %22, %20
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = call noundef i32 @_ZNK17double_conversion6Bignum11BigitLengthEv(ptr noundef nonnull align 4 dereferenceable(516) %24)
  store i32 %25, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = call noundef i32 @_ZNK17double_conversion6Bignum11BigitLengthEv(ptr noundef nonnull align 4 dereferenceable(516) %26)
  store i32 %27, ptr %7, align 4, !tbaa !9
  %28 = load i32, ptr %6, align 4, !tbaa !9
  %29 = load i32, ptr %7, align 4, !tbaa !9
  %30 = icmp slt i32 %28, %29
  br i1 %30, label %31, label %32

31:                                               ; preds = %23
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %77

32:                                               ; preds = %23
  %33 = load i32, ptr %6, align 4, !tbaa !9
  %34 = load i32, ptr %7, align 4, !tbaa !9
  %35 = icmp sgt i32 %33, %34
  br i1 %35, label %36, label %37

36:                                               ; preds = %32
  store i32 1, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %77

37:                                               ; preds = %32
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  %38 = load i32, ptr %6, align 4, !tbaa !9
  %39 = sub nsw i32 %38, 1
  store i32 %39, ptr %9, align 4, !tbaa !9
  br label %40

40:                                               ; preds = %71, %37
  %41 = load i32, ptr %9, align 4, !tbaa !9
  %42 = load ptr, ptr %4, align 8, !tbaa !5
  %43 = getelementptr inbounds %"class.double_conversion::Bignum", ptr %42, i32 0, i32 1
  %44 = load ptr, ptr %5, align 8, !tbaa !5
  %45 = getelementptr inbounds %"class.double_conversion::Bignum", ptr %44, i32 0, i32 1
  %46 = call noundef nonnull align 2 dereferenceable(2) ptr @_ZSt3minIsERKT_S2_S2_(ptr noundef nonnull align 2 dereferenceable(2) %43, ptr noundef nonnull align 2 dereferenceable(2) %45)
  %47 = load i16, ptr %46, align 2, !tbaa !11
  %48 = sext i16 %47 to i32
  %49 = icmp sge i32 %41, %48
  br i1 %49, label %51, label %50

50:                                               ; preds = %40
  store i32 2, ptr %8, align 4
  br label %74

51:                                               ; preds = %40
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  %52 = load ptr, ptr %4, align 8, !tbaa !5
  %53 = load i32, ptr %9, align 4, !tbaa !9
  %54 = call noundef i32 @_ZNK17double_conversion6Bignum11BigitOrZeroEi(ptr noundef nonnull align 4 dereferenceable(516) %52, i32 noundef %53)
  store i32 %54, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #6
  %55 = load ptr, ptr %5, align 8, !tbaa !5
  %56 = load i32, ptr %9, align 4, !tbaa !9
  %57 = call noundef i32 @_ZNK17double_conversion6Bignum11BigitOrZeroEi(ptr noundef nonnull align 4 dereferenceable(516) %55, i32 noundef %56)
  store i32 %57, ptr %11, align 4, !tbaa !9
  %58 = load i32, ptr %10, align 4, !tbaa !9
  %59 = load i32, ptr %11, align 4, !tbaa !9
  %60 = icmp ult i32 %58, %59
  br i1 %60, label %61, label %62

61:                                               ; preds = %51
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %68

62:                                               ; preds = %51
  %63 = load i32, ptr %10, align 4, !tbaa !9
  %64 = load i32, ptr %11, align 4, !tbaa !9
  %65 = icmp ugt i32 %63, %64
  br i1 %65, label %66, label %67

66:                                               ; preds = %62
  store i32 1, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %68

67:                                               ; preds = %62
  store i32 0, ptr %8, align 4
  br label %68

68:                                               ; preds = %67, %66, %61
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  %69 = load i32, ptr %8, align 4
  switch i32 %69, label %74 [
    i32 0, label %70
  ]

70:                                               ; preds = %68
  br label %71

71:                                               ; preds = %70
  %72 = load i32, ptr %9, align 4, !tbaa !9
  %73 = add nsw i32 %72, -1
  store i32 %73, ptr %9, align 4, !tbaa !9
  br label %40, !llvm.loop !13

74:                                               ; preds = %68, %50
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  %75 = load i32, ptr %8, align 4
  switch i32 %75, label %77 [
    i32 2, label %76
  ]

76:                                               ; preds = %74
  store i32 0, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %77

77:                                               ; preds = %76, %74, %36, %31
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  %78 = load i32, ptr %3, align 4
  ret i32 %78
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 2 dereferenceable(2) ptr @_ZSt3minIsERKT_S2_S2_(ptr noundef nonnull align 2 dereferenceable(2), ptr noundef nonnull align 2 dereferenceable(2)) #4

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 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 #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 = { inlinehint 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 #5 = { noreturn nounwind }
attributes #6 = { 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, !12, i64 0}
!12 = !{!"short", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"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"

@.str.1 = external hidden unnamed_addr constant [131 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [14 x i8], align 1
@__PRETTY_FUNCTION__._ZN17double_conversion6Bignum7CompareERKS0_S2_ = external hidden unnamed_addr constant [78 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [14 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 nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK17double_conversion6Bignum9IsClampedEv(ptr noundef nonnull align 4 dereferenceable(516)) local_unnamed_addr #1 align 2

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN17double_conversion6Bignum7CompareERKS0_S2_(ptr noundef nonnull align 4 dereferenceable(516) %0, ptr noundef nonnull align 4 dereferenceable(516) %1) local_unnamed_addr #2 align 2 {
  %3 = tail call noundef zeroext i1 @_ZNK17double_conversion6Bignum9IsClampedEv(ptr noundef nonnull align 4 dereferenceable(516) %0)
  br i1 %3, label %5, label %4

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

5:                                                ; preds = %2
  %6 = tail call noundef zeroext i1 @_ZNK17double_conversion6Bignum9IsClampedEv(ptr noundef nonnull align 4 dereferenceable(516) %1)
  br i1 %6, label %8, label %7

7:                                                ; preds = %5
  tail call void @__assert_fail(ptr noundef nonnull @.str.21, ptr noundef nonnull @.str.1, i32 noundef 646, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN17double_conversion6Bignum7CompareERKS0_S2_) #4
  unreachable

8:                                                ; preds = %5
  %9 = tail call noundef i32 @_ZNK17double_conversion6Bignum11BigitLengthEv(ptr noundef nonnull align 4 dereferenceable(516) %0)
  %10 = tail call noundef i32 @_ZNK17double_conversion6Bignum11BigitLengthEv(ptr noundef nonnull align 4 dereferenceable(516) %1)
  %11 = icmp slt i32 %9, %10
  br i1 %11, label %.thread, label %12

12:                                               ; preds = %8
  %13 = icmp sgt i32 %9, %10
  br i1 %13, label %.thread, label %.preheader

.preheader:                                       ; preds = %12
  %14 = getelementptr inbounds i8, ptr %0, i64 2
  %15 = getelementptr inbounds i8, ptr %1, i64 2
  br label %16

16:                                               ; preds = %.preheader, %24
  %.026.in = phi i32 [ %.026, %24 ], [ %9, %.preheader ]
  %.026 = add nsw i32 %.026.in, -1
  %17 = tail call noundef nonnull align 2 dereferenceable(2) ptr @_ZSt3minIsERKT_S2_S2_(ptr noundef nonnull align 2 dereferenceable(2) %14, ptr noundef nonnull align 2 dereferenceable(2) %15)
  %18 = load i16, ptr %17, align 2, !tbaa !5
  %19 = sext i16 %18 to i32
  %.not.not.not = icmp sgt i32 %.026.in, %19
  br i1 %.not.not.not, label %20, label %.thread

20:                                               ; preds = %16
  %21 = tail call noundef i32 @_ZNK17double_conversion6Bignum11BigitOrZeroEi(ptr noundef nonnull align 4 dereferenceable(516) %0, i32 noundef %.026)
  %22 = tail call noundef i32 @_ZNK17double_conversion6Bignum11BigitOrZeroEi(ptr noundef nonnull align 4 dereferenceable(516) %1, i32 noundef %.026)
  %23 = icmp ult i32 %21, %22
  br i1 %23, label %.thread, label %24

24:                                               ; preds = %20
  %.not = icmp ugt i32 %21, %22
  br i1 %.not, label %.thread, label %16, !llvm.loop !9

.thread:                                          ; preds = %24, %16, %20, %12, %8
  %.3 = phi i32 [ -1, %8 ], [ 1, %12 ], [ -1, %20 ], [ 0, %16 ], [ 1, %24 ]
  ret i32 %.3
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 2 dereferenceable(2) ptr @_ZSt3minIsERKT_S2_S2_(ptr noundef nonnull align 2 dereferenceable(2), ptr noundef nonnull align 2 dereferenceable(2)) local_unnamed_addr #3

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 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 = { inlinehint 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 #4 = { 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 = !{!"short", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopSimplifyPass,LoopUnrollPass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass