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

; 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 [76 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [47 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [47 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [44 x i8], align 1

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

23:                                               ; preds = %5
  %24 = call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 3, ptr noundef @.str, i32 noundef 46, ptr noundef @.str.1)
  store i32 %24, ptr %6, align 4
  br label %113

25:                                               ; preds = %5
  %26 = load i32, ptr %8, align 4, !tbaa !5
  %27 = icmp ult i32 %26, 1
  br i1 %27, label %28, label %30

28:                                               ; preds = %25
  %29 = call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 3, ptr noundef @.str, i32 noundef 48, ptr noundef @.str.2)
  store i32 %29, ptr %6, align 4
  br label %113

30:                                               ; preds = %25
  %31 = load float, ptr %9, align 4, !tbaa !9
  %32 = fcmp olt float %31, 0.000000e+00
  br i1 %32, label %36, label %33

33:                                               ; preds = %30
  %34 = load float, ptr %9, align 4, !tbaa !9
  %35 = fcmp ogt float %34, 1.000000e+00
  br i1 %35, label %36, label %38

36:                                               ; preds = %33, %30
  %37 = call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 3, ptr noundef @.str, i32 noundef 50, ptr noundef @.str.3)
  store i32 %37, ptr %6, align 4
  br label %113

38:                                               ; preds = %33
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #5
  %39 = load i32, ptr %7, align 4, !tbaa !5
  %40 = mul i32 2, %39
  %41 = load i32, ptr %8, align 4, !tbaa !5
  %42 = mul i32 %40, %41
  %43 = add i32 %42, 1
  store i32 %43, ptr %20, align 4, !tbaa !5
  store i32 0, ptr %12, align 4, !tbaa !5
  br label %44

44:                                               ; preds = %109, %38
  %45 = load i32, ptr %12, align 4, !tbaa !5
  %46 = load i32, ptr %20, align 4, !tbaa !5
  %47 = icmp ult i32 %45, %46
  br i1 %47, label %48, label %112

48:                                               ; preds = %44
  %49 = load i32, ptr %12, align 4, !tbaa !5
  %50 = uitofp i32 %49 to float
  store float %50, ptr %17, align 4, !tbaa !9
  %51 = load i32, ptr %7, align 4, !tbaa !5
  %52 = uitofp i32 %51 to float
  store float %52, ptr %18, align 4, !tbaa !9
  %53 = load i32, ptr %8, align 4, !tbaa !5
  %54 = uitofp i32 %53 to float
  store float %54, ptr %19, align 4, !tbaa !9
  %55 = load float, ptr %17, align 4, !tbaa !9
  %56 = load float, ptr %10, align 4, !tbaa !9
  %57 = fadd float %55, %56
  %58 = load float, ptr %18, align 4, !tbaa !9
  %59 = fdiv float %57, %58
  %60 = load float, ptr %19, align 4, !tbaa !9
  %61 = fsub float %59, %60
  store float %61, ptr %13, align 4, !tbaa !9
  %62 = load float, ptr %9, align 4, !tbaa !9
  %63 = fpext float %62 to double
  %64 = fmul double %63, 0x400921FB54442D18
  %65 = load float, ptr %13, align 4, !tbaa !9
  %66 = fpext float %65 to double
  %67 = fmul double %64, %66
  %68 = fptrunc double %67 to float
  %69 = call float @cosf(float noundef %68) #5
  store float %69, ptr %14, align 4, !tbaa !9
  %70 = load float, ptr %13, align 4, !tbaa !9
  %71 = call float @sincf(float noundef %70)
  store float %71, ptr %15, align 4, !tbaa !9
  %72 = load float, ptr %9, align 4, !tbaa !9
  %73 = fmul float 4.000000e+00, %72
  %74 = load float, ptr %9, align 4, !tbaa !9
  %75 = fmul float %73, %74
  %76 = load float, ptr %13, align 4, !tbaa !9
  %77 = fmul float %75, %76
  %78 = load float, ptr %13, align 4, !tbaa !9
  %79 = fneg float %77
  %80 = call float @llvm.fmuladd.f32(float %79, float %78, float 1.000000e+00)
  store float %80, ptr %16, align 4, !tbaa !9
  %81 = load float, ptr %16, align 4, !tbaa !9
  %82 = call float @llvm.fabs.f32(float %81)
  %83 = fcmp olt float %82, 0x3F50624DE0000000
  br i1 %83, label %84, label %98

84:                                               ; preds = %48
  %85 = load float, ptr %9, align 4, !tbaa !9
  %86 = fpext float %85 to double
  %87 = fmul double 2.000000e+00, %86
  %88 = fdiv double 0x400921FB54442D18, %87
  %89 = fptrunc double %88 to float
  %90 = call float @sinf(float noundef %89) #5
  %91 = load float, ptr %9, align 4, !tbaa !9
  %92 = fmul float %90, %91
  %93 = fmul float %92, 5.000000e-01
  %94 = load ptr, ptr %11, align 8, !tbaa !11
  %95 = load i32, ptr %12, align 4, !tbaa !5
  %96 = zext i32 %95 to i64
  %97 = getelementptr inbounds float, ptr %94, i64 %96
  store float %93, ptr %97, align 4, !tbaa !9
  br label %108

