; LLVM IR from 0intro/wmii :: lib/libfmt/pow10.ll_ (fmtpow10)

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

@tab = external hidden global [70 x double], align 16

; Function Attrs: nounwind uwtable
define dso_local double @__fmtpow10(i32 noundef %0) #0 {
  %2 = alloca double, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  store i32 %0, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #2
  %6 = load i32, ptr %3, align 4, !tbaa !5
  %7 = icmp slt i32 %6, 0
  br i1 %7, label %8, label %30

8:                                                ; preds = %1
  %9 = load i32, ptr %3, align 4, !tbaa !5
  %10 = sub nsw i32 0, %9
  store i32 %10, ptr %3, align 4, !tbaa !5
  %11 = load i32, ptr %3, align 4, !tbaa !5
  %12 = icmp slt i32 %11, 70
  br i1 %12, label %13, label %19

13:                                               ; preds = %8
  %14 = load i32, ptr %3, align 4, !tbaa !5
  %15 = sext i32 %14 to i64
  %16 = getelementptr inbounds [70 x double], ptr @tab, i64 0, i64 %15
  %17 = load double, ptr %16, align 8, !tbaa !9
  %18 = fdiv double 1.000000e+00, %17
  store double %18, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %48

19:                                               ; preds = %8
  %20 = load i32, ptr %3, align 4, !tbaa !5
  %21 = sdiv i32 %20, 2
  store i32 %21, ptr %4, align 4, !tbaa !5
  %22 = load i32, ptr %4, align 4, !tbaa !5
  %23 = sub nsw i32 0, %22
  %24 = call double @__fmtpow10(i32 noundef %23)
  %25 = load i32, ptr %4, align 4, !tbaa !5
  %26 = load i32, ptr %3, align 4, !tbaa !5
  %27 = sub nsw i32 %25, %26
  %28 = call double @__fmtpow10(i32 noundef %27)
  %29 = fmul double %24, %28
  store double %29, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %48

30:                                               ; preds = %1
  %31 = load i32, ptr %3, align 4, !tbaa !5
  %32 = icmp slt i32 %31, 70
  br i1 %32, label %33, label %38

33:                                               ; preds = %30
  %34 = load i32, ptr %3, align 4, !tbaa !5
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds [70 x double], ptr @tab, i64 0, i64 %35
  %37 = load double, ptr %36, align 8, !tbaa !9
  store double %37, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %48

38:                                               ; preds = %30
  %39 = load i32, ptr %3, align 4, !tbaa !5
  %40 = sdiv i32 %39, 2
  store i32 %40, ptr %4, align 4, !tbaa !5
  %41 = load i32, ptr %4, align 4, !tbaa !5
  %42 = call double @__fmtpow10(i32 noundef %41)
  %43 = load i32, ptr %3, align 4, !tbaa !5
  %44 = load i32, ptr %4, align 4, !tbaa !5
  %45 = sub nsw i32 %43, %44
  %46 = call double @__fmtpow10(i32 noundef %45)
  %47 = fmul double %42, %46
  store double %47, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %48

48:                                               ; preds = %38, %33, %19, %13
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #2
  %49 = load double, ptr %2, align 8
  ret double %49
}

; 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

attributes #0 = { 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 = { 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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}


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

@tab = external hidden local_unnamed_addr global [70 x double], align 16

; Function Attrs: nofree nosync nounwind memory(read, argmem: none, inaccessiblemem: none) uwtable
define dso_local double @__fmtpow10(i32 noundef %0) local_unnamed_addr #0 {
  %2 = icmp slt i32 %0, 0
  br i1 %2, label %3, label %18

3:                                                ; preds = %1
  %4 = sub nsw i32 0, %0
  %5 = icmp ugt i32 %0, -70
  br i1 %5, label %6, label %11

6:                                                ; preds = %3
  %7 = zext nneg i32 %4 to i64
  %8 = getelementptr inbounds [70 x double], ptr @tab, i64 0, i64 %7
  %9 = load double, ptr %8, align 8, !tbaa !5
  %10 = fdiv double 1.000000e+00, %9
  br label %common.ret17

common.ret17:                                     ; preds = %20, %6, %24, %11
  %common.ret17.op = phi double [ %17, %11 ], [ %29, %24 ], [ %10, %6 ], [ %23, %20 ]
  ret double %common.ret17.op

11:                                               ; preds = %3
  %12 = lshr i32 %4, 1
  %13 = sub nsw i32 0, %12
  %14 = tail call double @__fmtpow10(i32 noundef %13)
  %15 = add nsw i32 %12, %0
  %16 = tail call double @__fmtpow10(i32 noundef %15)
  %17 = fmul double %14, %16
  br label %common.ret17

18:                                               ; preds = %1
  %19 = icmp ult i32 %0, 70
  br i1 %19, label %20, label %24

20:                                               ; preds = %18
  %21 = zext nneg i32 %0 to i64
  %22 = getelementptr inbounds [70 x double], ptr @tab, i64 0, i64 %21
  %23 = load double, ptr %22, align 8, !tbaa !5
  br label %common.ret17

24:                                               ; preds = %18
  %25 = lshr i32 %0, 1
  %26 = tail call double @__fmtpow10(i32 noundef %25)
  %27 = sub nsw i32 %0, %25
  %28 = tail call double @__fmtpow10(i32 noundef %27)
  %29 = fmul double %26, %28
  br label %common.ret17
}

attributes #0 = { nofree nosync nounwind memory(read, argmem: none, inaccessiblemem: none) 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, !6, i64 0}
!6 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}


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