; LLVM IR from jgaeddert/liquid-dsp :: src/fft/tests (spgram_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.1 = external hidden unnamed_addr constant [86 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.44 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.73 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.74 = external hidden unnamed_addr constant [54 x i8], align 1
@.str.75 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.76 = external hidden unnamed_addr constant [27 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

declare ptr @spgramcf_create_default(i32 noundef) #1

declare i32 @spgramcf_push(ptr noundef, <2 x float> noundef) #1

declare float @randnf(...) #1

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

declare void @liquid_autotest_passed(...) #1

declare i32 @spgramcf_destroy(ptr noundef) #1

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

declare i32 @spgramcf_set_rate(ptr noundef, float noundef) #1

; Function Attrs: nounwind uwtable
define dso_local void @autotest_spgram_gnuplot() #2 {
  %1 = alloca ptr, align 8
  %2 = alloca i32, align 4
  %3 = alloca { float, float }, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %1) #3
  %4 = call ptr @spgramcf_create_default(i32 noundef 540)
  store ptr %4, ptr %1, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #3
  store i32 0, ptr %2, align 4, !tbaa !9
  br label %5

5:                                                ; preds = %19, %0
  %6 = load i32, ptr %2, align 4, !tbaa !9
  %7 = icmp ult i32 %6, 20000
  br i1 %7, label %8, label %22

8:                                                ; preds = %5
  %9 = load ptr, ptr %1, align 8, !tbaa !5
  %10 = call float (...) @randnf()
  %11 = call float (...) @randnf()
  %12 = fmul float 0.000000e+00, %11
  %13 = fmul float 1.000000e+00, %11
  %14 = fadd float %10, %12
  %15 = getelementptr inbounds { float, float }, ptr %3, i32 0, i32 0
  %16 = getelementptr inbounds { float, float }, ptr %3, i32 0, i32 1
  store float %14, ptr %15, align 4
  store float %13, ptr %16, align 4
  %17 = load <2 x float>, ptr %3, align 4
  %18 = call i32 @spgramcf_push(ptr noundef %9, <2 x float> noundef %17)
  br label %19

19:                                               ; preds = %8
  %20 = load i32, ptr %2, align 4, !tbaa !9
  %21 = add i32 %20, 1
  store i32 %21, ptr %2, align 4, !tbaa !9
  br label %5, !llvm.loop !11

22:                                               ; preds = %5
  %23 = load ptr, ptr %1, align 8, !tbaa !5
  %24 = call i32 @spgramcf_export_gnuplot(ptr noundef %23, ptr noundef @.str.73)
  %25 = icmp ne i32 0, %24
  br i1 %25, label %26, label %30

26:                                               ; preds = %22
  %27 = load ptr, ptr %1, align 8, !tbaa !5
  %28 = call i32 @spgramcf_export_gnuplot(ptr noundef %27, ptr noundef @.str.73)
  %29 = sitofp i32 %28 to double
  call void @liquid_autotest_failed_expr(ptr noundef @.str.1, i32 noundef 386, ptr noundef @.str.44, double noundef 0.000000e+00, ptr noundef @.str.3, ptr noundef @.str.74, double noundef %29)
  br label %31

30:                                               ; preds = %22
  call void (...) @liquid_autotest_passed()
  br label %31

31:                                               ; preds = %30, %26
  %32 = load ptr, ptr %1, align 8, !tbaa !5
  %33 = call i32 @spgramcf_set_freq(ptr noundef %32, float noundef 1.000000e+08)
  %34 = icmp ne i32 0, %33
  br i1 %34, label %35, label %39

35:                                               ; preds = %31
  %36 = load ptr, ptr %1, align 8, !tbaa !5
  %37 = call i32 @spgramcf_set_freq(ptr noundef %36, float noundef 1.000000e+08)
  %38 = sitofp i32 %37 to double
  call void @liquid_autotest_failed_expr(ptr noundef @.str.1, i32 noundef 389, ptr noundef @.str.44, double noundef 0.000000e+00, ptr noundef @.str.3, ptr noundef @.str.75, double noundef %38)
  br label %40

39:                                               ; preds = %31
  call void (...) @liquid_autotest_passed()
  br label %40

40:                                               ; preds = %39, %35
  %41 = load ptr, ptr %1, align 8, !tbaa !5
  %42 = call i32 @spgramcf_set_rate(ptr noundef %41, float noundef 2.000000e+07)
  %43 = icmp ne i32 0, %42
  br i1 %43, label %44, label %48

44:                                               ; preds = %40
  %45 = load ptr, ptr %1, align 8, !tbaa !5
  %46 = call i32 @spgramcf_set_rate(ptr noundef %45, float noundef 2.000000e+07)
  %47 = sitofp i32 %46 to double
  call void @liquid_autotest_failed_expr(ptr noundef @.str.1, i32 noundef 390, ptr noundef @.str.44, double noundef 0.000000e+00, ptr noundef @.str.3, ptr noundef @.str.76, double noundef %47)
  br label %49

48:                                               ; preds = %40
  call void (...) @liquid_autotest_passed()
  br label %49

49:                                               ; preds = %48, %44
  %50 = load ptr, ptr %1, align 8, !tbaa !5
  %51 = call i32 @spgramcf_export_gnuplot(ptr noundef %50, ptr noundef @.str.73)
  %52 = icmp ne i32 0, %51
  br i1 %52, label %53, label %57

53:                                               ; preds = %49
  %54 = load ptr, ptr %1, align 8, !tbaa !5
  %55 = call i32 @spgramcf_export_gnuplot(ptr noundef %54, ptr noundef @.str.73)
  %56 = sitofp i32 %55 to double
  call void @liquid_autotest_failed_expr(ptr noundef @.str.1, i32 noundef 391, ptr noundef @.str.44, double noundef 0.000000e+00, ptr noundef @.str.3, ptr noundef @.str.74, double noundef %56)
  br label %58

57:                                               ; preds = %49
  call void (...) @liquid_autotest_passed()
  br label %58

58:                                               ; preds = %57, %53
  %59 = load ptr, ptr %1, align 8, !tbaa !5
  %60 = call i32 @spgramcf_destroy(ptr noundef %59)
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #3
  ret void
}

declare i32 @spgramcf_export_gnuplot(ptr noundef, ptr noundef) #1

declare i32 @spgramcf_set_freq(ptr noundef, float 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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"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.1 = external hidden unnamed_addr constant [86 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.44 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.73 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.74 = external hidden unnamed_addr constant [54 x i8], align 1
@.str.75 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.76 = external hidden unnamed_addr constant [27 x i8], align 1

declare ptr @spgramcf_create_default(i32 noundef) local_unnamed_addr #0

declare i32 @spgramcf_push(ptr noundef, <2 x float> noundef) local_unnamed_addr #0

declare float @randnf(...) local_unnamed_addr #0

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

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

declare i32 @spgramcf_destroy(ptr noundef) local_unnamed_addr #0

declare i32 @spgramcf_set_rate(ptr noundef, float noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @autotest_spgram_gnuplot() local_unnamed_addr #1 {
  %1 = tail call ptr @spgramcf_create_default(i32 noundef 540) #2
  br label %2

2:                                                ; preds = %0, %2
  %.015 = phi i32 [ 0, %0 ], [ %8, %2 ]
  %3 = tail call float (...) @randnf() #2
  %4 = tail call float (...) @randnf() #2
  %5 = fmul float %4, 0.000000e+00
  %6 = fadd float %3, %5
  %.sroa.0.0.vec.insert = insertelement <2 x float> poison, float %6, i64 0
  %.sroa.0.4.vec.insert = insertelement <2 x float> %.sroa.0.0.vec.insert, float %4, i64 1
  %7 = tail call i32 @spgramcf_push(ptr noundef %1, <2 x float> noundef %.sroa.0.4.vec.insert) #2
  %8 = add nuw nsw i32 %.015, 1
  %exitcond.not = icmp eq i32 %8, 20000
  br i1 %exitcond.not, label %9, label %2, !llvm.loop !5

9:                                                ; preds = %2
  %10 = tail call i32 @spgramcf_export_gnuplot(ptr noundef %1, ptr noundef nonnull @.str.73) #2
  %.not = icmp eq i32 %10, 0
  br i1 %.not, label %14, label %11

11:                                               ; preds = %9
  %12 = tail call i32 @spgramcf_export_gnuplot(ptr noundef %1, ptr noundef nonnull @.str.73) #2
  %13 = sitofp i32 %12 to double
  tail call void @liquid_autotest_failed_expr(ptr noundef nonnull @.str.1, i32 noundef 386, ptr noundef nonnull @.str.44, double noundef 0.000000e+00, ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.74, double noundef %13) #2
  br label %15

14:                                               ; preds = %9
  tail call void (...) @liquid_autotest_passed() #2
  br label %15

15:                                               ; preds = %14, %11
  %16 = tail call i32 @spgramcf_set_freq(ptr noundef %1, float noundef 1.000000e+08) #2
  %.not12 = icmp eq i32 %16, 0
  br i1 %.not12, label %20, label %17

17:                                               ; preds = %15
  %18 = tail call i32 @spgramcf_set_freq(ptr noundef %1, float noundef 1.000000e+08) #2
  %19 = sitofp i32 %18 to double
  tail call void @liquid_autotest_failed_expr(ptr noundef nonnull @.str.1, i32 noundef 389, ptr noundef nonnull @.str.44, double noundef 0.000000e+00, ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.75, double noundef %19) #2
  br label %21

20:                                               ; preds = %15
  tail call void (...) @liquid_autotest_passed() #2
  br label %21

21:                                               ; preds = %20, %17
  %22 = tail call i32 @spgramcf_set_rate(ptr noundef %1, float noundef 2.000000e+07) #2
  %.not13 = icmp eq i32 %22, 0
  br i1 %.not13, label %26, label %23

23:                                               ; preds = %21
  %24 = tail call i32 @spgramcf_set_rate(ptr noundef %1, float noundef 2.000000e+07) #2
  %25 = sitofp i32 %24 to double
  tail call void @liquid_autotest_failed_expr(ptr noundef nonnull @.str.1, i32 noundef 390, ptr noundef nonnull @.str.44, double noundef 0.000000e+00, ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.76, double noundef %25) #2
  br label %27

26:                                               ; preds = %21
  tail call void (...) @liquid_autotest_passed() #2
  br label %27

27:                                               ; preds = %26, %23
  %28 = tail call i32 @spgramcf_export_gnuplot(ptr noundef %1, ptr noundef nonnull @.str.73) #2
  %.not14 = icmp eq i32 %28, 0
  br i1 %.not14, label %32, label %29

29:                                               ; preds = %27
  %30 = tail call i32 @spgramcf_export_gnuplot(ptr noundef %1, ptr noundef nonnull @.str.73) #2
  %31 = sitofp i32 %30 to double
  tail call void @liquid_autotest_failed_expr(ptr noundef nonnull @.str.1, i32 noundef 391, ptr noundef nonnull @.str.44, double noundef 0.000000e+00, ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.74, double noundef %31) #2
  br label %33

32:                                               ; preds = %27
  tail call void (...) @liquid_autotest_passed() #2
  br label %33

33:                                               ; preds = %32, %29
  %34 = tail call i32 @spgramcf_destroy(ptr noundef %1) #2
  ret void
}

declare i32 @spgramcf_export_gnuplot(ptr noundef, ptr noundef) local_unnamed_addr #0

declare i32 @spgramcf_set_freq(ptr noundef, float noundef) local_unnamed_addr #0

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"="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 #2 = { 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: EarlyCSEPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,SROAPass,SimplifyCFGPass,TailCallElimPass