98:                                               ; preds = %48
  %99 = load float, ptr %14, align 4, !tbaa !9
  %100 = load float, ptr %15, align 4, !tbaa !9
  %101 = fmul float %99, %100
  %102 = load float, ptr %16, align 4, !tbaa !9
  %103 = fdiv float %101, %102
  %104 = load ptr, ptr %11, align 8, !tbaa !11
  %105 = load i32, ptr %12, align 4, !tbaa !5
  %106 = zext i32 %105 to i64
  %107 = getelementptr inbounds float, ptr %104, i64 %106
  store float %103, ptr %107, align 4, !tbaa !9
  br label %108

108:                                              ; preds = %98, %84
  br label %109

109:                                              ; preds = %108
  %110 = load i32, ptr %12, align 4, !tbaa !5
  %111 = add i32 %110, 1
  store i32 %111, ptr %12, align 4, !tbaa !5
  br label %44, !llvm.loop !13

112:                                              ; preds = %44
  store i32 0, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  br label %113

113:                                              ; preds = %112, %36, %28, %23
  %114 = load i32, ptr %6, align 4
  ret i32 %114
}

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

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

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

declare float @sincf(float noundef) #1

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

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

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

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { "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 nosync nounwind willreturn memory(argmem: readwrite) }
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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { 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"

@.str = external hidden unnamed_addr constant [76 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [47 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [47 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [44 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @liquid_firdes_rcos(i32 noundef %0, i32 noundef %1, float noundef %2, float noundef %3, ptr nocapture noundef writeonly %4) local_unnamed_addr #0 {
  %6 = icmp eq i32 %0, 0
  br i1 %6, label %7, label %9

7:                                                ; preds = %5
  %8 = tail call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 3, ptr noundef nonnull @.str, i32 noundef 46, ptr noundef nonnull @.str.1) #4
  br label %.loopexit

9:                                                ; preds = %5
  %10 = icmp eq i32 %1, 0
  br i1 %10, label %11, label %13

11:                                               ; preds = %9
  %12 = tail call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 3, ptr noundef nonnull @.str, i32 noundef 48, ptr noundef nonnull @.str.2) #4
  br label %.loopexit

13:                                               ; preds = %9
  %14 = fcmp olt float %2, 0.000000e+00
  %15 = fcmp ogt float %2, 1.000000e+00
  %or.cond = or i1 %14, %15
  br i1 %or.cond, label %16, label %18

16:                                               ; preds = %13
  %17 = tail call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 3, ptr noundef nonnull @.str, i32 noundef 50, ptr noundef nonnull @.str.3) #4
  br label %.loopexit

18:                                               ; preds = %13
  %19 = shl i32 %0, 1
  %20 = mul i32 %19, %1
  %21 = uitofp i32 %0 to float
  %22 = uitofp i32 %1 to float
  %23 = fpext float %2 to double
  %24 = fmul double %23, 0x400921FB54442D18
  %25 = fmul float %2, -4.000000e+00
  %26 = fmul float %25, %2
  %27 = fmul double %23, 2.000000e+00
  %28 = fdiv double 0x400921FB54442D18, %27
  %29 = fptrunc double %28 to float
  %30 = or disjoint i32 %20, 1
  %wide.trip.count = zext i32 %30 to i64
  br label %31

31:                                               ; preds = %18, %53
  %indvars.iv = phi i64 [ 0, %18 ], [ %indvars.iv.next, %53 ]
  %32 = trunc nuw i64 %indvars.iv to i32
  %33 = uitofp i32 %32 to float
  %34 = fadd float %33, %3
  %35 = fdiv float %34, %21
  %36 = fsub float %35, %22
  %37 = fpext float %36 to double
  %38 = fmul double %24, %37
  %39 = fptrunc double %38 to float
  %40 = tail call float @cosf(float noundef %39) #4
  %41 = tail call float @sincf(float noundef %36) #4
  %42 = fmul float %26, %36
  %43 = tail call float @llvm.fmuladd.f32(float %42, float %36, float 1.000000e+00)
  %44 = tail call float @llvm.fabs.f32(float %43)
  %45 = fcmp olt float %44, 0x3F50624DE0000000
  br i1 %45, label %46, label %50

46:                                               ; preds = %31
  %47 = tail call float @sinf(float noundef %29) #4
  %48 = fmul float %47, %2
  %49 = fmul float %48, 5.000000e-01
  br label %53

50:                                               ; preds = %31
  %51 = fmul float %40, %41
  %52 = fdiv float %51, %43
  br label %53

53:                                               ; preds = %46, %50
  %.sink = phi float [ %49, %46 ], [ %52, %50 ]
  %54 = getelementptr inbounds float, ptr %4, i64 %indvars.iv
  store float %.sink, ptr %54, align 4
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond, label %.loopexit, label %31, !llvm.loop !5

.loopexit:                                        ; preds = %53, %16, %11, %7
  %.0 = phi i32 [ %8, %7 ], [ %12, %11 ], [ %17, %16 ], [ 0, %53 ]
  ret i32 %.0
}

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

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

declare float @sincf(float noundef) local_unnamed_addr #1

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

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare float @sinf(float noundef) local_unnamed_addr #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 = { "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 = { mustprogress 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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,MergedLoadStoreMotionPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass