; LLVM IR from microsoft/LightAIMD :: src (functional)

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

; Function Attrs: nounwind uwtable
define dso_local void @functional_lda_x(ptr noundef %0, ptr noundef %1, ptr noundef %2, i64 noundef %3) #0 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca double, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  store i64 %3, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  store i64 0, ptr %9, align 8, !tbaa !9
  br label %11

11:                                               ; preds = %46, %4
  %12 = load i64, ptr %9, align 8, !tbaa !9
  %13 = load i64, ptr %8, align 8, !tbaa !9
  %14 = icmp ult i64 %12, %13
  br i1 %14, label %16, label %15

15:                                               ; preds = %11
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  br label %49

16:                                               ; preds = %11
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = load i64, ptr %9, align 8, !tbaa !9
  %19 = getelementptr inbounds double, ptr %17, i64 %18
  %20 = load double, ptr %19, align 8, !tbaa !11
  %21 = fcmp olt double %20, 1.000000e-10
  br i1 %21, label %22, label %29

22:                                               ; preds = %16
  %23 = load ptr, ptr %6, align 8, !tbaa !5
  %24 = load i64, ptr %9, align 8, !tbaa !9
  %25 = getelementptr inbounds double, ptr %23, i64 %24
  store double 0.000000e+00, ptr %25, align 8, !tbaa !11
  %26 = load ptr, ptr %7, align 8, !tbaa !5
  %27 = load i64, ptr %9, align 8, !tbaa !9
  %28 = getelementptr inbounds double, ptr %26, i64 %27
  store double 0.000000e+00, ptr %28, align 8, !tbaa !11
  br label %45

29:                                               ; preds = %16
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = load i64, ptr %9, align 8, !tbaa !9
  %32 = getelementptr inbounds double, ptr %30, i64 %31
  %33 = load double, ptr %32, align 8, !tbaa !11
  %34 = call double @pow(double noundef %33, double noundef 0x3FD5555555555555) #3
  store double %34, ptr %10, align 8, !tbaa !11
  %35 = load double, ptr %10, align 8, !tbaa !11
  %36 = fmul double 0xBFE7A245FE791DD3, %35
  %37 = load ptr, ptr %6, align 8, !tbaa !5
  %38 = load i64, ptr %9, align 8, !tbaa !9
  %39 = getelementptr inbounds double, ptr %37, i64 %38
  store double %36, ptr %39, align 8, !tbaa !11
  %40 = load double, ptr %10, align 8, !tbaa !11
  %41 = fmul double 0xBFEF8307FDF6D26F, %40
  %42 = load ptr, ptr %7, align 8, !tbaa !5
  %43 = load i64, ptr %9, align 8, !tbaa !9
  %44 = getelementptr inbounds double, ptr %42, i64 %43
  store double %41, ptr %44, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  br label %45

45:                                               ; preds = %29, %22
  br label %46

46:                                               ; preds = %45
  %47 = load i64, ptr %9, align 8, !tbaa !9
  %48 = add i64 %47, 1
  store i64 %48, ptr %9, align 8, !tbaa !9
  br label %11, !llvm.loop !13

49:                                               ; preds = %15
  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: nounwind
declare double @pow(double noundef, double noundef) #2

; 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 "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 = { 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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !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"

; Function Attrs: nofree nounwind memory(write, argmem: readwrite) uwtable
define dso_local void @functional_lda_x(ptr nocapture noundef readonly %0, ptr nocapture noundef writeonly %1, ptr nocapture noundef writeonly %2, i64 noundef %3) local_unnamed_addr #0 {
  %.not = icmp eq i64 %3, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %4
  %xtraiter = and i64 %3, 1
  %5 = icmp eq i64 %3, 1
  br i1 %5, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph.preheader.new

.lr.ph.preheader.new:                             ; preds = %.lr.ph.preheader
  %unroll_iter = and i64 %3, -2
  br label %.lr.ph

._crit_edge.loopexit.unr-lcssa:                   ; preds = %32, %.lr.ph.preheader
  %.017.unr = phi i64 [ 0, %.lr.ph.preheader ], [ %35, %32 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %.lr.ph.epil

.lr.ph.epil:                                      ; preds = %._crit_edge.loopexit.unr-lcssa
  %6 = getelementptr inbounds double, ptr %0, i64 %.017.unr
  %7 = load double, ptr %6, align 8, !tbaa !5
  %8 = fcmp olt double %7, 1.000000e-10
  br i1 %8, label %._crit_edge.loopexit.epilog-lcssa, label %9

9:                                                ; preds = %.lr.ph.epil
  %10 = tail call double @pow(double noundef %7, double noundef 0x3FD5555555555555) #2
  %11 = fmul double %10, 0xBFE7A245FE791DD3
  %12 = fmul double %10, 0xBFEF8307FDF6D26F
  br label %._crit_edge.loopexit.epilog-lcssa

._crit_edge.loopexit.epilog-lcssa:                ; preds = %9, %.lr.ph.epil
  %.sink18.epil = phi double [ %11, %9 ], [ 0.000000e+00, %.lr.ph.epil ]
  %.sink.epil = phi double [ %12, %9 ], [ 0.000000e+00, %.lr.ph.epil ]
  %13 = getelementptr inbounds double, ptr %1, i64 %.017.unr
  store double %.sink18.epil, ptr %13, align 8
  %14 = getelementptr inbounds double, ptr %2, i64 %.017.unr
  store double %.sink.epil, ptr %14, align 8
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit.epilog-lcssa, %._crit_edge.loopexit.unr-lcssa, %4
  ret void

.lr.ph:                                           ; preds = %32, %.lr.ph.preheader.new
  %.017 = phi i64 [ 0, %.lr.ph.preheader.new ], [ %35, %32 ]
  %niter = phi i64 [ 0, %.lr.ph.preheader.new ], [ %niter.next.1, %32 ]
  %15 = getelementptr inbounds double, ptr %0, i64 %.017
  %16 = load double, ptr %15, align 8, !tbaa !5
  %17 = fcmp olt double %16, 1.000000e-10
  br i1 %17, label %.lr.ph.1, label %18

18:                                               ; preds = %.lr.ph
  %19 = tail call double @pow(double noundef %16, double noundef 0x3FD5555555555555) #2
  %20 = fmul double %19, 0xBFE7A245FE791DD3
  %21 = fmul double %19, 0xBFEF8307FDF6D26F
  br label %.lr.ph.1

.lr.ph.1:                                         ; preds = %.lr.ph, %18
  %.sink18 = phi double [ %20, %18 ], [ 0.000000e+00, %.lr.ph ]
  %.sink = phi double [ %21, %18 ], [ 0.000000e+00, %.lr.ph ]
  %22 = getelementptr inbounds double, ptr %1, i64 %.017
  store double %.sink18, ptr %22, align 8
  %23 = getelementptr inbounds double, ptr %2, i64 %.017
  store double %.sink, ptr %23, align 8
  %24 = or disjoint i64 %.017, 1
  %25 = getelementptr inbounds double, ptr %0, i64 %24
  %26 = load double, ptr %25, align 8, !tbaa !5
  %27 = fcmp olt double %26, 1.000000e-10
  br i1 %27, label %32, label %28

28:                                               ; preds = %.lr.ph.1
  %29 = tail call double @pow(double noundef %26, double noundef 0x3FD5555555555555) #2
  %30 = fmul double %29, 0xBFE7A245FE791DD3
  %31 = fmul double %29, 0xBFEF8307FDF6D26F
  br label %32

32:                                               ; preds = %28, %.lr.ph.1
  %.sink18.1 = phi double [ %30, %28 ], [ 0.000000e+00, %.lr.ph.1 ]
  %.sink.1 = phi double [ %31, %28 ], [ 0.000000e+00, %.lr.ph.1 ]
  %33 = getelementptr inbounds double, ptr %1, i64 %24
  store double %.sink18.1, ptr %33, align 8
  %34 = getelementptr inbounds double, ptr %2, i64 %24
  store double %.sink.1, ptr %34, align 8
  %35 = add nuw i64 %.017, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph, !llvm.loop !9
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @pow(double noundef, double noundef) local_unnamed_addr #1

attributes #0 = { nofree nounwind memory(write, argmem: readwrite) 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 nofree nounwind willreturn memory(write) "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 = { 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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


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