; LLVM IR from jgaeddert/liquid-dsp :: src/framing/src (framing_cccf)

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

; 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 @bsequence_create(i32 noundef) #2

declare i32 @bsequence_push(ptr noundef, i32 noundef) #2

; 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 ptr @bsync_cccf_create(i32 noundef %0, ptr noundef %1) #3 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  store i32 %0, ptr %3, align 4, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  %7 = call noalias ptr @malloc(i64 noundef 48) #5
  store ptr %7, ptr %5, align 8, !tbaa !9
  %8 = load i32, ptr %3, align 4, !tbaa !5
  %9 = load ptr, ptr %5, align 8, !tbaa !9
  %10 = getelementptr inbounds %struct.bsync_cccf_s, ptr %9, i32 0, i32 0
  store i32 %8, ptr %10, align 8, !tbaa !11
  %11 = load ptr, ptr %5, align 8, !tbaa !9
  %12 = getelementptr inbounds %struct.bsync_cccf_s, ptr %11, i32 0, i32 0
  %13 = load i32, ptr %12, align 8, !tbaa !11
  %14 = call ptr @bsequence_create(i32 noundef %13)
  %15 = load ptr, ptr %5, align 8, !tbaa !9
  %16 = getelementptr inbounds %struct.bsync_cccf_s, ptr %15, i32 0, i32 1
  store ptr %14, ptr %16, align 8, !tbaa !13
  %17 = load ptr, ptr %5, align 8, !tbaa !9
  %18 = getelementptr inbounds %struct.bsync_cccf_s, ptr %17, i32 0, i32 0
  %19 = load i32, ptr %18, align 8, !tbaa !11
  %20 = call ptr @bsequence_create(i32 noundef %19)
  %21 = load ptr, ptr %5, align 8, !tbaa !9
  %22 = getelementptr inbounds %struct.bsync_cccf_s, ptr %21, i32 0, i32 3
  store ptr %20, ptr %22, align 8, !tbaa !14
  %23 = load ptr, ptr %5, align 8, !tbaa !9
  %24 = getelementptr inbounds %struct.bsync_cccf_s, ptr %23, i32 0, i32 0
  %25 = load i32, ptr %24, align 8, !tbaa !11
  %26 = call ptr @bsequence_create(i32 noundef %25)
  %27 = load ptr, ptr %5, align 8, !tbaa !9
  %28 = getelementptr inbounds %struct.bsync_cccf_s, ptr %27, i32 0, i32 2
  store ptr %26, ptr %28, align 8, !tbaa !15
  %29 = load ptr, ptr %5, align 8, !tbaa !9
  %30 = getelementptr inbounds %struct.bsync_cccf_s, ptr %29, i32 0, i32 0
  %31 = load i32, ptr %30, align 8, !tbaa !11
  %32 = call ptr @bsequence_create(i32 noundef %31)
  %33 = load ptr, ptr %5, align 8, !tbaa !9
  %34 = getelementptr inbounds %struct.bsync_cccf_s, ptr %33, i32 0, i32 4
  store ptr %32, ptr %34, align 8, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %35

35:                                               ; preds = %70, %2
  %36 = load i32, ptr %6, align 4, !tbaa !5
  %37 = load ptr, ptr %5, align 8, !tbaa !9
  %38 = getelementptr inbounds %struct.bsync_cccf_s, ptr %37, i32 0, i32 0
  %39 = load i32, ptr %38, align 8, !tbaa !11
  %40 = icmp ult i32 %36, %39
  br i1 %40, label %41, label %73

