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

; 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.ordfilt_rrrf_s = type { i32, i32, ptr, ptr }

@.str.3 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.139 = external hidden unnamed_addr constant [85 x i8], align 1
@.str.140 = external hidden unnamed_addr constant [61 x i8], align 1
@.str.141 = external hidden unnamed_addr constant [53 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: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #1

declare ptr @windowf_create(i32 noundef) #2

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

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

; Function Attrs: nounwind uwtable
define dso_local ptr @ordfilt_rrrf_create(i32 noundef %0, i32 noundef %1) #3 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  store i32 %0, ptr %4, align 4, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !5
  %7 = load i32, ptr %4, align 4, !tbaa !5
  %8 = icmp eq i32 %7, 0
  br i1 %8, label %9, label %11

9:                                                ; preds = %2
  %10 = call ptr (ptr, i32, ptr, ...) @liquid_error_config_fl(ptr noundef @.str.139, i32 noundef 71, ptr noundef @.str.140, ptr noundef @.str.3)
  store ptr %10, ptr %3, align 8
  br label %42

11:                                               ; preds = %2
  %12 = load i32, ptr %5, align 4, !tbaa !5
  %13 = load i32, ptr %4, align 4, !tbaa !5
  %14 = icmp uge i32 %12, %13
  br i1 %14, label %15, label %17

15:                                               ; preds = %11
  %16 = call ptr (ptr, i32, ptr, ...) @liquid_error_config_fl(ptr noundef @.str.139, i32 noundef 73, ptr noundef @.str.141, ptr noundef @.str.3)
  store ptr %16, ptr %3, align 8
  br label %42

17:                                               ; preds = %11
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %18 = call noalias ptr @malloc(i64 noundef 24) #5
  store ptr %18, ptr %6, align 8, !tbaa !9
  %19 = load i32, ptr %4, align 4, !tbaa !5
  %20 = load ptr, ptr %6, align 8, !tbaa !9
  %21 = getelementptr inbounds %struct.ordfilt_rrrf_s, ptr %20, i32 0, i32 0
  store i32 %19, ptr %21, align 8, !tbaa !11
  %22 = load i32, ptr %5, align 4, !tbaa !5
  %23 = load ptr, ptr %6, align 8, !tbaa !9
  %24 = getelementptr inbounds %struct.ordfilt_rrrf_s, ptr %23, i32 0, i32 1
  store i32 %22, ptr %24, align 4, !tbaa !13
  %25 = load ptr, ptr %6, align 8, !tbaa !9
  %26 = getelementptr inbounds %struct.ordfilt_rrrf_s, ptr %25, i32 0, i32 0
  %27 = load i32, ptr %26, align 8, !tbaa !11
  %28 = call ptr @windowf_create(i32 noundef %27)
  %29 = load ptr, ptr %6, align 8, !tbaa !9
  %30 = getelementptr inbounds %struct.ordfilt_rrrf_s, ptr %29, i32 0, i32 2
  store ptr %28, ptr %30, align 8, !tbaa !14
  %31 = load ptr, ptr %6, align 8, !tbaa !9
  %32 = getelementptr inbounds %struct.ordfilt_rrrf_s, ptr %31, i32 0, i32 0
  %33 = load i32, ptr %32, align 8, !tbaa !11
  %34 = zext i32 %33 to i64
  %35 = mul i64 %34, 4
  %36 = call noalias ptr @malloc(i64 noundef %35) #5
  %37 = load ptr, ptr %6, align 8, !tbaa !9
  %38 = getelementptr inbounds %struct.ordfilt_rrrf_s, ptr %37, i32 0, i32 3
  store ptr %36, ptr %38, align 8, !tbaa !15
  %39 = load ptr, ptr %6, align 8, !tbaa !9
  %40 = call i32 @ordfilt_rrrf_reset(ptr noundef %39)
  %41 = load ptr, ptr %6, align 8, !tbaa !9
  store ptr %41, ptr %3, align 8
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  br label %42

42:                                               ; preds = %17, %15, %9
  %43 = load ptr, ptr %3, align 8
  ret ptr %43
}

; Function Attrs: nounwind uwtable
declare dso_local i32 @ordfilt_rrrf_reset(ptr noundef) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind allocsize(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 = { 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 #4 = { nounwind }
attributes #5 = { nounwind allocsize(0) }

!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 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"ordfilt_rrrf_s", !6, i64 0, !6, i64 4, !10, i64 8, !10, i64 16}
!13 = !{!12, !6, i64 4}
!14 = !{!12, !10, i64 8}
!15 = !{!12, !10, i64 16}


; 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.3 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.139 = external hidden unnamed_addr constant [85 x i8], align 1
@.str.140 = external hidden unnamed_addr constant [61 x i8], align 1
@.str.141 = external hidden unnamed_addr constant [53 x i8], align 1

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #0

declare ptr @windowf_create(i32 noundef) local_unnamed_addr #1

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

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

4:                                                ; preds = %2
  %5 = tail call ptr (ptr, i32, ptr, ...) @liquid_error_config_fl(ptr noundef nonnull @.str.139, i32 noundef 71, ptr noundef nonnull @.str.140, ptr noundef nonnull @.str.3) #3
  br label %19

6:                                                ; preds = %2
  %.not = icmp ult i32 %1, %0
  br i1 %.not, label %9, label %7

7:                                                ; preds = %6
  %8 = tail call ptr (ptr, i32, ptr, ...) @liquid_error_config_fl(ptr noundef nonnull @.str.139, i32 noundef 73, ptr noundef nonnull @.str.141, ptr noundef nonnull @.str.3) #3
  br label %19

9:                                                ; preds = %6
  %10 = tail call noalias dereferenceable_or_null(24) ptr @malloc(i64 noundef 24) #4
  store i32 %0, ptr %10, align 8, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %10, i64 4
  store i32 %1, ptr %11, align 4, !tbaa !11
  %12 = tail call ptr @windowf_create(i32 noundef %0) #3
  %13 = getelementptr inbounds i8, ptr %10, i64 8
  store ptr %12, ptr %13, align 8, !tbaa !12
  %14 = zext i32 %0 to i64
  %15 = shl nuw nsw i64 %14, 2
  %16 = tail call noalias ptr @malloc(i64 noundef %15) #4
  %17 = getelementptr inbounds i8, ptr %10, i64 16
  store ptr %16, ptr %17, align 8, !tbaa !13
  %18 = tail call i32 @ordfilt_rrrf_reset(ptr noundef nonnull %10)
  br label %19

19:                                               ; preds = %9, %7, %4
  %.0 = phi ptr [ %5, %4 ], [ %8, %7 ], [ %10, %9 ]
  ret ptr %.0
}

; Function Attrs: nounwind uwtable
declare dso_local i32 @ordfilt_rrrf_reset(ptr noundef) local_unnamed_addr #2

attributes #0 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { 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 }
attributes #4 = { nounwind allocsize(0) }

!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 = !{!"ordfilt_rrrf_s", !7, i64 0, !7, i64 4, !10, i64 8, !10, i64 16}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !7, i64 4}
!12 = !{!6, !10, i64 8}
!13 = !{!6, !10, i64 16}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,TailCallElimPass