; LLVM IR from herrkaefer/AccelerateWatch :: AccelerateWatch/Classes/acceleratelib (dsbuffer)

; 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._dsbuffer_t = type { ptr, i64, i64, ptr, i8, ptr, ptr, i64, ptr }

@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [109 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [15 x i8], align 1
@__PRETTY_FUNCTION__.dsbuffer_fir_filter = external hidden unnamed_addr constant [48 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: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #1

; 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 void @dsbuffer_fir_filter(ptr noundef %0, ptr noundef %1) #2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca i32, align 4
  %7 = alloca float, align 4
  %8 = alloca i64, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = icmp ne ptr %9, null
  br i1 %10, label %11, label %12

11:                                               ; preds = %2
  br label %13

12:                                               ; preds = %2
  call void @__assert_fail(ptr noundef @.str.1, ptr noundef @.str.2, i32 noundef 240, ptr noundef @__PRETTY_FUNCTION__.dsbuffer_fir_filter) #4
  unreachable

13:                                               ; preds = %11
  %14 = load ptr, ptr %3, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct._dsbuffer_t, ptr %14, i32 0, i32 6
  %16 = load ptr, ptr %15, align 8, !tbaa !9
  %17 = icmp ne ptr %16, null
  br i1 %17, label %18, label %19

18:                                               ; preds = %13
  br label %20

19:                                               ; preds = %13
  call void @__assert_fail(ptr noundef @.str.10, ptr noundef @.str.2, i32 noundef 241, ptr noundef @__PRETTY_FUNCTION__.dsbuffer_fir_filter) #4
  unreachable

20:                                               ; preds = %18
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = icmp ne ptr %21, null
  br i1 %22, label %23, label %24

23:                                               ; preds = %20
  br label %25

24:                                               ; preds = %20
  call void @__assert_fail(ptr noundef @.str.6, ptr noundef @.str.2, i32 noundef 242, ptr noundef @__PRETTY_FUNCTION__.dsbuffer_fir_filter) #4
  unreachable

25:                                               ; preds = %23
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  store i64 0, ptr %5, align 8, !tbaa !13
  br label %26

26:                                               ; preds = %80, %25
  %27 = load i64, ptr %5, align 8, !tbaa !13
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct._dsbuffer_t, ptr %28, i32 0, i32 1
  %30 = load i64, ptr %29, align 8, !tbaa !14
  %31 = icmp ult i64 %27, %30
  br i1 %31, label %33, label %32

32:                                               ; preds = %26
  store i32 2, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  br label %83

33:                                               ; preds = %26
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  store float 0.000000e+00, ptr %7, align 4, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  store i64 0, ptr %8, align 8, !tbaa !13
  br label %34

34:                                               ; preds = %71, %33
  %35 = load i64, ptr %8, align 8, !tbaa !13
  %36 = load ptr, ptr %3, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct._dsbuffer_t, ptr %36, i32 0, i32 7
  %38 = load i64, ptr %37, align 8, !tbaa !17
  %39 = icmp ult i64 %35, %38
  br i1 %39, label %41, label %40

40:                                               ; preds = %34
  store i32 5, ptr %6, align 4
  br label %74

41:                                               ; preds = %34
  %42 = load i64, ptr %5, align 8, !tbaa !13
  %43 = load i64, ptr %8, align 8, !tbaa !13
  %44 = icmp ult i64 %42, %43
  br i1 %44, label %45, label %46

45:                                               ; preds = %41
  store i32 5, ptr %6, align 4
  br label %74

46:                                               ; preds = %41
  %47 = load ptr, ptr %3, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct._dsbuffer_t, ptr %47, i32 0, i32 6
  %49 = load ptr, ptr %48, align 8, !tbaa !9
  %50 = load i64, ptr %8, align 8, !tbaa !13
  %51 = getelementptr inbounds float, ptr %49, i64 %50
  %52 = load float, ptr %51, align 4, !tbaa !15
  %53 = load ptr, ptr %3, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct._dsbuffer_t, ptr %53, i32 0, i32 0
  %55 = load ptr, ptr %54, align 8, !tbaa !18
  %56 = load ptr, ptr %3, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct._dsbuffer_t, ptr %56, i32 0, i32 2
  %58 = load i64, ptr %57, align 8, !tbaa !19
  %59 = load i64, ptr %5, align 8, !tbaa !13
  %60 = add i64 %58, %59
  %61 = load i64, ptr %8, align 8, !tbaa !13
  %62 = sub i64 %60, %61
  %63 = load ptr, ptr %3, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct._dsbuffer_t, ptr %63, i32 0, i32 1
  %65 = load i64, ptr %64, align 8, !tbaa !14
  %66 = urem i64 %62, %65
  %67 = getelementptr inbounds float, ptr %55, i64 %66
  %68 = load float, ptr %67, align 4, !tbaa !15
  %69 = load float, ptr %7, align 4, !tbaa !15
  %70 = call float @llvm.fmuladd.f32(float %52, float %68, float %69)
  store float %70, ptr %7, align 4, !tbaa !15
  br label %71

71:                                               ; preds = %46
  %72 = load i64, ptr %8, align 8, !tbaa !13
  %73 = add i64 %72, 1
  store i64 %73, ptr %8, align 8, !tbaa !13
  br label %34, !llvm.loop !20

74:                                               ; preds = %45, %40
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  br label %75

75:                                               ; preds = %74
  %76 = load float, ptr %7, align 4, !tbaa !15
  %77 = load ptr, ptr %4, align 8, !tbaa !5
  %78 = load i64, ptr %5, align 8, !tbaa !13
  %79 = getelementptr inbounds float, ptr %77, i64 %78
  store float %76, ptr %79, align 4, !tbaa !15
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  br label %80

80:                                               ; preds = %75
  %81 = load i64, ptr %5, align 8, !tbaa !13
  %82 = add i64 %81, 1
  store i64 %82, ptr %5, align 8, !tbaa !13
  br label %26, !llvm.loop !22

83:                                               ; preds = %32
  ret void
}

; 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 = { noreturn 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 #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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { noreturn nounwind }
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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 48}
!10 = !{!"_dsbuffer_t", !6, i64 0, !11, i64 8, !11, i64 16, !6, i64 24, !12, i64 32, !6, i64 40, !6, i64 48, !11, i64 56, !6, i64 64}
!11 = !{!"long", !7, i64 0}
!12 = !{!"_Bool", !7, i64 0}
!13 = !{!11, !11, i64 0}
!14 = !{!10, !11, i64 8}
!15 = !{!16, !16, i64 0}
!16 = !{!"float", !7, i64 0}
!17 = !{!10, !11, i64 56}
!18 = !{!10, !6, i64 0}
!19 = !{!10, !11, i64 16}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}
!22 = distinct !{!22, !21}


