; LLVM IR from jgaeddert/liquid-dsp :: src/math/src (windows)

; 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.23 = external hidden unnamed_addr constant [77 x i8], align 1
@.str.26 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.27 = external hidden unnamed_addr constant [54 x i8], align 1
@.str.28 = external hidden unnamed_addr constant [40 x i8], align 1

; 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

declare i32 @liquid_error_fl(i32 noundef, ptr noundef, i32 noundef, ptr noundef, ...) #1

; Function Attrs: nounwind uwtable
declare dso_local float @liquid_kaiser(i32 noundef, i32 noundef, float noundef) #2

; Function Attrs: nounwind uwtable
define dso_local float @liquid_kbd(i32 noundef %0, i32 noundef %1, float noundef %2) #2 {
  %4 = alloca float, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca float, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca float, align 4
  %11 = alloca float, align 4
  %12 = alloca float, align 4
  %13 = alloca i32, align 4
  store i32 %0, ptr %5, align 4, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !5
  store float %2, ptr %7, align 4, !tbaa !9
  %14 = load i32, ptr %5, align 4, !tbaa !5
  %15 = load i32, ptr %6, align 4, !tbaa !5
  %16 = icmp uge i32 %14, %15
  br i1 %16, label %17, label %19

17:                                               ; preds = %3
  %18 = call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 3, ptr noundef @.str.23, i32 noundef 134, ptr noundef @.str.26)
  store float 0.000000e+00, ptr %4, align 4
  br label %77

19:                                               ; preds = %3
  %20 = load i32, ptr %6, align 4, !tbaa !5
  %21 = icmp eq i32 %20, 0
  br i1 %21, label %22, label %24

22:                                               ; preds = %19
  %23 = call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 3, ptr noundef @.str.23, i32 noundef 137, ptr noundef @.str.27)
  store float 0.000000e+00, ptr %4, align 4
  br label %77

24:                                               ; preds = %19
  %25 = load i32, ptr %6, align 4, !tbaa !5
  %26 = urem i32 %25, 2
  %27 = icmp ne i32 %26, 0
  br i1 %27, label %28, label %30

28:                                               ; preds = %24
  %29 = call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 3, ptr noundef @.str.23, i32 noundef 140, ptr noundef @.str.28)
  store float 0.000000e+00, ptr %4, align 4
  br label %77

30:                                               ; preds = %24
  br label %31

31:                                               ; preds = %30
  br label %32

32:                                               ; preds = %31
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  %33 = load i32, ptr %6, align 4, !tbaa !5
  %34 = udiv i32 %33, 2
  store i32 %34, ptr %8, align 4, !tbaa !5
  %35 = load i32, ptr %5, align 4, !tbaa !5
  %36 = load i32, ptr %8, align 4, !tbaa !5
  %37 = icmp uge i32 %35, %36
  br i1 %37, label %38, label %46

38:                                               ; preds = %32
  %39 = load i32, ptr %6, align 4, !tbaa !5
  %40 = load i32, ptr %5, align 4, !tbaa !5
  %41 = sub i32 %39, %40
  %42 = sub i32 %41, 1
  %43 = load i32, ptr %6, align 4, !tbaa !5
  %44 = load float, ptr %7, align 4, !tbaa !9
  %45 = call float @liquid_kbd(i32 noundef %42, i32 noundef %43, float noundef %44)
  store float %45, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %76

46:                                               ; preds = %32
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  store float 0.000000e+00, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  store float 0.000000e+00, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  store i32 0, ptr %13, align 4, !tbaa !5
  br label %47

47:                                               ; preds = %68, %46
  %48 = load i32, ptr %13, align 4, !tbaa !5
  %49 = load i32, ptr %8, align 4, !tbaa !5
  %50 = icmp ule i32 %48, %49
  br i1 %50, label %51, label %71

51:                                               ; preds = %47
  %52 = load i32, ptr %13, align 4, !tbaa !5
  %53 = load i32, ptr %8, align 4, !tbaa !5
  %54 = add i32 %53, 1
  %55 = load float, ptr %7, align 4, !tbaa !9
  %56 = call float @liquid_kaiser(i32 noundef %52, i32 noundef %54, float noundef %55)
  store float %56, ptr %12, align 4, !tbaa !9
  %57 = load float, ptr %12, align 4, !tbaa !9
  %58 = load float, ptr %11, align 4, !tbaa !9
  %59 = fadd float %58, %57
  store float %59, ptr %11, align 4, !tbaa !9
  %60 = load i32, ptr %13, align 4, !tbaa !5
  %61 = load i32, ptr %5, align 4, !tbaa !5
  %62 = icmp ule i32 %60, %61
  br i1 %62, label %63, label %67

63:                                               ; preds = %51
  %64 = load float, ptr %12, align 4, !tbaa !9
  %65 = load float, ptr %10, align 4, !tbaa !9
  %66 = fadd float %65, %64
  store float %66, ptr %10, align 4, !tbaa !9
  br label %67

67:                                               ; preds = %63, %51
  br label %68

68:                                               ; preds = %67
  %69 = load i32, ptr %13, align 4, !tbaa !5
  %70 = add i32 %69, 1
  store i32 %70, ptr %13, align 4, !tbaa !5
  br label %47, !llvm.loop !11

71:                                               ; preds = %47
  %72 = load float, ptr %10, align 4, !tbaa !9
  %73 = load float, ptr %11, align 4, !tbaa !9
  %74 = fdiv float %72, %73
  %75 = call float @sqrtf(float noundef %74) #4
  store float %75, ptr %4, align 4
  store i32 1, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  br label %76

76:                                               ; preds = %71, %38
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  br label %77

77:                                               ; preds = %76, %28, %22, %17
  %78 = load float, ptr %4, align 4
  ret float %78
}

; Function Attrs: nounwind
declare float @sqrtf(float noundef) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 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 "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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"float", !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.23 = external hidden unnamed_addr constant [77 x i8], align 1
@.str.26 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.28 = external hidden unnamed_addr constant [40 x i8], align 1

declare i32 @liquid_error_fl(i32 noundef, ptr noundef, i32 noundef, ptr noundef, ...) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local float @liquid_kaiser(i32 noundef, i32 noundef, float noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local float @liquid_kbd(i32 noundef %0, i32 noundef %1, float noundef %2) local_unnamed_addr #1 {
  %.not40 = icmp ult i32 %0, %1
  br i1 %.not40, label %.lr.ph, label %tailrecurse._crit_edge

.lr.ph:                                           ; preds = %3
  %4 = and i32 %1, 1
  %.not32 = icmp eq i32 %4, 0
  %5 = lshr i32 %1, 1
  br i1 %.not32, label %.lr.ph.split, label %7

tailrecurse._crit_edge:                           ; preds = %tailrecurse, %3
  %6 = tail call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 3, ptr noundef nonnull @.str.23, i32 noundef 134, ptr noundef nonnull @.str.26) #3
  br label %20

.lr.ph.split:                                     ; preds = %.lr.ph, %tailrecurse
  %.tr41 = phi i32 [ %11, %tailrecurse ], [ %0, %.lr.ph ]
  %.not33 = icmp ugt i32 %5, %.tr41
  br i1 %.not33, label %.preheader, label %tailrecurse

7:                                                ; preds = %.lr.ph
  %8 = tail call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 3, ptr noundef nonnull @.str.23, i32 noundef 140, ptr noundef nonnull @.str.28) #3
  br label %20

.preheader:                                       ; preds = %.lr.ph.split
  %9 = add nuw i32 %5, 1
  br label %12

tailrecurse:                                      ; preds = %.lr.ph.split
  %10 = xor i32 %.tr41, -1
  %11 = add i32 %10, %1
  %.not = icmp ult i32 %11, %1
  br i1 %.not, label %.lr.ph.split, label %tailrecurse._crit_edge

12:                                               ; preds = %.preheader, %12
  %.044 = phi i32 [ 0, %.preheader ], [ %16, %12 ]
  %.02643 = phi float [ 0.000000e+00, %.preheader ], [ %14, %12 ]
  %.02742 = phi float [ 0.000000e+00, %.preheader ], [ %.128, %12 ]
  %13 = tail call float @liquid_kaiser(i32 noundef %.044, i32 noundef %9, float noundef %2)
  %14 = fadd float %.02643, %13
  %.not35 = icmp ugt i32 %.044, %.tr41
  %15 = fadd float %.02742, %13
  %.128 = select i1 %.not35, float %.02742, float %15
  %16 = add nuw i32 %.044, 1
  %exitcond.not = icmp eq i32 %.044, %5
  br i1 %exitcond.not, label %17, label %12, !llvm.loop !5

17:                                               ; preds = %12
  %18 = fdiv float %.128, %14
  %19 = tail call float @sqrtf(float noundef %18) #3
  br label %20

20:                                               ; preds = %17, %7, %tailrecurse._crit_edge
  %.1 = phi float [ 0.000000e+00, %tailrecurse._crit_edge ], [ 0.000000e+00, %7 ], [ %19, %17 ]
  ret float %.1
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare float @sqrtf(float noundef) local_unnamed_addr #2

attributes #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 = { 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 = { 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 #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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass