; LLVM IR from chriskiefer/libcccrt :: benchmarks/maximilian.ll (ZN10maxiFilter5loresEddd)

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

%class.maxiFilter = type { double, double, double, [10 x double], [10 x double], double, double, double, double, double, double, double }

@_ZN12maxiSettings10sampleRateE = external dso_local global i64, align 8

; 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
declare double @cos(double noundef) #2

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef double @_ZN10maxiFilter5loresEddd(ptr noundef nonnull align 8 dereferenceable(240) %0, double noundef %1, double noundef %2, double noundef %3) #3 align 2 {
  %5 = alloca ptr, align 8
  %6 = alloca double, align 8
  %7 = alloca double, align 8
  %8 = alloca double, align 8
  %9 = alloca double, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store double %1, ptr %6, align 8, !tbaa !9
  store double %2, ptr %7, align 8, !tbaa !9
  store double %3, ptr %8, align 8, !tbaa !9
  %10 = load ptr, ptr %5, align 8
  %11 = load double, ptr %7, align 8, !tbaa !9
  %12 = getelementptr inbounds %class.maxiFilter, ptr %10, i32 0, i32 10
  store double %11, ptr %12, align 8, !tbaa !11
  %13 = getelementptr inbounds %class.maxiFilter, ptr %10, i32 0, i32 10
  %14 = load double, ptr %13, align 8, !tbaa !11
  %15 = fcmp olt double %14, 1.000000e+01
  br i1 %15, label %16, label %18

16:                                               ; preds = %4
  %17 = getelementptr inbounds %class.maxiFilter, ptr %10, i32 0, i32 10
  store double 1.000000e+01, ptr %17, align 8, !tbaa !11
  br label %18

18:                                               ; preds = %16, %4
  %19 = getelementptr inbounds %class.maxiFilter, ptr %10, i32 0, i32 10
  %20 = load double, ptr %19, align 8, !tbaa !11
  %21 = load i64, ptr @_ZN12maxiSettings10sampleRateE, align 8, !tbaa !13
  %22 = uitofp i64 %21 to double
  %23 = fcmp ogt double %20, %22
  br i1 %23, label %24, label %28

24:                                               ; preds = %18
  %25 = load i64, ptr @_ZN12maxiSettings10sampleRateE, align 8, !tbaa !13
  %26 = uitofp i64 %25 to double
  %27 = getelementptr inbounds %class.maxiFilter, ptr %10, i32 0, i32 10
  store double %26, ptr %27, align 8, !tbaa !11
  br label %28

28:                                               ; preds = %24, %18
  %29 = load double, ptr %8, align 8, !tbaa !9
  %30 = fcmp olt double %29, 1.000000e+00
  br i1 %30, label %31, label %32

31:                                               ; preds = %28
  store double 1.000000e+00, ptr %8, align 8, !tbaa !9
  br label %32

