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

@.str.6 = external hidden unnamed_addr constant [84 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [72 x i8], align 1

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

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

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #2

declare ptr @bsequence_create(i32 noundef) #0

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

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

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

15:                                               ; preds = %2
  %16 = call ptr (ptr, i32, ptr, ...) @liquid_error_config_fl(ptr noundef @.str.6, i32 noundef 81, ptr noundef @.str.7)
  store ptr %16, ptr %3, align 8
  br label %91

17:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  %18 = load i32, ptr %4, align 4, !tbaa !5
  %19 = call i32 @liquid_msb_index(i32 noundef %18)
  %20 = sub i32 %19, 1
  store i32 %20, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %21 = load i32, ptr %6, align 4, !tbaa !5
  %22 = load i32, ptr %4, align 4, !tbaa !5
  %23 = call ptr @msequence_create(i32 noundef %21, i32 noundef %22, i32 noundef 1)
  store ptr %23, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %24 = call noalias ptr @malloc(i64 noundef 48) #5
  store ptr %24, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  %25 = load ptr, ptr %7, align 8, !tbaa !9
  %26 = call i32 @msequence_get_length(ptr noundef %25)
  store i32 %26, ptr %9, align 4, !tbaa !5
  %27 = load i32, ptr %9, align 4, !tbaa !5
  %28 = load i32, ptr %5, align 4, !tbaa !5
  %29 = mul i32 %27, %28
  %30 = call ptr @bsequence_create(i32 noundef %29)
  %31 = load ptr, ptr %8, align 8, !tbaa !9
  %32 = getelementptr inbounds %struct.bsync_cccf_s, ptr %31, i32 0, i32 1
  store ptr %30, ptr %32, align 8, !tbaa !11
  %33 = load i32, ptr %9, align 4, !tbaa !5
  %34 = load i32, ptr %5, align 4, !tbaa !5
  %35 = mul i32 %33, %34
  %36 = call ptr @bsequence_create(i32 noundef %35)
  %37 = load ptr, ptr %8, align 8, !tbaa !9
  %38 = getelementptr inbounds %struct.bsync_cccf_s, ptr %37, i32 0, i32 3
  store ptr %36, ptr %38, align 8, !tbaa !13
  %39 = load i32, ptr %9, align 4, !tbaa !5
  %40 = load i32, ptr %5, align 4, !tbaa !5
  %41 = mul i32 %39, %40
  %42 = call ptr @bsequence_create(i32 noundef %41)
  %43 = load ptr, ptr %8, align 8, !tbaa !9
  %44 = getelementptr inbounds %struct.bsync_cccf_s, ptr %43, i32 0, i32 2
  store ptr %42, ptr %44, align 8, !tbaa !14
  %45 = load i32, ptr %9, align 4, !tbaa !5
  %46 = load i32, ptr %5, align 4, !tbaa !5
  %47 = mul i32 %45, %46
  %48 = call ptr @bsequence_create(i32 noundef %47)
  %49 = load ptr, ptr %8, align 8, !tbaa !9
  %50 = getelementptr inbounds %struct.bsync_cccf_s, ptr %49, i32 0, i32 4
  store ptr %48, ptr %50, align 8, !tbaa !15
  %51 = load ptr, ptr %7, align 8, !tbaa !9
  %52 = call i32 @msequence_reset(ptr noundef %51)
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  store i32 0, ptr %10, align 4, !tbaa !5
  br label %53

53:                                               ; preds = %79, %17
  %54 = load i32, ptr %10, align 4, !tbaa !5
  %55 = load i32, ptr %9, align 4, !tbaa !5
  %56 = icmp ult i32 %54, %55
  br i1 %56, label %57, label %82

57:                                               ; preds = %53
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  %58 = load ptr, ptr %7, align 8, !tbaa !9
  %59 = call i32 @msequence_advance(ptr noundef %58)
  store i32 %59, ptr %12, align 4, !tbaa !5
  store i32 0, ptr %11, align 4, !tbaa !5
  br label %60

60:                                               ; preds = %75, %57
  %61 = load i32, ptr %11, align 4, !tbaa !5
  %62 = load i32, ptr %5, align 4, !tbaa !5
  %63 = icmp ult i32 %61, %62
  br i1 %63, label %64, label %78

64:                                               ; preds = %60
  %65 = load ptr, ptr %8, align 8, !tbaa !9
  %66 = getelementptr inbounds %struct.bsync_cccf_s, ptr %65, i32 0, i32 1
  %67 = load ptr, ptr %66, align 8, !tbaa !11
  %68 = load i32, ptr %12, align 4, !tbaa !5
  %69 = call i32 @bsequence_push(ptr noundef %67, i32 noundef %68)
  %70 = load ptr, ptr %8, align 8, !tbaa !9
  %71 = getelementptr inbounds %struct.bsync_cccf_s, ptr %70, i32 0, i32 3
  %72 = load ptr, ptr %71, align 8, !tbaa !13
  %73 = load i32, ptr %12, align 4, !tbaa !5
  %74 = call i32 @bsequence_push(ptr noundef %72, i32 noundef %73)
  br label %75

75:                                               ; preds = %64
  %76 = load i32, ptr %11, align 4, !tbaa !5
  %77 = add i32 %76, 1
  store i32 %77, ptr %11, align 4, !tbaa !5
  br label %60, !llvm.loop !16

78:                                               ; preds = %60
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  br label %79

79:                                               ; preds = %78
  %80 = load i32, ptr %10, align 4, !tbaa !5
  %81 = add i32 %80, 1
  store i32 %81, ptr %10, align 4, !tbaa !5
  br label %53, !llvm.loop !18

82:                                               ; preds = %53
  %83 = load ptr, ptr %7, align 8, !tbaa !9
  %84 = call i32 @msequence_destroy(ptr noundef %83)
  %85 = load i32, ptr %5, align 4, !tbaa !5
  %86 = load i32, ptr %9, align 4, !tbaa !5
  %87 = mul i32 %85, %86
  %88 = load ptr, ptr %8, align 8, !tbaa !9
  %89 = getelementptr inbounds %struct.bsync_cccf_s, ptr %88, i32 0, i32 0
  store i32 %87, ptr %89, align 8, !tbaa !19
  %90 = load ptr, ptr %8, align 8, !tbaa !9
  store ptr %90, ptr %3, align 8
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  br label %91

91:                                               ; preds = %82, %15
  %92 = load ptr, ptr %3, align 8
  ret ptr %92
}

