; LLVM IR from jgaeddert/liquid-dsp :: sandbox (minsearch_test)

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

@.str = external hidden unnamed_addr constant [8 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [79 x i8], align 1
@__PRETTY_FUNCTION__.main = external hidden unnamed_addr constant [11 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [29 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local double @function(double noundef) #0

; 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

; Function Attrs: nounwind uwtable
define dso_local i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca double, 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
  %9 = alloca double, align 8
  %10 = alloca double, align 8
  %11 = alloca double, align 8
  %12 = alloca i32, align 4
  %13 = alloca double, align 8
  %14 = alloca double, align 8
  %15 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  store i32 10, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #5
  store double 0x3FD3333340000000, ptr %3, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  store double 0x4008CCCCC0000000, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  store double 0x3EB0C6F7A0000000, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %16 = load double, ptr %3, align 8, !tbaa !9
  %17 = call double @function(double noundef %16)
  store double %17, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  %18 = load double, ptr %5, align 8, !tbaa !9
  %19 = call double @function(double noundef %18)
  store double %19, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  store double 0.000000e+00, ptr %11, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  store i32 0, ptr %12, align 4, !tbaa !5
  br label %20

20:                                               ; preds = %119, %0
  %21 = load i32, ptr %12, align 4, !tbaa !5
  %22 = load i32, ptr %2, align 4, !tbaa !5
  %23 = icmp ult i32 %21, %22
  br i1 %23, label %24, label %122

24:                                               ; preds = %20
  %25 = load double, ptr %3, align 8, !tbaa !9
  %26 = load double, ptr %5, align 8, !tbaa !9
  %27 = fadd double %25, %26
  %28 = fmul double 5.000000e-01, %27
  store double %28, ptr %4, align 8, !tbaa !9
  %29 = load double, ptr %3, align 8, !tbaa !9
  %30 = load double, ptr %5, align 8, !tbaa !9
  %31 = fadd double %29, %30
  %32 = fmul double 5.000000e-01, %31
  %33 = call double @function(double noundef %32)
  store double %33, ptr %8, align 8, !tbaa !9
  %34 = load double, ptr %5, align 8, !tbaa !9
  %35 = load double, ptr %4, align 8, !tbaa !9
  %36 = fcmp ogt double %34, %35
  br i1 %36, label %37, label %38

37:                                               ; preds = %24
  br label %39

38:                                               ; preds = %24
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 54, ptr noundef @__PRETTY_FUNCTION__.main) #6
  unreachable

39:                                               ; preds = %37
  %40 = load double, ptr %4, align 8, !tbaa !9
  %41 = load double, ptr %3, align 8, !tbaa !9
  %42 = fcmp ogt double %40, %41
  br i1 %42, label %43, label %44

43:                                               ; preds = %39
  br label %45

44:                                               ; preds = %39
  call void @__assert_fail(ptr noundef @.str.2, ptr noundef @.str.1, i32 noundef 55, ptr noundef @__PRETTY_FUNCTION__.main) #6
  unreachable

45:                                               ; preds = %43
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #5
  %46 = load double, ptr %7, align 8, !tbaa !9
  %47 = load double, ptr %4, align 8, !tbaa !9
  %48 = load double, ptr %4, align 8, !tbaa !9
  %49 = load double, ptr %5, align 8, !tbaa !9
  %50 = load double, ptr %5, align 8, !tbaa !9
  %51 = fmul double %49, %50
  %52 = fneg double %51
  %53 = call double @llvm.fmuladd.f64(double %47, double %48, double %52)
  %54 = load double, ptr %8, align 8, !tbaa !9
  %55 = load double, ptr %5, align 8, !tbaa !9
  %56 = load double, ptr %5, align 8, !tbaa !9
  %57 = load double, ptr %3, align 8, !tbaa !9
  %58 = load double, ptr %3, align 8, !tbaa !9
  %59 = fmul double %57, %58
  %60 = fneg double %59
  %61 = call double @llvm.fmuladd.f64(double %55, double %56, double %60)
  %62 = fmul double %54, %61
  %63 = call double @llvm.fmuladd.f64(double %46, double %53, double %62)
  %64 = load double, ptr %9, align 8, !tbaa !9
  %65 = load double, ptr %3, align 8, !tbaa !9
  %66 = load double, ptr %3, align 8, !tbaa !9
  %67 = load double, ptr %4, align 8, !tbaa !9
  %68 = load double, ptr %4, align 8, !tbaa !9
  %69 = fmul double %67, %68
  %70 = fneg double %69
  %71 = call double @llvm.fmuladd.f64(double %65, double %66, double %70)
  %72 = call double @llvm.fmuladd.f64(double %64, double %71, double %63)
  store double %72, ptr %13, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #5
  %73 = load double, ptr %7, align 8, !tbaa !9
  %74 = load double, ptr %4, align 8, !tbaa !9
  %75 = load double, ptr %5, align 8, !tbaa !9
  %76 = fsub double %74, %75
  %77 = load double, ptr %8, align 8, !tbaa !9
  %78 = load double, ptr %5, align 8, !tbaa !9
  %79 = load double, ptr %3, align 8, !tbaa !9
  %80 = fsub double %78, %79
  %81 = fmul double %77, %80
  %82 = call double @llvm.fmuladd.f64(double %73, double %76, double %81)
  %83 = load double, ptr %9, align 8, !tbaa !9
  %84 = load double, ptr %3, align 8, !tbaa !9
  %85 = load double, ptr %4, align 8, !tbaa !9
  %86 = fsub double %84, %85
  %87 = call double @llvm.fmuladd.f64(double %83, double %86, double %82)
  store double %87, ptr %14, align 8, !tbaa !9
  %88 = load double, ptr %13, align 8, !tbaa !9
  %89 = fmul double 5.000000e-01, %88
  %90 = load double, ptr %14, align 8, !tbaa !9
  %91 = fdiv double %89, %90
  store double %91, ptr %10, align 8, !tbaa !9
  %92 = load double, ptr %10, align 8, !tbaa !9
  %93 = load double, ptr %4, align 8, !tbaa !9
  %94 = fsub double %92, %93
  store double %94, ptr %11, align 8, !tbaa !9
  %95 = load i32, ptr %12, align 4, !tbaa !5
  %96 = load double, ptr %10, align 8, !tbaa !9
  %97 = load double, ptr %10, align 8, !tbaa !9
  %98 = fsub double %97, 0x3FF921FB54442D18
  %99 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i32 noundef %95, double noundef %96, double noundef %98)
  %100 = load double, ptr %10, align 8, !tbaa !9
  %101 = load double, ptr %4, align 8, !tbaa !9
  %102 = fcmp ogt double %100, %101
  br i1 %102, label %103, label %106

103:                                              ; preds = %45
  %104 = load double, ptr %4, align 8, !tbaa !9
  store double %104, ptr %3, align 8, !tbaa !9
  %105 = load double, ptr %8, align 8, !tbaa !9
  store double %105, ptr %7, align 8, !tbaa !9
  br label %109

106:                                              ; preds = %45
  %107 = load double, ptr %4, align 8, !tbaa !9
  store double %107, ptr %5, align 8, !tbaa !9
  %108 = load double, ptr %8, align 8, !tbaa !9
  store double %108, ptr %9, align 8, !tbaa !9
  br label %109

109:                                              ; preds = %106, %103
  %110 = load double, ptr %11, align 8, !tbaa !9
  %111 = call double @llvm.fabs.f64(double %110)
  %112 = load double, ptr %6, align 8, !tbaa !9
  %113 = fcmp olt double %111, %112
  br i1 %113, label %114, label %115

114:                                              ; preds = %109
  store i32 2, ptr %15, align 4
  br label %116

115:                                              ; preds = %109
  store i32 0, ptr %15, align 4
  br label %116

116:                                              ; preds = %115, %114
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #5
  %117 = load i32, ptr %15, align 4
  switch i32 %117, label %126 [
    i32 0, label %118
    i32 2, label %122
  ]

118:                                              ; preds = %116
  br label %119

119:                                              ; preds = %118
  %120 = load i32, ptr %12, align 4, !tbaa !5
  %121 = add i32 %120, 1
  store i32 %121, ptr %12, align 4, !tbaa !5
  br label %20, !llvm.loop !11

122:                                              ; preds = %116, %20
  %123 = load double, ptr %10, align 8, !tbaa !9
  %124 = call i32 (ptr, ...) @printf(ptr noundef @.str.4, double noundef %123, double noundef 0x3FF921FB54442D18)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %15, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #5
  %125 = load i32, ptr %1, align 4
  ret i32 %125

126:                                              ; preds = %116
  unreachable
}

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #2

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

declare i32 @printf(ptr noundef, ...) #4

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

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 = { noreturn 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { "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 #5 = { nounwind }
attributes #6 = { noreturn 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}
!11 = distinct !{!11, !12}
!12 = !{!"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"

@.str = external hidden unnamed_addr constant [8 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [79 x i8], align 1
@__PRETTY_FUNCTION__.main = external hidden unnamed_addr constant [11 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [29 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local double @function(double noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = tail call double @function(double noundef 0x3FD3333340000000)
  %2 = tail call double @function(double noundef 0x4008CCCCC0000000)
  br label %3

3:                                                ; preds = %0, %38
  %.05469 = phi double [ 0x3FD3333340000000, %0 ], [ %..054, %38 ]
  %.05568 = phi i32 [ 0, %0 ], [ %40, %38 ]
  %.05867 = phi double [ %2, %0 ], [ %.058., %38 ]
  %.06066 = phi double [ 0x4008CCCCC0000000, %0 ], [ %.060., %38 ]
  %.06265 = phi double [ %1, %0 ], [ %..062, %38 ]
  %4 = fadd double %.06066, %.05469
  %5 = fmul double %4, 5.000000e-01
  %6 = tail call double @function(double noundef %5)
  %7 = fcmp ogt double %.06066, %5
  br i1 %7, label %9, label %8

8:                                                ; preds = %3
  tail call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 54, ptr noundef nonnull @__PRETTY_FUNCTION__.main) #4
  unreachable

9:                                                ; preds = %3
  %10 = fcmp ogt double %5, %.05469
  br i1 %10, label %12, label %11

11:                                               ; preds = %9
  tail call void @__assert_fail(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.1, i32 noundef 55, ptr noundef nonnull @__PRETTY_FUNCTION__.main) #4
  unreachable

12:                                               ; preds = %9
  %13 = fneg double %.06066
  %14 = fmul double %.06066, %13
  %15 = tail call double @llvm.fmuladd.f64(double %5, double %5, double %14)
  %16 = fneg double %.05469
  %17 = fmul double %.05469, %16
  %18 = tail call double @llvm.fmuladd.f64(double %.06066, double %.06066, double %17)
  %19 = fmul double %18, %6
  %20 = tail call double @llvm.fmuladd.f64(double %.06265, double %15, double %19)
  %21 = fneg double %5
  %22 = fmul double %5, %21
  %23 = tail call double @llvm.fmuladd.f64(double %.05469, double %.05469, double %22)
  %24 = tail call double @llvm.fmuladd.f64(double %.05867, double %23, double %20)
  %25 = fsub double %5, %.06066
  %26 = fsub double %.06066, %.05469
  %27 = fmul double %26, %6
  %28 = tail call double @llvm.fmuladd.f64(double %.06265, double %25, double %27)
  %29 = fsub double %.05469, %5
  %30 = tail call double @llvm.fmuladd.f64(double %.05867, double %29, double %28)
  %31 = fmul double %24, 5.000000e-01
  %32 = fdiv double %31, %30
  %33 = fsub double %32, %5
  %34 = fadd double %32, 0xBFF921FB54442D18
  %35 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i32 noundef %.05568, double noundef %32, double noundef %34)
  %36 = tail call double @llvm.fabs.f64(double %33)
  %37 = fcmp olt double %36, 0x3EB0C6F7A0000000
  br i1 %37, label %41, label %38

38:                                               ; preds = %12
  %39 = fcmp ogt double %32, %5
  %..054 = select i1 %39, double %5, double %.05469
  %.058. = select i1 %39, double %.05867, double %6
  %.060. = select i1 %39, double %.06066, double %5
  %..062 = select i1 %39, double %6, double %.06265
  %40 = add nuw nsw i32 %.05568, 1
  %exitcond.not = icmp eq i32 %40, 10
  br i1 %exitcond.not, label %41, label %3, !llvm.loop !5

41:                                               ; preds = %12, %38
  %42 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, double noundef %32, double noundef 0x3FF921FB54442D18)
  ret i32 0
}

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

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

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #3

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

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 = { noreturn 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 #2 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { nofree 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 #4 = { noreturn 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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LoopRotatePass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass