; 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

; Function Attrs: nounwind uwtable
define dso_local i32 @ofdmframesync_estimate_gain_S0(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 8
  %25 = load i32, ptr %24, align 8, !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 = %120, %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 %123

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 %99

49:                                               ; preds = %39
  %50 = load i32, ptr %7, align 4, !tbaa !17
  %51 = urem i32 %50, 2
  %52 = icmp eq i32 %51, 0
  br i1 %52, label %53, label %99

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

82:                                               ; preds = %53
  %83 = fcmp uno float %80, %80
  br i1 %83, label %84, label %90, !prof !22

84:                                               ; preds = %82
  %85 = call <2 x float> @__mulsc3(float noundef %61, float noundef %63, float noundef %71, float noundef %74) #5
  store <2 x float> %85, ptr %9, align 4
  %86 = getelementptr inbounds { float, float }, ptr %9, i32 0, i32 0
  %87 = load float, ptr %86, align 4
  %88 = getelementptr inbounds { float, float }, ptr %9, i32 0, i32 1
  %89 = load float, ptr %88, align 4
  br label %90

90:                                               ; preds = %84, %82, %53
  %91 = phi float [ %79, %53 ], [ %79, %82 ], [ %87, %84 ]
  %92 = phi float [ %80, %53 ], [ %80, %82 ], [ %89, %84 ]
  %93 = load ptr, ptr %6, align 8, !tbaa !5
  %94 = load i32, ptr %7, align 4, !tbaa !17
  %95 = zext i32 %94 to i64
  %96 = getelementptr inbounds { float, float }, ptr %93, i64 %95
  %97 = getelementptr inbounds { float, float }, ptr %96, i32 0, i32 0
  %98 = getelementptr inbounds { float, float }, ptr %96, i32 0, i32 1
  store float %91, ptr %97, align 4
  store float %92, ptr %98, align 4
  br label %106

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

106:                                              ; preds = %99, %90
  %107 = load float, ptr %8, align 4, !tbaa !16
  %108 = load ptr, ptr %6, align 8, !tbaa !5
  %109 = load i32, ptr %7, align 4, !tbaa !17
  %110 = zext i32 %109 to i64
  %111 = getelementptr inbounds { float, float }, ptr %108, i64 %110
  %112 = getelementptr inbounds { float, float }, ptr %111, i32 0, i32 0
  %113 = load float, ptr %112, align 4
  %114 = getelementptr inbounds { float, float }, ptr %111, i32 0, i32 1
  %115 = load float, ptr %114, align 4
  %116 = fmul float %113, %107
  %117 = fmul float %115, %107
  %118 = getelementptr inbounds { float, float }, ptr %111, i32 0, i32 0
  %119 = getelementptr inbounds { float, float }, ptr %111, i32 0, i32 1
  store float %116, ptr %118, align 4
  store float %117, ptr %119, align 4
  br label %120

120:                                              ; preds = %106
  %121 = load i32, ptr %7, align 4, !tbaa !17
  %122 = add i32 %121, 1
  store i32 %122, ptr %7, align 4, !tbaa !17
  br label %33, !llvm.loop !23

123:                                              ; 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 <2 x float> @__mulsc3(float, float, float, float)

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 40}
!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 96}
!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

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @ofdmframesync_estimate_gain_S0(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
  %.not24 = icmp eq i32 %12, 0
  br i1 %.not24, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %3
  %13 = getelementptr inbounds i8, ptr %0, i64 40
  %14 = load i32, ptr %13, align 8, !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 96
  %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, %58
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %58 ]
  %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 ne i8 %26, 0
  %27 = and i64 %indvars.iv, 1
  %28 = icmp eq i64 %27, 0
  %or.cond = and i1 %28, %.not
  br i1 %or.cond, label %29, label %58

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

51:                                               ; preds = %29
  %52 = extractelement <2 x float> %47, i64 1
  %53 = fcmp uno float %52, 0.000000e+00
  br i1 %53, label %54, label %58, !prof !19

54:                                               ; preds = %51
  %55 = extractelement <2 x float> %38, i64 0
  %56 = extractelement <2 x float> %38, i64 1
  %57 = tail call <2 x float> @__mulsc3(float noundef %55, float noundef %56, float noundef %34, float noundef %37) #4
  br label %58

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

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

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

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 40}
!15 = !{!6, !10, i64 16}
!16 = !{!8, !8, i64 0}
!17 = !{!6, !10, i64 72}
!18 = !{!6, !10, i64 96}
!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