declare i32 @liquid_msb_index(i32 noundef) #0

declare ptr @msequence_create(i32 noundef, i32 noundef, i32 noundef) #0

declare i32 @msequence_get_length(ptr noundef) #0

declare i32 @msequence_reset(ptr noundef) #0

declare i32 @msequence_advance(ptr noundef) #0

declare i32 @msequence_destroy(ptr noundef) #0

attributes #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #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, !10, i64 8}
!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 24}
!14 = !{!12, !10, i64 16}
!15 = !{!12, !10, i64 32}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = distinct !{!18, !17}
!19 = !{!12, !6, i64 0}


; 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.6 = external hidden unnamed_addr constant [84 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [72 x i8], align 1

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

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

declare ptr @bsequence_create(i32 noundef) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
define dso_local ptr @bsync_cccf_create_msequence(i32 noundef %0, i32 noundef %1) local_unnamed_addr #2 {
  %3 = icmp eq i32 %1, 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.6, i32 noundef 81, ptr noundef nonnull @.str.7) #3
  br label %30

6:                                                ; preds = %2
  %7 = tail call i32 @liquid_msb_index(i32 noundef %0) #3
  %8 = add i32 %7, -1
  %9 = tail call ptr @msequence_create(i32 noundef %8, i32 noundef %0, i32 noundef 1) #3
  %10 = tail call noalias dereferenceable_or_null(48) ptr @malloc(i64 noundef 48) #4
  %11 = tail call i32 @msequence_get_length(ptr noundef %9) #3
  %12 = mul i32 %11, %1
  %13 = tail call ptr @bsequence_create(i32 noundef %12) #3
  %14 = getelementptr inbounds i8, ptr %10, i64 8
  store ptr %13, ptr %14, align 8, !tbaa !5
  %15 = tail call ptr @bsequence_create(i32 noundef %12) #3
  %16 = getelementptr inbounds i8, ptr %10, i64 24
  store ptr %15, ptr %16, align 8, !tbaa !11
  %17 = tail call ptr @bsequence_create(i32 noundef %12) #3
  %18 = getelementptr inbounds i8, ptr %10, i64 16
  store ptr %17, ptr %18, align 8, !tbaa !12
  %19 = tail call ptr @bsequence_create(i32 noundef %12) #3
  %20 = getelementptr inbounds i8, ptr %10, i64 32
  store ptr %19, ptr %20, align 8, !tbaa !13
  %21 = tail call i32 @msequence_reset(ptr noundef %9) #3
  %.not = icmp eq i32 %11, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %6, %27
  %.03538 = phi i32 [ %28, %27 ], [ 0, %6 ]
  %22 = tail call i32 @msequence_advance(ptr noundef %9) #3
  br label %23

23:                                               ; preds = %.lr.ph, %23
  %.03437 = phi i32 [ 0, %.lr.ph ], [ %26, %23 ]
  %24 = tail call i32 @bsequence_push(ptr noundef %13, i32 noundef %22) #3
  %25 = tail call i32 @bsequence_push(ptr noundef %15, i32 noundef %22) #3
  %26 = add nuw i32 %.03437, 1
  %exitcond.not = icmp eq i32 %26, %1
  br i1 %exitcond.not, label %27, label %23, !llvm.loop !14

27:                                               ; preds = %23
  %28 = add nuw i32 %.03538, 1
  %exitcond39.not = icmp eq i32 %28, %11
  br i1 %exitcond39.not, label %._crit_edge, label %.lr.ph, !llvm.loop !16

._crit_edge:                                      ; preds = %27, %6
  %29 = tail call i32 @msequence_destroy(ptr noundef %9) #3
  store i32 %12, ptr %10, align 8, !tbaa !17
  br label %30

30:                                               ; preds = %._crit_edge, %4
  %.0 = phi ptr [ %5, %4 ], [ %10, %._crit_edge ]
  ret ptr %.0
}

declare i32 @liquid_msb_index(i32 noundef) local_unnamed_addr #0

declare ptr @msequence_create(i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

declare i32 @msequence_get_length(ptr noundef) local_unnamed_addr #0

declare i32 @msequence_reset(ptr noundef) local_unnamed_addr #0

declare i32 @msequence_advance(ptr noundef) local_unnamed_addr #0

declare i32 @msequence_destroy(ptr noundef) local_unnamed_addr #0

attributes #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 = { 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 #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, !10, i64 8}
!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 24}
!12 = !{!6, !10, i64 16}
!13 = !{!6, !10, i64 32}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = distinct !{!16, !15}
!17 = !{!6, !7, i64 0}


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