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

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

@.str.11 = external hidden unnamed_addr constant [88 x i8], align 1
@.str.34 = external hidden unnamed_addr constant [60 x i8], align 1

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

; Function Attrs: nounwind uwtable
define dso_local i32 @qdetector_cccf_set_range(ptr noundef %0, float noundef %1) #1 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca float, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store float %1, ptr %5, align 4, !tbaa !9
  %6 = load float, ptr %5, align 4, !tbaa !9
  %7 = fcmp olt float %6, 0.000000e+00
  br i1 %7, label %11, label %8

8:                                                ; preds = %2
  %9 = load float, ptr %5, align 4, !tbaa !9
  %10 = fcmp ogt float %9, 5.000000e-01
  br i1 %10, label %11, label %15

11:                                               ; preds = %8, %2
  %12 = load float, ptr %5, align 4, !tbaa !9
  %13 = fpext float %12 to double
  %14 = call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 3, ptr noundef @.str.11, i32 noundef 397, ptr noundef @.str.34, double noundef %13)
  store i32 %14, ptr %3, align 4
  br label %45

15:                                               ; preds = %8
  %16 = load float, ptr %5, align 4, !tbaa !9
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.qdetector_cccf_s, ptr %17, i32 0, i32 13
  store float %16, ptr %18, align 8, !tbaa !11
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.qdetector_cccf_s, ptr %19, i32 0, i32 13
  %21 = load float, ptr %20, align 8, !tbaa !11
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.qdetector_cccf_s, ptr %22, i32 0, i32 8
  %24 = load i32, ptr %23, align 8, !tbaa !14
  %25 = uitofp i32 %24 to float
  %26 = fmul float %21, %25
  %27 = fpext float %26 to double
  %28 = fdiv double %27, 0x401921FB54442D18
  %29 = fptosi double %28 to i32
  %30 = load ptr, ptr %4, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.qdetector_cccf_s, ptr %30, i32 0, i32 14
  store i32 %29, ptr %31, align 4, !tbaa !15
  %32 = load ptr, ptr %4, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.qdetector_cccf_s, ptr %32, i32 0, i32 14
  %34 = load i32, ptr %33, align 4, !tbaa !15
  %35 = icmp slt i32 %34, 0
  br i1 %35, label %36, label %37

36:                                               ; preds = %15
  br label %41

37:                                               ; preds = %15
  %38 = load ptr, ptr %4, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.qdetector_cccf_s, ptr %38, i32 0, i32 14
  %40 = load i32, ptr %39, align 4, !tbaa !15
  br label %41

41:                                               ; preds = %37, %36
  %42 = phi i32 [ 0, %36 ], [ %40, %37 ]
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.qdetector_cccf_s, ptr %43, i32 0, i32 14
  store i32 %42, ptr %44, align 4, !tbaa !15
  store i32 0, ptr %3, align 4
  br label %45

45:                                               ; preds = %41, %11
  %46 = load i32, ptr %3, align 4
  ret i32 %46
}

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

!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 = !{!"float", !7, i64 0}
!11 = !{!12, !10, i64 96}
!12 = !{!"qdetector_cccf_s", !13, i64 0, !6, i64 8, !6, i64 16, !10, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !13, i64 64, !6, i64 72, !6, i64 80, !13, i64 88, !10, i64 92, !10, i64 96, !13, i64 100, !13, i64 104, !10, i64 108, !10, i64 112, !10, i64 116, !13, i64 120, !10, i64 124, !10, i64 128, !10, i64 132, !10, i64 136, !13, i64 140, !13, i64 144}
!13 = !{!"int", !7, i64 0}
!14 = !{!12, !13, i64 64}
!15 = !{!12, !13, i64 100}


; 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.11 = external hidden unnamed_addr constant [88 x i8], align 1
@.str.34 = external hidden unnamed_addr constant [60 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 i32 @qdetector_cccf_set_range(ptr nocapture noundef %0, float noundef %1) local_unnamed_addr #1 {
  %3 = fcmp olt float %1, 0.000000e+00
  %4 = fcmp ogt float %1, 5.000000e-01
  %or.cond = or i1 %3, %4
  br i1 %or.cond, label %5, label %8

5:                                                ; preds = %2
  %6 = fpext float %1 to double
  %7 = tail call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 3, ptr noundef nonnull @.str.11, i32 noundef 397, ptr noundef nonnull @.str.34, double noundef %6) #3
  br label %18

8:                                                ; preds = %2
  %9 = getelementptr inbounds i8, ptr %0, i64 96
  store float %1, ptr %9, align 8, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %0, i64 64
  %11 = load i32, ptr %10, align 8, !tbaa !12
  %12 = uitofp i32 %11 to float
  %13 = fmul float %12, %1
  %14 = fpext float %13 to double
  %15 = fdiv double %14, 0x401921FB54442D18
  %16 = fptosi double %15 to i32
  %17 = getelementptr inbounds i8, ptr %0, i64 100
  %spec.select = tail call i32 @llvm.smax.i32(i32 %16, i32 0)
  store i32 %spec.select, ptr %17, align 4, !tbaa !13
  br label %18

18:                                               ; preds = %8, %5
  %.0 = phi i32 [ %7, %5 ], [ 0, %8 ]
  ret i32 %.0
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smax.i32(i32, i32) #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, !11, i64 96}
!6 = !{!"qdetector_cccf_s", !7, i64 0, !10, i64 8, !10, i64 16, !11, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !10, i64 56, !7, i64 64, !10, i64 72, !10, i64 80, !7, i64 88, !11, i64 92, !11, i64 96, !7, i64 100, !7, i64 104, !11, i64 108, !11, i64 112, !11, i64 116, !7, i64 120, !11, i64 124, !11, i64 128, !11, i64 132, !11, i64 136, !7, i64 140, !7, i64 144}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"float", !8, i64 0}
!12 = !{!6, !7, i64 64}
!13 = !{!6, !7, i64 100}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass