; 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

declare i32 @synth_crcf_get_length(ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local <2 x float> @dsssframegen_generate_header(ptr noundef %0) #2 {
  %2 = alloca { float, float }, align 4
  %3 = alloca ptr, align 8
  %4 = alloca { float, float }, align 4
  %5 = alloca { float, float }, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  %6 = load ptr, ptr %3, align 8, !tbaa !5
  %7 = getelementptr inbounds %struct.dsssframegen_s, ptr %6, i32 0, i32 20
  %8 = load i32, ptr %7, align 8, !tbaa !9
  %9 = icmp eq i32 %8, 0
  br i1 %9, label %10, label %27

10:                                               ; preds = %1
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.dsssframegen_s, ptr %11, i32 0, i32 15
  %13 = load ptr, ptr %12, align 8, !tbaa !14
  %14 = load ptr, ptr %3, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.dsssframegen_s, ptr %14, i32 0, i32 22
  %16 = load i32, ptr %15, align 8, !tbaa !15
  %17 = zext i32 %16 to i64
  %18 = getelementptr inbounds { float, float }, ptr %13, i64 %17
  %19 = getelementptr inbounds { float, float }, ptr %18, i32 0, i32 0
  %20 = load float, ptr %19, align 4
  %21 = getelementptr inbounds { float, float }, ptr %18, i32 0, i32 1
  %22 = load float, ptr %21, align 4
  %23 = load ptr, ptr %3, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.dsssframegen_s, ptr %23, i32 0, i32 24
  %25 = getelementptr inbounds { float, float }, ptr %24, i32 0, i32 0
  %26 = getelementptr inbounds { float, float }, ptr %24, i32 0, i32 1
  store float %20, ptr %25, align 8
  store float %22, ptr %26, align 4
  br label %27

27:                                               ; preds = %10, %1
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.dsssframegen_s, ptr %28, i32 0, i32 8
  %30 = load ptr, ptr %29, align 8, !tbaa !16
  %31 = load ptr, ptr %3, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.dsssframegen_s, ptr %31, i32 0, i32 24
  %33 = getelementptr inbounds { float, float }, ptr %32, i32 0, i32 0
  %34 = load float, ptr %33, align 8
  %35 = getelementptr inbounds { float, float }, ptr %32, i32 0, i32 1
  %36 = load float, ptr %35, align 4
  %37 = getelementptr inbounds { float, float }, ptr %5, i32 0, i32 0
  %38 = getelementptr inbounds { float, float }, ptr %5, i32 0, i32 1
  store float %34, ptr %37, align 4
  store float %36, ptr %38, align 4
  %39 = load <2 x float>, ptr %5, align 4
  call void @synth_crcf_mix_up(ptr noundef %30, <2 x float> noundef %39, ptr noundef %4)
  %40 = load ptr, ptr %3, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.dsssframegen_s, ptr %40, i32 0, i32 8
  %42 = load ptr, ptr %41, align 8, !tbaa !16
  call void @synth_crcf_step(ptr noundef %42)
  %43 = load ptr, ptr %3, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.dsssframegen_s, ptr %43, i32 0, i32 20
  %45 = load i32, ptr %44, align 8, !tbaa !9
  %46 = add i32 %45, 1
  store i32 %46, ptr %44, align 8, !tbaa !9
  %47 = load ptr, ptr %3, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.dsssframegen_s, ptr %47, i32 0, i32 20
  %49 = load i32, ptr %48, align 8, !tbaa !9
  %50 = load ptr, ptr %3, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.dsssframegen_s, ptr %50, i32 0, i32 8
  %52 = load ptr, ptr %51, align 8, !tbaa !16
  %53 = call i32 @synth_crcf_get_length(ptr noundef %52)
  %54 = icmp eq i32 %49, %53
  br i1 %54, label %55, label %75

55:                                               ; preds = %27
  %56 = load ptr, ptr %3, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.dsssframegen_s, ptr %56, i32 0, i32 20
  store i32 0, ptr %57, align 8, !tbaa !9
  %58 = load ptr, ptr %3, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.dsssframegen_s, ptr %58, i32 0, i32 22
  %60 = load i32, ptr %59, align 8, !tbaa !15
  %61 = add i32 %60, 1
  store i32 %61, ptr %59, align 8, !tbaa !15
  %62 = load ptr, ptr %3, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.dsssframegen_s, ptr %62, i32 0, i32 22
  %64 = load i32, ptr %63, align 8, !tbaa !15
  %65 = load ptr, ptr %3, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.dsssframegen_s, ptr %65, i32 0, i32 14
  %67 = load i32, ptr %66, align 8, !tbaa !17
  %68 = icmp eq i32 %64, %67
  br i1 %68, label %69, label %74

69:                                               ; preds = %55
  %70 = load ptr, ptr %3, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.dsssframegen_s, ptr %70, i32 0, i32 22
  store i32 0, ptr %71, align 8, !tbaa !15
  %72 = load ptr, ptr %3, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.dsssframegen_s, ptr %72, i32 0, i32 27
  store i32 2, ptr %73, align 8, !tbaa !18
  br label %74

74:                                               ; preds = %69, %55
  br label %75

75:                                               ; preds = %74, %27
  %76 = getelementptr inbounds { float, float }, ptr %4, i32 0, i32 0
  %77 = load float, ptr %76, align 4
  %78 = getelementptr inbounds { float, float }, ptr %4, i32 0, i32 1
  %79 = load float, ptr %78, align 4
  %80 = getelementptr inbounds { float, float }, ptr %2, i32 0, i32 0
  %81 = getelementptr inbounds { float, float }, ptr %2, i32 0, i32 1
  store float %77, ptr %80, align 4
  store float %79, ptr %81, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  %82 = load <2 x float>, ptr %2, align 4
  ret <2 x float> %82
}

declare void @synth_crcf_mix_up(ptr noundef, <2 x float> noundef, ptr noundef) #1

declare void @synth_crcf_step(ptr noundef) #1

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 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 #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, !11, i64 160}
!10 = !{!"dsssframegen_s", !11, i64 0, !11, i64 4, !12, i64 8, !6, i64 16, !7, i64 24, !13, i64 40, !13, i64 52, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !11, i64 96, !11, i64 100, !6, i64 104, !11, i64 112, !6, i64 120, !11, i64 128, !6, i64 136, !11, i64 144, !6, i64 152, !11, i64 160, !11, i64 164, !11, i64 168, !11, i64 172, !7, i64 176, !11, i64 184, !11, i64 188, !11, i64 192}
!11 = !{!"int", !7, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{!"", !11, i64 0, !11, i64 4, !11, i64 8}
!14 = !{!10, !6, i64 120}
!15 = !{!10, !11, i64 168}
!16 = !{!10, !6, i64 72}
!17 = !{!10, !11, i64 112}
!18 = !{!10, !11, i64 192}


; 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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

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

declare i32 @synth_crcf_get_length(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local <2 x float> @dsssframegen_generate_header(ptr nocapture noundef %0) local_unnamed_addr #2 {
  %2 = alloca { float, float }, align 8
  %3 = getelementptr inbounds i8, ptr %0, i64 160
  %4 = load i32, ptr %3, align 8, !tbaa !5
  %5 = icmp eq i32 %4, 0
  br i1 %5, label %7, label %._crit_edge

._crit_edge:                                      ; preds = %1
  %.phi.trans.insert = getelementptr inbounds i8, ptr %0, i64 176
  %6 = load <2 x float>, ptr %.phi.trans.insert, align 8
  br label %16

7:                                                ; preds = %1
  %8 = getelementptr inbounds i8, ptr %0, i64 120
  %9 = load ptr, ptr %8, align 8, !tbaa !13
  %10 = getelementptr inbounds i8, ptr %0, i64 168
  %11 = load i32, ptr %10, align 8, !tbaa !14
  %12 = zext i32 %11 to i64
  %13 = getelementptr inbounds { float, float }, ptr %9, i64 %12
  %14 = load <2 x float>, ptr %13, align 4
  %15 = getelementptr inbounds i8, ptr %0, i64 176
  store <2 x float> %14, ptr %15, align 8
  br label %16

16:                                               ; preds = %._crit_edge, %7
  %17 = phi <2 x float> [ %6, %._crit_edge ], [ %14, %7 ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #3
  %18 = getelementptr inbounds i8, ptr %0, i64 72
  %19 = load ptr, ptr %18, align 8, !tbaa !15
  call void @synth_crcf_mix_up(ptr noundef %19, <2 x float> noundef %17, ptr noundef nonnull %2) #3
  %20 = load ptr, ptr %18, align 8, !tbaa !15
  call void @synth_crcf_step(ptr noundef %20) #3
  %21 = load i32, ptr %3, align 8, !tbaa !5
  %22 = add i32 %21, 1
  store i32 %22, ptr %3, align 8, !tbaa !5
  %23 = load ptr, ptr %18, align 8, !tbaa !15
  %24 = call i32 @synth_crcf_get_length(ptr noundef %23) #3
  %25 = icmp eq i32 %22, %24
  br i1 %25, label %26, label %35

26:                                               ; preds = %16
  store i32 0, ptr %3, align 8, !tbaa !5
  %27 = getelementptr inbounds i8, ptr %0, i64 168
  %28 = load i32, ptr %27, align 8, !tbaa !14
  %29 = add i32 %28, 1
  store i32 %29, ptr %27, align 8, !tbaa !14
  %30 = getelementptr inbounds i8, ptr %0, i64 112
  %31 = load i32, ptr %30, align 8, !tbaa !16
  %32 = icmp eq i32 %29, %31
  br i1 %32, label %33, label %35

33:                                               ; preds = %26
  store i32 0, ptr %27, align 8, !tbaa !14
  %34 = getelementptr inbounds i8, ptr %0, i64 192
  store i32 2, ptr %34, align 8, !tbaa !17
  br label %35

35:                                               ; preds = %26, %33, %16
  %36 = load <2 x float>, ptr %2, align 8
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #3
  ret <2 x float> %36
}

declare void @synth_crcf_mix_up(ptr noundef, <2 x float> noundef, ptr noundef) local_unnamed_addr #1

declare void @synth_crcf_step(ptr noundef) local_unnamed_addr #1

attributes #0 = { mustprogress 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 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 #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, !7, i64 160}
!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 120}
!14 = !{!6, !7, i64 168}
!15 = !{!6, !11, i64 72}
!16 = !{!6, !7, i64 112}
!17 = !{!6, !7, i64 192}


; Effective O3 passes: BDCEPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass