; LLVM IR from jgaeddert/liquid-dsp :: src/buffer/src (buffercf)

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

; 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 allocsize(0)
declare noalias ptr @malloc(i64 noundef) #1

; Function Attrs: nounwind
declare void @free(ptr noundef) #2

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

; Function Attrs: nounwind uwtable
define dso_local ptr @wdelaycf_recreate(ptr noundef %0, i32 noundef %1) #4 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca { float, float }, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.wdelaycf_s, ptr %9, i32 0, i32 1
  %11 = load i32, ptr %10, align 8, !tbaa !11
  %12 = add i32 %11, 1
  store i32 %12, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.wdelaycf_s, ptr %13, i32 0, i32 1
  %15 = load i32, ptr %14, align 8, !tbaa !11
  %16 = add i32 %15, 1
  %17 = zext i32 %16 to i64
  %18 = mul i64 %17, 8
  %19 = call noalias ptr @malloc(i64 noundef %18) #6
  store ptr %19, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  store i32 0, ptr %7, align 4, !tbaa !9
  br label %20

20:                                               ; preds = %53, %2
  %21 = load i32, ptr %7, align 4, !tbaa !9
  %22 = load ptr, ptr %3, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.wdelaycf_s, ptr %22, i32 0, i32 1
  %24 = load i32, ptr %23, align 8, !tbaa !11
  %25 = add i32 %24, 1
  %26 = icmp ult i32 %21, %25
  br i1 %26, label %27, label %56

27:                                               ; preds = %20
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.wdelaycf_s, ptr %28, i32 0, i32 0
  %30 = load ptr, ptr %29, align 8, !tbaa !13
  %31 = load i32, ptr %7, align 4, !tbaa !9
  %32 = load ptr, ptr %3, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.wdelaycf_s, ptr %32, i32 0, i32 2
  %34 = load i32, ptr %33, align 4, !tbaa !14
  %35 = add i32 %31, %34
  %36 = load ptr, ptr %3, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.wdelaycf_s, ptr %36, i32 0, i32 1
  %38 = load i32, ptr %37, align 8, !tbaa !11
  %39 = add i32 %38, 1
  %40 = urem i32 %35, %39
  %41 = zext i32 %40 to i64
  %42 = getelementptr inbounds { float, float }, ptr %30, i64 %41
  %43 = getelementptr inbounds { float, float }, ptr %42, i32 0, i32 0
  %44 = load float, ptr %43, align 4
  %45 = getelementptr inbounds { float, float }, ptr %42, i32 0, i32 1
  %46 = load float, ptr %45, align 4
  %47 = load ptr, ptr %6, align 8, !tbaa !5
  %48 = load i32, ptr %7, align 4, !tbaa !9
  %49 = zext i32 %48 to i64
  %50 = getelementptr inbounds { float, float }, ptr %47, i64 %49
  %51 = getelementptr inbounds { float, float }, ptr %50, i32 0, i32 0
  %52 = getelementptr inbounds { float, float }, ptr %50, i32 0, i32 1
  store float %44, ptr %51, align 4
  store float %46, ptr %52, align 4
  br label %53

53:                                               ; preds = %27
  %54 = load i32, ptr %7, align 4, !tbaa !9
  %55 = add i32 %54, 1
  store i32 %55, ptr %7, align 4, !tbaa !9
  br label %20, !llvm.loop !15

56:                                               ; preds = %20
  %57 = load ptr, ptr %3, align 8, !tbaa !5
  %58 = call i32 @wdelaycf_destroy(ptr noundef %57)
  %59 = load i32, ptr %4, align 4, !tbaa !9
  %60 = call ptr @wdelaycf_create(i32 noundef %59)
  store ptr %60, ptr %3, align 8, !tbaa !5
  store i32 0, ptr %7, align 4, !tbaa !9
  br label %61

61:                                               ; preds = %79, %56
  %62 = load i32, ptr %7, align 4, !tbaa !9
  %63 = load i32, ptr %5, align 4, !tbaa !9
  %64 = icmp ult i32 %62, %63
  br i1 %64, label %65, label %82

65:                                               ; preds = %61
  %66 = load ptr, ptr %3, align 8, !tbaa !5
  %67 = load ptr, ptr %6, align 8, !tbaa !5
  %68 = load i32, ptr %7, align 4, !tbaa !9
  %69 = zext i32 %68 to i64
  %70 = getelementptr inbounds { float, float }, ptr %67, i64 %69
  %71 = getelementptr inbounds { float, float }, ptr %70, i32 0, i32 0
  %72 = load float, ptr %71, align 4
  %73 = getelementptr inbounds { float, float }, ptr %70, i32 0, i32 1
  %74 = load float, ptr %73, align 4
  %75 = getelementptr inbounds { float, float }, ptr %8, i32 0, i32 0
  %76 = getelementptr inbounds { float, float }, ptr %8, i32 0, i32 1
  store float %72, ptr %75, align 4
  store float %74, ptr %76, align 4
  %77 = load <2 x float>, ptr %8, align 4
  %78 = call i32 @wdelaycf_push(ptr noundef %66, <2 x float> noundef %77)
  br label %79

79:                                               ; preds = %65
  %80 = load i32, ptr %7, align 4, !tbaa !9
  %81 = add i32 %80, 1
  store i32 %81, ptr %7, align 4, !tbaa !9
  br label %61, !llvm.loop !17

82:                                               ; preds = %61
  %83 = load ptr, ptr %6, align 8, !tbaa !5
  call void @free(ptr noundef %83) #5
  %84 = load ptr, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  ret ptr %84
}

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @wdelaycf_push(ptr noundef, <2 x float> noundef) #4

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 = { 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 = { 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 uwtable "min-legal-vector-width"="64" "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 #5 = { nounwind }
attributes #6 = { 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 = !{!"any pointer", !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 = !{!12, !10, i64 8}
!12 = !{!"wdelaycf_s", !6, i64 0, !10, i64 8, !10, i64 12}
!13 = !{!12, !6, i64 0}
!14 = !{!12, !10, i64 12}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !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"

; 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

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
define dso_local ptr @wdelaycf_recreate(ptr noundef %0, i32 noundef %1) local_unnamed_addr #3 {
  %3 = getelementptr inbounds i8, ptr %0, i64 8
  %4 = load i32, ptr %3, align 8, !tbaa !5
  %5 = add i32 %4, 1
  %6 = zext i32 %5 to i64
  %7 = shl nuw nsw i64 %6, 3
  %8 = tail call noalias ptr @malloc(i64 noundef %7) #4
  %.not = icmp eq i32 %5, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %2
  %9 = load ptr, ptr %0, align 8, !tbaa !11
  %10 = getelementptr inbounds i8, ptr %0, i64 12
  %11 = load i32, ptr %10, align 4, !tbaa !12
  %xtraiter = and i64 %6, 1
  %12 = icmp eq i32 %4, 0
  br i1 %12, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph.new

.lr.ph.new:                                       ; preds = %.lr.ph
  %unroll_iter = and i64 %6, 4294967294
  br label %13

13:                                               ; preds = %13, %.lr.ph.new
  %indvars.iv = phi i64 [ 0, %.lr.ph.new ], [ %indvars.iv.next.1, %13 ]
  %niter = phi i64 [ 0, %.lr.ph.new ], [ %niter.next.1, %13 ]
  %14 = trunc nuw i64 %indvars.iv to i32
  %15 = add i32 %11, %14
  %16 = urem i32 %15, %5
  %17 = zext i32 %16 to i64
  %18 = getelementptr inbounds { float, float }, ptr %9, i64 %17
  %19 = getelementptr inbounds { float, float }, ptr %8, i64 %indvars.iv
  %20 = load <2 x float>, ptr %18, align 4
  store <2 x float> %20, ptr %19, align 4
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %21 = trunc nuw i64 %indvars.iv.next to i32
  %22 = add i32 %11, %21
  %23 = urem i32 %22, %5
  %24 = zext i32 %23 to i64
  %25 = getelementptr inbounds { float, float }, ptr %9, i64 %24
  %26 = getelementptr inbounds { float, float }, ptr %8, i64 %indvars.iv.next
  %27 = load <2 x float>, ptr %25, align 4
  store <2 x float> %27, ptr %26, align 4
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 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.loopexit.unr-lcssa, label %13, !llvm.loop !13

._crit_edge.loopexit.unr-lcssa:                   ; preds = %13, %.lr.ph
  %indvars.iv.unr = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next.1, %13 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %._crit_edge.loopexit.epilog-lcssa

._crit_edge.loopexit.epilog-lcssa:                ; preds = %._crit_edge.loopexit.unr-lcssa
  %28 = trunc nuw i64 %indvars.iv.unr to i32
  %29 = add i32 %11, %28
  %30 = urem i32 %29, %5
  %31 = zext i32 %30 to i64
  %32 = getelementptr inbounds { float, float }, ptr %9, i64 %31
  %33 = getelementptr inbounds { float, float }, ptr %8, i64 %indvars.iv.unr
  %34 = load <2 x float>, ptr %32, align 4
  store <2 x float> %34, ptr %33, align 4
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit.epilog-lcssa, %._crit_edge.loopexit.unr-lcssa, %2
  %35 = tail call i32 @wdelaycf_destroy(ptr noundef nonnull %0)
  %36 = tail call ptr @wdelaycf_create(i32 noundef %1)
  br i1 %.not, label %._crit_edge26, label %.lr.ph25

.lr.ph25:                                         ; preds = %._crit_edge, %.lr.ph25
  %indvars.iv29 = phi i64 [ %indvars.iv.next30, %.lr.ph25 ], [ 0, %._crit_edge ]
  %37 = getelementptr inbounds { float, float }, ptr %8, i64 %indvars.iv29
  %38 = load <2 x float>, ptr %37, align 4
  %39 = tail call i32 @wdelaycf_push(ptr noundef %36, <2 x float> noundef %38)
  %indvars.iv.next30 = add nuw nsw i64 %indvars.iv29, 1
  %exitcond33.not = icmp eq i64 %indvars.iv.next30, %6
  br i1 %exitcond33.not, label %._crit_edge26, label %.lr.ph25, !llvm.loop !15

._crit_edge26:                                    ; preds = %.lr.ph25, %._crit_edge
  tail call void @free(ptr noundef %8) #5
  ret ptr %36
}

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @wdelaycf_push(ptr noundef, <2 x float> noundef) local_unnamed_addr #3

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 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, 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 #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 uwtable "min-legal-vector-width"="64" "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 allocsize(0) }
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, !10, i64 8}
!6 = !{!"wdelaycf_s", !7, i64 0, !10, i64 8, !10, i64 12}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!6, !7, i64 0}
!12 = !{!6, !10, i64 12}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}


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