; LLVM IR from jgaeddert/liquid-dsp :: src/framing/src (framing_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.bsync_rrrf_s = type { i32, ptr, ptr, ptr, ptr, float }

@.str = external hidden unnamed_addr constant [84 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [72 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 @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_rrrf_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, i32 noundef 81, ptr noundef @.str.1)
  store ptr %16, ptr %3, align 8
  br label %74

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_rrrf_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_rrrf_s, ptr %37, i32 0, i32 2
  store ptr %36, ptr %38, align 8, !tbaa !14
  %39 = load ptr, ptr %7, align 8, !tbaa !9
  %40 = call i32 @msequence_reset(ptr noundef %39)
  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 %41

41:                                               ; preds = %62, %17
  %42 = load i32, ptr %10, align 4, !tbaa !5
  %43 = load i32, ptr %9, align 4, !tbaa !5
  %44 = icmp ult i32 %42, %43
  br i1 %44, label %45, label %65

45:                                               ; preds = %41
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  %46 = load ptr, ptr %7, align 8, !tbaa !9
  %47 = call i32 @msequence_advance(ptr noundef %46)
  store i32 %47, ptr %12, align 4, !tbaa !5
  store i32 0, ptr %11, align 4, !tbaa !5
  br label %48

48:                                               ; preds = %58, %45
  %49 = load i32, ptr %11, align 4, !tbaa !5
  %50 = load i32, ptr %5, align 4, !tbaa !5
  %51 = icmp ult i32 %49, %50
  br i1 %51, label %52, label %61

52:                                               ; preds = %48
  %53 = load ptr, ptr %8, align 8, !tbaa !9
  %54 = getelementptr inbounds %struct.bsync_rrrf_s, ptr %53, i32 0, i32 1
  %55 = load ptr, ptr %54, align 8, !tbaa !11
  %56 = load i32, ptr %12, align 4, !tbaa !5
  %57 = call i32 @bsequence_push(ptr noundef %55, i32 noundef %56)
  br label %58

58:                                               ; preds = %52
  %59 = load i32, ptr %11, align 4, !tbaa !5
  %60 = add i32 %59, 1
  store i32 %60, ptr %11, align 4, !tbaa !5
  br label %48, !llvm.loop !15

61:                                               ; preds = %48
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  br label %62

62:                                               ; preds = %61
  %63 = load i32, ptr %10, align 4, !tbaa !5
  %64 = add i32 %63, 1
  store i32 %64, ptr %10, align 4, !tbaa !5
  br label %41, !llvm.loop !17

65:                                               ; preds = %41
  %66 = load ptr, ptr %7, align 8, !tbaa !9
  %67 = call i32 @msequence_destroy(ptr noundef %66)
  %68 = load i32, ptr %5, align 4, !tbaa !5
  %69 = load i32, ptr %9, align 4, !tbaa !5
  %70 = mul i32 %68, %69
  %71 = load ptr, ptr %8, align 8, !tbaa !9
  %72 = getelementptr inbounds %struct.bsync_rrrf_s, ptr %71, i32 0, i32 0
  store i32 %70, ptr %72, align 8, !tbaa !18
  %73 = load ptr, ptr %8, align 8, !tbaa !9
  store ptr %73, 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 %74

74:                                               ; preds = %65, %15
  %75 = load ptr, ptr %3, align 8
  ret ptr %75
}

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

declare i32 @liquid_msb_index(i32 noundef) #2

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

declare i32 @msequence_get_length(ptr noundef) #2

declare i32 @msequence_reset(ptr noundef) #2

declare i32 @msequence_advance(ptr noundef) #2

declare i32 @msequence_destroy(ptr noundef) #2

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, !10, i64 8}
!12 = !{!"bsync_rrrf_s", !6, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !13, i64 40}
!13 = !{!"float", !7, i64 0}
!14 = !{!12, !10, i64 16}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !16}
!18 = !{!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 = external hidden unnamed_addr constant [84 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [72 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 @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 ptr @bsync_rrrf_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, i32 noundef 81, ptr noundef nonnull @.str.1) #3
  br label %25

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 16
  store ptr %15, ptr %16, align 8, !tbaa !12
  %17 = 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, %22
  %.02730 = phi i32 [ %23, %22 ], [ 0, %6 ]
  %18 = tail call i32 @msequence_advance(ptr noundef %9) #3
  br label %19

19:                                               ; preds = %.lr.ph, %19
  %.02629 = phi i32 [ 0, %.lr.ph ], [ %21, %19 ]
  %20 = tail call i32 @bsequence_push(ptr noundef %13, i32 noundef %18) #3
  %21 = add nuw i32 %.02629, 1
  %exitcond.not = icmp eq i32 %21, %1
  br i1 %exitcond.not, label %22, label %19, !llvm.loop !13

22:                                               ; preds = %19
  %23 = add nuw i32 %.02730, 1
  %exitcond31.not = icmp eq i32 %23, %11
  br i1 %exitcond31.not, label %._crit_edge, label %.lr.ph, !llvm.loop !15

._crit_edge:                                      ; preds = %22, %6
  %24 = tail call i32 @msequence_destroy(ptr noundef %9) #3
  store i32 %12, ptr %10, align 8, !tbaa !16
  br label %25

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

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

declare i32 @liquid_msb_index(i32 noundef) local_unnamed_addr #1

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

declare i32 @msequence_get_length(ptr noundef) local_unnamed_addr #1

declare i32 @msequence_reset(ptr noundef) local_unnamed_addr #1

declare i32 @msequence_advance(ptr noundef) local_unnamed_addr #1

declare i32 @msequence_destroy(ptr noundef) local_unnamed_addr #1

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


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