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

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

%struct.fdelay_crcf_s = type { i32, i32, i32, float, ptr, ptr, i32, i32 }

@.str = external hidden unnamed_addr constant [84 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [53 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [61 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [52 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

; Function Attrs: nounwind uwtable
define dso_local i32 @fdelay_crcf_set_delay(ptr noundef %0, float noundef %1) #1 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca float, align 4
  %6 = alloca float, align 4
  %7 = alloca i32, align 4
  %8 = alloca float, align 4
  %9 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store float %1, ptr %5, align 4, !tbaa !9
  %10 = load float, ptr %5, align 4, !tbaa !9
  %11 = fcmp olt float %10, 0.000000e+00
  br i1 %11, label %12, label %16

12:                                               ; preds = %2
  %13 = load float, ptr %5, align 4, !tbaa !9
  %14 = fpext float %13 to double
  %15 = call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 4, ptr noundef @.str, i32 noundef 124, ptr noundef @.str.6, ptr noundef @.str.2, double noundef %14)
  store i32 %15, ptr %3, align 4
  br label %93

16:                                               ; preds = %2
  %17 = load float, ptr %5, align 4, !tbaa !9
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.fdelay_crcf_s, ptr %18, i32 0, i32 0
  %20 = load i32, ptr %19, align 8, !tbaa !11
  %21 = uitofp i32 %20 to float
  %22 = fcmp ogt float %17, %21
  br i1 %22, label %23, label %30

23:                                               ; preds = %16
  %24 = load float, ptr %5, align 4, !tbaa !9
  %25 = fpext float %24 to double
  %26 = load ptr, ptr %4, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.fdelay_crcf_s, ptr %26, i32 0, i32 0
  %28 = load i32, ptr %27, align 8, !tbaa !11
  %29 = call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 4, ptr noundef @.str, i32 noundef 127, ptr noundef @.str.7, ptr noundef @.str.2, double noundef %25, i32 noundef %28)
  store i32 %29, ptr %3, align 4
  br label %93

30:                                               ; preds = %16
  br label %31

31:                                               ; preds = %30
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  %32 = load ptr, ptr %4, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.fdelay_crcf_s, ptr %32, i32 0, i32 0
  %34 = load i32, ptr %33, align 8, !tbaa !11
  %35 = uitofp i32 %34 to float
  %36 = load float, ptr %5, align 4, !tbaa !9
  %37 = fsub float %35, %36
  store float %37, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  %38 = load float, ptr %6, align 4, !tbaa !9
  %39 = call float @llvm.floor.f32(float %38)
  %40 = fptosi float %39 to i32
  store i32 %40, ptr %7, align 4, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  %41 = load float, ptr %6, align 4, !tbaa !9
  %42 = load i32, ptr %7, align 4, !tbaa !14
  %43 = sitofp i32 %42 to float
  %44 = fsub float %41, %43
  store float %44, ptr %8, align 4, !tbaa !9
  %45 = load i32, ptr %7, align 4, !tbaa !14
  %46 = load ptr, ptr %4, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.fdelay_crcf_s, ptr %46, i32 0, i32 6
  store i32 %45, ptr %47, align 8, !tbaa !15
  %48 = load ptr, ptr %4, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.fdelay_crcf_s, ptr %48, i32 0, i32 2
  %50 = load i32, ptr %49, align 8, !tbaa !16
  %51 = uitofp i32 %50 to float
  %52 = load float, ptr %8, align 4, !tbaa !9
  %53 = fmul float %51, %52
  %54 = call float @llvm.round.f32(float %53)
  %55 = fptoui float %54 to i32
  %56 = load ptr, ptr %4, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.fdelay_crcf_s, ptr %56, i32 0, i32 7
  store i32 %55, ptr %57, align 4, !tbaa !17
  br label %58

58:                                               ; preds = %66, %31
  %59 = load ptr, ptr %4, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.fdelay_crcf_s, ptr %59, i32 0, i32 7
  %61 = load i32, ptr %60, align 4, !tbaa !17
  %62 = load ptr, ptr %4, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.fdelay_crcf_s, ptr %62, i32 0, i32 2
  %64 = load i32, ptr %63, align 8, !tbaa !16
  %65 = icmp uge i32 %61, %64
  br i1 %65, label %66, label %78

66:                                               ; preds = %58
  %67 = load ptr, ptr %4, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.fdelay_crcf_s, ptr %67, i32 0, i32 6
  %69 = load i32, ptr %68, align 8, !tbaa !15
  %70 = add i32 %69, 1
  store i32 %70, ptr %68, align 8, !tbaa !15
  %71 = load ptr, ptr %4, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.fdelay_crcf_s, ptr %71, i32 0, i32 2
  %73 = load i32, ptr %72, align 8, !tbaa !16
  %74 = load ptr, ptr %4, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.fdelay_crcf_s, ptr %74, i32 0, i32 7
  %76 = load i32, ptr %75, align 4, !tbaa !17
  %77 = sub i32 %76, %73
  store i32 %77, ptr %75, align 4, !tbaa !17
  br label %58, !llvm.loop !18

78:                                               ; preds = %58
  %79 = load ptr, ptr %4, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.fdelay_crcf_s, ptr %79, i32 0, i32 6
  %81 = load i32, ptr %80, align 8, !tbaa !15
  %82 = load ptr, ptr %4, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.fdelay_crcf_s, ptr %82, i32 0, i32 0
  %84 = load i32, ptr %83, align 8, !tbaa !11
  %85 = icmp ugt i32 %81, %84
  br i1 %85, label %86, label %88

86:                                               ; preds = %78
  %87 = call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 1, ptr noundef @.str, i32 noundef 145, ptr noundef @.str.8, ptr noundef @.str.2)
  store i32 %87, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %92

88:                                               ; preds = %78
  %89 = load float, ptr %5, align 4, !tbaa !9
  %90 = load ptr, ptr %4, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.fdelay_crcf_s, ptr %90, i32 0, i32 3
  store float %89, ptr %91, align 4, !tbaa !20
  store i32 0, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %92

92:                                               ; preds = %88, %86
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  br label %93

93:                                               ; preds = %92, %23, %12
  %94 = load i32, ptr %3, align 4
  ret i32 %94
}

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

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.round.f32(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 = { "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 = !{!"any pointer", !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, !13, i64 0}
!12 = !{!"fdelay_crcf_s", !13, i64 0, !13, i64 4, !13, i64 8, !10, i64 12, !6, i64 16, !6, i64 24, !13, i64 32, !13, i64 36}
!13 = !{!"int", !7, i64 0}
!14 = !{!13, !13, i64 0}
!15 = !{!12, !13, i64 32}
!16 = !{!12, !13, i64 8}
!17 = !{!12, !13, i64 36}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = !{!12, !10, i64 12}


; 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 [84 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [53 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [61 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [52 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @fdelay_crcf_set_delay(ptr nocapture noundef %0, float noundef %1) local_unnamed_addr #0 {
  %3 = fcmp olt float %1, 0.000000e+00
  br i1 %3, label %4, label %7

4:                                                ; preds = %2
  %5 = fpext float %1 to double
  %6 = tail call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 4, ptr noundef nonnull @.str, i32 noundef 124, ptr noundef nonnull @.str.6, ptr noundef nonnull @.str.2, double noundef %5) #3
  br label %38

7:                                                ; preds = %2
  %8 = load i32, ptr %0, align 8, !tbaa !5
  %9 = uitofp i32 %8 to float
  %10 = fcmp olt float %9, %1
  br i1 %10, label %11, label %14

11:                                               ; preds = %7
  %12 = fpext float %1 to double
  %13 = tail call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 4, ptr noundef nonnull @.str, i32 noundef 127, ptr noundef nonnull @.str.7, ptr noundef nonnull @.str.2, double noundef %12, i32 noundef %8) #3
  br label %38

14:                                               ; preds = %7
  %15 = fsub float %9, %1
  %16 = tail call float @llvm.floor.f32(float %15)
  %17 = fptosi float %16 to i32
  %18 = sitofp i32 %17 to float
  %19 = fsub float %15, %18
  %20 = getelementptr inbounds i8, ptr %0, i64 32
  store i32 %17, ptr %20, align 8, !tbaa !12
  %21 = getelementptr inbounds i8, ptr %0, i64 8
  %22 = load i32, ptr %21, align 8, !tbaa !13
  %23 = uitofp i32 %22 to float
  %24 = fmul float %19, %23
  %25 = tail call float @llvm.round.f32(float %24)
  %26 = fptoui float %25 to i32
  %27 = getelementptr inbounds i8, ptr %0, i64 36
  %.not28 = icmp ugt i32 %22, %26
  br i1 %.not28, label %31, label %.lr.ph

.lr.ph:                                           ; preds = %14, %.lr.ph
  %28 = phi i32 [ %29, %.lr.ph ], [ %17, %14 ]
  %storemerge29 = phi i32 [ %30, %.lr.ph ], [ %26, %14 ]
  %29 = add i32 %28, 1
  %30 = sub i32 %storemerge29, %22
  %.not = icmp ult i32 %30, %22
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !14

._crit_edge:                                      ; preds = %.lr.ph
  store i32 %29, ptr %20, align 8, !tbaa !12
  br label %31

31:                                               ; preds = %._crit_edge, %14
  %32 = phi i32 [ %29, %._crit_edge ], [ %17, %14 ]
  %storemerge.lcssa = phi i32 [ %30, %._crit_edge ], [ %26, %14 ]
  store i32 %storemerge.lcssa, ptr %27, align 4, !tbaa !16
  %33 = icmp ugt i32 %32, %8
  br i1 %33, label %34, label %36

34:                                               ; preds = %31
  %35 = tail call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 1, ptr noundef nonnull @.str, i32 noundef 145, ptr noundef nonnull @.str.8, ptr noundef nonnull @.str.2) #3
  br label %38

36:                                               ; preds = %31
  %37 = getelementptr inbounds i8, ptr %0, i64 12
  store float %1, ptr %37, align 4, !tbaa !17
  br label %38

38:                                               ; preds = %34, %36, %11, %4
  %.1 = phi i32 [ %6, %4 ], [ %13, %11 ], [ %35, %34 ], [ 0, %36 ]
  ret i32 %.1
}

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

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

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.round.f32(float) #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 nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 0}
!6 = !{!"fdelay_crcf_s", !7, i64 0, !7, i64 4, !7, i64 8, !10, i64 12, !11, i64 16, !11, i64 24, !7, i64 32, !7, i64 36}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"float", !8, i64 0}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!6, !7, i64 32}
!13 = !{!6, !7, i64 8}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = !{!6, !7, i64 36}
!17 = !{!6, !10, i64 12}


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