32:                                               ; preds = %31, %28
  %33 = getelementptr inbounds %class.maxiFilter, ptr %10, i32 0, i32 10
  %34 = load double, ptr %33, align 8, !tbaa !11
  %35 = fmul double 0x401921FB54442D18, %34
  %36 = load i64, ptr @_ZN12maxiSettings10sampleRateE, align 8, !tbaa !13
  %37 = uitofp i64 %36 to double
  %38 = fdiv double %35, %37
  %39 = call double @cos(double noundef %38) #4
  %40 = getelementptr inbounds %class.maxiFilter, ptr %10, i32 0, i32 8
  store double %39, ptr %40, align 8, !tbaa !15
  %41 = getelementptr inbounds %class.maxiFilter, ptr %10, i32 0, i32 8
  %42 = load double, ptr %41, align 8, !tbaa !15
  %43 = call double @llvm.fmuladd.f64(double -2.000000e+00, double %42, double 2.000000e+00)
  %44 = getelementptr inbounds %class.maxiFilter, ptr %10, i32 0, i32 9
  store double %43, ptr %44, align 8, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %45 = call double @sqrt(double noundef 2.000000e+00) #4
  %46 = getelementptr inbounds %class.maxiFilter, ptr %10, i32 0, i32 8
  %47 = load double, ptr %46, align 8, !tbaa !15
  %48 = fsub double %47, 1.000000e+00
  %49 = call double @pow(double noundef %48, double noundef 3.000000e+00) #4
  %50 = fneg double %49
  %51 = call double @sqrt(double noundef %50) #4
  %52 = load double, ptr %8, align 8, !tbaa !9
  %53 = getelementptr inbounds %class.maxiFilter, ptr %10, i32 0, i32 8
  %54 = load double, ptr %53, align 8, !tbaa !15
  %55 = fsub double %54, 1.000000e+00
  %56 = fmul double %52, %55
  %57 = call double @llvm.fmuladd.f64(double %45, double %51, double %56)
  %58 = load double, ptr %8, align 8, !tbaa !9
  %59 = getelementptr inbounds %class.maxiFilter, ptr %10, i32 0, i32 8
  %60 = load double, ptr %59, align 8, !tbaa !15
  %61 = fsub double %60, 1.000000e+00
  %62 = fmul double %58, %61
  %63 = fdiv double %57, %62
  store double %63, ptr %9, align 8, !tbaa !9
  %64 = getelementptr inbounds %class.maxiFilter, ptr %10, i32 0, i32 6
  %65 = load double, ptr %64, align 8, !tbaa !17
  %66 = load double, ptr %6, align 8, !tbaa !9
  %67 = getelementptr inbounds %class.maxiFilter, ptr %10, i32 0, i32 7
  %68 = load double, ptr %67, align 8, !tbaa !18
  %69 = fsub double %66, %68
  %70 = getelementptr inbounds %class.maxiFilter, ptr %10, i32 0, i32 9
  %71 = load double, ptr %70, align 8, !tbaa !16
  %72 = call double @llvm.fmuladd.f64(double %69, double %71, double %65)
  %73 = getelementptr inbounds %class.maxiFilter, ptr %10, i32 0, i32 6
  store double %72, ptr %73, align 8, !tbaa !17
  %74 = getelementptr inbounds %class.maxiFilter, ptr %10, i32 0, i32 7
  %75 = load double, ptr %74, align 8, !tbaa !18
  %76 = getelementptr inbounds %class.maxiFilter, ptr %10, i32 0, i32 6
  %77 = load double, ptr %76, align 8, !tbaa !17
  %78 = fadd double %75, %77
  %79 = getelementptr inbounds %class.maxiFilter, ptr %10, i32 0, i32 7
  store double %78, ptr %79, align 8, !tbaa !18
  %80 = getelementptr inbounds %class.maxiFilter, ptr %10, i32 0, i32 6
  %81 = load double, ptr %80, align 8, !tbaa !17
  %82 = load double, ptr %9, align 8, !tbaa !9
  %83 = fmul double %81, %82
  %84 = getelementptr inbounds %class.maxiFilter, ptr %10, i32 0, i32 6
  store double %83, ptr %84, align 8, !tbaa !17
  %85 = getelementptr inbounds %class.maxiFilter, ptr %10, i32 0, i32 7
  %86 = load double, ptr %85, align 8, !tbaa !18
  %87 = getelementptr inbounds %class.maxiFilter, ptr %10, i32 0, i32 2
  store double %86, ptr %87, align 8, !tbaa !19
  %88 = getelementptr inbounds %class.maxiFilter, ptr %10, i32 0, i32 2
  %89 = load double, ptr %88, align 8, !tbaa !19
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  ret double %89
}

; Function Attrs: nounwind
declare double @sqrt(double noundef) #2

