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

; 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.gmskframesync_s = type { ptr, i32, i32, float, ptr, ptr, %struct.framesyncstats_s, %struct.framedatastats_s, { float, float }, float, ptr, ptr, i32, float, float, i32, i32, float, ptr, float, float, float, ptr, ptr, i32, ptr, ptr, i32, i32, i32, ptr, ptr, ptr, ptr, i32, i8, i32, i32, i32, i32, i32, ptr, ptr, ptr, i32, i32, i32, i32, i32 }
%struct.framesyncstats_s = type { float, float, float, ptr, i32, i32, i32, i32, i32, i32 }
%struct.framedatastats_s = type { i32, i32, i32, i64 }

; 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

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

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

11:                                               ; preds = %40, %3
  %12 = load i32, ptr %7, align 4, !tbaa !9
  %13 = load i32, ptr %6, align 4, !tbaa !9
  %14 = icmp ult i32 %12, %13
  br i1 %14, label %15, label %43

15:                                               ; preds = %11
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.gmskframesync_s, ptr %16, i32 0, i32 0
  %18 = load ptr, ptr %17, align 8, !tbaa !11
  %19 = load ptr, ptr %5, align 8, !tbaa !5
  %20 = load i32, ptr %7, align 4, !tbaa !9
  %21 = zext i32 %20 to i64
  %22 = getelementptr inbounds { float, float }, ptr %19, i64 %21
  %23 = getelementptr inbounds { float, float }, ptr %22, i32 0, i32 0
  %24 = load float, ptr %23, align 4
  %25 = getelementptr inbounds { float, float }, ptr %22, i32 0, i32 1
  %26 = load float, ptr %25, align 4
  %27 = getelementptr inbounds { float, float }, ptr %9, i32 0, i32 0
  %28 = getelementptr inbounds { float, float }, ptr %9, i32 0, i32 1
  store float %24, ptr %27, align 4
  store float %26, ptr %28, align 4
  %29 = load <2 x float>, ptr %9, align 4
  %30 = call i32 @iirfilt_crcf_execute(ptr noundef %18, <2 x float> noundef %29, ptr noundef %8)
  %31 = load ptr, ptr %4, align 8, !tbaa !5
  %32 = getelementptr inbounds { float, float }, ptr %8, i32 0, i32 0
  %33 = load float, ptr %32, align 4
  %34 = getelementptr inbounds { float, float }, ptr %8, i32 0, i32 1
  %35 = load float, ptr %34, align 4
  %36 = getelementptr inbounds { float, float }, ptr %10, i32 0, i32 0
  %37 = getelementptr inbounds { float, float }, ptr %10, i32 0, i32 1
  store float %33, ptr %36, align 4
  store float %35, ptr %37, align 4
  %38 = load <2 x float>, ptr %10, align 4
  %39 = call i32 @gmskframesync_execute_sample(ptr noundef %31, <2 x float> noundef %38)
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  br label %40

40:                                               ; preds = %15
  %41 = load i32, ptr %7, align 4, !tbaa !9
  %42 = add i32 %41, 1
  store i32 %42, ptr %7, align 4, !tbaa !9
  br label %11, !llvm.loop !17

43:                                               ; preds = %11
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  ret i32 0
}

declare i32 @iirfilt_crcf_execute(ptr noundef, <2 x float> noundef, ptr noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { "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, !6, i64 0}
!12 = !{!"gmskframesync_s", !6, i64 0, !10, i64 8, !10, i64 12, !13, i64 16, !6, i64 24, !6, i64 32, !14, i64 40, !15, i64 88, !7, i64 112, !13, i64 120, !6, i64 128, !6, i64 136, !10, i64 144, !13, i64 148, !13, i64 152, !10, i64 156, !10, i64 160, !13, i64 164, !6, i64 168, !13, i64 176, !13, i64 180, !13, i64 184, !6, i64 192, !6, i64 200, !10, i64 208, !6, i64 216, !6, i64 224, !10, i64 232, !10, i64 236, !10, i64 240, !6, i64 248, !6, i64 256, !6, i64 264, !6, i64 272, !10, i64 280, !7, i64 284, !10, i64 288, !10, i64 292, !10, i64 296, !10, i64 300, !10, i64 304, !6, i64 312, !6, i64 320, !6, i64 328, !10, i64 336, !10, i64 340, !10, i64 344, !10, i64 348, !10, i64 352}
!13 = !{!"float", !7, i64 0}
!14 = !{!"", !13, i64 0, !13, i64 4, !13, i64 8, !6, i64 16, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !10, i64 40, !10, i64 44}
!15 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8, !16, i64 16}
!16 = !{!"long", !7, i64 0}
!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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

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

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

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @gmskframesync_execute(ptr noundef %0, ptr nocapture noundef readonly %1, i32 noundef %2) local_unnamed_addr #1 {
  %4 = alloca { float, float }, align 8
  %.not = icmp eq i32 %2, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

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

5:                                                ; preds = %.lr.ph, %5
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %5 ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #3
  %6 = load ptr, ptr %0, align 8, !tbaa !5
  %7 = getelementptr inbounds { float, float }, ptr %1, i64 %indvars.iv
  %8 = load <2 x float>, ptr %7, align 4
  %9 = call i32 @iirfilt_crcf_execute(ptr noundef %6, <2 x float> noundef %8, ptr noundef nonnull %4) #3
  %10 = load <2 x float>, ptr %4, align 8
  %11 = call i32 @gmskframesync_execute_sample(ptr noundef nonnull %0, <2 x float> noundef %10)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #3
  %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 %5, !llvm.loop !15

._crit_edge:                                      ; preds = %5, %3
  ret i32 0
}

declare i32 @iirfilt_crcf_execute(ptr noundef, <2 x float> noundef, ptr noundef) local_unnamed_addr #2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { "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, !7, i64 0}
!6 = !{!"gmskframesync_s", !7, i64 0, !10, i64 8, !10, i64 12, !11, i64 16, !7, i64 24, !7, i64 32, !12, i64 40, !13, i64 88, !8, i64 112, !11, i64 120, !7, i64 128, !7, i64 136, !10, i64 144, !11, i64 148, !11, i64 152, !10, i64 156, !10, i64 160, !11, i64 164, !7, i64 168, !11, i64 176, !11, i64 180, !11, i64 184, !7, i64 192, !7, i64 200, !10, i64 208, !7, i64 216, !7, i64 224, !10, i64 232, !10, i64 236, !10, i64 240, !7, i64 248, !7, i64 256, !7, i64 264, !7, i64 272, !10, i64 280, !8, i64 284, !10, i64 288, !10, i64 292, !10, i64 296, !10, i64 300, !10, i64 304, !7, i64 312, !7, i64 320, !7, i64 328, !10, i64 336, !10, i64 340, !10, i64 344, !10, i64 348, !10, i64 352}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"float", !8, i64 0}
!12 = !{!"", !11, i64 0, !11, i64 4, !11, i64 8, !7, i64 16, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !10, i64 40, !10, i64 44}
!13 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8, !14, i64 16}
!14 = !{!"long", !8, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}


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