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

@.str.35 = external hidden unnamed_addr constant [85 x i8], align 1
@.str.40 = external hidden unnamed_addr constant [46 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

declare i32 @liquid_error_fl(i32 noundef, ptr noundef, i32 noundef, ptr noundef, ...) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @qdsync_cccf_execute(ptr noundef %0, ptr noundef %1, i32 noundef %2) #2 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca { float, float }, align 4
  %10 = alloca { float, float }, align 4
  %11 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i32 %2, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  store i32 0, ptr %8, align 4, !tbaa !9
  br label %12

12:                                               ; preds = %51, %3
  %13 = load i32, ptr %8, align 4, !tbaa !9
  %14 = load i32, ptr %7, align 4, !tbaa !9
  %15 = icmp ult i32 %13, %14
  br i1 %15, label %16, label %54

16:                                               ; preds = %12
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.qdsync_cccf_s, ptr %17, i32 0, i32 8
  %19 = load i32, ptr %18, align 8, !tbaa !11
  switch i32 %19, label %48 [
    i32 0, label %20
    i32 1, label %34
  ]

20:                                               ; preds = %16
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = load ptr, ptr %6, align 8, !tbaa !5
  %23 = load i32, ptr %8, align 4, !tbaa !9
  %24 = zext i32 %23 to i64
  %25 = getelementptr inbounds { float, float }, ptr %22, i64 %24
  %26 = getelementptr inbounds { float, float }, ptr %25, i32 0, i32 0
  %27 = load float, ptr %26, align 4
  %28 = getelementptr inbounds { float, float }, ptr %25, i32 0, i32 1
  %29 = load float, ptr %28, align 4
  %30 = getelementptr inbounds { float, float }, ptr %9, i32 0, i32 0
  %31 = getelementptr inbounds { float, float }, ptr %9, i32 0, i32 1
  store float %27, ptr %30, align 4
  store float %29, ptr %31, align 4
  %32 = load <2 x float>, ptr %9, align 4
  %33 = call i32 @qdsync_cccf_execute_detect(ptr noundef %21, <2 x float> noundef %32)
  br label %50

34:                                               ; preds = %16
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = load ptr, ptr %6, align 8, !tbaa !5
  %37 = load i32, ptr %8, align 4, !tbaa !9
  %38 = zext i32 %37 to i64
  %39 = getelementptr inbounds { float, float }, ptr %36, i64 %38
  %40 = getelementptr inbounds { float, float }, ptr %39, i32 0, i32 0
  %41 = load float, ptr %40, align 4
  %42 = getelementptr inbounds { float, float }, ptr %39, i32 0, i32 1
  %43 = load float, ptr %42, align 4
  %44 = getelementptr inbounds { float, float }, ptr %10, i32 0, i32 0
  %45 = getelementptr inbounds { float, float }, ptr %10, i32 0, i32 1
  store float %41, ptr %44, align 4
  store float %43, ptr %45, align 4
  %46 = load <2 x float>, ptr %10, align 4
  %47 = call i32 @qdsync_cccf_step(ptr noundef %35, <2 x float> noundef %46)
  br label %50

48:                                               ; preds = %16
  %49 = call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 1, ptr noundef @.str.35, i32 noundef 286, ptr noundef @.str.40)
  store i32 %49, ptr %4, align 4
  store i32 1, ptr %11, align 4
  br label %55

50:                                               ; preds = %34, %20
  br label %51

51:                                               ; preds = %50
  %52 = load i32, ptr %8, align 4, !tbaa !9
  %53 = add i32 %52, 1
  store i32 %53, ptr %8, align 4, !tbaa !9
  br label %12, !llvm.loop !14

54:                                               ; preds = %12
  store i32 0, ptr %4, align 4
  store i32 1, ptr %11, align 4
  br label %55

55:                                               ; preds = %54, %48
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  %56 = load i32, ptr %4, align 4
  ret i32 %56
}

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

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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"="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 #3 = { 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, !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 48}
!12 = !{!"qdsync_cccf_s", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !13, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !10, i64 48, !10, i64 52, !6, i64 56, !6, i64 64, !10, i64 72, !10, i64 76, !10, i64 80, !10, i64 84, !6, i64 88, !10, i64 96}
!13 = !{!"float", !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"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"

@.str.35 = external hidden unnamed_addr constant [85 x i8], align 1
@.str.40 = external hidden unnamed_addr constant [46 x i8], align 1

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

; Function Attrs: nounwind uwtable
define dso_local i32 @qdsync_cccf_execute(ptr noundef %0, ptr nocapture noundef readonly %1, i32 noundef %2) local_unnamed_addr #1 {
  %.not = icmp eq i32 %2, 0
  br i1 %.not, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %3
  %4 = getelementptr inbounds i8, ptr %0, i64 48
  %wide.trip.count = zext i32 %2 to i64
  br label %5

5:                                                ; preds = %.lr.ph, %17
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %17 ]
  %6 = load i32, ptr %4, align 8, !tbaa !5
  switch i32 %6, label %15 [
    i32 0, label %7
    i32 1, label %11
  ]

7:                                                ; preds = %5
  %8 = getelementptr inbounds { float, float }, ptr %1, i64 %indvars.iv
  %9 = load <2 x float>, ptr %8, align 4
  %10 = tail call i32 @qdsync_cccf_execute_detect(ptr noundef nonnull %0, <2 x float> noundef %9)
  br label %17

11:                                               ; preds = %5
  %12 = getelementptr inbounds { float, float }, ptr %1, i64 %indvars.iv
  %13 = load <2 x float>, ptr %12, align 4
  %14 = tail call i32 @qdsync_cccf_step(ptr noundef nonnull %0, <2 x float> noundef %13)
  br label %17

15:                                               ; preds = %5
  %16 = tail call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 1, ptr noundef nonnull @.str.35, i32 noundef 286, ptr noundef nonnull @.str.40) #2
  br label %.loopexit

17:                                               ; preds = %7, %11
  %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 %.loopexit, label %5, !llvm.loop !12

.loopexit:                                        ; preds = %17, %3, %15
  %.013 = phi i32 [ %16, %15 ], [ 0, %3 ], [ 0, %17 ]
  ret i32 %.013
}

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

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

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 = { 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 #2 = { 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 48}
!6 = !{!"qdsync_cccf_s", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !10, i64 16, !11, i64 24, !11, i64 32, !11, i64 40, !7, i64 48, !7, i64 52, !11, i64 56, !11, i64 64, !7, i64 72, !7, i64 76, !7, i64 80, !7, i64 84, !11, i64 88, !7, i64 96}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"float", !8, i64 0}
!11 = !{!"any pointer", !8, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}


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