; LLVM IR from jgaeddert/liquid-dsp :: src/audio/tests (cvsd_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"

@.str = external hidden unnamed_addr constant [86 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [10 x i8], align 1
@liquid_autotest_verbose = external global i32, align 4
@.str.4 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [7 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @autotest_cvsd_rmse_sine() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca float, align 4
  %4 = alloca float, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca float, align 4
  %8 = alloca float, align 4
  %9 = alloca i32, align 4
  %10 = alloca i8, align 1
  %11 = alloca float, align 4
  %12 = alloca float, align 4
  %13 = alloca float, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #5
  store i32 256, ptr %1, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  store i32 3, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  store float 1.500000e+00, ptr %3, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  store float 0x3FECCCCCC0000000, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  %14 = load i32, ptr %2, align 4, !tbaa !5
  %15 = load float, ptr %3, align 4, !tbaa !9
  %16 = load float, ptr %4, align 4, !tbaa !9
  %17 = call ptr @cvsd_create(i32 noundef %14, float noundef %15, float noundef %16)
  store ptr %17, ptr %5, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  %18 = load i32, ptr %2, align 4, !tbaa !5
  %19 = load float, ptr %3, align 4, !tbaa !9
  %20 = load float, ptr %4, align 4, !tbaa !9
  %21 = call ptr @cvsd_create(i32 noundef %18, float noundef %19, float noundef %20)
  store ptr %21, ptr %6, align 8, !tbaa !11
  %22 = load ptr, ptr %5, align 8, !tbaa !11
  %23 = call i32 @cvsd_print(ptr noundef %22)
  %24 = icmp ne i32 %23, 0
  br i1 %24, label %25, label %29

25:                                               ; preds = %0
  %26 = load ptr, ptr %5, align 8, !tbaa !11
  %27 = call i32 @cvsd_print(ptr noundef %26)
  %28 = sitofp i32 %27 to double
  call void @liquid_autotest_failed_expr(ptr noundef @.str, i32 noundef 37, ptr noundef @.str.1, double noundef %28, ptr noundef @.str.2, ptr noundef @.str.3, double noundef 0.000000e+00)
  br label %30

29:                                               ; preds = %0
  call void (...) @liquid_autotest_passed()
  br label %30

30:                                               ; preds = %29, %25
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  store float 0.000000e+00, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  store float 0x3FB99999A0000000, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  call void @llvm.lifetime.start.p0(i64 1, ptr %10) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  store float 0.000000e+00, ptr %13, align 4, !tbaa !9
  store i32 0, ptr %9, align 4, !tbaa !5
  br label %31

31:                                               ; preds = %56, %30
  %32 = load i32, ptr %9, align 4, !tbaa !5
  %33 = load i32, ptr %1, align 4, !tbaa !5
  %34 = icmp ult i32 %32, %33
  br i1 %34, label %35, label %59

35:                                               ; preds = %31
  %36 = load float, ptr %7, align 4, !tbaa !9
  %37 = call float @sinf(float noundef %36) #5
  %38 = fmul float 5.000000e-01, %37
  store float %38, ptr %11, align 4, !tbaa !9
  %39 = load ptr, ptr %5, align 8, !tbaa !11
  %40 = load float, ptr %11, align 4, !tbaa !9
  %41 = call zeroext i8 @cvsd_encode(ptr noundef %39, float noundef %40)
  store i8 %41, ptr %10, align 1, !tbaa !13
  %42 = load ptr, ptr %6, align 8, !tbaa !11
  %43 = load i8, ptr %10, align 1, !tbaa !13
  %44 = call float @cvsd_decode(ptr noundef %42, i8 noundef zeroext %43)
  store float %44, ptr %12, align 4, !tbaa !9
  %45 = load float, ptr %11, align 4, !tbaa !9
  %46 = load float, ptr %12, align 4, !tbaa !9
  %47 = fsub float %45, %46
  %48 = load float, ptr %11, align 4, !tbaa !9
  %49 = load float, ptr %12, align 4, !tbaa !9
  %50 = fsub float %48, %49
  %51 = load float, ptr %13, align 4, !tbaa !9
  %52 = call float @llvm.fmuladd.f32(float %47, float %50, float %51)
  store float %52, ptr %13, align 4, !tbaa !9
  %53 = load float, ptr %8, align 4, !tbaa !9
  %54 = load float, ptr %7, align 4, !tbaa !9
  %55 = fadd float %54, %53
  store float %55, ptr %7, align 4, !tbaa !9
  br label %56

56:                                               ; preds = %35
  %57 = load i32, ptr %9, align 4, !tbaa !5
  %58 = add i32 %57, 1
  store i32 %58, ptr %9, align 4, !tbaa !5
  br label %31, !llvm.loop !14

59:                                               ; preds = %31
  %60 = load float, ptr %13, align 4, !tbaa !9
  %61 = load i32, ptr %1, align 4, !tbaa !5
  %62 = uitofp i32 %61 to float
  %63 = fdiv float %60, %62
  %64 = call float @log10f(float noundef %63) #5
  %65 = fmul float 1.000000e+01, %64
  store float %65, ptr %13, align 4, !tbaa !9
  %66 = load i32, ptr @liquid_autotest_verbose, align 4, !tbaa !5
  %67 = icmp ne i32 %66, 0
  br i1 %67, label %68, label %72

68:                                               ; preds = %59
  %69 = load float, ptr %13, align 4, !tbaa !9
  %70 = fpext float %69 to double
  %71 = call i32 (ptr, ...) @printf(ptr noundef @.str.4, double noundef %70)
  br label %72

72:                                               ; preds = %68, %59
  %73 = load float, ptr %13, align 4, !tbaa !9
  %74 = fcmp oge float %73, -2.000000e+01
  br i1 %74, label %75, label %78

75:                                               ; preds = %72
  %76 = load float, ptr %13, align 4, !tbaa !9
  %77 = fpext float %76 to double
  call void @liquid_autotest_failed_expr(ptr noundef @.str, i32 noundef 57, ptr noundef @.str.5, double noundef %77, ptr noundef @.str.6, ptr noundef @.str.7, double noundef -2.000000e+01)
  br label %79

78:                                               ; preds = %72
  call void (...) @liquid_autotest_passed()
  br label %79

79:                                               ; preds = %78, %75
  %80 = load ptr, ptr %5, align 8, !tbaa !11
  %81 = call i32 @cvsd_destroy(ptr noundef %80)
  %82 = load ptr, ptr %6, align 8, !tbaa !11
  %83 = call i32 @cvsd_destroy(ptr noundef %82)
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 1, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #5
  ret void
}

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

declare ptr @cvsd_create(i32 noundef, float noundef, float noundef) #2

declare i32 @cvsd_print(ptr noundef) #2

declare void @liquid_autotest_failed_expr(ptr noundef, i32 noundef, ptr noundef, double noundef, ptr noundef, ptr noundef, double noundef) #2

declare void @liquid_autotest_passed(...) #2

; Function Attrs: nounwind
declare float @sinf(float noundef) #3

declare zeroext i8 @cvsd_encode(ptr noundef, float noundef) #2

declare float @cvsd_decode(ptr noundef, i8 noundef zeroext) #2

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

; Function Attrs: nounwind
declare float @log10f(float noundef) #3

declare i32 @printf(ptr noundef, ...) #2

declare i32 @cvsd_destroy(ptr noundef) #2

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

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 = { "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 "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 = !{!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 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = !{!7, !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"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 [86 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [10 x i8], align 1
@liquid_autotest_verbose = external local_unnamed_addr global i32, align 4
@.str.4 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [7 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @autotest_cvsd_rmse_sine() local_unnamed_addr #0 {
  %1 = tail call ptr @cvsd_create(i32 noundef 3, float noundef 1.500000e+00, float noundef 0x3FECCCCCC0000000) #5
  %2 = tail call ptr @cvsd_create(i32 noundef 3, float noundef 1.500000e+00, float noundef 0x3FECCCCCC0000000) #5
  %3 = tail call i32 @cvsd_print(ptr noundef %1) #5
  %.not = icmp eq i32 %3, 0
  br i1 %.not, label %7, label %4

4:                                                ; preds = %0
  %5 = tail call i32 @cvsd_print(ptr noundef %1) #5
  %6 = sitofp i32 %5 to double
  tail call void @liquid_autotest_failed_expr(ptr noundef nonnull @.str, i32 noundef 37, ptr noundef nonnull @.str.1, double noundef %6, ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.3, double noundef 0.000000e+00) #5
  br label %.preheader

7:                                                ; preds = %0
  tail call void (...) @liquid_autotest_passed() #5
  br label %.preheader

.preheader:                                       ; preds = %7, %4
  br label %8

8:                                                ; preds = %.preheader, %8
  %.035 = phi float [ %14, %8 ], [ 0.000000e+00, %.preheader ]
  %.02934 = phi float [ %15, %8 ], [ 0.000000e+00, %.preheader ]
  %.03033 = phi i32 [ %16, %8 ], [ 0, %.preheader ]
  %9 = tail call float @sinf(float noundef %.02934) #5
  %10 = fmul float %9, 5.000000e-01
  %11 = tail call zeroext i8 @cvsd_encode(ptr noundef %1, float noundef %10) #5
  %12 = tail call float @cvsd_decode(ptr noundef %2, i8 noundef zeroext %11) #5
  %13 = fsub float %10, %12
  %14 = tail call float @llvm.fmuladd.f32(float %13, float %13, float %.035)
  %15 = fadd float %.02934, 0x3FB99999A0000000
  %16 = add nuw nsw i32 %.03033, 1
  %exitcond.not = icmp eq i32 %16, 256
  br i1 %exitcond.not, label %17, label %8, !llvm.loop !5

17:                                               ; preds = %8
  %18 = fmul float %14, 3.906250e-03
  %19 = tail call float @log10f(float noundef %18) #5
  %20 = fmul float %19, 1.000000e+01
  %21 = load i32, ptr @liquid_autotest_verbose, align 4, !tbaa !7
  %.not32 = icmp eq i32 %21, 0
  br i1 %.not32, label %25, label %22

22:                                               ; preds = %17
  %23 = fpext float %20 to double
  %24 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, double noundef %23)
  br label %25

25:                                               ; preds = %22, %17
  %26 = fcmp ult float %20, -2.000000e+01
  br i1 %26, label %29, label %27

27:                                               ; preds = %25
  %28 = fpext float %20 to double
  tail call void @liquid_autotest_failed_expr(ptr noundef nonnull @.str, i32 noundef 57, ptr noundef nonnull @.str.5, double noundef %28, ptr noundef nonnull @.str.6, ptr noundef nonnull @.str.7, double noundef -2.000000e+01) #5
  br label %30

29:                                               ; preds = %25
  tail call void (...) @liquid_autotest_passed() #5
  br label %30

30:                                               ; preds = %29, %27
  %31 = tail call i32 @cvsd_destroy(ptr noundef %1) #5
  %32 = tail call i32 @cvsd_destroy(ptr noundef %2) #5
  ret void
}

declare ptr @cvsd_create(i32 noundef, float noundef, float noundef) local_unnamed_addr #1

declare i32 @cvsd_print(ptr noundef) local_unnamed_addr #1

declare void @liquid_autotest_failed_expr(ptr noundef, i32 noundef, ptr noundef, double noundef, ptr noundef, ptr noundef, double noundef) local_unnamed_addr #1

declare void @liquid_autotest_passed(...) local_unnamed_addr #1

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare float @sinf(float noundef) local_unnamed_addr #2

declare zeroext i8 @cvsd_encode(ptr noundef, float noundef) local_unnamed_addr #1

declare float @cvsd_decode(ptr noundef, i8 noundef zeroext) local_unnamed_addr #1

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare float @log10f(float noundef) local_unnamed_addr #2

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #4

declare i32 @cvsd_destroy(ptr noundef) local_unnamed_addr #1

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 = { "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 nofree nounwind willreturn memory(write) "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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { nofree 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 #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"}
!7 = !{!8, !8, i64 0}
!8 = !{!"int", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LoopRotatePass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass