; LLVM IR from jgaeddert/liquid-dsp :: src/modem/src (fskdem)

; 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.fskdem_s = type { i32, i32, float, i32, float, i32, ptr, ptr, ptr, ptr, i32 }

@.str = external hidden unnamed_addr constant [77 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [67 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

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

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

; Function Attrs: nounwind uwtable
define dso_local float @fskdem_get_symbol_energy(ptr noundef %0, i32 noundef %1, i32 noundef %2) #2 {
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca { float, float }, align 4
  %9 = alloca float, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca { float, float }, align 4
  %14 = alloca { float, float }, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  store i32 %2, ptr %6, align 4, !tbaa !9
  %15 = load i32, ptr %5, align 4, !tbaa !9
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.fskdem_s, ptr %16, i32 0, i32 3
  %18 = load i32, ptr %17, align 4, !tbaa !11
  %19 = icmp uge i32 %15, %18
  br i1 %19, label %20, label %26

20:                                               ; preds = %3
  %21 = load i32, ptr %5, align 4, !tbaa !9
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.fskdem_s, ptr %22, i32 0, i32 3
  %24 = load i32, ptr %23, align 4, !tbaa !11
  %25 = call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 3, ptr noundef @.str, i32 noundef 269, ptr noundef @.str.11, i32 noundef %21, i32 noundef %24)
  store i32 0, ptr %5, align 4, !tbaa !9
  br label %26

26:                                               ; preds = %20, %3
  %27 = load i32, ptr %6, align 4, !tbaa !9
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.fskdem_s, ptr %28, i32 0, i32 5
  %30 = load i32, ptr %29, align 4, !tbaa !14
  %31 = icmp ugt i32 %27, %30
  br i1 %31, label %32, label %36

32:                                               ; preds = %26
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.fskdem_s, ptr %33, i32 0, i32 5
  %35 = load i32, ptr %34, align 4, !tbaa !14
  store i32 %35, ptr %6, align 4, !tbaa !9
  br label %36

36:                                               ; preds = %32, %26
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  %37 = load ptr, ptr %4, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.fskdem_s, ptr %37, i32 0, i32 9
  %39 = load ptr, ptr %38, align 8, !tbaa !15
  %40 = load i32, ptr %5, align 4, !tbaa !9
  %41 = zext i32 %40 to i64
  %42 = getelementptr inbounds i32, ptr %39, i64 %41
  %43 = load i32, ptr %42, align 4, !tbaa !9
  store i32 %43, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %44 = load ptr, ptr %4, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.fskdem_s, ptr %44, i32 0, i32 7
  %46 = load ptr, ptr %45, align 8, !tbaa !16
  %47 = load i32, ptr %7, align 4, !tbaa !9
  %48 = zext i32 %47 to i64
  %49 = getelementptr inbounds { float, float }, ptr %46, i64 %48
  %50 = getelementptr inbounds { float, float }, ptr %49, i32 0, i32 0
  %51 = load float, ptr %50, align 4
  %52 = getelementptr inbounds { float, float }, ptr %49, i32 0, i32 1
  %53 = load float, ptr %52, align 4
  %54 = getelementptr inbounds { float, float }, ptr %8, i32 0, i32 0
  %55 = getelementptr inbounds { float, float }, ptr %8, i32 0, i32 1
  store float %51, ptr %54, align 4
  store float %53, ptr %55, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  %56 = getelementptr inbounds { float, float }, ptr %8, i32 0, i32 0
  %57 = load float, ptr %56, align 4
  %58 = getelementptr inbounds { float, float }, ptr %8, i32 0, i32 1
  %59 = load float, ptr %58, align 4
  %60 = getelementptr inbounds { float, float }, ptr %8, i32 0, i32 0
  %61 = load float, ptr %60, align 4
  %62 = getelementptr inbounds { float, float }, ptr %8, i32 0, i32 1
  %63 = load float, ptr %62, align 4
  %64 = getelementptr inbounds { float, float }, ptr %8, i32 0, i32 0
  %65 = load float, ptr %64, align 4
  %66 = getelementptr inbounds { float, float }, ptr %8, i32 0, i32 1
  %67 = load float, ptr %66, align 4
  %68 = getelementptr inbounds { float, float }, ptr %8, i32 0, i32 0
  %69 = load float, ptr %68, align 4
  %70 = getelementptr inbounds { float, float }, ptr %8, i32 0, i32 1
  %71 = load float, ptr %70, align 4
  %72 = fmul float %67, %71
  %73 = call float @llvm.fmuladd.f32(float %57, float %61, float %72)
  store float %73, ptr %9, align 4, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  store i32 0, ptr %10, align 4, !tbaa !9
  br label %74

74:                                               ; preds = %161, %36
  %75 = load i32, ptr %10, align 4, !tbaa !9
  %76 = load i32, ptr %6, align 4, !tbaa !9
  %77 = icmp ult i32 %75, %76
  br i1 %77, label %78, label %164

78:                                               ; preds = %74
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  %79 = load i32, ptr %7, align 4, !tbaa !9
  %80 = load i32, ptr %10, align 4, !tbaa !9
  %81 = add i32 %79, %80
  %82 = load ptr, ptr %4, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.fskdem_s, ptr %82, i32 0, i32 5
  %84 = load i32, ptr %83, align 4, !tbaa !14
  %85 = urem i32 %81, %84
  store i32 %85, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  %86 = load i32, ptr %7, align 4, !tbaa !9
  %87 = load ptr, ptr %4, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.fskdem_s, ptr %87, i32 0, i32 5
  %89 = load i32, ptr %88, align 4, !tbaa !14
  %90 = add i32 %86, %89
  %91 = load i32, ptr %10, align 4, !tbaa !9
  %92 = sub i32 %90, %91
  %93 = load ptr, ptr %4, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.fskdem_s, ptr %93, i32 0, i32 5
  %95 = load i32, ptr %94, align 4, !tbaa !14
  %96 = urem i32 %92, %95
  store i32 %96, ptr %12, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  %97 = load ptr, ptr %4, align 8, !tbaa !5
  %98 = getelementptr inbounds %struct.fskdem_s, ptr %97, i32 0, i32 7
  %99 = load ptr, ptr %98, align 8, !tbaa !16
  %100 = load i32, ptr %11, align 4, !tbaa !9
  %101 = zext i32 %100 to i64
  %102 = getelementptr inbounds { float, float }, ptr %99, i64 %101
  %103 = getelementptr inbounds { float, float }, ptr %102, i32 0, i32 0
  %104 = load float, ptr %103, align 4
  %105 = getelementptr inbounds { float, float }, ptr %102, i32 0, i32 1
  %106 = load float, ptr %105, align 4
  %107 = getelementptr inbounds { float, float }, ptr %13, i32 0, i32 0
  %108 = getelementptr inbounds { float, float }, ptr %13, i32 0, i32 1
  store float %104, ptr %107, align 4
  store float %106, ptr %108, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  %109 = load ptr, ptr %4, align 8, !tbaa !5
  %110 = getelementptr inbounds %struct.fskdem_s, ptr %109, i32 0, i32 7
  %111 = load ptr, ptr %110, align 8, !tbaa !16
  %112 = load i32, ptr %12, align 4, !tbaa !9
  %113 = zext i32 %112 to i64
  %114 = getelementptr inbounds { float, float }, ptr %111, i64 %113
  %115 = getelementptr inbounds { float, float }, ptr %114, i32 0, i32 0
  %116 = load float, ptr %115, align 4
  %117 = getelementptr inbounds { float, float }, ptr %114, i32 0, i32 1
  %118 = load float, ptr %117, align 4
  %119 = getelementptr inbounds { float, float }, ptr %14, i32 0, i32 0
  %120 = getelementptr inbounds { float, float }, ptr %14, i32 0, i32 1
  store float %116, ptr %119, align 4
  store float %118, ptr %120, align 4
  %121 = getelementptr inbounds { float, float }, ptr %13, i32 0, i32 0
  %122 = load float, ptr %121, align 4
  %123 = getelementptr inbounds { float, float }, ptr %13, i32 0, i32 1
  %124 = load float, ptr %123, align 4
  %125 = getelementptr inbounds { float, float }, ptr %13, i32 0, i32 0
  %126 = load float, ptr %125, align 4
  %127 = getelementptr inbounds { float, float }, ptr %13, i32 0, i32 1
  %128 = load float, ptr %127, align 4
  %129 = getelementptr inbounds { float, float }, ptr %13, i32 0, i32 0
  %130 = load float, ptr %129, align 4
  %131 = getelementptr inbounds { float, float }, ptr %13, i32 0, i32 1
  %132 = load float, ptr %131, align 4
  %133 = getelementptr inbounds { float, float }, ptr %13, i32 0, i32 0
  %134 = load float, ptr %133, align 4
  %135 = getelementptr inbounds { float, float }, ptr %13, i32 0, i32 1
  %136 = load float, ptr %135, align 4
  %137 = fmul float %132, %136
  %138 = call float @llvm.fmuladd.f32(float %122, float %126, float %137)
  %139 = load float, ptr %9, align 4, !tbaa !17
  %140 = fadd float %139, %138
  store float %140, ptr %9, align 4, !tbaa !17
  %141 = getelementptr inbounds { float, float }, ptr %14, i32 0, i32 0
  %142 = load float, ptr %141, align 4
  %143 = getelementptr inbounds { float, float }, ptr %14, i32 0, i32 1
  %144 = load float, ptr %143, align 4
  %145 = getelementptr inbounds { float, float }, ptr %14, i32 0, i32 0
  %146 = load float, ptr %145, align 4
  %147 = getelementptr inbounds { float, float }, ptr %14, i32 0, i32 1
  %148 = load float, ptr %147, align 4
  %149 = getelementptr inbounds { float, float }, ptr %14, i32 0, i32 0
  %150 = load float, ptr %149, align 4
  %151 = getelementptr inbounds { float, float }, ptr %14, i32 0, i32 1
  %152 = load float, ptr %151, align 4
  %153 = getelementptr inbounds { float, float }, ptr %14, i32 0, i32 0
  %154 = load float, ptr %153, align 4
  %155 = getelementptr inbounds { float, float }, ptr %14, i32 0, i32 1
  %156 = load float, ptr %155, align 4
  %157 = fmul float %152, %156
  %158 = call float @llvm.fmuladd.f32(float %142, float %146, float %157)
  %159 = load float, ptr %9, align 4, !tbaa !17
  %160 = fadd float %159, %158
  store float %160, ptr %9, align 4, !tbaa !17
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  br label %161

161:                                              ; preds = %78
  %162 = load i32, ptr %10, align 4, !tbaa !9
  %163 = add nsw i32 %162, 1
  store i32 %163, ptr %10, align 4, !tbaa !9
  br label %74, !llvm.loop !18

164:                                              ; preds = %74
  %165 = load float, ptr %9, align 4, !tbaa !17
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  ret float %165
}

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

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"="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 #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, !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 12}
!12 = !{!"fskdem_s", !10, i64 0, !10, i64 4, !13, i64 8, !10, i64 12, !13, i64 16, !10, i64 20, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !10, i64 56}
!13 = !{!"float", !7, i64 0}
!14 = !{!12, !10, i64 20}
!15 = !{!12, !6, i64 48}
!16 = !{!12, !6, i64 32}
!17 = !{!13, !13, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"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"

@.str = external hidden unnamed_addr constant [77 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [67 x i8], align 1

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

; Function Attrs: nounwind uwtable
define dso_local float @fskdem_get_symbol_energy(ptr nocapture noundef readonly %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #1 {
  %4 = getelementptr inbounds i8, ptr %0, i64 12
  %5 = load i32, ptr %4, align 4, !tbaa !5
  %.not = icmp ugt i32 %5, %1
  br i1 %.not, label %8, label %6

6:                                                ; preds = %3
  %7 = tail call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 3, ptr noundef nonnull @.str, i32 noundef 269, ptr noundef nonnull @.str.11, i32 noundef %1, i32 noundef %5) #4
  br label %8

8:                                                ; preds = %6, %3
  %.0 = phi i32 [ 0, %6 ], [ %1, %3 ]
  %9 = getelementptr inbounds i8, ptr %0, i64 20
  %10 = load i32, ptr %9, align 4, !tbaa !12
  %spec.select = tail call i32 @llvm.umin.i32(i32 %10, i32 %2)
  %11 = getelementptr inbounds i8, ptr %0, i64 48
  %12 = load ptr, ptr %11, align 8, !tbaa !13
  %13 = zext i32 %.0 to i64
  %14 = getelementptr inbounds i32, ptr %12, i64 %13
  %15 = load i32, ptr %14, align 4, !tbaa !14
  %16 = getelementptr inbounds i8, ptr %0, i64 32
  %17 = load ptr, ptr %16, align 8, !tbaa !15
  %18 = zext i32 %15 to i64
  %19 = getelementptr inbounds { float, float }, ptr %17, i64 %18
  %20 = load float, ptr %19, align 4
  %21 = getelementptr inbounds i8, ptr %19, i64 4
  %22 = load float, ptr %21, align 4
  %23 = fmul float %22, %22
  %24 = tail call float @llvm.fmuladd.f32(float %20, float %20, float %23)
  %.not58 = icmp eq i32 %spec.select, 0
  br i1 %.not58, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %8
  %25 = add i32 %15, %10
  br label %26

26:                                               ; preds = %.lr.ph, %26
  %.05057 = phi float [ %24, %.lr.ph ], [ %46, %26 ]
  %.05156 = phi i32 [ 0, %.lr.ph ], [ %47, %26 ]
  %27 = add i32 %.05156, %15
  %28 = urem i32 %27, %10
  %29 = sub i32 %25, %.05156
  %30 = urem i32 %29, %10
  %31 = zext i32 %28 to i64
  %32 = getelementptr inbounds { float, float }, ptr %17, i64 %31
  %33 = load float, ptr %32, align 4
  %34 = getelementptr inbounds i8, ptr %32, i64 4
  %35 = load float, ptr %34, align 4
  %36 = zext i32 %30 to i64
  %37 = getelementptr inbounds { float, float }, ptr %17, i64 %36
  %38 = load float, ptr %37, align 4
  %39 = getelementptr inbounds i8, ptr %37, i64 4
  %40 = load float, ptr %39, align 4
  %41 = fmul float %35, %35
  %42 = tail call float @llvm.fmuladd.f32(float %33, float %33, float %41)
  %43 = fadd float %.05057, %42
  %44 = fmul float %40, %40
  %45 = tail call float @llvm.fmuladd.f32(float %38, float %38, float %44)
  %46 = fadd float %43, %45
  %47 = add nuw nsw i32 %.05156, 1
  %exitcond.not = icmp eq i32 %47, %spec.select
  br i1 %exitcond.not, label %._crit_edge, label %26, !llvm.loop !16

._crit_edge:                                      ; preds = %26, %8
  %.050.lcssa = phi float [ %24, %8 ], [ %46, %26 ]
  ret float %.050.lcssa
}

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

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

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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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, !7, i64 12}
!6 = !{!"fskdem_s", !7, i64 0, !7, i64 4, !10, i64 8, !7, i64 12, !10, i64 16, !7, i64 20, !11, i64 24, !11, i64 32, !11, i64 40, !11, i64 48, !7, i64 56}
!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 = !{!6, !7, i64 20}
!13 = !{!6, !11, i64 48}
!14 = !{!7, !7, i64 0}
!15 = !{!6, !11, i64 32}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}


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