; LLVM IR from Try/Tempest :: Engine/thirdparty/openal-soft/core/cubic_tables.ll (ZN11CubicFilterC2Ev)

; 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.CubicFilter = type { %"struct.std::array.1" }
%"struct.std::array.1" = type { [513 x float] }

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

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef double @_ZN12_GLOBAL__N_18GetCoeffEd(double noundef) #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_Zli3_uzy(i64 noundef) #1

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN11CubicFilterC2Ev(ptr noundef nonnull align 4 dereferenceable(2052) %0) unnamed_addr #1 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca i64, align 8
  %4 = alloca double, align 8
  %5 = alloca double, align 8
  %6 = alloca double, align 8
  %7 = alloca double, align 8
  %8 = alloca double, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %9 = load ptr, ptr %2, align 8
  %10 = getelementptr inbounds %struct.CubicFilter, ptr %9, i32 0, i32 0
  %11 = getelementptr inbounds %"struct.std::array.1", ptr %10, i32 0, i32 0
  call void @llvm.memset.p0.i64(ptr align 4 %11, i8 0, i64 2052, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  store i64 0, ptr %3, align 8, !tbaa !9
  br label %12

12:                                               ; preds = %77, %1
  %13 = load i64, ptr %3, align 8, !tbaa !9
  %14 = icmp ult i64 %13, 129
  br i1 %14, label %16, label %15

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

16:                                               ; preds = %12
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  %17 = load i64, ptr %3, align 8, !tbaa !9
  %18 = add i64 256, %17
  %19 = uitofp i64 %18 to double
  %20 = fmul double %19, 1.000000e+00
  %21 = call noundef double @_ZN12_GLOBAL__N_18GetCoeffEd(double noundef %20) #3
  store double %21, ptr %4, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %22 = load i64, ptr %3, align 8, !tbaa !9
  %23 = uitofp i64 %22 to double
  %24 = fmul double %23, 1.000000e+00
  %25 = call noundef double @_ZN12_GLOBAL__N_18GetCoeffEd(double noundef %24) #3
  store double %25, ptr %5, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %26 = load i64, ptr %3, align 8, !tbaa !9
  %27 = sub i64 256, %26
  %28 = uitofp i64 %27 to double
  %29 = fmul double %28, 1.000000e+00
  %30 = call noundef double @_ZN12_GLOBAL__N_18GetCoeffEd(double noundef %29) #3
  store double %30, ptr %6, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %31 = call noundef i64 @_Zli3_uzy(i64 noundef 2) #3
  %32 = mul i64 256, %31
  %33 = load i64, ptr %3, align 8, !tbaa !9
  %34 = sub i64 %32, %33
  %35 = uitofp i64 %34 to double
  %36 = fmul double %35, 1.000000e+00
  %37 = call noundef double @_ZN12_GLOBAL__N_18GetCoeffEd(double noundef %36) #3
  store double %37, ptr %7, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %38 = load double, ptr %4, align 8, !tbaa !11
  %39 = load double, ptr %5, align 8, !tbaa !11
  %40 = fadd double %38, %39
  %41 = load double, ptr %6, align 8, !tbaa !11
  %42 = fadd double %40, %41
  %43 = load double, ptr %7, align 8, !tbaa !11
  %44 = fadd double %42, %43
  %45 = fdiv double 1.000000e+00, %44
  store double %45, ptr %8, align 8, !tbaa !11
  %46 = load double, ptr %4, align 8, !tbaa !11
  %47 = load double, ptr %8, align 8, !tbaa !11
  %48 = fmul double %46, %47
  %49 = fptrunc double %48 to float
  %50 = getelementptr inbounds %struct.CubicFilter, ptr %9, i32 0, i32 0
  %51 = load i64, ptr %3, align 8, !tbaa !9
  %52 = add i64 256, %51
  %53 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIfLm513EEixEm(ptr noundef nonnull align 4 dereferenceable(2052) %50, i64 noundef %52) #3
  store float %49, ptr %53, align 4, !tbaa !13
  %54 = load double, ptr %5, align 8, !tbaa !11
  %55 = load double, ptr %8, align 8, !tbaa !11
  %56 = fmul double %54, %55
  %57 = fptrunc double %56 to float
  %58 = getelementptr inbounds %struct.CubicFilter, ptr %9, i32 0, i32 0
  %59 = load i64, ptr %3, align 8, !tbaa !9
  %60 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIfLm513EEixEm(ptr noundef nonnull align 4 dereferenceable(2052) %58, i64 noundef %59) #3
  store float %57, ptr %60, align 4, !tbaa !13
  %61 = load double, ptr %6, align 8, !tbaa !11
  %62 = load double, ptr %8, align 8, !tbaa !11
  %63 = fmul double %61, %62
  %64 = fptrunc double %63 to float
  %65 = getelementptr inbounds %struct.CubicFilter, ptr %9, i32 0, i32 0
  %66 = load i64, ptr %3, align 8, !tbaa !9
  %67 = sub i64 256, %66
  %68 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIfLm513EEixEm(ptr noundef nonnull align 4 dereferenceable(2052) %65, i64 noundef %67) #3
  store float %64, ptr %68, align 4, !tbaa !13
  %69 = load double, ptr %7, align 8, !tbaa !11
  %70 = load double, ptr %8, align 8, !tbaa !11
  %71 = fmul double %69, %70
  %72 = fptrunc double %71 to float
  %73 = getelementptr inbounds %struct.CubicFilter, ptr %9, i32 0, i32 0
  %74 = load i64, ptr %3, align 8, !tbaa !9
  %75 = sub i64 512, %74
  %76 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIfLm513EEixEm(ptr noundef nonnull align 4 dereferenceable(2052) %73, i64 noundef %75) #3
  store float %72, ptr %76, align 4, !tbaa !13
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  br label %77

77:                                               ; preds = %16
  %78 = load i64, ptr %3, align 8, !tbaa !9
  %79 = add i64 %78, 1
  store i64 %79, ptr %3, align 8, !tbaa !9
  br label %12, !llvm.loop !15

80:                                               ; preds = %15
  ret void
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIfLm513EEixEm(ptr noundef nonnull align 4 dereferenceable(2052), i64 noundef) #1 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"float", !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"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: mustprogress nounwind uwtable
declare hidden noundef double @_ZN12_GLOBAL__N_18GetCoeffEd(double noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_Zli3_uzy(i64 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN11CubicFilterC2Ev(ptr noundef nonnull align 4 dereferenceable(2052) %0) unnamed_addr #0 align 2 {
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 4 dereferenceable(2052) %0, i8 0, i64 2052, i1 false)
  br label %3

2:                                                ; preds = %3
  ret void

3:                                                ; preds = %1, %3
  %.022 = phi i64 [ 0, %1 ], [ %34, %3 ]
  %4 = or disjoint i64 %.022, 256
  %5 = uitofp nneg i64 %4 to double
  %6 = tail call noundef double @_ZN12_GLOBAL__N_18GetCoeffEd(double noundef %5) #2
  %7 = uitofp nneg i64 %.022 to double
  %8 = tail call noundef double @_ZN12_GLOBAL__N_18GetCoeffEd(double noundef %7) #2
  %9 = sub nuw nsw i64 256, %.022
  %10 = uitofp nneg i64 %9 to double
  %11 = tail call noundef double @_ZN12_GLOBAL__N_18GetCoeffEd(double noundef %10) #2
  %12 = tail call noundef i64 @_Zli3_uzy(i64 noundef 2) #2
  %13 = shl i64 %12, 8
  %14 = sub i64 %13, %.022
  %15 = uitofp i64 %14 to double
  %16 = tail call noundef double @_ZN12_GLOBAL__N_18GetCoeffEd(double noundef %15) #2
  %17 = fadd double %6, %8
  %18 = fadd double %17, %11
  %19 = fadd double %18, %16
  %20 = fdiv double 1.000000e+00, %19
  %21 = fmul double %6, %20
  %22 = fptrunc double %21 to float
  %23 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIfLm513EEixEm(ptr noundef nonnull align 4 dereferenceable(2052) %0, i64 noundef %4) #2
  store float %22, ptr %23, align 4, !tbaa !5
  %24 = fmul double %8, %20
  %25 = fptrunc double %24 to float
  %26 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIfLm513EEixEm(ptr noundef nonnull align 4 dereferenceable(2052) %0, i64 noundef %.022) #2
  store float %25, ptr %26, align 4, !tbaa !5
  %27 = fmul double %11, %20
  %28 = fptrunc double %27 to float
  %29 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIfLm513EEixEm(ptr noundef nonnull align 4 dereferenceable(2052) %0, i64 noundef %9) #2
  store float %28, ptr %29, align 4, !tbaa !5
  %30 = fmul double %16, %20
  %31 = fptrunc double %30 to float
  %32 = sub nuw nsw i64 512, %.022
  %33 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIfLm513EEixEm(ptr noundef nonnull align 4 dereferenceable(2052) %0, i64 noundef %32) #2
  store float %31, ptr %33, align 4, !tbaa !5
  %34 = add nuw nsw i64 %.022, 1
  %exitcond.not = icmp eq i64 %34, 129
  br i1 %exitcond.not, label %2, label %3, !llvm.loop !9
}

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIfLm513EEixEm(ptr noundef nonnull align 4 dereferenceable(2052), i64 noundef) local_unnamed_addr #0 align 2

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


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,SROAPass,SimplifyCFGPass,TailCallElimPass