; LLVM IR from jgaeddert/liquid-dsp :: src/filter/src (fnyquist)

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @liquid_firdes_fexp_freqresponse(i32 noundef %0, i32 noundef %1, float noundef %2, ptr noundef %3) #1 {
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca float, align 4
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca float, align 4
  %12 = alloca float, align 4
  %13 = alloca float, align 4
  %14 = alloca float, align 4
  %15 = alloca float, align 4
  %16 = alloca float, 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
  store ptr %3, ptr %8, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  %17 = load i32, ptr %5, align 4, !tbaa !5
  %18 = mul i32 2, %17
  %19 = load i32, ptr %6, align 4, !tbaa !5
  %20 = mul i32 %18, %19
  %21 = add i32 %20, 1
  store i32 %21, ptr %10, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  %22 = load float, ptr %7, align 4, !tbaa !9
  %23 = fsub float 1.000000e+00, %22
  %24 = fmul float 5.000000e-01, %23
  %25 = load i32, ptr %5, align 4, !tbaa !5
  %26 = uitofp i32 %25 to float
  %27 = fdiv float %24, %26
  store float %27, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  %28 = load i32, ptr %5, align 4, !tbaa !5
  %29 = uitofp i32 %28 to float
  %30 = fdiv float 5.000000e-01, %29
  store float %30, ptr %12, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  %31 = load float, ptr %7, align 4, !tbaa !9
  %32 = fadd float 1.000000e+00, %31
  %33 = fmul float 5.000000e-01, %32
  %34 = load i32, ptr %5, align 4, !tbaa !5
  %35 = uitofp i32 %34 to float
  %36 = fdiv float %33, %35
  store float %36, ptr %13, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  %37 = load i32, ptr %5, align 4, !tbaa !5
  %38 = uitofp i32 %37 to float
  %39 = fdiv float 5.000000e-01, %38
  store float %39, ptr %14, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #4
  %40 = call float @logf(float noundef 2.000000e+00) #4
  %41 = load float, ptr %7, align 4, !tbaa !9
  %42 = load float, ptr %14, align 4, !tbaa !9
  %43 = fmul float %41, %42
  %44 = fdiv float %40, %43
  store float %44, ptr %15, align 4, !tbaa !9
  store i32 0, ptr %9, align 4, !tbaa !5
  br label %45

45:                                               ; preds = %120, %4
  %46 = load i32, ptr %9, align 4, !tbaa !5
  %47 = load i32, ptr %10, align 4, !tbaa !5
  %48 = icmp ult i32 %46, %47
  br i1 %48, label %49, label %123

49:                                               ; preds = %45
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #4
  %50 = load i32, ptr %9, align 4, !tbaa !5
  %51 = uitofp i32 %50 to float
  %52 = load i32, ptr %10, align 4, !tbaa !5
  %53 = uitofp i32 %52 to float
  %54 = fdiv float %51, %53
  store float %54, ptr %16, align 4, !tbaa !9
  %55 = load float, ptr %16, align 4, !tbaa !9
  %56 = fcmp ogt float %55, 5.000000e-01
  br i1 %56, label %57, label %60

57:                                               ; preds = %49
  %58 = load float, ptr %16, align 4, !tbaa !9
  %59 = fsub float %58, 1.000000e+00
  store float %59, ptr %16, align 4, !tbaa !9
  br label %60

60:                                               ; preds = %57, %49
  %61 = load float, ptr %16, align 4, !tbaa !9
  %62 = call float @llvm.fabs.f32(float %61)
  store float %62, ptr %16, align 4, !tbaa !9
  %63 = load float, ptr %16, align 4, !tbaa !9
  %64 = load float, ptr %11, align 4, !tbaa !9
  %65 = fcmp olt float %63, %64
  br i1 %65, label %66, label %71

66:                                               ; preds = %60
  %67 = load ptr, ptr %8, align 8, !tbaa !11
  %68 = load i32, ptr %9, align 4, !tbaa !5
  %69 = zext i32 %68 to i64
  %70 = getelementptr inbounds float, ptr %67, i64 %69
  store float 1.000000e+00, ptr %70, align 4, !tbaa !9
  br label %119

71:                                               ; preds = %60
  %72 = load float, ptr %16, align 4, !tbaa !9
  %73 = load float, ptr %11, align 4, !tbaa !9
  %74 = fcmp ogt float %72, %73
  br i1 %74, label %75, label %113

75:                                               ; preds = %71
  %76 = load float, ptr %16, align 4, !tbaa !9
  %77 = load float, ptr %13, align 4, !tbaa !9
  %78 = fcmp olt float %76, %77
  br i1 %78, label %79, label %113

79:                                               ; preds = %75
  %80 = load float, ptr %16, align 4, !tbaa !9
  %81 = load float, ptr %12, align 4, !tbaa !9
  %82 = fcmp olt float %80, %81
  br i1 %82, label %83, label %97

83:                                               ; preds = %79
  %84 = load float, ptr %15, align 4, !tbaa !9
  %85 = load float, ptr %14, align 4, !tbaa !9
  %86 = load float, ptr %7, align 4, !tbaa !9
  %87 = fsub float 1.000000e+00, %86
  %88 = load float, ptr %16, align 4, !tbaa !9
  %89 = fneg float %88
  %90 = call float @llvm.fmuladd.f32(float %85, float %87, float %89)
  %91 = fmul float %84, %90
  %92 = call float @expf(float noundef %91) #4, !tbaa !5
  %93 = load ptr, ptr %8, align 8, !tbaa !11
  %94 = load i32, ptr %9, align 4, !tbaa !5
  %95 = zext i32 %94 to i64
  %96 = getelementptr inbounds float, ptr %93, i64 %95
  store float %92, ptr %96, align 4, !tbaa !9
  br label %112

