; LLVM IR from InsightSoftwareConsortium/ITK :: Modules/ThirdParty/DoubleConversion/src/double-conversion (cached-powers)

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

%"struct.double_conversion::PowersOfTenCache::CachedPower" = type { i64, i16, i16 }
%"class.double_conversion::DiyFp" = type <{ i64, i32, [4 x i8] }>

@.str = external hidden unnamed_addr constant [168 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [138 x i8], align 1
@__PRETTY_FUNCTION__._ZN17double_conversion16PowersOfTenCache36GetCachedPowerForBinaryExponentRangeEiiPNS_5DiyFpEPi = external hidden unnamed_addr constant [105 x i8], align 1
@_ZN17double_conversion16PowersOfTenCacheL13kCachedPowersE = external hidden constant [87 x %"struct.double_conversion::PowersOfTenCache::CachedPower"], align 16
@.str.2 = external hidden unnamed_addr constant [45 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [45 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN17double_conversion16PowersOfTenCache36GetCachedPowerForBinaryExponentRangeEiiPNS_5DiyFpEPi(i32 noundef %0, i32 noundef %1, ptr noundef %2, ptr noundef %3) #0 {
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca double, align 8
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca %"struct.double_conversion::PowersOfTenCache::CachedPower", align 8
  %14 = alloca %"class.double_conversion::DiyFp", align 8
  store i32 %0, ptr %5, align 4, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !9
  store ptr %3, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  store i32 64, ptr %9, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #6
  %15 = load i32, ptr %5, align 4, !tbaa !5
  %16 = load i32, ptr %9, align 4, !tbaa !5
  %17 = add nsw i32 %15, %16
  %18 = sub nsw i32 %17, 1
  %19 = sitofp i32 %18 to double
  %20 = fmul double %19, 0x3FD34413509F79FE
  %21 = call double @llvm.ceil.f64(double %20)
  store double %21, ptr %10, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #6
  store i32 348, ptr %11, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #6
  %22 = load i32, ptr %11, align 4, !tbaa !5
  %23 = load double, ptr %10, align 8, !tbaa !11
  %24 = fptosi double %23 to i32
  %25 = add nsw i32 %22, %24
  %26 = sub nsw i32 %25, 1
  %27 = sdiv i32 %26, 8
  %28 = add nsw i32 %27, 1
  store i32 %28, ptr %12, align 4, !tbaa !5
  %29 = load i32, ptr %12, align 4, !tbaa !5
  %30 = icmp sle i32 0, %29
  br i1 %30, label %31, label %34

31:                                               ; preds = %4
  %32 = load i32, ptr %12, align 4, !tbaa !5
  %33 = icmp slt i32 %32, 87
  br label %34

34:                                               ; preds = %31, %4
  %35 = phi i1 [ false, %4 ], [ %33, %31 ]
  br i1 %35, label %36, label %37

36:                                               ; preds = %34
  br label %39

37:                                               ; preds = %34
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 149, ptr noundef @__PRETTY_FUNCTION__._ZN17double_conversion16PowersOfTenCache36GetCachedPowerForBinaryExponentRangeEiiPNS_5DiyFpEPi) #7
  unreachable

38:                                               ; No predecessors!
  br label %39

39:                                               ; preds = %38, %36
  call void @llvm.lifetime.start.p0(i64 16, ptr %13) #6
  %40 = load i32, ptr %12, align 4, !tbaa !5
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds [87 x %"struct.double_conversion::PowersOfTenCache::CachedPower"], ptr @_ZN17double_conversion16PowersOfTenCacheL13kCachedPowersE, i64 0, i64 %41
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %13, ptr align 16 %42, i64 16, i1 false), !tbaa.struct !13
  %43 = load i32, ptr %5, align 4, !tbaa !5
  %44 = getelementptr inbounds %"struct.double_conversion::PowersOfTenCache::CachedPower", ptr %13, i32 0, i32 1
  %45 = load i16, ptr %44, align 8, !tbaa !18
  %46 = sext i16 %45 to i32
  %47 = icmp sle i32 %43, %46
  br i1 %47, label %48, label %49

48:                                               ; preds = %39
  br label %51

49:                                               ; preds = %39
  call void @__assert_fail(ptr noundef @.str.2, ptr noundef @.str.1, i32 noundef 151, ptr noundef @__PRETTY_FUNCTION__._ZN17double_conversion16PowersOfTenCache36GetCachedPowerForBinaryExponentRangeEiiPNS_5DiyFpEPi) #7
  unreachable

50:                                               ; No predecessors!
  br label %51

51:                                               ; preds = %50, %48
  %52 = getelementptr inbounds %"struct.double_conversion::PowersOfTenCache::CachedPower", ptr %13, i32 0, i32 1
  %53 = load i16, ptr %52, align 8, !tbaa !18
  %54 = sext i16 %53 to i32
  %55 = load i32, ptr %6, align 4, !tbaa !5
  %56 = icmp sle i32 %54, %55
  br i1 %56, label %57, label %58

57:                                               ; preds = %51
  br label %60

58:                                               ; preds = %51
  call void @__assert_fail(ptr noundef @.str.3, ptr noundef @.str.1, i32 noundef 153, ptr noundef @__PRETTY_FUNCTION__._ZN17double_conversion16PowersOfTenCache36GetCachedPowerForBinaryExponentRangeEiiPNS_5DiyFpEPi) #7
  unreachable

59:                                               ; No predecessors!
  br label %60

60:                                               ; preds = %59, %57
  %61 = getelementptr inbounds %"struct.double_conversion::PowersOfTenCache::CachedPower", ptr %13, i32 0, i32 2
  %62 = load i16, ptr %61, align 2, !tbaa !20
  %63 = sext i16 %62 to i32
  %64 = load ptr, ptr %8, align 8, !tbaa !9
  store i32 %63, ptr %64, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %14) #6
  %65 = getelementptr inbounds %"struct.double_conversion::PowersOfTenCache::CachedPower", ptr %13, i32 0, i32 0
  %66 = load i64, ptr %65, align 8, !tbaa !21
  %67 = getelementptr inbounds %"struct.double_conversion::PowersOfTenCache::CachedPower", ptr %13, i32 0, i32 1
  %68 = load i16, ptr %67, align 8, !tbaa !18
  %69 = sext i16 %68 to i32
  call void @_ZN17double_conversion5DiyFpC2Emi(ptr noundef nonnull align 8 dereferenceable(12) %14, i64 noundef %66, i32 noundef %69)
  %70 = load ptr, ptr %7, align 8, !tbaa !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %70, ptr align 8 %14, i64 12, i1 false), !tbaa.struct !22
  call void @llvm.lifetime.end.p0(i64 16, ptr %14) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr %13) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  ret void
}