; 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.1 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [109 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [15 x i8], align 1
@__PRETTY_FUNCTION__.dsbuffer_fir_filter = external hidden unnamed_addr constant [48 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @dsbuffer_fir_filter(ptr noundef readonly %0, ptr noundef writeonly %1) local_unnamed_addr #1 {
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %3, label %4

3:                                                ; preds = %2
  tail call void @__assert_fail(ptr noundef nonnull @.str.1, ptr noundef nonnull @.str.2, i32 noundef 240, ptr noundef nonnull @__PRETTY_FUNCTION__.dsbuffer_fir_filter) #5
  unreachable

4:                                                ; preds = %2
  %5 = getelementptr inbounds i8, ptr %0, i64 48
  %6 = load ptr, ptr %5, align 8, !tbaa !5
  %.not25 = icmp eq ptr %6, null
  br i1 %.not25, label %7, label %8

7:                                                ; preds = %4
  tail call void @__assert_fail(ptr noundef nonnull @.str.10, ptr noundef nonnull @.str.2, i32 noundef 241, ptr noundef nonnull @__PRETTY_FUNCTION__.dsbuffer_fir_filter) #5
  unreachable

8:                                                ; preds = %4
  %.not26 = icmp eq ptr %1, null
  br i1 %.not26, label %19, label %.preheader27

.preheader27:                                     ; preds = %8
  %9 = getelementptr inbounds i8, ptr %0, i64 8
  %10 = load i64, ptr %9, align 8, !tbaa !12
  %.not32 = icmp eq i64 %10, 0
  br i1 %.not32, label %._crit_edge31, label %.preheader.lr.ph

.preheader.lr.ph:                                 ; preds = %.preheader27
  %11 = getelementptr inbounds i8, ptr %0, i64 56
  %12 = load i64, ptr %11, align 8, !tbaa !13
  %13 = icmp eq i64 %12, 0
  br i1 %13, label %.preheader.us.preheader, label %.preheader.lr.ph.split

.preheader.us.preheader:                          ; preds = %.preheader.lr.ph
  %14 = shl nuw i64 %10, 2
  tail call void @llvm.memset.p0.i64(ptr nonnull align 4 %1, i8 0, i64 %14, i1 false), !tbaa !14
  br label %._crit_edge31

.preheader.lr.ph.split:                           ; preds = %.preheader.lr.ph
  %15 = getelementptr inbounds i8, ptr %0, i64 16
  %16 = load ptr, ptr %0, align 8, !tbaa !16
  %17 = load i64, ptr %15, align 8, !tbaa !17
  %18 = add i64 %12, -1
  br label %.preheader

19:                                               ; preds = %8
  tail call void @__assert_fail(ptr noundef nonnull @.str.6, ptr noundef nonnull @.str.2, i32 noundef 242, ptr noundef nonnull @__PRETTY_FUNCTION__.dsbuffer_fir_filter) #5
  unreachable

.preheader:                                       ; preds = %.preheader.lr.ph.split, %._crit_edge
  %.02230 = phi i64 [ 0, %.preheader.lr.ph.split ], [ %51, %._crit_edge ]
  %umin35 = tail call i64 @llvm.umin.i64(i64 %.02230, i64 %18)
  %20 = icmp eq i64 %umin35, 0
  br i1 %20, label %._crit_edge.unr-lcssa, label %.preheader.new

.preheader.new:                                   ; preds = %.preheader
  %21 = add nuw i64 %umin35, 1
  %unroll_iter = and i64 %21, -2
  br label %22

._crit_edge31:                                    ; preds = %._crit_edge, %.preheader.us.preheader, %.preheader27
  ret void

22:                                               ; preds = %22, %.preheader.new
  %.029 = phi i64 [ 0, %.preheader.new ], [ %40, %22 ]
  %.02128 = phi float [ 0.000000e+00, %.preheader.new ], [ %39, %22 ]
  %niter = phi i64 [ 0, %.preheader.new ], [ %niter.next.1, %22 ]
  %23 = getelementptr inbounds float, ptr %6, i64 %.029
  %24 = load float, ptr %23, align 4, !tbaa !14
  %25 = sub i64 %.02230, %.029
  %26 = add i64 %25, %17
  %27 = urem i64 %26, %10
  %28 = getelementptr inbounds float, ptr %16, i64 %27
  %29 = load float, ptr %28, align 4, !tbaa !14
  %30 = tail call float @llvm.fmuladd.f32(float %24, float %29, float %.02128)
  %31 = or disjoint i64 %.029, 1
  %32 = getelementptr inbounds float, ptr %6, i64 %31
  %33 = load float, ptr %32, align 4, !tbaa !14
  %34 = sub i64 %.02230, %31
  %35 = add i64 %34, %17
  %36 = urem i64 %35, %10
  %37 = getelementptr inbounds float, ptr %16, i64 %36
  %38 = load float, ptr %37, align 4, !tbaa !14
  %39 = tail call float @llvm.fmuladd.f32(float %33, float %38, float %30)
  %40 = add nuw i64 %.029, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %._crit_edge.unr-lcssa, label %22, !llvm.loop !18

._crit_edge.unr-lcssa:                            ; preds = %22, %.preheader
  %.lcssa.ph = phi float [ poison, %.preheader ], [ %39, %22 ]
  %.029.unr = phi i64 [ 0, %.preheader ], [ %40, %22 ]
  %.02128.unr = phi float [ 0.000000e+00, %.preheader ], [ %39, %22 ]
  %41 = and i64 %umin35, 1
  %lcmp.mod.not.not = icmp eq i64 %41, 0
  br i1 %lcmp.mod.not.not, label %._crit_edge.epilog-lcssa, label %._crit_edge

._crit_edge.epilog-lcssa:                         ; preds = %._crit_edge.unr-lcssa
  %42 = getelementptr inbounds float, ptr %6, i64 %.029.unr
  %43 = load float, ptr %42, align 4, !tbaa !14
  %44 = sub i64 %.02230, %.029.unr
  %45 = add i64 %44, %17
  %46 = urem i64 %45, %10
  %47 = getelementptr inbounds float, ptr %16, i64 %46
  %48 = load float, ptr %47, align 4, !tbaa !14
  %49 = tail call float @llvm.fmuladd.f32(float %43, float %48, float %.02128.unr)
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.unr-lcssa, %._crit_edge.epilog-lcssa
  %.lcssa = phi float [ %.lcssa.ph, %._crit_edge.unr-lcssa ], [ %49, %._crit_edge.epilog-lcssa ]
  %50 = getelementptr inbounds float, ptr %1, i64 %.02230
  store float %.lcssa, ptr %50, align 4, !tbaa !14
  %51 = add nuw i64 %.02230, 1
  %exitcond34.not = icmp eq i64 %51, %10
  br i1 %exitcond34.not, label %._crit_edge31, label %.preheader, !llvm.loop !20
}

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

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #4

attributes #0 = { noreturn 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 #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 nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { noreturn 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 48}
!6 = !{!"_dsbuffer_t", !7, i64 0, !10, i64 8, !10, i64 16, !7, i64 24, !11, i64 32, !7, i64 40, !7, i64 48, !10, i64 56, !7, i64 64}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!"_Bool", !8, i64 0}
!12 = !{!6, !10, i64 8}
!13 = !{!6, !10, i64 56}
!14 = !{!15, !15, i64 0}
!15 = !{!"float", !8, i64 0}
!16 = !{!6, !7, i64 0}
!17 = !{!6, !10, i64 16}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = distinct !{!20, !19}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopIdiomRecognizePass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass