; LLVM IR from jgaeddert/liquid-dsp :: src/multichannel/src/ofdmframe.common (ofdmframe_init_S1)

; 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"

@.str = external hidden unnamed_addr constant [94 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [62 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

declare i32 @liquid_nextpow2(i32 noundef) #1

declare ptr @msequence_create_default(i32 noundef) #1

declare i32 @msequence_generate_symbol(ptr noundef, i32 noundef) #1

declare i32 @msequence_destroy(ptr noundef) #1

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

declare i32 @fft_run(i32 noundef, ptr noundef, ptr noundef, i32 noundef, i32 noundef) #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 @ofdmframe_init_S1(ptr noundef %0, i32 noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4) #3 {
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca ptr, align 8
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca float, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store i32 %1, ptr %8, align 4, !tbaa !9
  store ptr %2, ptr %9, align 8, !tbaa !5
  store ptr %3, ptr %10, align 8, !tbaa !5
  store ptr %4, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  %19 = load i32, ptr %8, align 4, !tbaa !9
  %20 = call i32 @liquid_nextpow2(i32 noundef %19)
  store i32 %20, ptr %13, align 4, !tbaa !9
  %21 = load i32, ptr %13, align 4, !tbaa !9
  %22 = icmp ult i32 %21, 4
  br i1 %22, label %23, label %24

23:                                               ; preds = %5
  store i32 4, ptr %13, align 4, !tbaa !9
  br label %29

24:                                               ; preds = %5
  %25 = load i32, ptr %13, align 4, !tbaa !9
  %26 = icmp ugt i32 %25, 8
  br i1 %26, label %27, label %28

27:                                               ; preds = %24
  store i32 8, ptr %13, align 4, !tbaa !9
  br label %28

28:                                               ; preds = %27, %24
  br label %29

29:                                               ; preds = %28, %23
  %30 = load i32, ptr %13, align 4, !tbaa !9
  %31 = add i32 %30, 1
  store i32 %31, ptr %13, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  %32 = load i32, ptr %13, align 4, !tbaa !9
  %33 = call ptr @msequence_create_default(i32 noundef %32)
  store ptr %33, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #4
  store i32 0, ptr %16, align 4, !tbaa !9
  store i32 0, ptr %12, align 4, !tbaa !9
  br label %34

34:                                               ; preds = %70, %29
  %35 = load i32, ptr %12, align 4, !tbaa !9
  %36 = load i32, ptr %8, align 4, !tbaa !9
  %37 = icmp ult i32 %35, %36
  br i1 %37, label %38, label %73

38:                                               ; preds = %34
  %39 = load ptr, ptr %14, align 8, !tbaa !5
  %40 = call i32 @msequence_generate_symbol(ptr noundef %39, i32 noundef 3)
  %41 = and i32 %40, 1
  store i32 %41, ptr %15, align 4, !tbaa !9
  %42 = load ptr, ptr %7, align 8, !tbaa !5
  %43 = load i32, ptr %12, align 4, !tbaa !9
  %44 = zext i32 %43 to i64
  %45 = getelementptr inbounds i8, ptr %42, i64 %44
  %46 = load i8, ptr %45, align 1, !tbaa !11
  %47 = zext i8 %46 to i32
  %48 = icmp eq i32 %47, 0
  br i1 %48, label %49, label %56

49:                                               ; preds = %38
  %50 = load ptr, ptr %9, align 8, !tbaa !5
  %51 = load i32, ptr %12, align 4, !tbaa !9
  %52 = zext i32 %51 to i64
  %53 = getelementptr inbounds { float, float }, ptr %50, i64 %52
  %54 = getelementptr inbounds { float, float }, ptr %53, i32 0, i32 0
  %55 = getelementptr inbounds { float, float }, ptr %53, i32 0, i32 1
  store float 0.000000e+00, ptr %54, align 4
  store float 0.000000e+00, ptr %55, align 4
  br label %69

56:                                               ; preds = %38
  %57 = load i32, ptr %15, align 4, !tbaa !9
  %58 = icmp ne i32 %57, 0
  %59 = zext i1 %58 to i64
  %60 = select i1 %58, float 1.000000e+00, float -1.000000e+00
  %61 = load ptr, ptr %9, align 8, !tbaa !5
  %62 = load i32, ptr %12, align 4, !tbaa !9
  %63 = zext i32 %62 to i64
  %64 = getelementptr inbounds { float, float }, ptr %61, i64 %63
  %65 = getelementptr inbounds { float, float }, ptr %64, i32 0, i32 0
  %66 = getelementptr inbounds { float, float }, ptr %64, i32 0, i32 1
  store float %60, ptr %65, align 4
  store float 0.000000e+00, ptr %66, align 4
  %67 = load i32, ptr %16, align 4, !tbaa !9
  %68 = add i32 %67, 1
  store i32 %68, ptr %16, align 4, !tbaa !9
  br label %69

69:                                               ; preds = %56, %49
  br label %70

70:                                               ; preds = %69
  %71 = load i32, ptr %12, align 4, !tbaa !9
  %72 = add i32 %71, 1
  store i32 %72, ptr %12, align 4, !tbaa !9
  br label %34, !llvm.loop !12

73:                                               ; preds = %34
  %74 = load ptr, ptr %14, align 8, !tbaa !5
  %75 = call i32 @msequence_destroy(ptr noundef %74)
  %76 = load i32, ptr %16, align 4, !tbaa !9
  %77 = icmp eq i32 %76, 0
  br i1 %77, label %78, label %80

78:                                               ; preds = %73
  %79 = call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 3, ptr noundef @.str, i32 noundef 152, ptr noundef @.str.2)
  store i32 %79, ptr %6, align 4
  store i32 1, ptr %17, align 4
  br label %113

80:                                               ; preds = %73
  %81 = load i32, ptr %16, align 4, !tbaa !9
  %82 = load ptr, ptr %11, align 8, !tbaa !5
  store i32 %81, ptr %82, align 4, !tbaa !9
  %83 = load i32, ptr %8, align 4, !tbaa !9
  %84 = load ptr, ptr %9, align 8, !tbaa !5
  %85 = load ptr, ptr %10, align 8, !tbaa !5
  %86 = call i32 @fft_run(i32 noundef %83, ptr noundef %84, ptr noundef %85, i32 noundef -1, i32 noundef 0)
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #4
  %87 = load i32, ptr %16, align 4, !tbaa !9
  %88 = uitofp i32 %87 to float
  %89 = call float @sqrtf(float noundef %88) #4
  %90 = fdiv float 1.000000e+00, %89
  store float %90, ptr %18, align 4, !tbaa !14
  store i32 0, ptr %12, align 4, !tbaa !9
  br label %91

91:                                               ; preds = %109, %80
  %92 = load i32, ptr %12, align 4, !tbaa !9
  %93 = load i32, ptr %8, align 4, !tbaa !9
  %94 = icmp ult i32 %92, %93
  br i1 %94, label %95, label %112

95:                                               ; preds = %91
  %96 = load float, ptr %18, align 4, !tbaa !14
  %97 = load ptr, ptr %10, align 8, !tbaa !5
  %98 = load i32, ptr %12, align 4, !tbaa !9
  %99 = zext i32 %98 to i64
  %100 = getelementptr inbounds { float, float }, ptr %97, i64 %99
  %101 = getelementptr inbounds { float, float }, ptr %100, i32 0, i32 0
  %102 = load float, ptr %101, align 4
  %103 = getelementptr inbounds { float, float }, ptr %100, i32 0, i32 1
  %104 = load float, ptr %103, align 4
  %105 = fmul float %102, %96
  %106 = fmul float %104, %96
  %107 = getelementptr inbounds { float, float }, ptr %100, i32 0, i32 0
  %108 = getelementptr inbounds { float, float }, ptr %100, i32 0, i32 1
  store float %105, ptr %107, align 4
  store float %106, ptr %108, align 4
  br label %109

109:                                              ; preds = %95
  %110 = load i32, ptr %12, align 4, !tbaa !9
  %111 = add i32 %110, 1
  store i32 %111, ptr %12, align 4, !tbaa !9
  br label %91, !llvm.loop !16

112:                                              ; preds = %91
  store i32 0, ptr %6, align 4
  store i32 1, ptr %17, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #4
  br label %113

113:                                              ; preds = %112, %78
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  %114 = load i32, ptr %6, align 4
  ret i32 %114
}

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 "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 }

!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 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = !{!15, !15, i64 0}
!15 = !{!"float", !7, i64 0}
!16 = distinct !{!16, !13}


; 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 [94 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [62 x i8], align 1

declare i32 @liquid_nextpow2(i32 noundef) local_unnamed_addr #0

declare ptr @msequence_create_default(i32 noundef) local_unnamed_addr #0

declare i32 @msequence_generate_symbol(ptr noundef, i32 noundef) local_unnamed_addr #0

declare i32 @msequence_destroy(ptr noundef) local_unnamed_addr #0

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

declare i32 @fft_run(i32 noundef, ptr noundef, ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local i32 @ofdmframe_init_S1(ptr nocapture noundef readonly %0, i32 noundef %1, ptr noundef %2, ptr noundef %3, ptr nocapture noundef writeonly %4) local_unnamed_addr #1 {
  %6 = tail call i32 @liquid_nextpow2(i32 noundef %1) #3
  %7 = icmp ult i32 %6, 4
  %spec.store.select = tail call i32 @llvm.umin.i32(i32 %6, i32 8)
  %8 = add nuw nsw i32 %spec.store.select, 1
  %.034 = select i1 %7, i32 5, i32 %8
  %9 = tail call ptr @msequence_create_default(i32 noundef %.034) #3
  %.not42 = icmp eq i32 %1, 0
  br i1 %.not42, label %._crit_edge.thread, label %.lr.ph.preheader

._crit_edge.thread:                               ; preds = %5
  %10 = tail call i32 @msequence_destroy(ptr noundef %9) #3
  br label %26

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

.lr.ph:                                           ; preds = %.lr.ph.preheader, %23
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next, %23 ]
  %.03138 = phi i32 [ 0, %.lr.ph.preheader ], [ %.1, %23 ]
  %11 = tail call i32 @msequence_generate_symbol(ptr noundef %9, i32 noundef 3) #3
  %12 = getelementptr inbounds i8, ptr %0, i64 %indvars.iv
  %13 = load i8, ptr %12, align 1, !tbaa !5
  %14 = icmp eq i8 %13, 0
  br i1 %14, label %15, label %17

15:                                               ; preds = %.lr.ph
  %16 = getelementptr inbounds { float, float }, ptr %2, i64 %indvars.iv
  store <2 x float> zeroinitializer, ptr %16, align 4
  br label %23

17:                                               ; preds = %.lr.ph
  %18 = and i32 %11, 1
  %.not = icmp eq i32 %18, 0
  %19 = select i1 %.not, float -1.000000e+00, float 1.000000e+00
  %20 = getelementptr inbounds { float, float }, ptr %2, i64 %indvars.iv
  %21 = getelementptr inbounds i8, ptr %20, i64 4
  store float %19, ptr %20, align 4
  store float 0.000000e+00, ptr %21, align 4
  %22 = add i32 %.03138, 1
  br label %23

23:                                               ; preds = %15, %17
  %.1 = phi i32 [ %.03138, %15 ], [ %22, %17 ]
  %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 %.lr.ph, !llvm.loop !8

._crit_edge:                                      ; preds = %23
  %24 = tail call i32 @msequence_destroy(ptr noundef %9) #3
  %25 = icmp eq i32 %.1, 0
  br i1 %25, label %26, label %28

26:                                               ; preds = %._crit_edge.thread, %._crit_edge
  %27 = tail call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 3, ptr noundef nonnull @.str, i32 noundef 152, ptr noundef nonnull @.str.2) #3
  br label %.loopexit

28:                                               ; preds = %._crit_edge
  store i32 %.1, ptr %4, align 4, !tbaa !10
  %29 = tail call i32 @fft_run(i32 noundef %1, ptr noundef nonnull %2, ptr noundef %3, i32 noundef -1, i32 noundef 0) #3
  %30 = uitofp i32 %.1 to float
  %sqrt = tail call float @llvm.sqrt.f32(float %30)
  %31 = fdiv float 1.000000e+00, %sqrt
  br i1 %.not42, label %.loopexit, label %.lr.ph41.preheader

.lr.ph41.preheader:                               ; preds = %28
  %wide.trip.count48 = zext i32 %1 to i64
  %min.iters.check = icmp eq i32 %1, 1
  br i1 %min.iters.check, label %.lr.ph41.preheader52, label %vector.ph

vector.ph:                                        ; preds = %.lr.ph41.preheader
  %n.vec = and i64 %wide.trip.count, 4294967294
  %broadcast.splatinsert = insertelement <2 x float> poison, float %31, i64 0
  %32 = shufflevector <2 x float> %broadcast.splatinsert, <2 x float> poison, <4 x i32> zeroinitializer
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %33 = getelementptr inbounds { float, float }, ptr %3, i64 %index
  %34 = load <4 x float>, ptr %33, align 4
  %interleaved.vec = fmul <4 x float> %32, %34
  store <4 x float> %interleaved.vec, ptr %33, align 4
  %index.next = add nuw i64 %index, 2
  %35 = icmp eq i64 %index.next, %n.vec
  br i1 %35, label %middle.block, label %vector.body, !llvm.loop !12

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %n.vec, %wide.trip.count
  br i1 %cmp.n, label %.loopexit, label %.lr.ph41.preheader52

.lr.ph41.preheader52:                             ; preds = %middle.block, %.lr.ph41.preheader
  %indvars.iv45.ph = phi i64 [ 0, %.lr.ph41.preheader ], [ %n.vec, %middle.block ]
  %36 = insertelement <2 x float> poison, float %31, i64 0
  %37 = shufflevector <2 x float> %36, <2 x float> poison, <2 x i32> zeroinitializer
  br label %.lr.ph41

.lr.ph41:                                         ; preds = %.lr.ph41.preheader52, %.lr.ph41
  %indvars.iv45 = phi i64 [ %indvars.iv.next46, %.lr.ph41 ], [ %indvars.iv45.ph, %.lr.ph41.preheader52 ]
  %38 = getelementptr inbounds { float, float }, ptr %3, i64 %indvars.iv45
  %39 = load <2 x float>, ptr %38, align 4
  %40 = fmul <2 x float> %37, %39
  store <2 x float> %40, ptr %38, align 4
  %indvars.iv.next46 = add nuw nsw i64 %indvars.iv45, 1
  %exitcond49.not = icmp eq i64 %indvars.iv.next46, %wide.trip.count48
  br i1 %exitcond49.not, label %.loopexit, label %.lr.ph41, !llvm.loop !15

.loopexit:                                        ; preds = %.lr.ph41, %middle.block, %28, %26
  %.0 = phi i32 [ %27, %26 ], [ 0, %28 ], [ 0, %middle.block ], [ 0, %.lr.ph41 ]
  ret i32 %.0
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.umin.i32(i32, i32) #2

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

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"="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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = distinct !{!8, !9}
!9 = !{!"llvm.loop.mustprogress"}
!10 = !{!11, !11, i64 0}
!11 = !{!"int", !6, i64 0}
!12 = distinct !{!12, !9, !13, !14}
!13 = !{!"llvm.loop.isvectorized", i32 1}
!14 = !{!"llvm.loop.unroll.runtime.disable"}
!15 = distinct !{!15, !9, !14, !13}


; Effective O3 passes: AggressiveInstCombinePass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,PostOrderFunctionAttrsPass,ReassociatePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass,VectorCombinePass