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

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

; Function Attrs: nounwind uwtable
define dso_local void @qdetector_cccf_runtest_linear(i32 noundef %0) #0 {
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca float, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca i64, align 8
  %10 = alloca ptr, align 8
  store i32 %0, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #6
  store i32 2, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  store i32 7, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #6
  store float 0x3FD3333340000000, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  store i32 7, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  %11 = load i32, ptr %2, align 4, !tbaa !5
  %12 = zext i32 %11 to i64
  %13 = call ptr @llvm.stacksave.p0()
  store ptr %13, ptr %8, align 8
  %14 = alloca { float, float }, i64 %12, align 16
  store i64 %12, ptr %9, align 8
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %15

15:                                               ; preds = %44, %1
  %16 = load i32, ptr %7, align 4, !tbaa !5
  %17 = load i32, ptr %2, align 4, !tbaa !5
  %18 = icmp ult i32 %16, %17
  br i1 %18, label %19, label %47

19:                                               ; preds = %15
  %20 = call i32 @rand() #6
  %21 = srem i32 %20, 2
  %22 = icmp ne i32 %21, 0
  %23 = zext i1 %22 to i64
  %24 = select i1 %22, float 1.000000e+00, float -1.000000e+00
  %25 = fpext float %24 to double
  %26 = fmul double %25, 0x3FE6A09E667F3BCD
  %27 = call i32 @rand() #6
  %28 = srem i32 %27, 2
  %29 = icmp ne i32 %28, 0
  %30 = zext i1 %29 to i64
  %31 = select i1 %29, float 1.000000e+00, float -1.000000e+00
  %32 = fpext float %31 to double
  %33 = fmul double %32, 0x3FE6A09E667F3BCD
  %34 = fmul double %33, 0.000000e+00
  %35 = fmul double %33, 1.000000e+00
  %36 = fadd double %26, %34
  %37 = fptrunc double %36 to float
  %38 = fptrunc double %35 to float
  %39 = load i32, ptr %7, align 4, !tbaa !5
  %40 = zext i32 %39 to i64
  %41 = getelementptr inbounds { float, float }, ptr %14, i64 %40
  %42 = getelementptr inbounds { float, float }, ptr %41, i32 0, i32 0
  %43 = getelementptr inbounds { float, float }, ptr %41, i32 0, i32 1
  store float %37, ptr %42, align 8
  store float %38, ptr %43, align 4
  br label %44

44:                                               ; preds = %19
  %45 = load i32, ptr %7, align 4, !tbaa !5
  %46 = add i32 %45, 1
  store i32 %46, ptr %7, align 4, !tbaa !5
  br label %15, !llvm.loop !11

47:                                               ; preds = %15
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #6
  %48 = load i32, ptr %2, align 4, !tbaa !5
  %49 = load i32, ptr %6, align 4, !tbaa !5
  %50 = load i32, ptr %3, align 4, !tbaa !5
  %51 = load i32, ptr %4, align 4, !tbaa !5
  %52 = load float, ptr %5, align 4, !tbaa !9
  %53 = call ptr @qdetector_cccf_create_linear(ptr noundef %14, i32 noundef %48, i32 noundef %49, i32 noundef %50, i32 noundef %51, float noundef %52)
  store ptr %53, ptr %10, align 8, !tbaa !13
  %54 = load ptr, ptr %10, align 8, !tbaa !13
  call void @qdetector_cccf_runtest(ptr noundef %54)
  %55 = load ptr, ptr %10, align 8, !tbaa !13
  %56 = call i32 @qdetector_cccf_destroy(ptr noundef %55)
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #6
  %57 = load ptr, ptr %8, align 8
  call void @llvm.stackrestore.p0(ptr %57)
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #6
  ret void
}

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

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #2

; Function Attrs: nounwind
declare i32 @rand() #3

declare ptr @qdetector_cccf_create_linear(ptr noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, float noundef) #4

; Function Attrs: nounwind uwtable
declare dso_local void @qdetector_cccf_runtest(ptr noundef) #5

declare i32 @qdetector_cccf_destroy(ptr noundef) #4

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

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nosync nounwind willreturn }
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 = { "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 #5 = { 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 #6 = { 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 = !{!"int", !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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !14, i64 0}
!14 = !{!"any pointer", !7, i64 0}


; 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 void @qdetector_cccf_runtest_linear(i32 noundef %0) local_unnamed_addr #0 {
  %2 = zext i32 %0 to i64
  %3 = alloca { float, float }, i64 %2, align 16
  %.not15 = icmp eq i32 %0, 0
  br i1 %.not15, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %1, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %1 ]
  %4 = tail call i32 @rand() #5
  %5 = and i32 %4, 1
  %.not = icmp eq i32 %5, 0
  %6 = select i1 %.not, double 0xBFE6A09E667F3BCD, double 0x3FE6A09E667F3BCD
  %7 = tail call i32 @rand() #5
  %8 = and i32 %7, 1
  %.not13 = icmp eq i32 %8, 0
  %9 = select i1 %.not13, double 0xBFE6A09E667F3BCD, double 0x3FE6A09E667F3BCD
  %10 = tail call double @llvm.copysign.f64(double 0.000000e+00, double %9)
  %11 = fadd double %6, %10
  %12 = getelementptr inbounds { float, float }, ptr %3, i64 %indvars.iv
  %13 = insertelement <2 x double> poison, double %11, i64 0
  %14 = insertelement <2 x double> %13, double %9, i64 1
  %15 = fptrunc <2 x double> %14 to <2 x float>
  store <2 x float> %15, ptr %12, align 8
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %2
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !5

._crit_edge:                                      ; preds = %.lr.ph, %1
  %16 = call ptr @qdetector_cccf_create_linear(ptr noundef nonnull %3, i32 noundef %0, i32 noundef 7, i32 noundef 2, i32 noundef 7, float noundef 0x3FD3333340000000) #5
  call void @qdetector_cccf_runtest(ptr noundef %16)
  %17 = call i32 @qdetector_cccf_destroy(ptr noundef %16) #5
  ret void
}

; Function Attrs: nounwind
declare i32 @rand() local_unnamed_addr #1

declare ptr @qdetector_cccf_create_linear(ptr noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, float noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local void @qdetector_cccf_runtest(ptr noundef) local_unnamed_addr #3

declare i32 @qdetector_cccf_destroy(ptr noundef) local_unnamed_addr #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.copysign.f64(double, double) #4

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 = { 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 #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 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 #4 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { 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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}


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