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

; 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_crcf_s = type { i32, ptr, ptr, ptr, ptr, { float, 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_crcf_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 %80

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_crcf_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_crcf_s, ptr %37, i32 0, i32 2
  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_crcf_s, ptr %43, i32 0, i32 4
  store ptr %42, ptr %44, align 8, !tbaa !14
  %45 = load ptr, ptr %7, align 8, !tbaa !9
  %46 = call i32 @msequence_reset(ptr noundef %45)
  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 %47

47:                                               ; preds = %68, %17
  %48 = load i32, ptr %10, align 4, !tbaa !5
  %49 = load i32, ptr %9, align 4, !tbaa !5
  %50 = icmp ult i32 %48, %49
  br i1 %50, label %51, label %71

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

54:                                               ; preds = %64, %51
  %55 = load i32, ptr %11, align 4, !tbaa !5
  %56 = load i32, ptr %5, align 4, !tbaa !5
  %57 = icmp ult i32 %55, %56
  br i1 %57, label %58, label %67

58:                                               ; preds = %54
  %59 = load ptr, ptr %8, align 8, !tbaa !9
  %60 = getelementptr inbounds %struct.bsync_crcf_s, ptr %59, i32 0, i32 1
  %61 = load ptr, ptr %60, align 8, !tbaa !11
  %62 = load i32, ptr %12, align 4, !tbaa !5
  %63 = call i32 @bsequence_push(ptr noundef %61, i32 noundef %62)
  br label %64

64:                                               ; preds = %58
  %65 = load i32, ptr %11, align 4, !tbaa !5
  %66 = add i32 %65, 1
  store i32 %66, ptr %11, align 4, !tbaa !5
  br label %54, !llvm.loop !15

67:                                               ; preds = %54
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  br label %68

68:                                               ; preds = %67
  %69 = load i32, ptr %10, align 4, !tbaa !5
  %70 = add i32 %69, 1
  store i32 %70, ptr %10, align 4, !tbaa !5
  br label %47, !llvm.loop !17

71:                                               ; preds = %47
  %72 = load ptr, ptr %7, align 8, !tbaa !9
  %73 = call i32 @msequence_destroy(ptr noundef %72)
  %74 = load i32, ptr %5, align 4, !tbaa !5
  %75 = load i32, ptr %9, align 4, !tbaa !5
  %76 = mul i32 %74, %75
  %77 = load ptr, ptr %8, align 8, !tbaa !9
  %78 = getelementptr inbounds %struct.bsync_crcf_s, ptr %77, i32 0, i32 0
  store i32 %76, ptr %78, align 8, !tbaa !18
  %79 = load ptr, ptr %8, align 8, !tbaa !9
  store ptr %79, 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 %80

80:                                               ; preds = %71, %15
  %81 = load ptr, ptr %3, align 8
  ret ptr %81
}

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_crcf_s", !6, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !7, i64 40}
!13 = !{!12, !10, i64 16}
!14 = !{!12, !10, i64 32}
!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_crcf_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 %27

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 !11
  %17 = tail call ptr @bsequence_create(i32 noundef %12) #3
  %18 = getelementptr inbounds i8, ptr %10, i64 32
  store ptr %17, ptr %18, align 8, !tbaa !12
  %19 = 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, %24
  %.03033 = phi i32 [ %25, %24 ], [ 0, %6 ]
  %20 = tail call i32 @msequence_advance(ptr noundef %9) #3
  br label %21

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

24:                                               ; preds = %21
  %25 = add nuw i32 %.03033, 1
  %exitcond34.not = icmp eq i32 %25, %11
  br i1 %exitcond34.not, label %._crit_edge, label %.lr.ph, !llvm.loop !15

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

27:                                               ; 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_crcf_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 16}
!12 = !{!6, !10, i64 32}
!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