41:                                               ; preds = %35
  %42 = load ptr, ptr %5, align 8, !tbaa !9
  %43 = getelementptr inbounds %struct.bsync_cccf_s, ptr %42, i32 0, i32 1
  %44 = load ptr, ptr %43, align 8, !tbaa !13
  %45 = load ptr, ptr %4, align 8, !tbaa !9
  %46 = load i32, ptr %6, align 4, !tbaa !5
  %47 = zext i32 %46 to i64
  %48 = getelementptr inbounds { float, float }, ptr %45, i64 %47
  %49 = getelementptr inbounds { float, float }, ptr %48, i32 0, i32 0
  %50 = load float, ptr %49, align 4
  %51 = getelementptr inbounds { float, float }, ptr %48, i32 0, i32 1
  %52 = load float, ptr %51, align 4
  %53 = fcmp ogt float %50, 0.000000e+00
  %54 = zext i1 %53 to i32
  %55 = call i32 @bsequence_push(ptr noundef %44, i32 noundef %54)
  %56 = load ptr, ptr %5, align 8, !tbaa !9
  %57 = getelementptr inbounds %struct.bsync_cccf_s, ptr %56, i32 0, i32 3
  %58 = load ptr, ptr %57, align 8, !tbaa !14
  %59 = load ptr, ptr %4, align 8, !tbaa !9
  %60 = load i32, ptr %6, align 4, !tbaa !5
  %61 = zext i32 %60 to i64
  %62 = getelementptr inbounds { float, float }, ptr %59, i64 %61
  %63 = getelementptr inbounds { float, float }, ptr %62, i32 0, i32 0
  %64 = load float, ptr %63, align 4
  %65 = getelementptr inbounds { float, float }, ptr %62, i32 0, i32 1
  %66 = load float, ptr %65, align 4
  %67 = fcmp ogt float %66, 0.000000e+00
  %68 = zext i1 %67 to i32
  %69 = call i32 @bsequence_push(ptr noundef %58, i32 noundef %68)
  br label %70

70:                                               ; preds = %41
  %71 = load i32, ptr %6, align 4, !tbaa !5
  %72 = add i32 %71, 1
  store i32 %72, ptr %6, align 4, !tbaa !5
  br label %35, !llvm.loop !17

73:                                               ; preds = %35
  %74 = load ptr, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  ret ptr %74
}

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 = !{!"bsync_cccf_s", !6, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !7, i64 40}
!13 = !{!12, !10, i64 8}
!14 = !{!12, !10, i64 24}
!15 = !{!12, !10, i64 16}
!16 = !{!12, !10, i64 32}
!17 = distinct !{!17, !18}
!18 = !{!"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"

; 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 @bsequence_create(i32 noundef) local_unnamed_addr #1

declare i32 @bsequence_push(ptr noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local noalias noundef ptr @bsync_cccf_create(i32 noundef %0, ptr nocapture noundef readonly %1) local_unnamed_addr #2 {
  %3 = tail call noalias dereferenceable_or_null(48) ptr @malloc(i64 noundef 48) #3
  store i32 %0, ptr %3, align 8, !tbaa !5
  %4 = tail call ptr @bsequence_create(i32 noundef %0) #4
  %5 = getelementptr inbounds i8, ptr %3, i64 8
  store ptr %4, ptr %5, align 8, !tbaa !11
  %6 = tail call ptr @bsequence_create(i32 noundef %0) #4
  %7 = getelementptr inbounds i8, ptr %3, i64 24
  store ptr %6, ptr %7, align 8, !tbaa !12
  %8 = tail call ptr @bsequence_create(i32 noundef %0) #4
  %9 = getelementptr inbounds i8, ptr %3, i64 16
  store ptr %8, ptr %9, align 8, !tbaa !13
  %10 = tail call ptr @bsequence_create(i32 noundef %0) #4
  %11 = getelementptr inbounds i8, ptr %3, i64 32
  store ptr %10, ptr %11, align 8, !tbaa !14
  %.not = icmp eq i32 %0, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %2
  %wide.trip.count = zext i32 %0 to i64
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next, %.lr.ph ]
  %12 = getelementptr inbounds { float, float }, ptr %1, i64 %indvars.iv
  %13 = load float, ptr %12, align 4
  %14 = getelementptr inbounds i8, ptr %12, i64 4
  %15 = fcmp ogt float %13, 0.000000e+00
  %16 = zext i1 %15 to i32
  %17 = tail call i32 @bsequence_push(ptr noundef %4, i32 noundef %16) #4
  %18 = load float, ptr %14, align 4
  %19 = fcmp ogt float %18, 0.000000e+00
  %20 = zext i1 %19 to i32
  %21 = tail call i32 @bsequence_push(ptr noundef %6, i32 noundef %20) #4
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !15

._crit_edge:                                      ; preds = %.lr.ph, %2
  ret ptr %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 = { "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 allocsize(0) }
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, !7, i64 0}
!6 = !{!"bsync_cccf_s", !7, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !8, i64 40}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !10, i64 8}
!12 = !{!6, !10, i64 24}
!13 = !{!6, !10, i64 16}
!14 = !{!6, !10, i64 32}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}


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