97:                                               ; preds = %79
  %98 = load float, ptr %15, align 4, !tbaa !9
  %99 = load float, ptr %16, align 4, !tbaa !9
  %100 = load float, ptr %7, align 4, !tbaa !9
  %101 = fadd float 1.000000e+00, %100
  %102 = load float, ptr %14, align 4, !tbaa !9
  %103 = fneg float %101
  %104 = call float @llvm.fmuladd.f32(float %103, float %102, float %99)
  %105 = fmul float %98, %104
  %106 = call float @expf(float noundef %105) #4, !tbaa !5
  %107 = fsub float 1.000000e+00, %106
  %108 = load ptr, ptr %8, align 8, !tbaa !11
  %109 = load i32, ptr %9, align 4, !tbaa !5
  %110 = zext i32 %109 to i64
  %111 = getelementptr inbounds float, ptr %108, i64 %110
  store float %107, ptr %111, align 4, !tbaa !9
  br label %112

112:                                              ; preds = %97, %83
  br label %118

113:                                              ; preds = %75, %71
  %114 = load ptr, ptr %8, align 8, !tbaa !11
  %115 = load i32, ptr %9, align 4, !tbaa !5
  %116 = zext i32 %115 to i64
  %117 = getelementptr inbounds float, ptr %114, i64 %116
  store float 0.000000e+00, ptr %117, align 4, !tbaa !9
  br label %118

118:                                              ; preds = %113, %112
  br label %119

119:                                              ; preds = %118, %66
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #4
  br label %120

120:                                              ; preds = %119
  %121 = load i32, ptr %9, align 4, !tbaa !5
  %122 = add i32 %121, 1
  store i32 %122, ptr %9, align 4, !tbaa !5
  br label %45, !llvm.loop !13

123:                                              ; preds = %45
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #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
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  ret i32 0
}

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

; Function Attrs: nounwind
declare float @logf(float noundef) #2

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

; Function Attrs: nounwind
declare float @expf(float noundef) #2

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

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

; Function Attrs: nofree nounwind memory(write) uwtable
define dso_local noundef i32 @liquid_firdes_fexp_freqresponse(i32 noundef %0, i32 noundef %1, float noundef %2, ptr nocapture noundef writeonly %3) local_unnamed_addr #0 {
  %5 = shl i32 %0, 1
  %6 = mul i32 %5, %1
  %7 = or disjoint i32 %6, 1
  %8 = fsub float 1.000000e+00, %2
  %9 = fmul float %8, 5.000000e-01
  %10 = uitofp i32 %0 to float
  %11 = fdiv float %9, %10
  %12 = fdiv float 5.000000e-01, %10
  %13 = fadd float %2, 1.000000e+00
  %14 = fmul float %13, 5.000000e-01
  %15 = fdiv float %14, %10
  %16 = fmul float %12, %2
  %17 = fdiv float 0x3FE62E4300000000, %16
  %18 = uitofp i32 %7 to float
  %19 = fneg float %13
  %20 = or disjoint i32 %6, 1
  %wide.trip.count = zext i32 %20 to i64
  br label %21

21:                                               ; preds = %4, %49
  %indvars.iv = phi i64 [ 0, %4 ], [ %indvars.iv.next, %49 ]
  %22 = trunc nuw i64 %indvars.iv to i32
  %23 = uitofp i32 %22 to float
  %24 = fdiv float %23, %18
  %25 = fcmp ogt float %24, 5.000000e-01
  %26 = fadd float %24, -1.000000e+00
  %.0 = select i1 %25, float %26, float %24
  %27 = tail call float @llvm.fabs.f32(float %.0)
  %28 = fcmp olt float %27, %11
  br i1 %28, label %29, label %31

29:                                               ; preds = %21
  %30 = getelementptr inbounds float, ptr %3, i64 %indvars.iv
  store float 1.000000e+00, ptr %30, align 4, !tbaa !5
  br label %49

31:                                               ; preds = %21
  %32 = fcmp ogt float %27, %11
  %33 = fcmp olt float %27, %15
  %or.cond = and i1 %32, %33
  br i1 %or.cond, label %34, label %47

34:                                               ; preds = %31
  %35 = fcmp olt float %27, %12
  %36 = getelementptr inbounds float, ptr %3, i64 %indvars.iv
  br i1 %35, label %37, label %42

37:                                               ; preds = %34
  %38 = fneg float %27
  %39 = tail call float @llvm.fmuladd.f32(float %12, float %8, float %38)
  %40 = fmul float %17, %39
  %41 = tail call float @expf(float noundef %40) #3, !tbaa !9
  store float %41, ptr %36, align 4, !tbaa !5
  br label %49

42:                                               ; preds = %34
  %43 = tail call float @llvm.fmuladd.f32(float %19, float %12, float %27)
  %44 = fmul float %17, %43
  %45 = tail call float @expf(float noundef %44) #3, !tbaa !9
  %46 = fsub float 1.000000e+00, %45
  store float %46, ptr %36, align 4, !tbaa !5
  br label %49

47:                                               ; preds = %31
  %48 = getelementptr inbounds float, ptr %3, i64 %indvars.iv
  store float 0.000000e+00, ptr %48, align 4, !tbaa !5
  br label %49

49:                                               ; preds = %47, %42, %37, %29
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond, label %50, label %21, !llvm.loop !11

50:                                               ; preds = %49
  ret i32 0
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fabs.f32(float) #1

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

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

attributes #0 = { nofree nounwind memory(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 #1 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!6, !6, i64 0}
!6 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


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