; LLVM IR from venumb/ZSPACE :: cpp/depends/spa (spa)

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

@Y_TERMS = external dso_local constant [63 x [5 x i32]], align 16

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

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #1

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

7:                                                ; preds = %26, %2
  %8 = load i32, ptr %5, align 4, !tbaa !5
  %9 = icmp slt i32 %8, 5
  br i1 %9, label %10, label %29

10:                                               ; preds = %7
  %11 = load ptr, ptr %4, align 8, !tbaa !9
  %12 = load i32, ptr %5, align 4, !tbaa !5
  %13 = sext i32 %12 to i64
  %14 = getelementptr inbounds double, ptr %11, i64 %13
  %15 = load double, ptr %14, align 8, !tbaa !11
  %16 = load i32, ptr %3, align 4, !tbaa !5
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds [63 x [5 x i32]], ptr @Y_TERMS, i64 0, i64 %17
  %19 = load i32, ptr %5, align 4, !tbaa !5
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds [5 x i32], ptr %18, i64 0, i64 %20
  %22 = load i32, ptr %21, align 4, !tbaa !5
  %23 = sitofp i32 %22 to double
  %24 = load double, ptr %6, align 8, !tbaa !11
  %25 = call double @llvm.fmuladd.f64(double %15, double %23, double %24)
  store double %25, ptr %6, align 8, !tbaa !11
  br label %26

26:                                               ; preds = %10
  %27 = load i32, ptr %5, align 4, !tbaa !5
  %28 = add nsw i32 %27, 1
  store i32 %28, ptr %5, align 4, !tbaa !5
  br label %7, !llvm.loop !13

29:                                               ; preds = %7
  %30 = load double, ptr %6, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  ret double %30
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { 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 = { 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 = !{!"any pointer", !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"

@Y_TERMS = external dso_local local_unnamed_addr constant [63 x [5 x i32]], align 16

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

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) uwtable
define dso_local double @xy_term_summation(i32 noundef %0, ptr nocapture noundef readonly %1) local_unnamed_addr #1 {
  %3 = sext i32 %0 to i64
  %4 = load double, ptr %1, align 8, !tbaa !5
  %5 = getelementptr inbounds [63 x [5 x i32]], ptr @Y_TERMS, i64 0, i64 %3, i64 0
  %6 = load i32, ptr %5, align 4, !tbaa !9
  %7 = sitofp i32 %6 to double
  %8 = tail call double @llvm.fmuladd.f64(double %4, double %7, double 0.000000e+00)
  %9 = getelementptr inbounds i8, ptr %1, i64 8
  %10 = load double, ptr %9, align 8, !tbaa !5
  %11 = getelementptr inbounds [63 x [5 x i32]], ptr @Y_TERMS, i64 0, i64 %3, i64 1
  %12 = load i32, ptr %11, align 4, !tbaa !9
  %13 = sitofp i32 %12 to double
  %14 = tail call double @llvm.fmuladd.f64(double %10, double %13, double %8)
  %15 = getelementptr inbounds i8, ptr %1, i64 16
  %16 = load double, ptr %15, align 8, !tbaa !5
  %17 = getelementptr inbounds [63 x [5 x i32]], ptr @Y_TERMS, i64 0, i64 %3, i64 2
  %18 = load i32, ptr %17, align 4, !tbaa !9
  %19 = sitofp i32 %18 to double
  %20 = tail call double @llvm.fmuladd.f64(double %16, double %19, double %14)
  %21 = getelementptr inbounds i8, ptr %1, i64 24
  %22 = load double, ptr %21, align 8, !tbaa !5
  %23 = getelementptr inbounds [63 x [5 x i32]], ptr @Y_TERMS, i64 0, i64 %3, i64 3
  %24 = load i32, ptr %23, align 4, !tbaa !9
  %25 = sitofp i32 %24 to double
  %26 = tail call double @llvm.fmuladd.f64(double %22, double %25, double %20)
  %27 = getelementptr inbounds i8, ptr %1, i64 32
  %28 = load double, ptr %27, align 8, !tbaa !5
  %29 = getelementptr inbounds [63 x [5 x i32]], ptr @Y_TERMS, i64 0, i64 %3, i64 4
  %30 = load i32, ptr %29, align 4, !tbaa !9
  %31 = sitofp i32 %30 to double
  %32 = tail call double @llvm.fmuladd.f64(double %28, double %31, double %26)
  ret double %32
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) 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"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LCSSAPass,LICMPass,LoopRotatePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass