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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @ofdmframe_init_S0(ptr noundef %0, i32 noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4) #0 {
  %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
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  %30 = load i32, ptr %13, align 4, !tbaa !9
  %31 = call ptr @msequence_create_default(i32 noundef %30)
  store ptr %31, 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 %32

32:                                               ; preds = %80, %29
  %33 = load i32, ptr %12, align 4, !tbaa !9
  %34 = load i32, ptr %8, align 4, !tbaa !9
  %35 = icmp ult i32 %33, %34
  br i1 %35, label %36, label %83

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

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

54:                                               ; preds = %36
  %55 = load i32, ptr %12, align 4, !tbaa !9
  %56 = urem i32 %55, 2
  %57 = icmp eq i32 %56, 0
  br i1 %57, label %58, label %71

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

71:                                               ; preds = %54
  %72 = load ptr, ptr %9, align 8, !tbaa !5
  %73 = load i32, ptr %12, align 4, !tbaa !9
  %74 = zext i32 %73 to i64
  %75 = getelementptr inbounds { float, float }, ptr %72, i64 %74
  %76 = getelementptr inbounds { float, float }, ptr %75, i32 0, i32 0
  %77 = getelementptr inbounds { float, float }, ptr %75, i32 0, i32 1
  store float 0.000000e+00, ptr %76, align 4
  store float 0.000000e+00, ptr %77, align 4
  br label %78

78:                                               ; preds = %71, %58
  br label %79

79:                                               ; preds = %78, %47
  br label %80

80:                                               ; preds = %79
  %81 = load i32, ptr %12, align 4, !tbaa !9
  %82 = add i32 %81, 1
  store i32 %82, ptr %12, align 4, !tbaa !9
  br label %32, !llvm.loop !12

83:                                               ; preds = %32
  %84 = load ptr, ptr %14, align 8, !tbaa !5
  %85 = call i32 @msequence_destroy(ptr noundef %84)
  %86 = load i32, ptr %16, align 4, !tbaa !9
  %87 = icmp eq i32 %86, 0
  br i1 %87, label %88, label %90

88:                                               ; preds = %83
  %89 = call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 3, ptr noundef @.str, i32 noundef 86, ptr noundef @.str.1)
  store i32 %89, ptr %6, align 4
  store i32 1, ptr %17, align 4
  br label %123

90:                                               ; preds = %83
  %91 = load i32, ptr %16, align 4, !tbaa !9
  %92 = load ptr, ptr %11, align 8, !tbaa !5
  store i32 %91, ptr %92, align 4, !tbaa !9
  %93 = load i32, ptr %8, align 4, !tbaa !9
  %94 = load ptr, ptr %9, align 8, !tbaa !5
  %95 = load ptr, ptr %10, align 8, !tbaa !5
  %96 = call i32 @fft_run(i32 noundef %93, ptr noundef %94, ptr noundef %95, i32 noundef -1, i32 noundef 0)
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #4
  %97 = load i32, ptr %16, align 4, !tbaa !9
  %98 = uitofp i32 %97 to float
  %99 = call float @sqrtf(float noundef %98) #4
  %100 = fdiv float 1.000000e+00, %99
  store float %100, ptr %18, align 4, !tbaa !14
  store i32 0, ptr %12, align 4, !tbaa !9
  br label %101

101:                                              ; preds = %119, %90
  %102 = load i32, ptr %12, align 4, !tbaa !9
  %103 = load i32, ptr %8, align 4, !tbaa !9
  %104 = icmp ult i32 %102, %103
  br i1 %104, label %105, label %122

105:                                              ; preds = %101
  %106 = load float, ptr %18, align 4, !tbaa !14
  %107 = load ptr, ptr %10, align 8, !tbaa !5
  %108 = load i32, ptr %12, align 4, !tbaa !9
  %109 = zext i32 %108 to i64
  %110 = getelementptr inbounds { float, float }, ptr %107, i64 %109
  %111 = getelementptr inbounds { float, float }, ptr %110, i32 0, i32 0
  %112 = load float, ptr %111, align 4
  %113 = getelementptr inbounds { float, float }, ptr %110, i32 0, i32 1
  %114 = load float, ptr %113, align 4
  %115 = fmul float %112, %106
  %116 = fmul float %114, %106
  %117 = getelementptr inbounds { float, float }, ptr %110, i32 0, i32 0
  %118 = getelementptr inbounds { float, float }, ptr %110, i32 0, i32 1
  store float %115, ptr %117, align 4
  store float %116, ptr %118, align 4
  br label %119

119:                                              ; preds = %105
  %120 = load i32, ptr %12, align 4, !tbaa !9
  %121 = add i32 %120, 1
  store i32 %121, ptr %12, align 4, !tbaa !9
  br label %101, !llvm.loop !16

122:                                              ; preds = %101
  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 %123

123:                                              ; preds = %122, %88
  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
  %124 = load i32, ptr %6, align 4
  ret i32 %124
}

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

declare i32 @liquid_nextpow2(i32 noundef) #2

declare ptr @msequence_create_default(i32 noundef) #2

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

declare i32 @msequence_destroy(ptr noundef) #2

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

declare i32 @fft_run(i32 noundef, ptr noundef, ptr noundef, i32 noundef, i32 noundef) #2

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

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

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 "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.1 = external hidden unnamed_addr constant [62 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @ofdmframe_init_S0(ptr nocapture noundef readonly %0, i32 noundef %1, ptr noundef %2, ptr noundef %3, ptr nocapture noundef writeonly %4) local_unnamed_addr #0 {
  %6 = tail call i32 @liquid_nextpow2(i32 noundef %1) #3
  %spec.store.select = tail call i32 @llvm.umin.i32(i32 %6, i32 8)
  %.036 = tail call i32 @llvm.umax.i32(i32 %spec.store.select, i32 4)
  %7 = tail call ptr @msequence_create_default(i32 noundef %.036) #3
  %.not44 = icmp eq i32 %1, 0
  br i1 %.not44, label %._crit_edge.thread, label %.lr.ph.preheader

._crit_edge.thread:                               ; preds = %5
  %8 = tail call i32 @msequence_destroy(ptr noundef %7) #3
  br label %29

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

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

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

16:                                               ; preds = %.lr.ph
  %17 = and i64 %indvars.iv, 1
  %18 = icmp eq i64 %17, 0
  br i1 %18, label %19, label %24

19:                                               ; preds = %16
  %.not = icmp eq i32 %10, 0
  %20 = select i1 %.not, float -1.000000e+00, float 1.000000e+00
  %21 = getelementptr inbounds { float, float }, ptr %2, i64 %indvars.iv
  %22 = getelementptr inbounds i8, ptr %21, i64 4
  store float %20, ptr %21, align 4
  store float 0.000000e+00, ptr %22, align 4
  %23 = add i32 %.03340, 1
  br label %26

24:                                               ; preds = %16
  %25 = getelementptr inbounds { float, float }, ptr %2, i64 %indvars.iv
  store <2 x float> zeroinitializer, ptr %25, align 4
  br label %26

26:                                               ; preds = %14, %24, %19
  %.1 = phi i32 [ %.03340, %14 ], [ %23, %19 ], [ %.03340, %24 ]
  %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 = %26
  %27 = tail call i32 @msequence_destroy(ptr noundef %7) #3
  %28 = icmp eq i32 %.1, 0
  br i1 %28, label %29, label %31

29:                                               ; preds = %._crit_edge.thread, %._crit_edge
  %30 = tail call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 3, ptr noundef nonnull @.str, i32 noundef 86, ptr noundef nonnull @.str.1) #3
  br label %.loopexit

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

.lr.ph43.preheader:                               ; preds = %31
  %wide.trip.count50 = zext i32 %1 to i64
  %min.iters.check = icmp eq i32 %1, 1
  br i1 %min.iters.check, label %.lr.ph43.preheader54, label %vector.ph

vector.ph:                                        ; preds = %.lr.ph43.preheader
  %n.vec = and i64 %wide.trip.count, 4294967294
  %broadcast.splatinsert = insertelement <2 x float> poison, float %34, i64 0
  %35 = 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 ]
  %36 = getelementptr inbounds { float, float }, ptr %3, i64 %index
  %37 = load <4 x float>, ptr %36, align 4
  %interleaved.vec = fmul <4 x float> %35, %37
  store <4 x float> %interleaved.vec, ptr %36, align 4
  %index.next = add nuw i64 %index, 2
  %38 = icmp eq i64 %index.next, %n.vec
  br i1 %38, 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.ph43.preheader54

.lr.ph43.preheader54:                             ; preds = %middle.block, %.lr.ph43.preheader
  %indvars.iv47.ph = phi i64 [ 0, %.lr.ph43.preheader ], [ %n.vec, %middle.block ]
  %39 = insertelement <2 x float> poison, float %34, i64 0
  %40 = shufflevector <2 x float> %39, <2 x float> poison, <2 x i32> zeroinitializer
  br label %.lr.ph43

.lr.ph43:                                         ; preds = %.lr.ph43.preheader54, %.lr.ph43
  %indvars.iv47 = phi i64 [ %indvars.iv.next48, %.lr.ph43 ], [ %indvars.iv47.ph, %.lr.ph43.preheader54 ]
  %41 = getelementptr inbounds { float, float }, ptr %3, i64 %indvars.iv47
  %42 = load <2 x float>, ptr %41, align 4
  %43 = fmul <2 x float> %40, %42
  store <2 x float> %43, ptr %41, align 4
  %indvars.iv.next48 = add nuw nsw i64 %indvars.iv47, 1
  %exitcond51.not = icmp eq i64 %indvars.iv.next48, %wide.trip.count50
  br i1 %exitcond51.not, label %.loopexit, label %.lr.ph43, !llvm.loop !15

.loopexit:                                        ; preds = %.lr.ph43, %middle.block, %31, %29
  %.0 = phi i32 [ %30, %29 ], [ 0, %31 ], [ 0, %middle.block ], [ 0, %.lr.ph43 ]
  ret i32 %.0
}

declare i32 @liquid_nextpow2(i32 noundef) local_unnamed_addr #1

declare ptr @msequence_create_default(i32 noundef) local_unnamed_addr #1

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

declare i32 @msequence_destroy(ptr noundef) local_unnamed_addr #1

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

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

; 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 i32 @llvm.umax.i32(i32, i32) #2

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

attributes #0 = { 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 #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 = { 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