; 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 speculatable willreturn memory(none)
declare double @llvm.ceil.f64(double) #2

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #4

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN17double_conversion5DiyFpC2Emi(ptr noundef nonnull align 8 dereferenceable(12), i64 noundef, i32 noundef) unnamed_addr #5 align 2

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

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { 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 #4 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { 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 #6 = { nounwind }
attributes #7 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = !{i64 0, i64 8, !14, i64 8, i64 2, !16, i64 10, i64 2, !16}
!14 = !{!15, !15, i64 0}
!15 = !{!"long", !7, i64 0}
!16 = !{!17, !17, i64 0}
!17 = !{!"short", !7, i64 0}
!18 = !{!19, !17, i64 8}
!19 = !{!"_ZTSN17double_conversion16PowersOfTenCache11CachedPowerE", !15, i64 0, !17, i64 8, !17, i64 10}
!20 = !{!19, !17, i64 10}
!21 = !{!19, !15, i64 0}
!22 = !{i64 0, i64 8, !14, i64 8, i64 4, !5}


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

%"struct.double_conversion::PowersOfTenCache::CachedPower" = type { i64, i16, i16 }
%"class.double_conversion::DiyFp" = type <{ i64, i32, [4 x i8] }>

@.str = external hidden unnamed_addr constant [168 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [138 x i8], align 1
@__PRETTY_FUNCTION__._ZN17double_conversion16PowersOfTenCache36GetCachedPowerForBinaryExponentRangeEiiPNS_5DiyFpEPi = external hidden unnamed_addr constant [105 x i8], align 1
@_ZN17double_conversion16PowersOfTenCacheL13kCachedPowersE = external hidden local_unnamed_addr constant [87 x %"struct.double_conversion::PowersOfTenCache::CachedPower"], align 16
@.str.2 = external hidden unnamed_addr constant [45 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [45 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN17double_conversion16PowersOfTenCache36GetCachedPowerForBinaryExponentRangeEiiPNS_5DiyFpEPi(i32 noundef %0, i32 noundef %1, ptr nocapture noundef writeonly %2, ptr nocapture noundef writeonly %3) local_unnamed_addr #0 {
  %5 = alloca %"class.double_conversion::DiyFp", align 8
  %6 = add nsw i32 %0, 63
  %7 = sitofp i32 %6 to double
  %8 = fmul double %7, 0x3FD34413509F79FE
  %9 = tail call double @llvm.ceil.f64(double %8)
  %10 = fptosi double %9 to i32
  %11 = add i32 %10, 362
  %12 = icmp ult i32 %11, 703
  br i1 %12, label %14, label %13

13:                                               ; preds = %4
  tail call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 149, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN17double_conversion16PowersOfTenCache36GetCachedPowerForBinaryExponentRangeEiiPNS_5DiyFpEPi) #5
  unreachable

14:                                               ; preds = %4
  %15 = trunc i32 %10 to i16
  %.lhs.trunc = add nsw i16 %15, 347
  %16 = sdiv i16 %.lhs.trunc, 8
  %narrow = add nsw i16 %16, 1
  %17 = zext nneg i16 %narrow to i64
  %18 = getelementptr inbounds [87 x %"struct.double_conversion::PowersOfTenCache::CachedPower"], ptr @_ZN17double_conversion16PowersOfTenCacheL13kCachedPowersE, i64 0, i64 %17
  %.sroa.0.0.copyload = load i64, ptr %18, align 16, !tbaa !5
  %.sroa.4.0..sroa_idx = getelementptr inbounds i8, ptr %18, i64 8
  %.sroa.4.0.copyload = load i16, ptr %.sroa.4.0..sroa_idx, align 8, !tbaa !9
  %.sroa.7.0..sroa_idx = getelementptr inbounds i8, ptr %18, i64 10
  %.sroa.7.0.copyload = load i16, ptr %.sroa.7.0..sroa_idx, align 2, !tbaa !9
  %19 = sext i16 %.sroa.4.0.copyload to i32
  %.not = icmp slt i32 %19, %0
  br i1 %.not, label %20, label %21

20:                                               ; preds = %14
  tail call void @__assert_fail(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.1, i32 noundef 151, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN17double_conversion16PowersOfTenCache36GetCachedPowerForBinaryExponentRangeEiiPNS_5DiyFpEPi) #5
  unreachable

21:                                               ; preds = %14
  %.not13 = icmp sgt i32 %19, %1
  br i1 %.not13, label %22, label %23

22:                                               ; preds = %21
  tail call void @__assert_fail(ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.1, i32 noundef 153, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN17double_conversion16PowersOfTenCache36GetCachedPowerForBinaryExponentRangeEiiPNS_5DiyFpEPi) #5
  unreachable

23:                                               ; preds = %21
  %24 = sext i16 %.sroa.7.0.copyload to i32
  store i32 %24, ptr %3, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %5) #6
  call void @_ZN17double_conversion5DiyFpC2Emi(ptr noundef nonnull align 8 dereferenceable(12) %5, i64 noundef %.sroa.0.0.copyload, i32 noundef %19)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(12) %2, ptr noundef nonnull align 8 dereferenceable(12) %5, i64 12, i1 false), !tbaa.struct !13
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %5) #6
  ret void
}

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

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.ceil.f64(double) #2

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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #4

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN17double_conversion5DiyFpC2Emi(ptr noundef nonnull align 8 dereferenceable(12), i64 noundef, i32 noundef) unnamed_addr #0 align 2

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

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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { 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 #4 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"short", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{i64 0, i64 8, !5, i64 8, i64 4, !11}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass