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

; 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.dsssframegen_s = type { i32, i32, float, ptr, [2 x { float, float }], %struct.dsssframegenprops_s, %struct.dsssframegenprops_s, ptr, ptr, ptr, ptr, i32, i32, ptr, i32, ptr, i32, ptr, i32, ptr, i32, i32, i32, i32, { float, float }, i32, i32, i32 }
%struct.dsssframegenprops_s = type { i32, i32, i32 }

; 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
define dso_local i32 @dsssframegen_write_samples(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 = %117, %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 %120

15:                                               ; preds = %11
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.dsssframegen_s, ptr %16, i32 0, i32 21
  %18 = load i32, ptr %17, align 4, !tbaa !11
  %19 = icmp eq i32 %18, 0
  br i1 %19, label %20, label %43

20:                                               ; preds = %15
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = call <2 x float> @dsssframegen_generate_symbol(ptr noundef %21)
  store <2 x float> %22, ptr %9, align 4
  %23 = getelementptr inbounds { float, float }, ptr %9, i32 0, i32 0
  %24 = load float, ptr %23, align 4
  %25 = getelementptr inbounds { float, float }, ptr %9, i32 0, i32 1
  %26 = load float, ptr %25, align 4
  %27 = getelementptr inbounds { float, float }, ptr %8, i32 0, i32 0
  %28 = getelementptr inbounds { float, float }, ptr %8, i32 0, i32 1
  store float %24, ptr %27, align 4
  store float %26, ptr %28, align 4
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.dsssframegen_s, ptr %29, i32 0, i32 3
  %31 = load ptr, ptr %30, align 8, !tbaa !15
  %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 = load ptr, ptr %4, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.dsssframegen_s, ptr %36, i32 0, i32 4
  %38 = getelementptr inbounds [2 x { float, float }], ptr %37, i64 0, i64 0
  %39 = getelementptr inbounds { float, float }, ptr %10, i32 0, i32 0
  %40 = getelementptr inbounds { float, float }, ptr %10, i32 0, i32 1
  store float %33, ptr %39, align 4
  store float %35, ptr %40, align 4
  %41 = load <2 x float>, ptr %10, align 4
  %42 = call i32 @firinterp_crcf_execute(ptr noundef %31, <2 x float> noundef %41, ptr noundef %38)
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  br label %43

43:                                               ; preds = %20, %15
  %44 = load ptr, ptr %4, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.dsssframegen_s, ptr %44, i32 0, i32 4
  %46 = load ptr, ptr %4, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.dsssframegen_s, ptr %46, i32 0, i32 21
  %48 = load i32, ptr %47, align 4, !tbaa !11
  %49 = zext i32 %48 to i64
  %50 = getelementptr inbounds [2 x { float, float }], ptr %45, i64 0, i64 %49
  %51 = getelementptr inbounds { float, float }, ptr %50, i32 0, i32 0
  %52 = load float, ptr %51, align 8
  %53 = getelementptr inbounds { float, float }, ptr %50, i32 0, i32 1
  %54 = load float, ptr %53, align 4
  %55 = load ptr, ptr %5, align 8, !tbaa !5
  %56 = load i32, ptr %7, align 4, !tbaa !9
  %57 = zext i32 %56 to i64
  %58 = getelementptr inbounds { float, float }, ptr %55, i64 %57
  %59 = getelementptr inbounds { float, float }, ptr %58, i32 0, i32 0
  %60 = getelementptr inbounds { float, float }, ptr %58, i32 0, i32 1
  store float %52, ptr %59, align 4
  store float %54, ptr %60, align 4
  %61 = load ptr, ptr %4, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.dsssframegen_s, ptr %61, i32 0, i32 20
  %63 = load i32, ptr %62, align 8, !tbaa !16
  %64 = load ptr, ptr %4, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.dsssframegen_s, ptr %64, i32 0, i32 1
  %66 = load i32, ptr %65, align 4, !tbaa !17
  %67 = icmp ult i32 %63, %66
  br i1 %67, label %68, label %106

68:                                               ; preds = %43
  %69 = load ptr, ptr %4, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.dsssframegen_s, ptr %69, i32 0, i32 27
  %71 = load i32, ptr %70, align 8, !tbaa !18
  %72 = icmp eq i32 %71, 0
  br i1 %72, label %73, label %106

73:                                               ; preds = %68
  %74 = load ptr, ptr %4, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.dsssframegen_s, ptr %74, i32 0, i32 20
  %76 = load i32, ptr %75, align 8, !tbaa !16
  %77 = load ptr, ptr %4, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.dsssframegen_s, ptr %77, i32 0, i32 0
  %79 = load i32, ptr %78, align 8, !tbaa !19
  %80 = mul i32 %76, %79
  %81 = load ptr, ptr %4, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.dsssframegen_s, ptr %81, i32 0, i32 21
  %83 = load i32, ptr %82, align 4, !tbaa !11
  %84 = add i32 %80, %83
  %85 = load ptr, ptr %4, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.dsssframegen_s, ptr %85, i32 0, i32 1
  %87 = load i32, ptr %86, align 4, !tbaa !17
  %88 = mul i32 2, %87
  %89 = load ptr, ptr %4, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct.dsssframegen_s, ptr %89, i32 0, i32 0
  %91 = load i32, ptr %90, align 8, !tbaa !19
  %92 = mul i32 %88, %91
  %93 = call float @liquid_hamming(i32 noundef %84, i32 noundef %92)
  %94 = load ptr, ptr %5, align 8, !tbaa !5
  %95 = load i32, ptr %7, align 4, !tbaa !9
  %96 = zext i32 %95 to i64
  %97 = getelementptr inbounds { float, float }, ptr %94, i64 %96
  %98 = getelementptr inbounds { float, float }, ptr %97, i32 0, i32 0
  %99 = load float, ptr %98, align 4
  %100 = getelementptr inbounds { float, float }, ptr %97, i32 0, i32 1
  %101 = load float, ptr %100, align 4
  %102 = fmul float %99, %93
  %103 = fmul float %101, %93
  %104 = getelementptr inbounds { float, float }, ptr %97, i32 0, i32 0
  %105 = getelementptr inbounds { float, float }, ptr %97, i32 0, i32 1
  store float %102, ptr %104, align 4
  store float %103, ptr %105, align 4
  br label %106

106:                                              ; preds = %73, %68, %43
  %107 = load ptr, ptr %4, align 8, !tbaa !5
  %108 = getelementptr inbounds %struct.dsssframegen_s, ptr %107, i32 0, i32 21
  %109 = load i32, ptr %108, align 4, !tbaa !11
  %110 = add i32 %109, 1
  %111 = load ptr, ptr %4, align 8, !tbaa !5
  %112 = getelementptr inbounds %struct.dsssframegen_s, ptr %111, i32 0, i32 0
  %113 = load i32, ptr %112, align 8, !tbaa !19
  %114 = urem i32 %110, %113
  %115 = load ptr, ptr %4, align 8, !tbaa !5
  %116 = getelementptr inbounds %struct.dsssframegen_s, ptr %115, i32 0, i32 21
  store i32 %114, ptr %116, align 4, !tbaa !11
  br label %117

117:                                              ; preds = %106
  %118 = load i32, ptr %7, align 4, !tbaa !9
  %119 = add i32 %118, 1
  store i32 %119, ptr %7, align 4, !tbaa !9
  br label %11, !llvm.loop !20

120:                                              ; preds = %11
  %121 = load ptr, ptr %4, align 8, !tbaa !5
  %122 = getelementptr inbounds %struct.dsssframegen_s, ptr %121, i32 0, i32 26
  %123 = load i32, ptr %122, align 4, !tbaa !22
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  ret i32 %123
}

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

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

declare float @liquid_hamming(i32 noundef, i32 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, !10, i64 164}
!12 = !{!"dsssframegen_s", !10, i64 0, !10, i64 4, !13, i64 8, !6, i64 16, !7, i64 24, !14, i64 40, !14, i64 52, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !10, i64 96, !10, i64 100, !6, i64 104, !10, i64 112, !6, i64 120, !10, i64 128, !6, i64 136, !10, i64 144, !6, i64 152, !10, i64 160, !10, i64 164, !10, i64 168, !10, i64 172, !7, i64 176, !10, i64 184, !10, i64 188, !10, i64 192}
!13 = !{!"float", !7, i64 0}
!14 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8}
!15 = !{!12, !6, i64 16}
!16 = !{!12, !10, i64 160}
!17 = !{!12, !10, i64 4}
!18 = !{!12, !10, i64 192}
!19 = !{!12, !10, i64 0}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}
!22 = !{!12, !10, i64 188}


; 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: nounwind uwtable
define dso_local i32 @dsssframegen_write_samples(ptr noundef %0, ptr nocapture noundef %1, i32 noundef %2) local_unnamed_addr #0 {
  %.not = icmp eq i32 %2, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %3
  %4 = getelementptr inbounds i8, ptr %0, i64 164
  %5 = getelementptr inbounds i8, ptr %0, i64 16
  %6 = getelementptr inbounds i8, ptr %0, i64 24
  %7 = getelementptr inbounds i8, ptr %0, i64 160
  %8 = getelementptr inbounds i8, ptr %0, i64 4
  %9 = getelementptr inbounds i8, ptr %0, i64 192
  %wide.trip.count = zext i32 %2 to i64
  %.pre = load i32, ptr %4, align 4, !tbaa !5
  br label %10

10:                                               ; preds = %.lr.ph, %41
  %11 = phi i32 [ %.pre, %.lr.ph ], [ %45, %41 ]
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %41 ]
  %12 = icmp eq i32 %11, 0
  br i1 %12, label %13, label %17

13:                                               ; preds = %10
  %14 = tail call <2 x float> @dsssframegen_generate_symbol(ptr noundef nonnull %0)
  %15 = load ptr, ptr %5, align 8, !tbaa !13
  %16 = tail call i32 @firinterp_crcf_execute(ptr noundef %15, <2 x float> noundef %14, ptr noundef nonnull %6) #2
  %.pre31 = load i32, ptr %4, align 4, !tbaa !5
  br label %17

17:                                               ; preds = %13, %10
  %18 = phi i32 [ %.pre31, %13 ], [ %11, %10 ]
  %19 = zext i32 %18 to i64
  %20 = getelementptr inbounds [2 x { float, float }], ptr %6, i64 0, i64 %19
  %21 = getelementptr inbounds { float, float }, ptr %1, i64 %indvars.iv
  %22 = load <2 x float>, ptr %20, align 8
  store <2 x float> %22, ptr %21, align 4
  %23 = load i32, ptr %7, align 8, !tbaa !14
  %24 = load i32, ptr %8, align 4, !tbaa !15
  %25 = icmp ult i32 %23, %24
  br i1 %25, label %26, label %41

26:                                               ; preds = %17
  %27 = load i32, ptr %9, align 8, !tbaa !16
  %28 = icmp eq i32 %27, 0
  br i1 %28, label %29, label %41

29:                                               ; preds = %26
  %30 = load i32, ptr %0, align 8, !tbaa !17
  %31 = mul i32 %30, %23
  %32 = load i32, ptr %4, align 4, !tbaa !5
  %33 = add i32 %31, %32
  %34 = shl i32 %24, 1
  %35 = mul i32 %34, %30
  %36 = tail call float @liquid_hamming(i32 noundef %33, i32 noundef %35) #2
  %37 = load <2 x float>, ptr %21, align 4
  %38 = insertelement <2 x float> poison, float %36, i64 0
  %39 = shufflevector <2 x float> %38, <2 x float> poison, <2 x i32> zeroinitializer
  %40 = fmul <2 x float> %39, %37
  store <2 x float> %40, ptr %21, align 4
  br label %41

41:                                               ; preds = %29, %26, %17
  %42 = load i32, ptr %4, align 4, !tbaa !5
  %43 = add i32 %42, 1
  %44 = load i32, ptr %0, align 8, !tbaa !17
  %45 = urem i32 %43, %44
  store i32 %45, ptr %4, align 4, !tbaa !5
  %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 %10, !llvm.loop !18

._crit_edge:                                      ; preds = %41, %3
  %46 = getelementptr inbounds i8, ptr %0, i64 188
  %47 = load i32, ptr %46, align 4, !tbaa !20
  ret i32 %47
}

; Function Attrs: nounwind uwtable
declare dso_local <2 x float> @dsssframegen_generate_symbol(ptr noundef) local_unnamed_addr #0

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

declare float @liquid_hamming(i32 noundef, i32 noundef) local_unnamed_addr #1

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

!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 164}
!6 = !{!"dsssframegen_s", !7, i64 0, !7, i64 4, !10, i64 8, !11, i64 16, !8, i64 24, !12, i64 40, !12, i64 52, !11, i64 64, !11, i64 72, !11, i64 80, !11, i64 88, !7, i64 96, !7, i64 100, !11, i64 104, !7, i64 112, !11, i64 120, !7, i64 128, !11, i64 136, !7, i64 144, !11, i64 152, !7, i64 160, !7, i64 164, !7, i64 168, !7, i64 172, !8, i64 176, !7, i64 184, !7, i64 188, !7, i64 192}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"float", !8, i64 0}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!"", !7, i64 0, !7, i64 4, !7, i64 8}
!13 = !{!6, !11, i64 16}
!14 = !{!6, !7, i64 160}
!15 = !{!6, !7, i64 4}
!16 = !{!6, !7, i64 192}
!17 = !{!6, !7, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = !{!6, !7, i64 188}


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