; LLVM IR from jgaeddert/liquid-dsp :: src/multichannel/src (ofdmframesync)

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

; 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 nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memmove.p0.p0.i64(ptr nocapture writeonly, ptr nocapture readonly, i64, i1 immarg) #1

; Function Attrs: nounwind
declare float @sqrtf(float noundef) #2

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

declare <2 x float> @__mulsc3(float, float, float, float)

; Function Attrs: nounwind uwtable
define dso_local i32 @ofdmframesync_estimate_gain_S1(ptr noundef %0, ptr noundef %1, ptr noundef %2) #3 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca float, align 4
  %9 = alloca { float, float }, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.ofdmframesync_s, ptr %10, i32 0, i32 15
  %12 = load ptr, ptr %11, align 8, !tbaa !9
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.ofdmframesync_s, ptr %14, i32 0, i32 0
  %16 = load i32, ptr %15, align 8, !tbaa !13
  %17 = zext i32 %16 to i64
  %18 = mul i64 %17, 8
  call void @llvm.memmove.p0.p0.i64(ptr align 4 %12, ptr align 4 %13, i64 %18, i1 false)
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.ofdmframesync_s, ptr %19, i32 0, i32 13
  %21 = load ptr, ptr %20, align 8, !tbaa !14
  %22 = call i32 @fft_execute(ptr noundef %21)
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.ofdmframesync_s, ptr %23, i32 0, i32 9
  %25 = load i32, ptr %24, align 4, !tbaa !15
  %26 = uitofp i32 %25 to float
  %27 = call float @sqrtf(float noundef %26) #5
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.ofdmframesync_s, ptr %28, i32 0, i32 0
  %30 = load i32, ptr %29, align 8, !tbaa !13
  %31 = uitofp i32 %30 to float
  %32 = fdiv float %27, %31
  store float %32, ptr %8, align 4, !tbaa !16
  store i32 0, ptr %7, align 4, !tbaa !17
  br label %33

33:                                               ; preds = %116, %3
  %34 = load i32, ptr %7, align 4, !tbaa !17
  %35 = load ptr, ptr %4, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.ofdmframesync_s, ptr %35, i32 0, i32 0
  %37 = load i32, ptr %36, align 8, !tbaa !13
  %38 = icmp ult i32 %34, %37
  br i1 %38, label %39, label %119

39:                                               ; preds = %33
  %40 = load ptr, ptr %4, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.ofdmframesync_s, ptr %40, i32 0, i32 3
  %42 = load ptr, ptr %41, align 8, !tbaa !18
  %43 = load i32, ptr %7, align 4, !tbaa !17
  %44 = zext i32 %43 to i64
  %45 = getelementptr inbounds i8, ptr %42, i64 %44
  %46 = load i8, ptr %45, align 1, !tbaa !19
  %47 = zext i8 %46 to i32
  %48 = icmp ne i32 %47, 0
  br i1 %48, label %49, label %95

49:                                               ; preds = %39
  %50 = load ptr, ptr %4, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.ofdmframesync_s, ptr %50, i32 0, i32 14
  %52 = load ptr, ptr %51, align 8, !tbaa !20
  %53 = load i32, ptr %7, align 4, !tbaa !17
  %54 = zext i32 %53 to i64
  %55 = getelementptr inbounds { float, float }, ptr %52, i64 %54
  %56 = getelementptr inbounds { float, float }, ptr %55, i32 0, i32 0
  %57 = load float, ptr %56, align 4
  %58 = getelementptr inbounds { float, float }, ptr %55, i32 0, i32 1
  %59 = load float, ptr %58, align 4
  %60 = load ptr, ptr %4, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.ofdmframesync_s, ptr %60, i32 0, i32 19
  %62 = load ptr, ptr %61, align 8, !tbaa !21
  %63 = load i32, ptr %7, align 4, !tbaa !17
  %64 = zext i32 %63 to i64
  %65 = getelementptr inbounds { float, float }, ptr %62, i64 %64
  %66 = getelementptr inbounds { float, float }, ptr %65, i32 0, i32 0
  %67 = load float, ptr %66, align 4
  %68 = getelementptr inbounds { float, float }, ptr %65, i32 0, i32 1
  %69 = load float, ptr %68, align 4
  %70 = fneg float %69
  %71 = fmul float %57, %67
  %72 = fmul float %59, %70
  %73 = fmul float %57, %70
  %74 = fmul float %59, %67
  %75 = fsub float %71, %72
  %76 = fadd float %73, %74
  %77 = fcmp uno float %75, %75
  br i1 %77, label %78, label %86, !prof !22

78:                                               ; preds = %49
  %79 = fcmp uno float %76, %76
  br i1 %79, label %80, label %86, !prof !22

80:                                               ; preds = %78
  %81 = call <2 x float> @__mulsc3(float noundef %57, float noundef %59, float noundef %67, float noundef %70) #5
  store <2 x float> %81, ptr %9, align 4
  %82 = getelementptr inbounds { float, float }, ptr %9, i32 0, i32 0
  %83 = load float, ptr %82, align 4
  %84 = getelementptr inbounds { float, float }, ptr %9, i32 0, i32 1
  %85 = load float, ptr %84, align 4
  br label %86

86:                                               ; preds = %80, %78, %49
  %87 = phi float [ %75, %49 ], [ %75, %78 ], [ %83, %80 ]
  %88 = phi float [ %76, %49 ], [ %76, %78 ], [ %85, %80 ]
  %89 = load ptr, ptr %6, align 8, !tbaa !5
  %90 = load i32, ptr %7, align 4, !tbaa !17
  %91 = zext i32 %90 to i64
  %92 = getelementptr inbounds { float, float }, ptr %89, i64 %91
  %93 = getelementptr inbounds { float, float }, ptr %92, i32 0, i32 0
  %94 = getelementptr inbounds { float, float }, ptr %92, i32 0, i32 1
  store float %87, ptr %93, align 4
  store float %88, ptr %94, align 4
  br label %102

95:                                               ; preds = %39
  %96 = load ptr, ptr %6, align 8, !tbaa !5
  %97 = load i32, ptr %7, align 4, !tbaa !17
  %98 = zext i32 %97 to i64
  %99 = getelementptr inbounds { float, float }, ptr %96, i64 %98
  %100 = getelementptr inbounds { float, float }, ptr %99, i32 0, i32 0
  %101 = getelementptr inbounds { float, float }, ptr %99, i32 0, i32 1
  store float 0.000000e+00, ptr %100, align 4
  store float 0.000000e+00, ptr %101, align 4
  br label %102

102:                                              ; preds = %95, %86
  %103 = load float, ptr %8, align 4, !tbaa !16
  %104 = load ptr, ptr %6, align 8, !tbaa !5
  %105 = load i32, ptr %7, align 4, !tbaa !17
  %106 = zext i32 %105 to i64
  %107 = getelementptr inbounds { float, float }, ptr %104, i64 %106
  %108 = getelementptr inbounds { float, float }, ptr %107, i32 0, i32 0
  %109 = load float, ptr %108, align 4
  %110 = getelementptr inbounds { float, float }, ptr %107, i32 0, i32 1
  %111 = load float, ptr %110, align 4
  %112 = fmul float %109, %103
  %113 = fmul float %111, %103
  %114 = getelementptr inbounds { float, float }, ptr %107, i32 0, i32 0
  %115 = getelementptr inbounds { float, float }, ptr %107, i32 0, i32 1
  store float %112, ptr %114, align 4
  store float %113, ptr %115, align 4
  br label %116

116:                                              ; preds = %102
  %117 = load i32, ptr %7, align 4, !tbaa !17
  %118 = add i32 %117, 1
  store i32 %118, ptr %7, align 4, !tbaa !17
  br label %33, !llvm.loop !23

119:                                              ; preds = %33
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  ret i32 0
}

declare i32 @fft_execute(ptr noundef) #4

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nounwind "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"="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 #4 = { "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 #5 = { 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, !6, i64 80}
!10 = !{!"ofdmframesync_s", !11, i64 0, !11, i64 4, !11, i64 8, !6, i64 16, !11, i64 24, !11, i64 28, !11, i64 32, !11, i64 36, !11, i64 40, !11, i64 44, !12, i64 48, !12, i64 52, !12, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !12, i64 128, !6, i64 136, !6, i64 144, !6, i64 152, !6, i64 160, !6, i64 168, !6, i64 176, !11, i64 184, !6, i64 192, !6, i64 200, !12, i64 208, !12, i64 212, !11, i64 216, !11, i64 220, !11, i64 224, !7, i64 228, !7, i64 236, !12, i64 244, !12, i64 248, !6, i64 256, !6, i64 264}
!11 = !{!"int", !7, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{!10, !11, i64 0}
!14 = !{!10, !6, i64 64}
!15 = !{!10, !11, i64 44}
!16 = !{!12, !12, i64 0}
!17 = !{!11, !11, i64 0}
!18 = !{!10, !6, i64 16}
!19 = !{!7, !7, i64 0}
!20 = !{!10, !6, i64 72}
!21 = !{!10, !6, i64 112}
!22 = !{!"branch_weights", i32 1, i32 1048575}
!23 = distinct !{!23, !24}
!24 = !{!"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 nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memmove.p0.p0.i64(ptr nocapture writeonly, ptr nocapture readonly, i64, i1 immarg) #0

declare <2 x float> @__mulsc3(float, float, float, float) local_unnamed_addr

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @ofdmframesync_estimate_gain_S1(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1, ptr nocapture noundef writeonly %2) local_unnamed_addr #1 {
  %4 = getelementptr inbounds i8, ptr %0, i64 80
  %5 = load ptr, ptr %4, align 8, !tbaa !5
  %6 = load i32, ptr %0, align 8, !tbaa !12
  %7 = zext i32 %6 to i64
  %8 = shl nuw nsw i64 %7, 3
  tail call void @llvm.memmove.p0.p0.i64(ptr align 4 %5, ptr align 4 %1, i64 %8, i1 false)
  %9 = getelementptr inbounds i8, ptr %0, i64 64
  %10 = load ptr, ptr %9, align 8, !tbaa !13
  %11 = tail call i32 @fft_execute(ptr noundef %10) #4
  %12 = load i32, ptr %0, align 8, !tbaa !12
  %.not22 = icmp eq i32 %12, 0
  br i1 %.not22, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %3
  %13 = getelementptr inbounds i8, ptr %0, i64 44
  %14 = load i32, ptr %13, align 4, !tbaa !14
  %15 = uitofp i32 %14 to float
  %sqrt = tail call float @llvm.sqrt.f32(float %15)
  %16 = uitofp i32 %12 to float
  %17 = fdiv float %sqrt, %16
  %18 = getelementptr inbounds i8, ptr %0, i64 16
  %19 = getelementptr inbounds i8, ptr %0, i64 72
  %20 = getelementptr inbounds i8, ptr %0, i64 112
  %21 = insertelement <2 x float> poison, float %17, i64 0
  %22 = shufflevector <2 x float> %21, <2 x float> poison, <2 x i32> zeroinitializer
  br label %23

23:                                               ; preds = %.lr.ph, %56
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %56 ]
  %24 = load ptr, ptr %18, align 8, !tbaa !15
  %25 = getelementptr inbounds i8, ptr %24, i64 %indvars.iv
  %26 = load i8, ptr %25, align 1, !tbaa !16
  %.not = icmp eq i8 %26, 0
  br i1 %.not, label %56, label %27

27:                                               ; preds = %23
  %28 = load ptr, ptr %19, align 8, !tbaa !17
  %29 = getelementptr inbounds { float, float }, ptr %28, i64 %indvars.iv
  %30 = load ptr, ptr %20, align 8, !tbaa !18
  %31 = getelementptr inbounds { float, float }, ptr %30, i64 %indvars.iv
  %32 = load float, ptr %31, align 4
  %33 = getelementptr inbounds i8, ptr %31, i64 4
  %34 = load float, ptr %33, align 4
  %35 = fneg float %34
  %36 = load <2 x float>, ptr %29, align 4
  %37 = insertelement <2 x float> poison, float %32, i64 0
  %38 = shufflevector <2 x float> %37, <2 x float> poison, <2 x i32> zeroinitializer
  %39 = fmul <2 x float> %36, %38
  %40 = insertelement <2 x float> poison, float %34, i64 0
  %41 = shufflevector <2 x float> %40, <2 x float> poison, <2 x i32> zeroinitializer
  %42 = fmul <2 x float> %36, %41
  %43 = shufflevector <2 x float> %42, <2 x float> poison, <2 x i32> <i32 1, i32 0>
  %44 = fadd <2 x float> %39, %43
  %45 = fsub <2 x float> %39, %43
  %46 = shufflevector <2 x float> %44, <2 x float> %45, <2 x i32> <i32 0, i32 3>
  %47 = extractelement <2 x float> %44, i64 0
  %48 = fcmp uno float %47, 0.000000e+00
  br i1 %48, label %49, label %56, !prof !19

49:                                               ; preds = %27
  %50 = extractelement <2 x float> %45, i64 1
  %51 = fcmp uno float %50, 0.000000e+00
  br i1 %51, label %52, label %56, !prof !19

52:                                               ; preds = %49
  %53 = extractelement <2 x float> %36, i64 0
  %54 = extractelement <2 x float> %36, i64 1
  %55 = tail call <2 x float> @__mulsc3(float noundef %53, float noundef %54, float noundef %32, float noundef %35) #4
  br label %56

56:                                               ; preds = %23, %27, %49, %52
  %57 = phi <2 x float> [ %46, %27 ], [ %46, %49 ], [ %55, %52 ], [ zeroinitializer, %23 ]
  %58 = getelementptr inbounds { float, float }, ptr %2, i64 %indvars.iv
  %59 = fmul <2 x float> %22, %57
  store <2 x float> %59, ptr %58, align 4
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %60 = load i32, ptr %0, align 8, !tbaa !12
  %61 = zext i32 %60 to i64
  %62 = icmp ult i64 %indvars.iv.next, %61
  br i1 %62, label %23, label %._crit_edge, !llvm.loop !20

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

declare i32 @fft_execute(ptr noundef) local_unnamed_addr #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.sqrt.f32(float) #3

attributes #0 = { mustprogress nocallback nofree 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { 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, !10, i64 80}
!6 = !{!"ofdmframesync_s", !7, i64 0, !7, i64 4, !7, i64 8, !10, i64 16, !7, i64 24, !7, i64 28, !7, i64 32, !7, i64 36, !7, i64 40, !7, i64 44, !11, i64 48, !11, i64 52, !11, i64 56, !10, i64 64, !10, i64 72, !10, i64 80, !10, i64 88, !10, i64 96, !10, i64 104, !10, i64 112, !10, i64 120, !11, i64 128, !10, i64 136, !10, i64 144, !10, i64 152, !10, i64 160, !10, i64 168, !10, i64 176, !7, i64 184, !10, i64 192, !10, i64 200, !11, i64 208, !11, i64 212, !7, i64 216, !7, i64 220, !7, i64 224, !8, i64 228, !8, i64 236, !11, i64 244, !11, i64 248, !10, i64 256, !10, i64 264}
!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, !7, i64 0}
!13 = !{!6, !10, i64 64}
!14 = !{!6, !7, i64 44}
!15 = !{!6, !10, i64 16}
!16 = !{!8, !8, i64 0}
!17 = !{!6, !10, i64 72}
!18 = !{!6, !10, i64 112}
!19 = !{!"branch_weights", i32 1, i32 1048575}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}


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