; Function Attrs: nounwind
declare double @pow(double noundef, double noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = { 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 #4 = { 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 = !{!"double", !7, i64 0}
!11 = !{!12, !10, i64 224}
!12 = !{!"_ZTS10maxiFilter", !10, i64 0, !10, i64 8, !10, i64 16, !7, i64 24, !7, i64 104, !10, i64 184, !10, i64 192, !10, i64 200, !10, i64 208, !10, i64 216, !10, i64 224, !10, i64 232}
!13 = !{!14, !14, i64 0}
!14 = !{!"long", !7, i64 0}
!15 = !{!12, !10, i64 208}
!16 = !{!12, !10, i64 216}
!17 = !{!12, !10, i64 192}
!18 = !{!12, !10, i64 200}
!19 = !{!12, !10, i64 16}


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

@_ZN12maxiSettings10sampleRateE = external dso_local local_unnamed_addr global i64, align 8

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

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(readwrite, inaccessiblemem: write) uwtable
define dso_local noundef double @_ZN10maxiFilter5loresEddd(ptr nocapture noundef nonnull align 8 dereferenceable(240) %0, double noundef %1, double noundef %2, double noundef %3) local_unnamed_addr #2 align 2 {
  %5 = getelementptr inbounds i8, ptr %0, i64 224
  %6 = fcmp olt double %2, 1.000000e+01
  %storemerge = select i1 %6, double 1.000000e+01, double %2
  store double %storemerge, ptr %5, align 8, !tbaa !5
  %7 = load i64, ptr @_ZN12maxiSettings10sampleRateE, align 8, !tbaa !10
  %8 = uitofp i64 %7 to double
  %9 = fcmp ogt double %storemerge, %8
  br i1 %9, label %10, label %11

10:                                               ; preds = %4
  store double %8, ptr %5, align 8, !tbaa !5
  br label %11

11:                                               ; preds = %10, %4
  %12 = phi double [ %8, %10 ], [ %storemerge, %4 ]
  %13 = fcmp olt double %3, 1.000000e+00
  %.0 = select i1 %13, double 1.000000e+00, double %3
  %14 = fmul double %12, 0x401921FB54442D18
  %15 = fdiv double %14, %8
  %16 = tail call double @cos(double noundef %15) #3
  %17 = getelementptr inbounds i8, ptr %0, i64 208
  store double %16, ptr %17, align 8, !tbaa !12
  %18 = tail call double @llvm.fmuladd.f64(double %16, double -2.000000e+00, double 2.000000e+00)
  %19 = getelementptr inbounds i8, ptr %0, i64 216
  store double %18, ptr %19, align 8, !tbaa !13
  %20 = fadd double %16, -1.000000e+00
  %21 = tail call double @pow(double noundef %20, double noundef 3.000000e+00) #3
  %22 = fneg double %21
  %23 = tail call double @sqrt(double noundef %22) #3
  %24 = load double, ptr %17, align 8, !tbaa !12
  %25 = fadd double %24, -1.000000e+00
  %26 = fmul double %.0, %25
  %27 = tail call double @llvm.fmuladd.f64(double %23, double 0x3FF6A09E667F3BCD, double %26)
  %28 = fdiv double %27, %26
  %29 = getelementptr inbounds i8, ptr %0, i64 192
  %30 = load double, ptr %29, align 8, !tbaa !14
  %31 = getelementptr inbounds i8, ptr %0, i64 200
  %32 = load double, ptr %31, align 8, !tbaa !15
  %33 = fsub double %1, %32
  %34 = load double, ptr %19, align 8, !tbaa !13
  %35 = tail call double @llvm.fmuladd.f64(double %33, double %34, double %30)
  %36 = fadd double %32, %35
  store double %36, ptr %31, align 8, !tbaa !15
  %37 = fmul double %35, %28
  store double %37, ptr %29, align 8, !tbaa !14
  %38 = getelementptr inbounds i8, ptr %0, i64 16
  store double %36, ptr %38, align 8, !tbaa !16
  ret double %36
}

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

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = { mustprogress nofree nounwind willreturn memory(readwrite, inaccessiblemem: write) 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, !7, i64 224}
!6 = !{!"_ZTS10maxiFilter", !7, i64 0, !7, i64 8, !7, i64 16, !8, i64 24, !8, i64 104, !7, i64 184, !7, i64 192, !7, i64 200, !7, i64 208, !7, i64 216, !7, i64 224, !7, i64 232}
!7 = !{!"double", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!11, !11, i64 0}
!11 = !{!"long", !8, i64 0}
!12 = !{!6, !7, i64 208}
!13 = !{!6, !7, i64 216}
!14 = !{!6, !7, i64 192}
!15 = !{!6, !7, i64 200}
!16 = !{!6, !7, i64 16}


; Effective O3 passes: DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass